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

Commit 6cde4de8 authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields
Browse files

lockd: eliminate duplicate nlmsvc_lookup_host call from nlmsvc_lock



nlmsvc_lock calls nlmsvc_lookup_host to find a nlm_host struct. The
callers of this function, however, call nlmsvc_retrieve_args or
nlm4svc_retrieve_args, which also return a nlm_host struct.

Change nlmsvc_lock to take a host arg instead of calling
nlmsvc_lookup_host itself and change the callers to pass a pointer to
the nlm_host they've already found.

Since nlmsvc_testlock() now just uses the caller's reference, we no
longer need to get or release it.

Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 8f920d5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
#endif

	/* Now try to lock the file */
	resp->status = nlmsvc_lock(rqstp, file, &argp->lock,
	resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock,
					argp->block, &argp->cookie);
	if (resp->status == nlm_drop_reply)
		rc = rpc_drop_reply;
+2 −8
Original line number Diff line number Diff line
@@ -358,10 +358,10 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block)
 */
__be32
nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
			struct nlm_lock *lock, int wait, struct nlm_cookie *cookie)
	    struct nlm_host *host, struct nlm_lock *lock, int wait,
	    struct nlm_cookie *cookie)
{
	struct nlm_block	*block = NULL;
	struct nlm_host		*host;
	int			error;
	__be32			ret;

@@ -373,11 +373,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
				(long long)lock->fl.fl_end,
				wait);

	/* Create host handle for callback */
	host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
	if (host == NULL)
		return nlm_lck_denied_nolocks;

	/* Lock file against concurrent access */
	mutex_lock(&file->f_mutex);
	/* Get existing block (in case client is busy-waiting)
@@ -450,7 +445,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
out:
	mutex_unlock(&file->f_mutex);
	nlmsvc_release_block(block);
	nlm_release_host(host);
	dprintk("lockd: nlmsvc_lock returned %u\n", ret);
	return ret;
}
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
#endif

	/* Now try to lock the file */
	resp->status = cast_status(nlmsvc_lock(rqstp, file, &argp->lock,
	resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock,
					       argp->block, &argp->cookie));
	if (resp->status == nlm_drop_reply)
		rc = rpc_drop_reply;
+2 −1
Original line number Diff line number Diff line
@@ -200,7 +200,8 @@ typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref);
 * Server-side lock handling
 */
__be32		  nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
					struct nlm_lock *, int, struct nlm_cookie *);
			      struct nlm_host *, struct nlm_lock *, int,
			      struct nlm_cookie *);
__be32		  nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
__be32		  nlmsvc_testlock(struct svc_rqst *, struct nlm_file *,
			struct nlm_host *, struct nlm_lock *,