fixes for uncached IO
Subsystems (3)
cover fixes for uncached IO
Jingbo Xu (2):
mm/filemap: fix miscalculated file range for
filemap_fdatawrite_range_kick()
mm/truncate: don't skip dirty page in folio_unmap_invalidate()
include/linux/fs.h | 4 ++-- mm/filemap.c | 2 +- mm/truncate.c | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.19.1.6.gb485710b
PATCH 1/2 mm/filemap: fix miscalculated file range for filemap_fdatawrite_range_kick()
iocb->ki_pos has been updated with the number of written bytes since generic_perform_write().
Besides __filemap_fdatawrite_range() accepts the inclusive end of the data range.
--- include/linux/fs.h | 4 ++-- mm/filemap.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/fs.h +2 -2
@@ -2975,8 +2975,8 @@ static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count) }else if (iocb->ki_flags &IOCB_DONTCACHE ) {struct address_space *mapping = iocb->ki_filp->f_mapping; -filemap_fdatawrite_range_kick (mapping, iocb->ki_pos, - iocb->ki_pos + count); +filemap_fdatawrite_range_kick (mapping, iocb->ki_pos - count, + iocb->ki_pos -1 ); }return count;
mm/filemap.c +1 -1
@@ -445,7 +445,7 @@ EXPORT_SYMBOL(filemap_fdatawrite_range);* filemap_fdatawrite_range_kick - start writeback on a range * @mapping: target address_space * @start: index to start writeback on -* @end: last (non-inclusive) index for writeback +* @end: last (inclusive) index for writeback * * This is a non-integrity writeback helper, to start writing back folios * for the indicated range.
Signature · 1 line
2.19.1.6.gb485710b
Re: [PATCH 1/2] mm/filemap: fix miscalculated file range for filemap_fdatawrite_range_kick()
Quoted 5 lines · Jingbo Xu
iocb->ki_poshas been updated with the number of written bytes sincegeneric_perform_write().Besides
__filemap_fdatawrite_range()accepts the inclusive end of the data range.
Fix looks good, this got introduced because the logic got moved into generic_write_sync() rather than being a separate helper.
Signature · 1 line
Jens Axboe
PATCH 2/2 mm/truncate: don't skip dirty page in folio_unmap_invalidate()
In reply to Jingbo Xu... otherwise this is a behavior change for the previous callers of invalidate_complete_folio2(), e.g. the page invalidation routine.
--- mm/truncate.c | 2 -- 1 file changed, 2 deletions(-)
mm/truncate.c +0 -2
@@ -548,8 +548,6 @@ int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio); -if (folio_test_dirty (folio)) -return 0 ;if (folio_mapped (folio))unmap_mapping_folio (folio);BUG_ON (folio_mapped (folio));
Signature · 1 line
2.19.1.6.gb485710b
Re: [PATCH 2/2] mm/truncate: don't skip dirty page in folio_unmap_invalidate()
Quoted 2 lines · Jingbo Xu
... otherwise this is a behavior change for the previous callers of
invalidate_complete_folio2(), e.g. the page invalidation routine.
Hm. Shouldn't the check be moved to caller of the helper in mm/filemap.c?
Otherwise we would drop pages without writing them back. And lose user's data.
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Re: [PATCH 2/2] mm/truncate: don't skip dirty page in folio_unmap_invalidate()
Quoted 9 lines · Kirill A. Shutemov
Quoted 2 lines · Jingbo Xu
... otherwise this is a behavior change for the previous callers of
invalidate_complete_folio2(), e.g. the page invalidation routine.Hm. Shouldn't the check be moved to caller of the helper in
mm/filemap.c?Otherwise we would drop pages without writing them back. And lose user's data.
IMHO this check is not needed as the following folio_launder() called inside folio_unmap_invalidate() will write back the dirty page.
Hi Jens,
What do you think about it?
Signature · 2 lines
Thanks, Jingbo
Re: [PATCH 2/2] mm/truncate: don't skip dirty page in folio_unmap_invalidate()
Quoted 13 lines · Jingbo Xu
Quoted 9 lines · Kirill A. Shutemov
Quoted 2 lines · Jingbo Xu
... otherwise this is a behavior change for the previous callers of
invalidate_complete_folio2(), e.g. the page invalidation routine.Hm. Shouldn't the check be moved to caller of the helper in
mm/filemap.c?Otherwise we would drop pages without writing them back. And lose user's data.
Quoted 6 lines
IMHO this check is not needed as the following
folio_launder()called insidefolio_unmap_invalidate()will write back the dirty page.Hi Jens,
What do you think about it?
Yep agree on that.
Signature · 1 line
Jens Axboe
Re: [PATCH 2/2] mm/truncate: don't skip dirty page in folio_unmap_invalidate()
In reply to Jingbo XuQuoted 14 lines · Jingbo Xu
... otherwise this is a behavior change for the previous callers of
invalidate_complete_folio2(), e.g. the page invalidation routine.Fixes 4a9e23159fd3 ("mm/truncate: add folio_unmap_invalidate() helper")Signed-off-by Jingbo Xu <[email protected]>--- mm/truncate.c | 2 -- 1 file changed, 2 deletions(-)mm/truncate.c +0
-0
mm/truncate.c int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, · line 552
Quoted 5 lines
mm/truncate.c +0
-2@@ -548,8 +548,6 @@ int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio); -if (folio_test_dirty (folio)) -return 0 ;
Shouldn't that actually return -EBUSY because the folio could not be invalidated?
Indeed, further down the function the folio gets locked and the dirty test is repeated. If it fails there it returns -EBUSY....
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/2] mm/truncate: don't skip dirty page in folio_unmap_invalidate()
Quoted 24 lines · Dave Chinner
Quoted 14 lines · Jingbo Xu
... otherwise this is a behavior change for the previous callers of
invalidate_complete_folio2(), e.g. the page invalidation routine.Fixes 4a9e23159fd3 ("mm/truncate: add folio_unmap_invalidate() helper")Signed-off-by Jingbo Xu <[email protected]>--- mm/truncate.c | 2 -- 1 file changed, 2 deletions(-)mm/truncate.c +0
-0mm/truncate.c int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, · line 552
Quoted 5 lines
mm/truncate.c +0
-2@@ -548,8 +548,6 @@ int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio); -if (folio_test_dirty (folio)) -return 0 ;Shouldn't that actually return
-EBUSYbecause the folio could not be invalidated?
Quoted 4 lines
Indeed, further down the function the folio gets locked and the dirty test is repeated. If it fails there it returns
-EBUSY....-Dave.
Yeah, the original logic of invalidate_inode_pages2_range() is like
```
invalidate_inode_pages2_range
# lock page
# launder the page if it's dirty
invalidate_complete_folio2
# recheck if it's dirty, and skip the dirty page (no idea how page
could be redirtied after launder_page())
```while after commit 4a9e23159fd3 ("mm/truncate: add folio_unmap_invalidate() helper"), this logic is changed to:
```
invalidate_inode_pages2_range
# lock page
folio_unmap_invalidate
# check if it's dirty, and skip dirty page
# launder the page if it's dirty (doubt if it's noops)
# recheck if it's dirty, and skip the dirty page
```Signature · 2 lines
Thanks, Jingbo
Hi Christian,
Quoted 10 lines · Jingbo Xu
Jingbo Xu (2):
mm/filemap: fix miscalculated file range for
filemap_fdatawrite_range_kick()
mm/truncate: don't skip dirty page infolio_unmap_invalidate()include/linux/fs.h | 4 ++-- mm/filemap.c | 2 +- mm/truncate.c | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-)
Would you consider these fixes?
Signature · 2 lines
Thanks, Jingbo
Quoted 11 lines · Jingbo Xu
Jingbo Xu (2):
mm/filemap: fix miscalculated file range for
filemap_fdatawrite_range_kick()
mm/truncate: don't skip dirty page infolio_unmap_invalidate()
include/linux/fs.h| 4 ++--mm/filemap.c | 2 +- mm/truncate.c | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-)[...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/2] mm/filemap: fix miscalculated file range for filemap_fdatawrite_range_kick()
https://git.kernel.org/vfs/vfs/c/8510edf191d2 [2/2] mm/truncate: don't skip dirty page in folio_unmap_invalidate() https://git.kernel.org/vfs/vfs/c/927289988068