|
@@ -714,7 +714,6 @@ static void unhash_lockowner(struct nfs4_lockowner *lo)
|
|
struct nfs4_ol_stateid *stp;
|
|
struct nfs4_ol_stateid *stp;
|
|
|
|
|
|
list_del(&lo->lo_owner.so_strhash);
|
|
list_del(&lo->lo_owner.so_strhash);
|
|
- list_del(&lo->lo_owner_ino_hash);
|
|
|
|
while (!list_empty(&lo->lo_owner.so_stateids)) {
|
|
while (!list_empty(&lo->lo_owner.so_stateids)) {
|
|
stp = list_first_entry(&lo->lo_owner.so_stateids,
|
|
stp = list_first_entry(&lo->lo_owner.so_stateids,
|
|
struct nfs4_ol_stateid, st_perstateowner);
|
|
struct nfs4_ol_stateid, st_perstateowner);
|
|
@@ -4225,8 +4224,6 @@ out:
|
|
|
|
|
|
#define LOFF_OVERFLOW(start, len) ((u64)(len) > ~(u64)(start))
|
|
#define LOFF_OVERFLOW(start, len) ((u64)(len) > ~(u64)(start))
|
|
|
|
|
|
-#define LOCKOWNER_INO_HASH_MASK (LOCKOWNER_INO_HASH_SIZE - 1)
|
|
|
|
-
|
|
|
|
static inline u64
|
|
static inline u64
|
|
end_offset(u64 start, u64 len)
|
|
end_offset(u64 start, u64 len)
|
|
{
|
|
{
|
|
@@ -4247,13 +4244,6 @@ last_byte_offset(u64 start, u64 len)
|
|
return end > start ? end - 1: NFS4_MAX_UINT64;
|
|
return end > start ? end - 1: NFS4_MAX_UINT64;
|
|
}
|
|
}
|
|
|
|
|
|
-static unsigned int lockowner_ino_hashval(struct inode *inode, u32 cl_id, struct xdr_netobj *ownername)
|
|
|
|
-{
|
|
|
|
- return (file_hashval(inode) + cl_id
|
|
|
|
- + opaque_hashval(ownername->data, ownername->len))
|
|
|
|
- & LOCKOWNER_INO_HASH_MASK;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* TODO: Linux file offsets are _signed_ 64-bit quantities, which means that
|
|
* TODO: Linux file offsets are _signed_ 64-bit quantities, which means that
|
|
* we can't properly handle lock requests that go beyond the (2^63 - 1)-th
|
|
* we can't properly handle lock requests that go beyond the (2^63 - 1)-th
|
|
@@ -4306,46 +4296,23 @@ nevermind:
|
|
deny->ld_type = NFS4_WRITE_LT;
|
|
deny->ld_type = NFS4_WRITE_LT;
|
|
}
|
|
}
|
|
|
|
|
|
-static bool same_lockowner_ino(struct nfs4_lockowner *lo, struct inode *inode, clientid_t *clid, struct xdr_netobj *owner)
|
|
|
|
-{
|
|
|
|
- struct nfs4_ol_stateid *lst;
|
|
|
|
-
|
|
|
|
- if (!same_owner_str(&lo->lo_owner, owner, clid))
|
|
|
|
- return false;
|
|
|
|
- if (list_empty(&lo->lo_owner.so_stateids)) {
|
|
|
|
- WARN_ON_ONCE(1);
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- lst = list_first_entry(&lo->lo_owner.so_stateids,
|
|
|
|
- struct nfs4_ol_stateid, st_perstateowner);
|
|
|
|
- return lst->st_file->fi_inode == inode;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static struct nfs4_lockowner *
|
|
static struct nfs4_lockowner *
|
|
-find_lockowner_str(struct inode *inode, clientid_t *clid,
|
|
|
|
- struct xdr_netobj *owner, struct nfsd_net *nn)
|
|
|
|
|
|
+find_lockowner_str(clientid_t *clid, struct xdr_netobj *owner,
|
|
|
|
+ struct nfsd_net *nn)
|
|
{
|
|
{
|
|
- unsigned int hashval = lockowner_ino_hashval(inode, clid->cl_id, owner);
|
|
|
|
- struct nfs4_lockowner *lo;
|
|
|
|
|
|
+ unsigned int strhashval = ownerstr_hashval(clid->cl_id, owner);
|
|
|
|
+ struct nfs4_stateowner *so;
|
|
|
|
|
|
- list_for_each_entry(lo, &nn->lockowner_ino_hashtbl[hashval], lo_owner_ino_hash) {
|
|
|
|
- if (same_lockowner_ino(lo, inode, clid, owner))
|
|
|
|
- return lo;
|
|
|
|
|
|
+ list_for_each_entry(so, &nn->ownerstr_hashtbl[strhashval], so_strhash) {
|
|
|
|
+ if (so->so_is_open_owner)
|
|
|
|
+ continue;
|
|
|
|
+ if (!same_owner_str(so, owner, clid))
|
|
|
|
+ continue;
|
|
|
|
+ return lockowner(so);
|
|
}
|
|
}
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
-static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp)
|
|
|
|
-{
|
|
|
|
- struct inode *inode = open_stp->st_file->fi_inode;
|
|
|
|
- unsigned int inohash = lockowner_ino_hashval(inode,
|
|
|
|
- clp->cl_clientid.cl_id, &lo->lo_owner.so_owner);
|
|
|
|
- struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
|
|
|
|
-
|
|
|
|
- list_add(&lo->lo_owner.so_strhash, &nn->ownerstr_hashtbl[strhashval]);
|
|
|
|
- list_add(&lo->lo_owner_ino_hash, &nn->lockowner_ino_hashtbl[inohash]);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Alloc a lock owner structure.
|
|
* Alloc a lock owner structure.
|
|
* Called in nfsd4_lock - therefore, OPEN and OPEN_CONFIRM (if needed) has
|
|
* Called in nfsd4_lock - therefore, OPEN and OPEN_CONFIRM (if needed) has
|
|
@@ -4353,10 +4320,10 @@ static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, s
|
|
*
|
|
*
|
|
* strhashval = ownerstr_hashval
|
|
* strhashval = ownerstr_hashval
|
|
*/
|
|
*/
|
|
-
|
|
|
|
static struct nfs4_lockowner *
|
|
static struct nfs4_lockowner *
|
|
alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp, struct nfsd4_lock *lock) {
|
|
alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp, struct nfsd4_lock *lock) {
|
|
struct nfs4_lockowner *lo;
|
|
struct nfs4_lockowner *lo;
|
|
|
|
+ struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
|
|
|
|
|
|
lo = alloc_stateowner(lockowner_slab, &lock->lk_new_owner, clp);
|
|
lo = alloc_stateowner(lockowner_slab, &lock->lk_new_owner, clp);
|
|
if (!lo)
|
|
if (!lo)
|
|
@@ -4366,7 +4333,7 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, str
|
|
/* It is the openowner seqid that will be incremented in encode in the
|
|
/* It is the openowner seqid that will be incremented in encode in the
|
|
* case of new lockowners; so increment the lock seqid manually: */
|
|
* case of new lockowners; so increment the lock seqid manually: */
|
|
lo->lo_owner.so_seqid = lock->lk_new_lock_seqid + 1;
|
|
lo->lo_owner.so_seqid = lock->lk_new_lock_seqid + 1;
|
|
- hash_lockowner(lo, strhashval, clp, open_stp);
|
|
|
|
|
|
+ list_add(&lo->lo_owner.so_strhash, &nn->ownerstr_hashtbl[strhashval]);
|
|
return lo;
|
|
return lo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4432,8 +4399,7 @@ static __be32 lookup_or_create_lock_state(struct nfsd4_compound_state *cstate, s
|
|
unsigned int strhashval;
|
|
unsigned int strhashval;
|
|
struct nfsd_net *nn = net_generic(cl->net, nfsd_net_id);
|
|
struct nfsd_net *nn = net_generic(cl->net, nfsd_net_id);
|
|
|
|
|
|
- lo = find_lockowner_str(fi->fi_inode, &cl->cl_clientid,
|
|
|
|
- &lock->v.new.owner, nn);
|
|
|
|
|
|
+ lo = find_lockowner_str(&cl->cl_clientid, &lock->v.new.owner, nn);
|
|
if (!lo) {
|
|
if (!lo) {
|
|
strhashval = ownerstr_hashval(cl->cl_clientid.cl_id,
|
|
strhashval = ownerstr_hashval(cl->cl_clientid.cl_id,
|
|
&lock->v.new.owner);
|
|
&lock->v.new.owner);
|
|
@@ -4647,7 +4613,6 @@ __be32
|
|
nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|
nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|
struct nfsd4_lockt *lockt)
|
|
struct nfsd4_lockt *lockt)
|
|
{
|
|
{
|
|
- struct inode *inode;
|
|
|
|
struct file_lock *file_lock = NULL;
|
|
struct file_lock *file_lock = NULL;
|
|
struct nfs4_lockowner *lo;
|
|
struct nfs4_lockowner *lo;
|
|
__be32 status;
|
|
__be32 status;
|
|
@@ -4670,7 +4635,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|
if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)))
|
|
if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)))
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- inode = cstate->current_fh.fh_dentry->d_inode;
|
|
|
|
file_lock = locks_alloc_lock();
|
|
file_lock = locks_alloc_lock();
|
|
if (!file_lock) {
|
|
if (!file_lock) {
|
|
dprintk("NFSD: %s: unable to allocate lock!\n", __func__);
|
|
dprintk("NFSD: %s: unable to allocate lock!\n", __func__);
|
|
@@ -4693,7 +4657,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- lo = find_lockowner_str(inode, &lockt->lt_clientid, &lockt->lt_owner, nn);
|
|
|
|
|
|
+ lo = find_lockowner_str(&lockt->lt_clientid, &lockt->lt_owner, nn);
|
|
if (lo)
|
|
if (lo)
|
|
file_lock->fl_owner = (fl_owner_t)lo;
|
|
file_lock->fl_owner = (fl_owner_t)lo;
|
|
file_lock->fl_pid = current->tgid;
|
|
file_lock->fl_pid = current->tgid;
|
|
@@ -5187,10 +5151,6 @@ static int nfs4_state_create_net(struct net *net)
|
|
OWNER_HASH_SIZE, GFP_KERNEL);
|
|
OWNER_HASH_SIZE, GFP_KERNEL);
|
|
if (!nn->ownerstr_hashtbl)
|
|
if (!nn->ownerstr_hashtbl)
|
|
goto err_ownerstr;
|
|
goto err_ownerstr;
|
|
- nn->lockowner_ino_hashtbl = kmalloc(sizeof(struct list_head) *
|
|
|
|
- LOCKOWNER_INO_HASH_SIZE, GFP_KERNEL);
|
|
|
|
- if (!nn->lockowner_ino_hashtbl)
|
|
|
|
- goto err_lockowner_ino;
|
|
|
|
nn->sessionid_hashtbl = kmalloc(sizeof(struct list_head) *
|
|
nn->sessionid_hashtbl = kmalloc(sizeof(struct list_head) *
|
|
SESSION_HASH_SIZE, GFP_KERNEL);
|
|
SESSION_HASH_SIZE, GFP_KERNEL);
|
|
if (!nn->sessionid_hashtbl)
|
|
if (!nn->sessionid_hashtbl)
|
|
@@ -5202,8 +5162,6 @@ static int nfs4_state_create_net(struct net *net)
|
|
}
|
|
}
|
|
for (i = 0; i < OWNER_HASH_SIZE; i++)
|
|
for (i = 0; i < OWNER_HASH_SIZE; i++)
|
|
INIT_LIST_HEAD(&nn->ownerstr_hashtbl[i]);
|
|
INIT_LIST_HEAD(&nn->ownerstr_hashtbl[i]);
|
|
- for (i = 0; i < LOCKOWNER_INO_HASH_SIZE; i++)
|
|
|
|
- INIT_LIST_HEAD(&nn->lockowner_ino_hashtbl[i]);
|
|
|
|
for (i = 0; i < SESSION_HASH_SIZE; i++)
|
|
for (i = 0; i < SESSION_HASH_SIZE; i++)
|
|
INIT_LIST_HEAD(&nn->sessionid_hashtbl[i]);
|
|
INIT_LIST_HEAD(&nn->sessionid_hashtbl[i]);
|
|
nn->conf_name_tree = RB_ROOT;
|
|
nn->conf_name_tree = RB_ROOT;
|
|
@@ -5219,8 +5177,6 @@ static int nfs4_state_create_net(struct net *net)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
err_sessionid:
|
|
err_sessionid:
|
|
- kfree(nn->lockowner_ino_hashtbl);
|
|
|
|
-err_lockowner_ino:
|
|
|
|
kfree(nn->ownerstr_hashtbl);
|
|
kfree(nn->ownerstr_hashtbl);
|
|
err_ownerstr:
|
|
err_ownerstr:
|
|
kfree(nn->unconf_id_hashtbl);
|
|
kfree(nn->unconf_id_hashtbl);
|
|
@@ -5252,7 +5208,6 @@ nfs4_state_destroy_net(struct net *net)
|
|
}
|
|
}
|
|
|
|
|
|
kfree(nn->sessionid_hashtbl);
|
|
kfree(nn->sessionid_hashtbl);
|
|
- kfree(nn->lockowner_ino_hashtbl);
|
|
|
|
kfree(nn->ownerstr_hashtbl);
|
|
kfree(nn->ownerstr_hashtbl);
|
|
kfree(nn->unconf_id_hashtbl);
|
|
kfree(nn->unconf_id_hashtbl);
|
|
kfree(nn->conf_id_hashtbl);
|
|
kfree(nn->conf_id_hashtbl);
|