Skip to content

Commit 25b065a

Browse files
axboebrauner
authored andcommitted
mm/filemap: use filemap_end_dropbehind() for read invalidation
Use the filemap_end_dropbehind() helper rather than calling folio_unmap_invalidate() directly, as we need to check if the folio has been redirtied or marked for writeback once the folio lock has been re-acquired. Cc: [email protected] Reported-by: Trond Myklebust <[email protected]> Fixes: 8026e49 ("mm/filemap: add read support for RWF_DONTCACHE") Link: https://lore.kernel.org/linux-fsdevel/[email protected]/ Signed-off-by: Jens Axboe <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 095f627 commit 25b065a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

mm/filemap.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,16 +2644,15 @@ static inline bool pos_same_folio(loff_t pos1, loff_t pos2, struct folio *folio)
26442644
return (pos1 >> shift == pos2 >> shift);
26452645
}
26462646

2647-
static void filemap_end_dropbehind_read(struct address_space *mapping,
2648-
struct folio *folio)
2647+
static void filemap_end_dropbehind_read(struct folio *folio)
26492648
{
26502649
if (!folio_test_dropbehind(folio))
26512650
return;
26522651
if (folio_test_writeback(folio) || folio_test_dirty(folio))
26532652
return;
26542653
if (folio_trylock(folio)) {
26552654
if (folio_test_clear_dropbehind(folio))
2656-
folio_unmap_invalidate(mapping, folio, 0);
2655+
filemap_end_dropbehind(folio);
26572656
folio_unlock(folio);
26582657
}
26592658
}
@@ -2774,7 +2773,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
27742773
for (i = 0; i < folio_batch_count(&fbatch); i++) {
27752774
struct folio *folio = fbatch.folios[i];
27762775

2777-
filemap_end_dropbehind_read(mapping, folio);
2776+
filemap_end_dropbehind_read(folio);
27782777
folio_put(folio);
27792778
}
27802779
folio_batch_init(&fbatch);

0 commit comments

Comments
 (0)