Commit e1aaa891 authored by J. Bruce Fields's avatar J. Bruce Fields
Browse files

nfsd4: nfsd4_lock() cleanup



Share a little common logic.  And note the comments here are a little
out of date (e.g. we don't always create new state in the "new" case any
more.)

Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 9068bed1
Loading
Loading
Loading
Loading
+3 −12
Original line number Original line Diff line number Diff line
@@ -4059,11 +4059,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
	nfs4_lock_state();
	nfs4_lock_state();


	if (lock->lk_is_new) {
	if (lock->lk_is_new) {
		/*
		 * Client indicates that this is a new lockowner.
		 * Use open owner and open stateid to create lock owner and
		 * lock stateid.
		 */
		struct nfs4_ol_stateid *open_stp = NULL;
		struct nfs4_ol_stateid *open_stp = NULL;


		if (nfsd4_has_session(cstate))
		if (nfsd4_has_session(cstate))
@@ -4090,17 +4085,13 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
			goto out;
			goto out;
		status = lookup_or_create_lock_state(cstate, open_stp, lock,
		status = lookup_or_create_lock_state(cstate, open_stp, lock,
							&lock_stp, &new_state);
							&lock_stp, &new_state);
		if (status)
	} else
			goto out;
	} else {
		/* lock (lock owner + lock stateid) already exists */
		status = nfs4_preprocess_seqid_op(cstate,
		status = nfs4_preprocess_seqid_op(cstate,
				       lock->lk_old_lock_seqid,
				       lock->lk_old_lock_seqid,
				       &lock->lk_old_lock_stateid,
				       &lock->lk_old_lock_stateid,
				       NFS4_LOCK_STID, &lock_stp);
				       NFS4_LOCK_STID, &lock_stp);
	if (status)
	if (status)
		goto out;
		goto out;
	}
	lock_sop = lockowner(lock_stp->st_stateowner);
	lock_sop = lockowner(lock_stp->st_stateowner);


	lkflg = setlkflg(lock->lk_type);
	lkflg = setlkflg(lock->lk_type);