Skip to content

Commit 6b19687

Browse files
chucklevertrondmypd
authored andcommitted
nfs: stat(2) fails during cthon04 basic test5 on NFSv4.0
When running the Connectathon basic tests against a Solaris NFS server over NFSv4.0, test5 reports that stat(2) returns a file size of zero instead of 1MB. On success, nfs_commit_inode() can return a positive result; see other call sites such as nfs_file_fsync_commit() and nfs_commit_unstable_pages(). The call site recently added in nfs_wb_all() does not prevent that positive return value from leaking to its callers. If it leaks through nfs_sync_inode() back to nfs_getattr(), that causes stat(2) to return a positive return value to user space while also not filling in the passed-in struct stat. Additional clean up: the new logic in nfs_wb_all() is rewritten in bfields-normal form. Fixes: 5bb89b4 ("NFSv4.1/pnfs: Separate out metadata . . .") Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 030bbdb commit 6b19687

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/nfs/write.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,12 +1845,15 @@ int nfs_wb_all(struct inode *inode)
18451845
trace_nfs_writeback_inode_enter(inode);
18461846

18471847
ret = filemap_write_and_wait(inode->i_mapping);
1848-
if (!ret) {
1849-
ret = nfs_commit_inode(inode, FLUSH_SYNC);
1850-
if (!ret)
1851-
pnfs_sync_inode(inode, true);
1852-
}
1848+
if (ret)
1849+
goto out;
1850+
ret = nfs_commit_inode(inode, FLUSH_SYNC);
1851+
if (ret < 0)
1852+
goto out;
1853+
pnfs_sync_inode(inode, true);
1854+
ret = 0;
18531855

1856+
out:
18541857
trace_nfs_writeback_inode_exit(inode, ret);
18551858
return ret;
18561859
}

0 commit comments

Comments
 (0)