Commit fe0750e5 authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: split stateowners into open and lockowners

The stateowner has some fields that only make sense for openowners, and
some that only make sense for lockowners, and I find it a lot clearer if
those are separated out.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent f4dee24c
...@@ -250,7 +250,7 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o ...@@ -250,7 +250,7 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
fh_dup2(current_fh, &resfh); fh_dup2(current_fh, &resfh);
/* set reply cache */ /* set reply cache */
fh_copy_shallow(&open->op_stateowner->so_replay.rp_openfh, fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh,
&resfh.fh_handle); &resfh.fh_handle);
if (!created) if (!created)
status = do_open_permission(rqstp, current_fh, open, status = do_open_permission(rqstp, current_fh, open,
...@@ -277,7 +277,7 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_ ...@@ -277,7 +277,7 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info)); memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info));
/* set replay cache */ /* set replay cache */
fh_copy_shallow(&open->op_stateowner->so_replay.rp_openfh, fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh,
&current_fh->fh_handle); &current_fh->fh_handle);
open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
...@@ -306,9 +306,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -306,9 +306,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
__be32 status; __be32 status;
struct nfsd4_compoundres *resp; struct nfsd4_compoundres *resp;
dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n", dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n",
(int)open->op_fname.len, open->op_fname.data, (int)open->op_fname.len, open->op_fname.data,
open->op_stateowner); open->op_openowner);
/* This check required by spec. */ /* This check required by spec. */
if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
...@@ -332,7 +332,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -332,7 +332,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
resp = rqstp->rq_resp; resp = rqstp->rq_resp;
status = nfsd4_process_open1(&resp->cstate, open); status = nfsd4_process_open1(&resp->cstate, open);
if (status == nfserr_replay_me) { if (status == nfserr_replay_me) {
struct nfs4_replay *rp = &open->op_stateowner->so_replay; struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay;
fh_put(&cstate->current_fh); fh_put(&cstate->current_fh);
fh_copy_shallow(&cstate->current_fh.fh_handle, fh_copy_shallow(&cstate->current_fh.fh_handle,
&rp->rp_openfh); &rp->rp_openfh);
...@@ -374,7 +374,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -374,7 +374,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
goto out; goto out;
break; break;
case NFS4_OPEN_CLAIM_PREVIOUS: case NFS4_OPEN_CLAIM_PREVIOUS:
open->op_stateowner->so_confirmed = 1; open->op_openowner->oo_confirmed = 1;
/* /*
* The CURRENT_FH is already set to the file being * The CURRENT_FH is already set to the file being
* opened. (1) set open->op_cinfo, (2) set * opened. (1) set open->op_cinfo, (2) set
...@@ -387,7 +387,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -387,7 +387,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
goto out; goto out;
break; break;
case NFS4_OPEN_CLAIM_DELEGATE_PREV: case NFS4_OPEN_CLAIM_DELEGATE_PREV:
open->op_stateowner->so_confirmed = 1; open->op_openowner->oo_confirmed = 1;
dprintk("NFSD: unsupported OPEN claim type %d\n", dprintk("NFSD: unsupported OPEN claim type %d\n",
open->op_claim_type); open->op_claim_type);
status = nfserr_notsupp; status = nfserr_notsupp;
...@@ -405,8 +405,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -405,8 +405,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
*/ */
status = nfsd4_process_open2(rqstp, &cstate->current_fh, open); status = nfsd4_process_open2(rqstp, &cstate->current_fh, open);
out: out:
if (open->op_stateowner) if (open->op_openowner)
cstate->replay_owner = open->op_stateowner; cstate->replay_owner = &open->op_openowner->oo_owner;
else else
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
......
This diff is collapsed.
...@@ -646,7 +646,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) ...@@ -646,7 +646,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
memset(open->op_bmval, 0, sizeof(open->op_bmval)); memset(open->op_bmval, 0, sizeof(open->op_bmval));
open->op_iattr.ia_valid = 0; open->op_iattr.ia_valid = 0;
open->op_stateowner = NULL; open->op_openowner = NULL;
/* seqid, share_access, share_deny, clientid, ownerlen */ /* seqid, share_access, share_deny, clientid, ownerlen */
READ_BUF(16 + sizeof(clientid_t)); READ_BUF(16 + sizeof(clientid_t));
......
...@@ -337,14 +337,11 @@ struct nfs4_replay { ...@@ -337,14 +337,11 @@ struct nfs4_replay {
* reaped (when so_perfilestate is empty) to hold the last close replay. * reaped (when so_perfilestate is empty) to hold the last close replay.
* reaped by laundramat thread after lease period. * reaped by laundramat thread after lease period.
*/ */
struct nfs4_stateowner { struct nfs4_stateowner {
struct list_head so_idhash; /* hash by so_id */ struct list_head so_idhash; /* hash by so_id */
struct list_head so_strhash; /* hash by op_name */ struct list_head so_strhash; /* hash by op_name */
struct list_head so_perclient;
struct list_head so_stateids; struct list_head so_stateids;
struct list_head so_perstateid; /* for lockowners only */
struct list_head so_close_lru; /* tail queue */
time_t so_time; /* time of placement on so_close_lru */
int so_is_open_owner; /* 1=openowner,0=lockowner */ int so_is_open_owner; /* 1=openowner,0=lockowner */
u32 so_id; u32 so_id;
struct nfs4_client * so_client; struct nfs4_client * so_client;
...@@ -352,10 +349,33 @@ struct nfs4_stateowner { ...@@ -352,10 +349,33 @@ struct nfs4_stateowner {
* sequence id expected from the client: */ * sequence id expected from the client: */
u32 so_seqid; u32 so_seqid;
struct xdr_netobj so_owner; /* open owner name */ struct xdr_netobj so_owner; /* open owner name */
int so_confirmed; /* successful OPEN_CONFIRM? */
struct nfs4_replay so_replay; struct nfs4_replay so_replay;
}; };
struct nfs4_openowner {
struct nfs4_stateowner oo_owner; /* must be first field */
struct list_head oo_perclient;
struct list_head oo_close_lru; /* tail queue */
time_t oo_time; /* time of placement on so_close_lru */
int oo_confirmed; /* successful OPEN_CONFIRM? */
};
struct nfs4_lockowner {
struct nfs4_stateowner lo_owner; /* must be first element */
struct list_head lo_perstateid; /* for lockowners only */
struct list_head lo_list; /* for temporary uses */
};
static inline struct nfs4_openowner * openowner(struct nfs4_stateowner *so)
{
return container_of(so, struct nfs4_openowner, oo_owner);
}
static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)
{
return container_of(so, struct nfs4_lockowner, lo_owner);
}
/* /*
* nfs4_file: a file opened by some number of (open) nfs4_stateowners. * nfs4_file: a file opened by some number of (open) nfs4_stateowners.
* o fi_perfile list is used to search for conflicting * o fi_perfile list is used to search for conflicting
...@@ -457,7 +477,8 @@ extern void nfs4_lock_state(void); ...@@ -457,7 +477,8 @@ extern void nfs4_lock_state(void);
extern void nfs4_unlock_state(void); extern void nfs4_unlock_state(void);
extern int nfs4_in_grace(void); extern int nfs4_in_grace(void);
extern __be32 nfs4_check_open_reclaim(clientid_t *clid); extern __be32 nfs4_check_open_reclaim(clientid_t *clid);
extern void nfs4_free_stateowner(struct nfs4_stateowner *sop); extern void nfs4_free_openowner(struct nfs4_openowner *);
extern void nfs4_free_lockowner(struct nfs4_lockowner *);
extern int set_callback_cred(void); extern int set_callback_cred(void);
extern void nfsd4_probe_callback(struct nfs4_client *clp); extern void nfsd4_probe_callback(struct nfs4_client *clp);
extern void nfsd4_probe_callback_sync(struct nfs4_client *clp); extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
......
...@@ -227,7 +227,7 @@ struct nfsd4_open { ...@@ -227,7 +227,7 @@ struct nfsd4_open {
struct nfsd4_change_info op_cinfo; /* response */ struct nfsd4_change_info op_cinfo; /* response */
u32 op_rflags; /* response */ u32 op_rflags; /* response */
int op_truncate; /* used during processing */ int op_truncate; /* used during processing */
struct nfs4_stateowner *op_stateowner; /* used during processing */ struct nfs4_openowner *op_openowner; /* used during processing */
struct nfs4_acl *op_acl; struct nfs4_acl *op_acl;
}; };
#define op_iattr iattr #define op_iattr iattr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment