2005-06-01 01:20:38

by NeilBrown

[permalink] [raw]
Subject: [PATCH kNFSd 002 of 2] 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~current~ 2005-06-01 10:36:09.000000000 +1000
+++ ./fs/nfsd/vfs.c 2005-06-01 11:16:13.000000000 +1000
@@ -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)

### 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~current~ 2005-06-01 10:36:09.000000000 +1000
+++ ./fs/nfsd/vfs.c 2005-06-01 11:16:13.000000000 +1000
@@ -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)


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs