[PATCH] Claim i_alloc_sem while changing file size in nfsd

Linux Kernel Mailing List <[email protected]> Sun, 19 Jun 2005 04:56:27 -0700
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
tree 6f43f201f6ce5438ac5127a6a98f1bc16bc2a54f
parent c3616f6fc4d1b45866e9ff3f782345b1dbc4ca3f
author NeilBrown <[email protected]> Wed, 01 Jun 2005 11:20:26 +1000
committer Marcelo Tosatti <[email protected]> Tue, 07 Jun 2005 19:26:54 -0300

[PATCH] Claim i_alloc_sem while changing file size in nfsd

nfsd should hold i_alloc_sem while calling notify_change
with ATTR_SIZE set, just like do_truncate does.

From: Oleg Drokin <[email protected]>
Signed-off-by: Neil Brown <[email protected]>

### Diffstat output
 ./fs/nfsd/vfs.c |    2 ++
 1 files changed, 2 insertions(+)

diff ./fs/nfsd/vfs.c~current~ ./fs/nfsd/vfs.c

 fs/nfsd/vfs.c |    2 ++
 1 files changed, 2 insertions(+)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -301,6 +301,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str
 	iap->ia_valid |= ATTR_CTIME;
 
 	if (iap->ia_valid & ATTR_SIZE) {
+		down_write(&inode->i_alloc_sem);
 		fh_lock(fhp);
 		size_change = 1;
 	}
@@ -311,6 +312,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str
 	}
 	if (size_change) {
 		fh_unlock(fhp);
+		up_write(&inode->i_alloc_sem);
 		put_write_access(inode);
 	}
 	if (!err)