Skip to content

Commit 19d1c32

Browse files
martinetddhowells
andcommitted
9p: fix enodata when reading growing file
Reading from a file that was just extended by a write, but the write had not yet reached the server would return ENODATA as illustrated by this command: $ xfs_io -c 'open -ft test' -c 'w 4096 1000' -c 'r 0 1000' wrote 1000/1000 bytes at offset 4096 1000.000000 bytes, 1 ops; 0.0001 sec (5.610 MiB/sec and 5882.3529 ops/sec) pread: No data available Fix this case by having netfs assume zeroes when reads from server come short like AFS and CEPH do Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: eb49794 ("9p: Convert to using the netfs helper lib to do reads and caching") Co-authored-by: David Howells <[email protected]> Reviewed-by: David Howells <[email protected]> Tested-by: David Howells <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent 15e2721 commit 19d1c32

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/9p/vfs_addr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ static void v9fs_req_issue_op(struct netfs_read_subrequest *subreq)
4242
iov_iter_xarray(&to, READ, &rreq->mapping->i_pages, pos, len);
4343

4444
total = p9_client_read(fid, pos, &to, &err);
45+
46+
/* if we just extended the file size, any portion not in
47+
* cache won't be on server and is zeroes */
48+
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
49+
4550
netfs_subreq_terminated(subreq, err ?: total, false);
4651
}
4752

0 commit comments

Comments
 (0)