Commit 1cdabef5 authored by Zizhi Wo's avatar Zizhi Wo
Browse files

cachefiles: Fix missing pos updates in cachefiles_ondemand_fd_write_iter()

mainline inclusion
from mainline-v6.13-rc1
commit 56f4856b425a30e1d8b3e41e6cde8bfba90ba5f8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56f4856b425a30e1d8b3e41e6cde8bfba90ba5f8



--------------------------------

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: c8383054 ("cachefiles: notify the user daemon when looking up cookie")
Conflicts:
	fs/cachefiles/ondemand.c
[Context conflict for object->file fix, not related to this patch.]
Signed-off-by: default avatarZizhi Wo <wozizhi@huawei.com>
Link: https://lore.kernel.org/r/20241107110649.3980193-3-wozizhi@huawei.com


Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent ec0faf02
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -84,8 +84,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;
	}
out:
	fput(file);
	return ret;