1 From 499f3edc23ca0431f3a0a6736b3a40944c81bf3b Mon Sep 17 00:00:00 2001
2 From: "J. Bruce Fields" <bfields@redhat.com>
3 Date: Mon, 27 Jun 2011 16:57:12 -0400
4 Subject: nfsd4: remember to put RW access on stateid destruction
6 From: "J. Bruce Fields" <bfields@redhat.com>
8 commit 499f3edc23ca0431f3a0a6736b3a40944c81bf3b upstream.
10 Without this, for example,
16 will result in a struct file leak.
18 Regression from 7d94784293096c0a46897acdb83be5abd9278ece "nfsd4: fix
19 downgrade/lock logic".
21 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
25 fs/nfsd/nfs4state.c | 17 ++++++-----------
26 1 file changed, 6 insertions(+), 11 deletions(-)
28 --- a/fs/nfsd/nfs4state.c
29 +++ b/fs/nfsd/nfs4state.c
30 @@ -381,14 +381,6 @@ static int nfs4_access_to_omode(u32 acce
34 -static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp)
36 - unsigned int access;
38 - set_access(&access, stp->st_access_bmap);
39 - return nfs4_access_to_omode(access);
42 static void unhash_generic_stateid(struct nfs4_stateid *stp)
44 list_del(&stp->st_hash);
45 @@ -398,11 +390,14 @@ static void unhash_generic_stateid(struc
47 static void free_generic_stateid(struct nfs4_stateid *stp)
52 if (stp->st_access_bmap) {
53 - oflag = nfs4_access_bmap_to_omode(stp);
54 - nfs4_file_put_access(stp->st_file, oflag);
55 + for (i = 1; i < 4; i++) {
56 + if (test_bit(i, &stp->st_access_bmap))
57 + nfs4_file_put_access(stp->st_file,
58 + nfs4_access_to_omode(i));
61 put_nfs4_file(stp->st_file);
62 kmem_cache_free(stateid_slab, stp);