diff mbox series

[1/2] mm/filemap: fix miscalculated file range for filemap_fdatawrite_range_kick()

Message ID 20250218120209.88093-2-jefflexu@linux.alibaba.com (mailing list archive)
State New
Headers show
Series fixes for uncached IO | expand

Commit Message

Jingbo Xu Feb. 18, 2025, 12:02 p.m. UTC
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.

Fixes: 1d4457576570 ("mm: call filemap_fdatawrite_range_kick() after IOCB_DONTCACHE issue")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 include/linux/fs.h | 4 ++--
 mm/filemap.c       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Jens Axboe Feb. 19, 2025, 4:25 p.m. UTC | #1
On 2/18/25 5:02 AM, Jingbo Xu wrote:
> 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.

Fix looks good, this got introduced because the logic got moved into
generic_write_sync() rather than being a separate helper.

Reviewed-by: Jens Axboe <axboe@kernel.dk>
diff mbox series

Patch

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2c3b2f8a621f..f12774291423 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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;
diff --git a/mm/filemap.c b/mm/filemap.c
index 804d7365680c..d4564a79eb35 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -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.