* minor nfsd4 state code cleanup
@ 2009-01-11 23:52 J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic J. Bruce Fields
0 siblings, 1 reply; 6+ messages in thread
From: J. Bruce Fields @ 2009-01-11 23:52 UTC (permalink / raw)
To: linux-nfs
I'm queuing the following minor nfsd4 cleanup for 2.6.30.
--b.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] nfsd4: split lockstateid/openstateid release logic
2009-01-11 23:52 minor nfsd4 state code cleanup J. Bruce Fields
@ 2009-01-11 23:52 ` J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: remove a forward declaration J. Bruce Fields
2009-01-12 8:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic Benny Halevy
0 siblings, 2 replies; 6+ messages in thread
From: J. Bruce Fields @ 2009-01-11 23:52 UTC (permalink / raw)
To: linux-nfs; +Cc: J. Bruce Fields
The flags here attempt to make the code more general, but I find it
actually just adds confusion.
I think it's clearer to separate the logic for the open and lock cases
entirely. And eventually we may want to separate the stateowner and
stateid types as well, as many of the fields aren't shared between the
lock and open cases.
Also move to eliminate forward references.
Start with the stateid's.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
fs/nfsd/nfs4state.c | 49 ++++++++++++++++++++++++++-----------------------
1 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 88db7d3..6b8e5a9 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -119,7 +119,6 @@ opaque_hashval(const void *ptr, int nbytes)
/* forward declarations */
static void release_stateowner(struct nfs4_stateowner *sop);
-static void release_stateid(struct nfs4_stateid *stp, int flags);
/*
* Delegation state
@@ -311,6 +310,28 @@ static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE];
static struct list_head client_lru;
static struct list_head close_lru;
+static void release_generic_stateid(struct nfs4_stateid *stp)
+{
+ list_del(&stp->st_hash);
+ list_del(&stp->st_perfile);
+ list_del(&stp->st_perstateowner);
+ put_nfs4_file(stp->st_file);
+ kmem_cache_free(stateid_slab, stp);
+}
+
+static void release_lock_stateid(struct nfs4_stateid *stp)
+{
+ locks_remove_posix(stp->st_vfs_file, (fl_owner_t)stp->st_stateowner);
+ release_generic_stateid(stp);
+}
+
+static void release_open_stateid(struct nfs4_stateid *stp)
+{
+ release_stateid_lockowners(stp);
+ nfsd_close(stp->st_vfs_file);
+ release_generic_stateid(stp);
+}
+
static inline void
renew_client(struct nfs4_client *clp)
{
@@ -1065,9 +1086,9 @@ unhash_stateowner(struct nfs4_stateowner *sop)
stp = list_entry(sop->so_stateids.next,
struct nfs4_stateid, st_perstateowner);
if (sop->so_is_open_owner)
- release_stateid(stp, OPEN_STATE);
+ release_open_stateid(stp);
else
- release_stateid(stp, LOCK_STATE);
+ release_lock_stateid(stp);
}
}
@@ -1106,24 +1127,6 @@ init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *
}
static void
-release_stateid(struct nfs4_stateid *stp, int flags)
-{
- struct file *filp = stp->st_vfs_file;
-
- list_del(&stp->st_hash);
- list_del(&stp->st_perfile);
- list_del(&stp->st_perstateowner);
- if (flags & OPEN_STATE) {
- release_stateid_lockowners(stp);
- stp->st_vfs_file = NULL;
- nfsd_close(filp);
- } else if (flags & LOCK_STATE)
- locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner);
- put_nfs4_file(stp->st_file);
- kmem_cache_free(stateid_slab, stp);
-}
-
-static void
move_to_close_lru(struct nfs4_stateowner *sop)
{
dprintk("NFSD: move_to_close_lru nfs4_stateowner %p\n", sop);
@@ -1764,7 +1767,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
init_stateid(stp, fp, open);
status = nfsd4_truncate(rqstp, current_fh, open);
if (status) {
- release_stateid(stp, OPEN_STATE);
+ release_open_stateid(stp);
goto out;
}
}
@@ -2373,7 +2376,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
/* release_stateid() calls nfsd_close() if needed */
- release_stateid(stp, OPEN_STATE);
+ release_open_stateid(stp);
/* place unused nfs4_stateowners on so_close_lru list to be
* released by the laundromat service after the lease period
--
1.5.5.rc1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] nfsd4: remove a forward declaration
2009-01-11 23:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic J. Bruce Fields
@ 2009-01-11 23:52 ` J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: split open/lockowner release code J. Bruce Fields
2009-01-12 8:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic Benny Halevy
1 sibling, 1 reply; 6+ messages in thread
From: J. Bruce Fields @ 2009-01-11 23:52 UTC (permalink / raw)
To: linux-nfs; +Cc: J. Bruce Fields
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
fs/nfsd/nfs4state.c | 85 +++++++++++++++++++++++++--------------------------
1 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 6b8e5a9..298d6ce 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -75,7 +75,6 @@ static stateid_t onestateid; /* bits all 1 */
/* forward declarations */
static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags);
static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid);
-static void release_stateid_lockowners(struct nfs4_stateid *open_stp);
static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
static void nfs4_set_recdir(char *recdir);
@@ -325,6 +324,20 @@ static void release_lock_stateid(struct nfs4_stateid *stp)
release_generic_stateid(stp);
}
+static void
+release_stateid_lockowners(struct nfs4_stateid *open_stp)
+{
+ struct nfs4_stateowner *lock_sop;
+
+ while (!list_empty(&open_stp->st_lockowners)) {
+ lock_sop = list_entry(open_stp->st_lockowners.next,
+ struct nfs4_stateowner, so_perstateid);
+ /* list_del(&open_stp->st_lockowners); */
+ BUG_ON(lock_sop->so_is_open_owner);
+ release_stateowner(lock_sop);
+ }
+}
+
static void release_open_stateid(struct nfs4_stateid *stp)
{
release_stateid_lockowners(stp);
@@ -332,6 +345,34 @@ static void release_open_stateid(struct nfs4_stateid *stp)
release_generic_stateid(stp);
}
+static void
+unhash_stateowner(struct nfs4_stateowner *sop)
+{
+ struct nfs4_stateid *stp;
+
+ list_del(&sop->so_idhash);
+ list_del(&sop->so_strhash);
+ if (sop->so_is_open_owner)
+ list_del(&sop->so_perclient);
+ list_del(&sop->so_perstateid);
+ while (!list_empty(&sop->so_stateids)) {
+ stp = list_entry(sop->so_stateids.next,
+ struct nfs4_stateid, st_perstateowner);
+ if (sop->so_is_open_owner)
+ release_open_stateid(stp);
+ else
+ release_lock_stateid(stp);
+ }
+}
+
+static void
+release_stateowner(struct nfs4_stateowner *sop)
+{
+ unhash_stateowner(sop);
+ list_del(&sop->so_close_lru);
+ nfs4_put_stateowner(sop);
+}
+
static inline void
renew_client(struct nfs4_client *clp)
{
@@ -1058,48 +1099,6 @@ alloc_init_open_stateowner(unsigned int strhashval, struct nfs4_client *clp, str
return sop;
}
-static void
-release_stateid_lockowners(struct nfs4_stateid *open_stp)
-{
- struct nfs4_stateowner *lock_sop;
-
- while (!list_empty(&open_stp->st_lockowners)) {
- lock_sop = list_entry(open_stp->st_lockowners.next,
- struct nfs4_stateowner, so_perstateid);
- /* list_del(&open_stp->st_lockowners); */
- BUG_ON(lock_sop->so_is_open_owner);
- release_stateowner(lock_sop);
- }
-}
-
-static void
-unhash_stateowner(struct nfs4_stateowner *sop)
-{
- struct nfs4_stateid *stp;
-
- list_del(&sop->so_idhash);
- list_del(&sop->so_strhash);
- if (sop->so_is_open_owner)
- list_del(&sop->so_perclient);
- list_del(&sop->so_perstateid);
- while (!list_empty(&sop->so_stateids)) {
- stp = list_entry(sop->so_stateids.next,
- struct nfs4_stateid, st_perstateowner);
- if (sop->so_is_open_owner)
- release_open_stateid(stp);
- else
- release_lock_stateid(stp);
- }
-}
-
-static void
-release_stateowner(struct nfs4_stateowner *sop)
-{
- unhash_stateowner(sop);
- list_del(&sop->so_close_lru);
- nfs4_put_stateowner(sop);
-}
-
static inline void
init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) {
struct nfs4_stateowner *sop = open->op_stateowner;
--
1.5.5.rc1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] nfsd4: split open/lockowner release code
2009-01-11 23:52 ` [PATCH] nfsd4: remove a forward declaration J. Bruce Fields
@ 2009-01-11 23:52 ` J. Bruce Fields
0 siblings, 0 replies; 6+ messages in thread
From: J. Bruce Fields @ 2009-01-11 23:52 UTC (permalink / raw)
To: linux-nfs; +Cc: J. Bruce Fields
The caller always knows specifically whether it's releasing a lockowner
or an openowner, and the code is simpler if we use separate functions
(and the apparent recursion is gone).
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
fs/nfsd/nfs4state.c | 57 ++++++++++++++++++++++++++++++--------------------
1 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 298d6ce..847bddd 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -116,9 +116,6 @@ opaque_hashval(const void *ptr, int nbytes)
return x;
}
-/* forward declarations */
-static void release_stateowner(struct nfs4_stateowner *sop);
-
/*
* Delegation state
*/
@@ -324,6 +321,26 @@ static void release_lock_stateid(struct nfs4_stateid *stp)
release_generic_stateid(stp);
}
+static void unhash_lockowner(struct nfs4_stateowner *sop)
+{
+ struct nfs4_stateid *stp;
+
+ list_del(&sop->so_idhash);
+ list_del(&sop->so_strhash);
+ list_del(&sop->so_perstateid);
+ while (!list_empty(&sop->so_stateids)) {
+ stp = list_first_entry(&sop->so_stateids,
+ struct nfs4_stateid, st_perstateowner);
+ release_lock_stateid(stp);
+ }
+}
+
+static void release_lockowner(struct nfs4_stateowner *sop)
+{
+ unhash_lockowner(sop);
+ nfs4_put_stateowner(sop);
+}
+
static void
release_stateid_lockowners(struct nfs4_stateid *open_stp)
{
@@ -334,7 +351,7 @@ release_stateid_lockowners(struct nfs4_stateid *open_stp)
struct nfs4_stateowner, so_perstateid);
/* list_del(&open_stp->st_lockowners); */
BUG_ON(lock_sop->so_is_open_owner);
- release_stateowner(lock_sop);
+ release_lockowner(lock_sop);
}
}
@@ -345,30 +362,24 @@ static void release_open_stateid(struct nfs4_stateid *stp)
release_generic_stateid(stp);
}
-static void
-unhash_stateowner(struct nfs4_stateowner *sop)
+static void unhash_openowner(struct nfs4_stateowner *sop)
{
struct nfs4_stateid *stp;
list_del(&sop->so_idhash);
list_del(&sop->so_strhash);
- if (sop->so_is_open_owner)
- list_del(&sop->so_perclient);
- list_del(&sop->so_perstateid);
+ list_del(&sop->so_perclient);
+ list_del(&sop->so_perstateid); /* XXX: necessary? */
while (!list_empty(&sop->so_stateids)) {
- stp = list_entry(sop->so_stateids.next,
- struct nfs4_stateid, st_perstateowner);
- if (sop->so_is_open_owner)
- release_open_stateid(stp);
- else
- release_lock_stateid(stp);
+ stp = list_first_entry(&sop->so_stateids,
+ struct nfs4_stateid, st_perstateowner);
+ release_open_stateid(stp);
}
}
-static void
-release_stateowner(struct nfs4_stateowner *sop)
+static void release_openowner(struct nfs4_stateowner *sop)
{
- unhash_stateowner(sop);
+ unhash_openowner(sop);
list_del(&sop->so_close_lru);
nfs4_put_stateowner(sop);
}
@@ -482,7 +493,7 @@ expire_client(struct nfs4_client *clp)
list_del(&clp->cl_lru);
while (!list_empty(&clp->cl_openowners)) {
sop = list_entry(clp->cl_openowners.next, struct nfs4_stateowner, so_perclient);
- release_stateowner(sop);
+ release_openowner(sop);
}
put_nfs4_client(clp);
}
@@ -1437,7 +1448,7 @@ nfsd4_process_open1(struct nfsd4_open *open)
if (!sop->so_confirmed) {
/* Replace unconfirmed owners without checking for replay. */
clp = sop->so_client;
- release_stateowner(sop);
+ release_openowner(sop);
open->op_stateowner = NULL;
goto renew;
}
@@ -1900,7 +1911,7 @@ nfs4_laundromat(void)
}
dprintk("NFSD: purging unused open stateowner (so_id %d)\n",
sop->so_id);
- release_stateowner(sop);
+ release_openowner(sop);
}
if (clientid_val < NFSD_LAUNDROMAT_MINTIMEOUT)
clientid_val = NFSD_LAUNDROMAT_MINTIMEOUT;
@@ -2790,7 +2801,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
}
out:
if (status && lock->lk_is_new && lock_sop)
- release_stateowner(lock_sop);
+ release_lockowner(lock_sop);
if (lock->lk_replay_owner) {
nfs4_get_stateowner(lock->lk_replay_owner);
cstate->replay_owner = lock->lk_replay_owner;
@@ -3040,7 +3051,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
/* unhash_stateowner deletes so_perclient only
* for openowners. */
list_del(&sop->so_perclient);
- release_stateowner(sop);
+ release_lockowner(sop);
}
out:
nfs4_unlock_state();
--
1.5.5.rc1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] nfsd4: split lockstateid/openstateid release logic
2009-01-11 23:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: remove a forward declaration J. Bruce Fields
@ 2009-01-12 8:52 ` Benny Halevy
2009-01-12 16:20 ` J. Bruce Fields
1 sibling, 1 reply; 6+ messages in thread
From: Benny Halevy @ 2009-01-12 8:52 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: linux-nfs
On Jan. 12, 2009, 1:52 +0200, "J. Bruce Fields" <bfields@citi.umich.edu> wrote:
> The flags here attempt to make the code more general, but I find it
> actually just adds confusion.
>
> I think it's clearer to separate the logic for the open and lock cases
> entirely. And eventually we may want to separate the stateowner and
> stateid types as well, as many of the fields aren't shared between the
> lock and open cases.
>
> Also move to eliminate forward references.
>
> Start with the stateid's.
>
> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
> ---
> fs/nfsd/nfs4state.c | 49 ++++++++++++++++++++++++++-----------------------
> 1 files changed, 26 insertions(+), 23 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 88db7d3..6b8e5a9 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -119,7 +119,6 @@ opaque_hashval(const void *ptr, int nbytes)
>
> /* forward declarations */
> static void release_stateowner(struct nfs4_stateowner *sop);
> -static void release_stateid(struct nfs4_stateid *stp, int flags);
>
> /*
> * Delegation state
> @@ -311,6 +310,28 @@ static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE];
> static struct list_head client_lru;
> static struct list_head close_lru;
>
> +static void release_generic_stateid(struct nfs4_stateid *stp)
> +{
> + list_del(&stp->st_hash);
> + list_del(&stp->st_perfile);
> + list_del(&stp->st_perstateowner);
> + put_nfs4_file(stp->st_file);
> + kmem_cache_free(stateid_slab, stp);
> +}
> +
> +static void release_lock_stateid(struct nfs4_stateid *stp)
> +{
> + locks_remove_posix(stp->st_vfs_file, (fl_owner_t)stp->st_stateowner);
> + release_generic_stateid(stp);
> +}
> +
> +static void release_open_stateid(struct nfs4_stateid *stp)
> +{
> + release_stateid_lockowners(stp);
> + nfsd_close(stp->st_vfs_file);
> + release_generic_stateid(stp);
Bruce, previously the state got unhashed before calling nfsd_close.
In the pnfs world we even go further and release the state lock
before diving into the filesystem since it may invoke callbacks
in the close path (recalling layouts in particular).
How about the code below?
Note that put_nfs4_file still happens in this proposal
after nfsd_close so not to change the current behavior, though
it might be possible to swap the order. I'm not sure about
the ramifications.
Benny
static void unhash_generic_stateid(struct nfs4_stateid *stp)
{
list_del(&stp->st_hash);
list_del(&stp->st_perfile);
list_del(&stp->st_perstateowner);
}
static void free_generic_stateid(struct nfs4_stateid *stp)
{
put_nfs4_file(stp->st_file);
kmem_cache_free(stateid_slab, stp);
}
static void release_open_stateid(struct nfs4_stateid *stp)
{
struct file *filp = stp->st_vfs_file;
release_stateid_lockowners(stp);
unhash_generic_stateid(stp);
nfsd_close(filep);
free_generic_stateid(stp);
}
> +}
> +
> static inline void
> renew_client(struct nfs4_client *clp)
> {
> @@ -1065,9 +1086,9 @@ unhash_stateowner(struct nfs4_stateowner *sop)
> stp = list_entry(sop->so_stateids.next,
> struct nfs4_stateid, st_perstateowner);
> if (sop->so_is_open_owner)
> - release_stateid(stp, OPEN_STATE);
> + release_open_stateid(stp);
> else
> - release_stateid(stp, LOCK_STATE);
> + release_lock_stateid(stp);
> }
> }
>
> @@ -1106,24 +1127,6 @@ init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *
> }
>
> static void
> -release_stateid(struct nfs4_stateid *stp, int flags)
> -{
> - struct file *filp = stp->st_vfs_file;
> -
> - list_del(&stp->st_hash);
> - list_del(&stp->st_perfile);
> - list_del(&stp->st_perstateowner);
> - if (flags & OPEN_STATE) {
> - release_stateid_lockowners(stp);
> - stp->st_vfs_file = NULL;
> - nfsd_close(filp);
> - } else if (flags & LOCK_STATE)
> - locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner);
> - put_nfs4_file(stp->st_file);
> - kmem_cache_free(stateid_slab, stp);
> -}
> -
> -static void
> move_to_close_lru(struct nfs4_stateowner *sop)
> {
> dprintk("NFSD: move_to_close_lru nfs4_stateowner %p\n", sop);
> @@ -1764,7 +1767,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
> init_stateid(stp, fp, open);
> status = nfsd4_truncate(rqstp, current_fh, open);
> if (status) {
> - release_stateid(stp, OPEN_STATE);
> + release_open_stateid(stp);
> goto out;
> }
> }
> @@ -2373,7 +2376,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
>
> /* release_stateid() calls nfsd_close() if needed */
> - release_stateid(stp, OPEN_STATE);
> + release_open_stateid(stp);
>
> /* place unused nfs4_stateowners on so_close_lru list to be
> * released by the laundromat service after the lease period
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nfsd4: split lockstateid/openstateid release logic
2009-01-12 8:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic Benny Halevy
@ 2009-01-12 16:20 ` J. Bruce Fields
0 siblings, 0 replies; 6+ messages in thread
From: J. Bruce Fields @ 2009-01-12 16:20 UTC (permalink / raw)
To: Benny Halevy; +Cc: linux-nfs
On Mon, Jan 12, 2009 at 10:52:37AM +0200, Benny Halevy wrote:
> static void unhash_generic_stateid(struct nfs4_stateid *stp)
> {
> list_del(&stp->st_hash);
> list_del(&stp->st_perfile);
> list_del(&stp->st_perstateowner);
> }
>
> static void free_generic_stateid(struct nfs4_stateid *stp)
> {
> put_nfs4_file(stp->st_file);
> kmem_cache_free(stateid_slab, stp);
> }
>
> static void release_open_stateid(struct nfs4_stateid *stp)
> {
> struct file *filp = stp->st_vfs_file;
>
> release_stateid_lockowners(stp);
> unhash_generic_stateid(stp);
> nfsd_close(filep);
> free_generic_stateid(stp);
> }
Thanks, makes sense to me; so:
--b.
commit cef099ecffe597a4c1c4cb6073190e87433ced61
Author: J. Bruce Fields <bfields@citi.umich.edu>
Date: Sun Jan 11 14:27:17 2009 -0500
nfsd4: split lockstateid/openstateid release logic
The flags here attempt to make the code more general, but I find it
actually just adds confusion.
I think it's clearer to separate the logic for the open and lock cases
entirely. And eventually we may want to separate the stateowner and
stateid types as well, as many of the fields aren't shared between the
lock and open cases.
Also move to eliminate forward references.
Start with the stateid's.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Reviewed-by: Benny Halevy <bhalevy@panasas.com>
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 88db7d3..bccc28d 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -119,7 +119,6 @@ opaque_hashval(const void *ptr, int nbytes)
/* forward declarations */
static void release_stateowner(struct nfs4_stateowner *sop);
-static void release_stateid(struct nfs4_stateid *stp, int flags);
/*
* Delegation state
@@ -311,6 +310,34 @@ static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE];
static struct list_head client_lru;
static struct list_head close_lru;
+static void unhash_generic_stateid(struct nfs4_stateid *stp)
+{
+ list_del(&stp->st_hash);
+ list_del(&stp->st_perfile);
+ list_del(&stp->st_perstateowner);
+}
+
+static void free_generic_stateid(struct nfs4_stateid *stp)
+{
+ put_nfs4_file(stp->st_file);
+ kmem_cache_free(stateid_slab, stp);
+}
+
+static void release_lock_stateid(struct nfs4_stateid *stp)
+{
+ unhash_generic_stateid(stp);
+ locks_remove_posix(stp->st_vfs_file, (fl_owner_t)stp->st_stateowner);
+ free_generic_stateid(stp);
+}
+
+static void release_open_stateid(struct nfs4_stateid *stp)
+{
+ unhash_generic_stateid(stp);
+ release_stateid_lockowners(stp);
+ nfsd_close(stp->st_vfs_file);
+ free_generic_stateid(stp);
+}
+
static inline void
renew_client(struct nfs4_client *clp)
{
@@ -1065,9 +1092,9 @@ unhash_stateowner(struct nfs4_stateowner *sop)
stp = list_entry(sop->so_stateids.next,
struct nfs4_stateid, st_perstateowner);
if (sop->so_is_open_owner)
- release_stateid(stp, OPEN_STATE);
+ release_open_stateid(stp);
else
- release_stateid(stp, LOCK_STATE);
+ release_lock_stateid(stp);
}
}
@@ -1106,24 +1133,6 @@ init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *
}
static void
-release_stateid(struct nfs4_stateid *stp, int flags)
-{
- struct file *filp = stp->st_vfs_file;
-
- list_del(&stp->st_hash);
- list_del(&stp->st_perfile);
- list_del(&stp->st_perstateowner);
- if (flags & OPEN_STATE) {
- release_stateid_lockowners(stp);
- stp->st_vfs_file = NULL;
- nfsd_close(filp);
- } else if (flags & LOCK_STATE)
- locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner);
- put_nfs4_file(stp->st_file);
- kmem_cache_free(stateid_slab, stp);
-}
-
-static void
move_to_close_lru(struct nfs4_stateowner *sop)
{
dprintk("NFSD: move_to_close_lru nfs4_stateowner %p\n", sop);
@@ -1764,7 +1773,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
init_stateid(stp, fp, open);
status = nfsd4_truncate(rqstp, current_fh, open);
if (status) {
- release_stateid(stp, OPEN_STATE);
+ release_open_stateid(stp);
goto out;
}
}
@@ -2373,7 +2382,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
/* release_stateid() calls nfsd_close() if needed */
- release_stateid(stp, OPEN_STATE);
+ release_open_stateid(stp);
/* place unused nfs4_stateowners on so_close_lru list to be
* released by the laundromat service after the lease period
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-01-12 16:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-11 23:52 minor nfsd4 state code cleanup J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: remove a forward declaration J. Bruce Fields
2009-01-11 23:52 ` [PATCH] nfsd4: split open/lockowner release code J. Bruce Fields
2009-01-12 8:52 ` [PATCH] nfsd4: split lockstateid/openstateid release logic Benny Halevy
2009-01-12 16:20 ` J. Bruce Fields
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox