This is a note to let you know that I've just added the patch titled

    filemap: update ki_pos in generic_perform_write

to the 6.1-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     filemap-update-ki_pos-in-generic_perform_write.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From [email protected] Tue Oct 21 16:16:51 
>2025
From: Mahmoud Adam <[email protected]>
Date: Tue, 21 Oct 2025 09:03:38 +0200
Subject: filemap: update ki_pos in generic_perform_write
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>, Christoph Hellwig 
<[email protected]>, Xiubo Li <[email protected]>, Damien Le Moal 
<[email protected]>, Hannes Reinecke <[email protected]>, Theodore Ts'o 
<[email protected]>, "Darrick J. Wong" <[email protected]>, Al Viro 
<[email protected]>, Andreas Gruenbacher <[email protected]>, "Anna 
Schumaker" <[email protected]>, Chao Yu <[email protected]>, Christian Brauner 
<[email protected]>, Ilya Dryomov <[email protected]>, Jaegeuk Kim 
<[email protected]>, Jens Axboe <[email protected]>, Johannes Thumshirn 
<[email protected]>, Matthew Wilcox <[email protected]>, "Miklos 
Szeredi" <[email protected]>, Miklos Szeredi <[email protected]>, "Trond 
Myklebust" <[email protected]>, Andrew Morton 
<[email protected]>, Jeff Layton <[email protected]>, Andreas Dilger 
<[email protected]>, Christoph Hellwig <[email protected]>, "Ryusuke 
Konishi" <[email protected]>, Luis Chamberlain <[email protected]>,
  <[email protected]>, <[email protected]>, 
<[email protected]>, <[email protected]>, 
<[email protected]>, <[email protected]>, 
<[email protected]>, <[email protected]>, 
<[email protected]>, <[email protected]>
Message-ID: <[email protected]>

From: Christoph Hellwig <[email protected]>

commit 182c25e9c157f37bd0ab5a82fe2417e2223df459 upstream.

All callers of generic_perform_write need to updated ki_pos, move it into
common code.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Xiubo Li <[email protected]>
Reviewed-by: Damien Le Moal <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Acked-by: Theodore Ts'o <[email protected]>
Acked-by: Darrick J. Wong <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Andreas Gruenbacher <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Chao Yu <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Ilya Dryomov <[email protected]>
Cc: Jaegeuk Kim <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Johannes Thumshirn <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Cc: Trond Myklebust <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Mahmoud Adam <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 fs/ceph/file.c |    2 --
 fs/ext4/file.c |    9 +++------
 fs/f2fs/file.c |    1 -
 fs/nfs/file.c  |    1 -
 mm/filemap.c   |    8 ++++----
 5 files changed, 7 insertions(+), 14 deletions(-)

--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1891,8 +1891,6 @@ retry_snap:
                 * can not run at the same time
                 */
                written = generic_perform_write(iocb, from);
-               if (likely(written >= 0))
-                       iocb->ki_pos = pos + written;
                ceph_end_io_write(inode);
        }
 
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -287,12 +287,9 @@ static ssize_t ext4_buffered_write_iter(
 
 out:
        inode_unlock(inode);
-       if (likely(ret > 0)) {
-               iocb->ki_pos += ret;
-               ret = generic_write_sync(iocb, ret);
-       }
-
-       return ret;
+       if (unlikely(ret <= 0))
+               return ret;
+       return generic_write_sync(iocb, ret);
 }
 
 static ssize_t ext4_handle_inode_extension(struct inode *inode, loff_t offset,
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4659,7 +4659,6 @@ static ssize_t f2fs_buffered_write_iter(
        current->backing_dev_info = NULL;
 
        if (ret > 0) {
-               iocb->ki_pos += ret;
                f2fs_update_iostat(F2FS_I_SB(inode), inode,
                                                APP_BUFFERED_IO, ret);
        }
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -645,7 +645,6 @@ ssize_t nfs_file_write(struct kiocb *ioc
                goto out;
 
        written = result;
-       iocb->ki_pos += written;
        nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
 
        if (mntflags & NFS_MOUNT_WRITE_EAGER) {
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3891,7 +3891,10 @@ again:
                balance_dirty_pages_ratelimited(mapping);
        } while (iov_iter_count(i));
 
-       return written ? written : status;
+       if (!written)
+               return status;
+       iocb->ki_pos += written;
+       return written;
 }
 EXPORT_SYMBOL(generic_perform_write);
 
@@ -3970,7 +3973,6 @@ ssize_t __generic_file_write_iter(struct
                endbyte = pos + status - 1;
                err = filemap_write_and_wait_range(mapping, pos, endbyte);
                if (err == 0) {
-                       iocb->ki_pos = endbyte + 1;
                        written += status;
                        invalidate_mapping_pages(mapping,
                                                 pos >> PAGE_SHIFT,
@@ -3983,8 +3985,6 @@ ssize_t __generic_file_write_iter(struct
                }
        } else {
                written = generic_perform_write(iocb, from);
-               if (likely(written > 0))
-                       iocb->ki_pos += written;
        }
 out:
        current->backing_dev_info = NULL;


Patches currently in stable-queue which might be from [email protected] are

queue-6.1/block-fix-race-between-set_blocksize-and-read-paths.patch
queue-6.1/filemap-add-a-kiocb_invalidate_pages-helper.patch
queue-6.1/fs-factor-out-a-direct_write_fallback-helper.patch
queue-6.1/direct_write_fallback-on-error-revert-the-ki_pos-update-from-buffered-write.patch
queue-6.1/filemap-update-ki_pos-in-generic_perform_write.patch
queue-6.1/filemap-add-a-kiocb_invalidate_post_direct_write-helper.patch
queue-6.1/nilfs2-fix-deadlock-warnings-caused-by-lock-dependency-in-init_nilfs.patch
queue-6.1/block-open-code-__generic_file_write_iter-for-blkdev-writes.patch


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to