From: Benny Halevy <bhalevy@tonian.com>
To: tigran.mkrtchyan@desy.de
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/2] nfsv41: handle current stateid on open and close
Date: Sun, 04 Dec 2011 14:42:11 +0200 [thread overview]
Message-ID: <4EDB6AA3.1030702@tonian.com> (raw)
In-Reply-To: <1323000237-13565-3-git-send-email-tigran.mkrtchyan@desy.de>
On 2011-12-04 14:03, tigran.mkrtchyan@desy.de wrote:
> From: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
>
>
> Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
> ---
> fs/nfsd/nfs4proc.c | 6 ++++++
> fs/nfsd/nfs4state.c | 26 ++++++++++++++++++++------
> 2 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index fa38336..535aed2 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -400,6 +400,12 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> */
> status = nfsd4_process_open2(rqstp, &cstate->current_fh, open);
> WARN_ON(status && open->op_created);
> +
> + if(status)
> + goto out;
> +
> + /* set current state id */
> + memcpy(&cstate->current_stateid, &open->op_stateid, sizeof(stateid_t));
Since this should be done for all stateid-returning operations
I think that a cleaner approach could be to mark those as such in
nfsd4_ops by providing a per-op function to return the operation's
stateid. You can then call this method from nfsd4_proc_compound()
after the call to nfsd4_encode_operation() and when status == 0.
> out:
> nfsd4_cleanup_open_state(open, status);
> if (open->op_openowner)
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 47e94e3..a34d82e 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -51,10 +51,14 @@ time_t nfsd4_grace = 90;
> static time_t boot_time;
> static stateid_t zerostateid; /* bits all 0 */
> static stateid_t onestateid; /* bits all 1 */
> +static stateid_t currentstateid; /* other all 0, seqid 1 */
> static u64 current_sessionid = 1;
>
> #define ZERO_STATEID(stateid) (!memcmp((stateid), &zerostateid, sizeof(stateid_t)))
> #define ONE_STATEID(stateid) (!memcmp((stateid), &onestateid, sizeof(stateid_t)))
> +#define CURRENT_STATEID(stateid) (!memcmp((stateid), ¤tstateid, sizeof(stateid_t)))
> +
> +#define STATEID_OF(s, c) ( CURRENT_STATEID((s)) ? &(c)->current_stateid : (s) )
>
> /* forward declarations */
> static int check_for_locks(struct nfs4_file *filp, struct nfs4_lockowner *lowner);
> @@ -3314,13 +3318,15 @@ static __be32 nfsd4_lookup_stateid(stateid_t *stateid, unsigned char typemask, s
> */
> __be32
> nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
> - stateid_t *stateid, int flags, struct file **filpp)
> + stateid_t *stateid_in, int flags, struct file **filpp)
> {
> struct nfs4_stid *s;
> struct nfs4_ol_stateid *stp = NULL;
> struct nfs4_delegation *dp = NULL;
> struct svc_fh *current_fh = &cstate->current_fh;
> struct inode *ino = current_fh->fh_dentry->d_inode;
> + stateid_t *stateid;
> +
> __be32 status;
>
> if (filpp)
> @@ -3329,9 +3335,11 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
> if (grace_disallows_io(ino))
> return nfserr_grace;
>
> - if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
> - return check_special_stateids(current_fh, stateid, flags);
> + if (ZERO_STATEID(stateid_in) || ONE_STATEID(stateid_in))
> + return check_special_stateids(current_fh, stateid_in, flags);
>
> + stateid = STATEID_OF(stateid_in, cstate);
> +
> status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, &s);
> if (status)
> return status;
> @@ -3655,14 +3663,17 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> __be32 status;
> struct nfs4_openowner *oo;
> struct nfs4_ol_stateid *stp;
> + stateid_t *stateid;
>
> dprintk("NFSD: nfsd4_close on file %.*s\n",
> (int)cstate->current_fh.fh_dentry->d_name.len,
> cstate->current_fh.fh_dentry->d_name.name);
>
> nfs4_lock_state();
> + stateid = STATEID_OF( &close->cl_stateid, cstate);
nit: extra space after open-parentheses
> +
> status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid,
> - &close->cl_stateid,
> + stateid,
> NFS4_OPEN_STID|NFS4_CLOSED_STID,
> &stp);
> if (status)
> @@ -3670,7 +3681,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> oo = openowner(stp->st_stateowner);
> status = nfs_ok;
> update_stateid(&stp->st_stid.sc_stateid);
> - memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
> + memcpy(stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
Currently, nfsd4_encode_close uses close->cl_stateid so we need to keep its value
up-to-date. With the scheme I outlined above, copying into cstate->current_stateid can
be done in a centralized place.
Benny
>
> nfsd4_close_open_stateid(stp);
> oo->oo_last_closed_stid = stp;
> @@ -4400,7 +4411,7 @@ int
> nfs4_state_init(void)
> {
> int i, status;
> -
> + uint32_t one = 1;
> status = nfsd4_init_slabs();
> if (status)
> return status;
> @@ -4423,6 +4434,9 @@ nfs4_state_init(void)
> INIT_LIST_HEAD(&lock_ownerstr_hashtbl[i]);
> }
> memset(&onestateid, ~0, sizeof(stateid_t));
> + /* seqid 1, other all 0 */
> + memcpy(¤tstateid , &one, sizeof(one));
> +
you mean currentstateid.si_generation = cpu_to_be32(1) ?
> INIT_LIST_HEAD(&close_lru);
> INIT_LIST_HEAD(&client_lru);
> INIT_LIST_HEAD(&del_recall_lru);
next prev parent reply other threads:[~2011-12-04 12:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-04 12:03 nfsv41: add current_stateid processing tigran.mkrtchyan
2011-12-04 12:03 ` [PATCH 1/2] nfsv41: add current stateid into compound_state tigran.mkrtchyan
2011-12-04 12:25 ` Benny Halevy
2011-12-04 12:03 ` [PATCH 2/2] nfsv41: handle current stateid on open and close tigran.mkrtchyan
2011-12-04 12:42 ` Benny Halevy [this message]
2011-12-04 13:53 ` Tigran Mkrtchyan
2011-12-06 2:08 ` J. Bruce Fields
2011-12-06 11:26 ` Benny Halevy
2011-12-06 12:40 ` J. Bruce Fields
2011-12-06 14:30 ` Benny Halevy
2011-12-06 19:10 ` J. Bruce Fields
2011-12-06 21:47 ` Tigran Mkrtchyan
2011-12-07 14:15 ` Benny Halevy
2011-12-06 13:31 ` Tigran Mkrtchyan
2011-12-06 13:40 ` J. Bruce Fields
2011-12-06 14:32 ` Benny Halevy
2011-12-06 18:24 ` Tigran Mkrtchyan
2011-12-07 14:17 ` Benny Halevy
2011-12-04 12:48 ` nfsv41: add current_stateid processing Benny Halevy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EDB6AA3.1030702@tonian.com \
--to=bhalevy@tonian.com \
--cc=linux-nfs@vger.kernel.org \
--cc=tigran.mkrtchyan@desy.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.