Commit a86a92cb authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch2_seek_pagecache_data() folio conversion

This converts bch2_seek_pagecache_data() to handle large folios.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e8d28c3e
...@@ -3488,10 +3488,10 @@ loff_t bch2_remap_file_range(struct file *file_src, loff_t pos_src, ...@@ -3488,10 +3488,10 @@ loff_t bch2_remap_file_range(struct file *file_src, loff_t pos_src,
static int folio_data_offset(struct folio *folio, unsigned offset) static int folio_data_offset(struct folio *folio, unsigned offset)
{ {
struct bch_folio *s = bch2_folio(folio); struct bch_folio *s = bch2_folio(folio);
unsigned i; unsigned i, sectors = folio_sectors(folio);
if (s) if (s)
for (i = offset >> 9; i < PAGE_SECTORS; i++) for (i = offset >> 9; i < sectors; i++)
if (s->s[i].state >= SECTOR_DIRTY) if (s->s[i].state >= SECTOR_DIRTY)
return i << 9; return i << 9;
...@@ -3519,12 +3519,10 @@ static loff_t bch2_seek_pagecache_data(struct inode *vinode, ...@@ -3519,12 +3519,10 @@ static loff_t bch2_seek_pagecache_data(struct inode *vinode,
folio_lock(folio); folio_lock(folio);
offset = folio_data_offset(folio, offset = folio_data_offset(folio,
folio->index == start_index max(folio_pos(folio), start_offset) -
? start_offset & (PAGE_SIZE - 1) folio_pos(folio));
: 0);
if (offset >= 0) { if (offset >= 0) {
ret = clamp(((loff_t) folio->index << PAGE_SHIFT) + ret = clamp(folio_pos(folio) + offset,
offset,
start_offset, end_offset); start_offset, end_offset);
folio_unlock(folio); folio_unlock(folio);
folio_batch_release(&fbatch); folio_batch_release(&fbatch);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment