Short write in nfsd becomes a full write to the client
If a filesystem being written to via NFS returns a short write count (as opposed to an error) to nfsd, nfsd treats that as a success for the entire write, rather than the short count that actually succeeded. For example, given a 8192 byte write, if the underlying filesystem only writes 4096 bytes, nfsd will ack back to the nfs client that all 8192 bytes were written. The nfs client does have retry logic for short writes, but this is never called as the client is told the complete write succeeded. There are probably other ways it could happen, but in my case it happened with a fuse (filesystem in userspace) filesystem which can rather easily have a partial write. Here is a patch to properly return the short write count to the client. Signed-off-by: David Shaw <dshaw@jabberwocky.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
committed by
J. Bruce Fields
parent
1e685ec270
commit
31dec2538e
@@ -960,7 +960,7 @@ static void kill_suid(struct dentry *dentry)
|
||||
static __be32
|
||||
nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||
loff_t offset, struct kvec *vec, int vlen,
|
||||
unsigned long cnt, int *stablep)
|
||||
unsigned long *cnt, int *stablep)
|
||||
{
|
||||
struct svc_export *exp;
|
||||
struct dentry *dentry;
|
||||
@@ -974,7 +974,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||
err = nfserr_perm;
|
||||
|
||||
if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
|
||||
(!lock_may_write(file->f_path.dentry->d_inode, offset, cnt)))
|
||||
(!lock_may_write(file->f_path.dentry->d_inode, offset, *cnt)))
|
||||
goto out;
|
||||
#endif
|
||||
|
||||
@@ -1006,7 +1006,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||
host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
|
||||
set_fs(oldfs);
|
||||
if (host_err >= 0) {
|
||||
nfsdstats.io_write += cnt;
|
||||
nfsdstats.io_write += host_err;
|
||||
fsnotify_modify(file->f_path.dentry);
|
||||
}
|
||||
|
||||
@@ -1051,9 +1051,10 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||
}
|
||||
|
||||
dprintk("nfsd: write complete host_err=%d\n", host_err);
|
||||
if (host_err >= 0)
|
||||
if (host_err >= 0) {
|
||||
err = 0;
|
||||
else
|
||||
*cnt = host_err;
|
||||
} else
|
||||
err = nfserrno(host_err);
|
||||
out:
|
||||
return err;
|
||||
@@ -1095,7 +1096,7 @@ out:
|
||||
*/
|
||||
__be32
|
||||
nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
|
||||
loff_t offset, struct kvec *vec, int vlen, unsigned long cnt,
|
||||
loff_t offset, struct kvec *vec, int vlen, unsigned long *cnt,
|
||||
int *stablep)
|
||||
{
|
||||
__be32 err = 0;
|
||||
|
Reference in New Issue
Block a user