]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cachefiles: Fix missing pos updates in cachefiles_ondemand_fd_write_iter()
authorZizhi Wo <wozizhi@huawei.com>
Thu, 7 Nov 2024 11:06:46 +0000 (19:06 +0800)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 Nov 2024 13:39:38 +0000 (14:39 +0100)
In the erofs on-demand loading scenario, read and write operations are
usually delivered through "off" and "len" contained in read req in user
mode. Naturally, pwrite is used to specify a specific offset to complete
write operations.

However, if the write(not pwrite) syscall is called multiple times in the
read-ahead scenario, we need to manually update ki_pos after each write
operation to update file->f_pos.

This step is currently missing from the cachefiles_ondemand_fd_write_iter
function, added to address this issue.

Fixes: c8383054506c ("cachefiles: notify the user daemon when looking up cookie")
Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Link: https://lore.kernel.org/r/20241107110649.3980193-3-wozizhi@huawei.com
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/cachefiles/ondemand.c

index bdd321017f1c40a313e3d0a61e34a8c4d9f99d33..38ca6dce8ef291e8345c57c92bb6183813a90467 100644 (file)
@@ -77,8 +77,10 @@ static ssize_t cachefiles_ondemand_fd_write_iter(struct kiocb *kiocb,
 
        trace_cachefiles_ondemand_fd_write(object, file_inode(file), pos, len);
        ret = __cachefiles_write(object, file, pos, iter, NULL, NULL);
-       if (!ret)
+       if (!ret) {
                ret = len;
+               kiocb->ki_pos += ret;
+       }
 
        return ret;
 }