bcachefs: bch2_seek_pagecache_data() folio conversion

This converts bch2_seek_pagecache_data() to handle large folios.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-03-19 19:07:28 -04:00
parent e8d28c3e47
commit a86a92cb0d

View File

@ -3488,10 +3488,10 @@ err:
static int folio_data_offset(struct folio *folio, unsigned offset)
{
struct bch_folio *s = bch2_folio(folio);
unsigned i;
unsigned i, sectors = folio_sectors(folio);
if (s)
for (i = offset >> 9; i < PAGE_SECTORS; i++)
for (i = offset >> 9; i < sectors; i++)
if (s->s[i].state >= SECTOR_DIRTY)
return i << 9;
@ -3519,12 +3519,10 @@ static loff_t bch2_seek_pagecache_data(struct inode *vinode,
folio_lock(folio);
offset = folio_data_offset(folio,
folio->index == start_index
? start_offset & (PAGE_SIZE - 1)
: 0);
max(folio_pos(folio), start_offset) -
folio_pos(folio));
if (offset >= 0) {
ret = clamp(((loff_t) folio->index << PAGE_SHIFT) +
offset,
ret = clamp(folio_pos(folio) + offset,
start_offset, end_offset);
folio_unlock(folio);
folio_batch_release(&fbatch);