Skip to content

Commit 56f4856

Browse files
Zizhi Wobrauner
authored andcommitted
cachefiles: Fix missing pos updates in cachefiles_ondemand_fd_write_iter()
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: c838305 ("cachefiles: notify the user daemon when looking up cookie") Signed-off-by: Zizhi Wo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: David Howells <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 10c35ab commit 56f4856

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/cachefiles/ondemand.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ static ssize_t cachefiles_ondemand_fd_write_iter(struct kiocb *kiocb,
7777

7878
trace_cachefiles_ondemand_fd_write(object, file_inode(file), pos, len);
7979
ret = __cachefiles_write(object, file, pos, iter, NULL, NULL);
80-
if (!ret)
80+
if (!ret) {
8181
ret = len;
82+
kiocb->ki_pos += ret;
83+
}
8284

8385
return ret;
8486
}

0 commit comments

Comments
 (0)