diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-11-07 16:37:57 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-11-07 21:10:47 -0500 |
commit | b93d87c19821ba7d3ee11557403d782e541071ad (patch) | |
tree | 982cdf816584c05131e497e3d79503e91260db8f /fs | |
parent | f8e6defe7f4456d8700e5a3796a1e9fb54a88543 (diff) |
nfsd4: fix lockowner matching
Lockowners are looked up by file as well as by owner, but we were
forgetting to do a comparison on the file. This could cause an
incorrect result from lockt.
(Note looking up the inode from the lockowner is pretty awkward here.
The data structures need fixing.)
Cc: stable@kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4state.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 47e94e33a975..5abced7a7408 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -3809,16 +3809,29 @@ nevermind: | |||
3809 | deny->ld_type = NFS4_WRITE_LT; | 3809 | deny->ld_type = NFS4_WRITE_LT; |
3810 | } | 3810 | } |
3811 | 3811 | ||
3812 | static bool same_lockowner_ino(struct nfs4_lockowner *lo, struct inode *inode, clientid_t *clid, struct xdr_netobj *owner) | ||
3813 | { | ||
3814 | struct nfs4_ol_stateid *lst; | ||
3815 | |||
3816 | if (!same_owner_str(&lo->lo_owner, owner, clid)) | ||
3817 | return false; | ||
3818 | lst = list_first_entry(&lo->lo_owner.so_stateids, | ||
3819 | struct nfs4_ol_stateid, st_perstateowner); | ||
3820 | return lst->st_file->fi_inode == inode; | ||
3821 | } | ||
3822 | |||
3812 | static struct nfs4_lockowner * | 3823 | static struct nfs4_lockowner * |
3813 | find_lockowner_str(struct inode *inode, clientid_t *clid, | 3824 | find_lockowner_str(struct inode *inode, clientid_t *clid, |
3814 | struct xdr_netobj *owner) | 3825 | struct xdr_netobj *owner) |
3815 | { | 3826 | { |
3816 | unsigned int hashval = lock_ownerstr_hashval(inode, clid->cl_id, owner); | 3827 | unsigned int hashval = lock_ownerstr_hashval(inode, clid->cl_id, owner); |
3828 | struct nfs4_lockowner *lo; | ||
3817 | struct nfs4_stateowner *op; | 3829 | struct nfs4_stateowner *op; |
3818 | 3830 | ||
3819 | list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) { | 3831 | list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) { |
3820 | if (same_owner_str(op, owner, clid)) | 3832 | lo = lockowner(op); |
3821 | return lockowner(op); | 3833 | if (same_lockowner_ino(lo, inode, clid, owner)) |
3834 | return lo; | ||
3822 | } | 3835 | } |
3823 | return NULL; | 3836 | return NULL; |
3824 | } | 3837 | } |