2005-04-08 01:57:25

by NeilBrown

[permalink] [raw]
Subject: [PATCH kNFSd 003 of 16] nfsd4: fix struct file leak



We were failing to close on an error path, resulting in a leak of struct files
which could take a v4 server down fairly quickly....
So call nfs4_close_delegation instead of just open-coding parts of it.

Simplify the cleanup on delegation failure while we're at it.

Signed-off-by: J. Bruce Fields <[email protected]>
Signed-off-by: Neil Brown <[email protected]>

### Diffstat output
./fs/nfsd/nfs4state.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)

diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
--- ./fs/nfsd/nfs4state.c~current~ 2005-04-08 10:31:12.000000000 +1000
+++ ./fs/nfsd/nfs4state.c 2005-04-08 10:35:24.000000000 +1000
@@ -190,7 +190,8 @@ nfs4_close_delegation(struct nfs4_delega
dp->dl_vfs_file = NULL;
/* The following nfsd_close may not actually close the file,
* but we want to remove the lease in any case. */
- setlease(filp, F_UNLCK, &dp->dl_flock);
+ if (dp->dl_flock)
+ setlease(filp, F_UNLCK, &dp->dl_flock);
nfsd_close(filp);
vfsclose++;
}
@@ -1673,10 +1674,7 @@ nfs4_open_delegation(struct svc_fh *fh,
if ((status = setlease(stp->st_vfs_file,
flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK, &flp))) {
dprintk("NFSD: setlease failed [%d], no delegation\n", status);
- list_del(&dp->dl_del_perfile);
- list_del(&dp->dl_del_perclnt);
- nfs4_put_delegation(dp);
- free_delegation++;
+ unhash_delegation(dp);
flag = NFS4_OPEN_DELEGATE_NONE;
goto out;
}


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs