Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acf9295b authored by Trond Myklebust's avatar Trond Myklebust Committed by J. Bruce Fields
Browse files

nfsd: clean up nfsd4_close_open_stateid



Minor cleanup that should introduce no behavioral changes.

Currently this function just unhashes the stateid and leaves the caller
to do the work of the CLOSE processing.

Change nfsd4_close_open_stateid so that it handles doing all of the work
of closing a stateid. Move the handling of the unhashed stateid into it
instead of doing that work in nfsd4_close. This will help isolate some
coming changes to stateid handling from nfsd4_close.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent db24b3b4
Loading
Loading
Loading
Loading
+18 −20
Original line number Original line Diff line number Diff line
@@ -4129,8 +4129,25 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,


static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
{
{
	unhash_open_stateid(s);
	struct nfs4_client *clp = s->st_stid.sc_client;
	struct nfs4_openowner *oo = openowner(s->st_stateowner);

	s->st_stid.sc_type = NFS4_CLOSED_STID;
	s->st_stid.sc_type = NFS4_CLOSED_STID;
	unhash_open_stateid(s);

	if (clp->cl_minorversion) {
		free_generic_stateid(s);
		if (list_empty(&oo->oo_owner.so_stateids))
			release_openowner(oo);
	} else {
		oo->oo_last_closed_stid = s;
		/*
		 * In the 4.0 case we need to keep the owners around a
		 * little while to handle CLOSE replay.
		 */
		if (list_empty(&oo->oo_owner.so_stateids))
			move_to_close_lru(oo, clp->net);
	}
}
}


/*
/*
@@ -4141,7 +4158,6 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
	    struct nfsd4_close *close)
	    struct nfsd4_close *close)
{
{
	__be32 status;
	__be32 status;
	struct nfs4_openowner *oo;
	struct nfs4_ol_stateid *stp;
	struct nfs4_ol_stateid *stp;
	struct net *net = SVC_NET(rqstp);
	struct net *net = SVC_NET(rqstp);
	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
@@ -4157,28 +4173,10 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
	nfsd4_bump_seqid(cstate, status);
	nfsd4_bump_seqid(cstate, status);
	if (status)
	if (status)
		goto out; 
		goto out; 
	oo = openowner(stp->st_stateowner);
	update_stateid(&stp->st_stid.sc_stateid);
	update_stateid(&stp->st_stid.sc_stateid);
	memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
	memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));


	nfsd4_close_open_stateid(stp);
	nfsd4_close_open_stateid(stp);

	if (cstate->minorversion)
		free_generic_stateid(stp);
	else
		oo->oo_last_closed_stid = stp;

	if (list_empty(&oo->oo_owner.so_stateids)) {
		if (cstate->minorversion)
			release_openowner(oo);
		else {
			/*
			 * In the 4.0 case we need to keep the owners around a
			 * little while to handle CLOSE replay.
			 */
			move_to_close_lru(oo, SVC_NET(rqstp));
		}
	}
out:
out:
	if (!cstate->replay_owner)
	if (!cstate->replay_owner)
		nfs4_unlock_state();
		nfs4_unlock_state();