]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iomap: update ki_pos a little later in iomap_dio_complete
authorChristoph Hellwig <hch@lst.de>
Tue, 22 Oct 2024 16:33:46 +0000 (18:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Nov 2024 15:21:58 +0000 (16:21 +0100)
upstream 936e114a245b6e38e0dbf706a67e7611fc993da1 commit.

Move the ki_pos update down a bit to prepare for a better common helper
that invalidates pages based of an iocb.

Link: https://lkml.kernel.org/r/20230601145904.1385409-3-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Anna Schumaker <anna@kernel.org>
Cc: Chao Yu <chao@kernel.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mahmoud Adam <mngyadam@amazon.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/iomap/direct-io.c

index 933f234d5becd01a7ab369abbc7476a6d0b89b14..8a49c0d3a7b46b5f9c45d64fc0984647f75cd32d 100644 (file)
@@ -93,7 +93,6 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
                if (offset + ret > dio->i_size &&
                    !(dio->flags & IOMAP_DIO_WRITE))
                        ret = dio->i_size - offset;
-               iocb->ki_pos += ret;
        }
 
        /*
@@ -119,15 +118,18 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
        }
 
        inode_dio_end(file_inode(iocb->ki_filp));
-       /*
-        * If this is a DSYNC write, make sure we push it to stable storage now
-        * that we've written data.
-        */
-       if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC))
-               ret = generic_write_sync(iocb, ret);
 
-       kfree(dio);
+       if (ret > 0) {
+               iocb->ki_pos += ret;
 
+               /*
+                * If this is a DSYNC write, make sure we push it to stable
+                * storage now that we've written data.
+                */
+               if (dio->flags & IOMAP_DIO_NEED_SYNC)
+                       ret = generic_write_sync(iocb, ret);
+       }
+       kfree(dio);
        return ret;
 }
 EXPORT_SYMBOL_GPL(iomap_dio_complete);