diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-11-07 17:40:10 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-11-15 19:26:08 -0500 |
commit | 009673b439cf74d70a486fca0177e274febd81a7 (patch) | |
tree | 24c5e96d30a498abc4122e7dc10d98eb338c6a91 /fs/nfsd | |
parent | 353de31b86850309b205a3d4cc1294052471b14d (diff) |
nfsd4: add a separate (lockowner, inode) lookup
Address the possible performance regression mentioned in "nfsd4: hash
lockowners to simplify RELEASE_LOCKOWNER" by providing a separate
(lockowner, inode) hash.
Really, I doubt this matters much, but I think it's likely we'll change
these data structures here and I'd rather that the need for (owner,
inode) lookups be well-documented.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 29 | ||||
-rw-r--r-- | fs/nfsd/state.h | 1 |
2 files changed, 24 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 7e4edbde7373..a84978c13bb8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -514,6 +514,7 @@ static void unhash_lockowner(struct nfs4_lockowner *lo) | |||
514 | 514 | ||
515 | list_del(&lo->lo_owner.so_strhash); | 515 | list_del(&lo->lo_owner.so_strhash); |
516 | list_del(&lo->lo_perstateid); | 516 | list_del(&lo->lo_perstateid); |
517 | list_del(&lo->lo_owner_ino_hash); | ||
517 | while (!list_empty(&lo->lo_owner.so_stateids)) { | 518 | while (!list_empty(&lo->lo_owner.so_stateids)) { |
518 | stp = list_first_entry(&lo->lo_owner.so_stateids, | 519 | stp = list_first_entry(&lo->lo_owner.so_stateids, |
519 | struct nfs4_ol_stateid, st_perstateowner); | 520 | struct nfs4_ol_stateid, st_perstateowner); |
@@ -3722,6 +3723,10 @@ out: | |||
3722 | 3723 | ||
3723 | #define LOFF_OVERFLOW(start, len) ((u64)(len) > ~(u64)(start)) | 3724 | #define LOFF_OVERFLOW(start, len) ((u64)(len) > ~(u64)(start)) |
3724 | 3725 | ||
3726 | #define LOCKOWNER_INO_HASH_BITS 8 | ||
3727 | #define LOCKOWNER_INO_HASH_SIZE (1 << LOCKOWNER_INO_HASH_BITS) | ||
3728 | #define LOCKOWNER_INO_HASH_MASK (LOCKOWNER_INO_HASH_SIZE - 1) | ||
3729 | |||
3725 | static inline u64 | 3730 | static inline u64 |
3726 | end_offset(u64 start, u64 len) | 3731 | end_offset(u64 start, u64 len) |
3727 | { | 3732 | { |
@@ -3742,6 +3747,15 @@ last_byte_offset(u64 start, u64 len) | |||
3742 | return end > start ? end - 1: NFS4_MAX_UINT64; | 3747 | return end > start ? end - 1: NFS4_MAX_UINT64; |
3743 | } | 3748 | } |
3744 | 3749 | ||
3750 | static unsigned int lockowner_ino_hashval(struct inode *inode, u32 cl_id, struct xdr_netobj *ownername) | ||
3751 | { | ||
3752 | return (file_hashval(inode) + cl_id | ||
3753 | + opaque_hashval(ownername->data, ownername->len)) | ||
3754 | & LOCKOWNER_INO_HASH_MASK; | ||
3755 | } | ||
3756 | |||
3757 | static struct list_head lockowner_ino_hashtbl[LOCKOWNER_INO_HASH_SIZE]; | ||
3758 | |||
3745 | /* | 3759 | /* |
3746 | * TODO: Linux file offsets are _signed_ 64-bit quantities, which means that | 3760 | * TODO: Linux file offsets are _signed_ 64-bit quantities, which means that |
3747 | * we can't properly handle lock requests that go beyond the (2^63 - 1)-th | 3761 | * we can't properly handle lock requests that go beyond the (2^63 - 1)-th |
@@ -3809,14 +3823,10 @@ static struct nfs4_lockowner * | |||
3809 | find_lockowner_str(struct inode *inode, clientid_t *clid, | 3823 | find_lockowner_str(struct inode *inode, clientid_t *clid, |
3810 | struct xdr_netobj *owner) | 3824 | struct xdr_netobj *owner) |
3811 | { | 3825 | { |
3812 | unsigned int hashval = ownerstr_hashval(clid->cl_id, owner); | 3826 | unsigned int hashval = lockowner_ino_hashval(inode, clid->cl_id, owner); |
3813 | struct nfs4_lockowner *lo; | 3827 | struct nfs4_lockowner *lo; |
3814 | struct nfs4_stateowner *op; | ||
3815 | 3828 | ||
3816 | list_for_each_entry(op, &ownerstr_hashtbl[hashval], so_strhash) { | 3829 | list_for_each_entry(lo, &lockowner_ino_hashtbl[hashval], lo_owner_ino_hash) { |
3817 | if (op->so_is_open_owner) | ||
3818 | continue; | ||
3819 | lo = lockowner(op); | ||
3820 | if (same_lockowner_ino(lo, inode, clid, owner)) | 3830 | if (same_lockowner_ino(lo, inode, clid, owner)) |
3821 | return lo; | 3831 | return lo; |
3822 | } | 3832 | } |
@@ -3825,7 +3835,12 @@ find_lockowner_str(struct inode *inode, clientid_t *clid, | |||
3825 | 3835 | ||
3826 | static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp) | 3836 | static void hash_lockowner(struct nfs4_lockowner *lo, unsigned int strhashval, struct nfs4_client *clp, struct nfs4_ol_stateid *open_stp) |
3827 | { | 3837 | { |
3838 | struct inode *inode = open_stp->st_file->fi_inode; | ||
3839 | unsigned int inohash = lockowner_ino_hashval(inode, | ||
3840 | clp->cl_clientid.cl_id, &lo->lo_owner.so_owner); | ||
3841 | |||
3828 | list_add(&lo->lo_owner.so_strhash, &ownerstr_hashtbl[strhashval]); | 3842 | list_add(&lo->lo_owner.so_strhash, &ownerstr_hashtbl[strhashval]); |
3843 | list_add(&lo->lo_owner_ino_hash, &lockowner_ino_hashtbl[inohash]); | ||
3829 | list_add(&lo->lo_perstateid, &open_stp->st_lockowners); | 3844 | list_add(&lo->lo_perstateid, &open_stp->st_lockowners); |
3830 | } | 3845 | } |
3831 | 3846 | ||
@@ -4548,6 +4563,8 @@ nfs4_state_init(void) | |||
4548 | for (i = 0; i < OWNER_HASH_SIZE; i++) { | 4563 | for (i = 0; i < OWNER_HASH_SIZE; i++) { |
4549 | INIT_LIST_HEAD(&ownerstr_hashtbl[i]); | 4564 | INIT_LIST_HEAD(&ownerstr_hashtbl[i]); |
4550 | } | 4565 | } |
4566 | for (i = 0; i < LOCKOWNER_INO_HASH_SIZE; i++) | ||
4567 | INIT_LIST_HEAD(&lockowner_ino_hashtbl[i]); | ||
4551 | memset(&onestateid, ~0, sizeof(stateid_t)); | 4568 | memset(&onestateid, ~0, sizeof(stateid_t)); |
4552 | INIT_LIST_HEAD(&close_lru); | 4569 | INIT_LIST_HEAD(&close_lru); |
4553 | INIT_LIST_HEAD(&client_lru); | 4570 | INIT_LIST_HEAD(&client_lru); |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index a3cf38476a1b..89c2cd84d796 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -366,6 +366,7 @@ struct nfs4_openowner { | |||
366 | 366 | ||
367 | struct nfs4_lockowner { | 367 | struct nfs4_lockowner { |
368 | struct nfs4_stateowner lo_owner; /* must be first element */ | 368 | struct nfs4_stateowner lo_owner; /* must be first element */ |
369 | struct list_head lo_owner_ino_hash; /* hash by owner,file */ | ||
369 | struct list_head lo_perstateid; /* for lockowners only */ | 370 | struct list_head lo_perstateid; /* for lockowners only */ |
370 | struct list_head lo_list; /* for temporary uses */ | 371 | struct list_head lo_list; /* for temporary uses */ |
371 | }; | 372 | }; |