Skip to content

Commit

Permalink
lockd: shift grabbing a reference to nlm_host into nlm_alloc_call()
Browse files Browse the repository at this point in the history
It's used both for client and server hosts; we can't do nlmclnt_release_host()
on failure exits, since the host might need nlmsvc_release_host(), with BUG_ON()
for calling the wrong one.  Makes life simpler for callers, actually...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jul 29, 2012
1 parent a51d9ea commit 446945a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
9 changes: 2 additions & 7 deletions fs/lockd/clntproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl)
struct nlm_rqst *call;
int status;

nlm_get_host(host);
call = nlm_alloc_call(host);
if (call == NULL)
return -ENOMEM;
Expand Down Expand Up @@ -185,9 +184,6 @@ EXPORT_SYMBOL_GPL(nlmclnt_proc);

/*
* Allocate an NLM RPC call struct
*
* Note: the caller must hold a reference to host. In case of failure,
* this reference will be released.
*/
struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)
{
Expand All @@ -199,15 +195,14 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)
atomic_set(&call->a_count, 1);
locks_init_lock(&call->a_args.lock.fl);
locks_init_lock(&call->a_res.lock.fl);
call->a_host = host;
call->a_host = nlm_get_host(host);
return call;
}
if (signalled())
break;
printk("nlm_alloc_call: failed, waiting for memory\n");
schedule_timeout_interruptible(5*HZ);
}
nlmclnt_release_host(host);
return NULL;
}

Expand Down Expand Up @@ -750,7 +745,7 @@ static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl
dprintk("lockd: blocking lock attempt was interrupted by a signal.\n"
" Attempting to cancel lock.\n");

req = nlm_alloc_call(nlm_get_host(host));
req = nlm_alloc_call(host);
if (!req)
return -ENOMEM;
req->a_flags = RPC_TASK_ASYNC;
Expand Down
1 change: 1 addition & 0 deletions fs/lockd/svc4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args
return rpc_system_err;

call = nlm_alloc_call(host);
nlmsvc_release_host(host);
if (call == NULL)
return rpc_system_err;

Expand Down
1 change: 0 additions & 1 deletion fs/lockd/svclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host,
struct nlm_block *block;
struct nlm_rqst *call = NULL;

nlm_get_host(host);
call = nlm_alloc_call(host);
if (call == NULL)
return NULL;
Expand Down
1 change: 1 addition & 0 deletions fs/lockd/svcproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args
return rpc_system_err;

call = nlm_alloc_call(host);
nlmsvc_release_host(host);
if (call == NULL)
return rpc_system_err;

Expand Down

0 comments on commit 446945a

Please sign in to comment.