mirror of https://gitee.com/openkylin/linux.git
lockd: eliminate duplicate nlmsvc_lookup_host call from nlmsvc_testlock
nlmsvc_testlock calls nlmsvc_lookup_host to find a nlm_host struct. The callers of this functions, however, call nlmsvc_retrieve_args or nlm4svc_retrieve_args, which also return a nlm_host struct. Change nlmsvc_testlock 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. We take a reference to host in the place where nlmsvc_testlock() previous did a new lookup, so the reference counting is unchanged from before. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
parent
b0e92aae15
commit
8f920d5e29
|
@ -99,7 +99,7 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||||
|
|
||||||
/* Now check for conflicting locks */
|
/* Now check for conflicting locks */
|
||||||
resp->status = nlmsvc_testlock(rqstp, file, &argp->lock, &resp->lock, &resp->cookie);
|
resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie);
|
||||||
if (resp->status == nlm_drop_reply)
|
if (resp->status == nlm_drop_reply)
|
||||||
rc = rpc_drop_reply;
|
rc = rpc_drop_reply;
|
||||||
else
|
else
|
||||||
|
|
|
@ -460,8 +460,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||||
*/
|
*/
|
||||||
__be32
|
__be32
|
||||||
nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
|
nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||||
struct nlm_lock *lock, struct nlm_lock *conflock,
|
struct nlm_host *host, struct nlm_lock *lock,
|
||||||
struct nlm_cookie *cookie)
|
struct nlm_lock *conflock, struct nlm_cookie *cookie)
|
||||||
{
|
{
|
||||||
struct nlm_block *block = NULL;
|
struct nlm_block *block = NULL;
|
||||||
int error;
|
int error;
|
||||||
|
@ -479,16 +479,10 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
|
||||||
|
|
||||||
if (block == NULL) {
|
if (block == NULL) {
|
||||||
struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
|
struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
|
||||||
struct nlm_host *host;
|
|
||||||
|
|
||||||
if (conf == NULL)
|
if (conf == NULL)
|
||||||
return nlm_granted;
|
return nlm_granted;
|
||||||
/* Create host handle for callback */
|
nlm_get_host(host);
|
||||||
host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
|
|
||||||
if (host == NULL) {
|
|
||||||
kfree(conf);
|
|
||||||
return nlm_lck_denied_nolocks;
|
|
||||||
}
|
|
||||||
block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
|
block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
|
||||||
if (block == NULL) {
|
if (block == NULL) {
|
||||||
kfree(conf);
|
kfree(conf);
|
||||||
|
|
|
@ -128,7 +128,7 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
|
||||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||||
|
|
||||||
/* Now check for conflicting locks */
|
/* Now check for conflicting locks */
|
||||||
resp->status = cast_status(nlmsvc_testlock(rqstp, file, &argp->lock, &resp->lock, &resp->cookie));
|
resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie));
|
||||||
if (resp->status == nlm_drop_reply)
|
if (resp->status == nlm_drop_reply)
|
||||||
rc = rpc_drop_reply;
|
rc = rpc_drop_reply;
|
||||||
else
|
else
|
||||||
|
|
|
@ -203,7 +203,8 @@ __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
|
||||||
struct nlm_lock *, int, struct nlm_cookie *);
|
struct nlm_lock *, int, struct nlm_cookie *);
|
||||||
__be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
|
__be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
|
||||||
__be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *,
|
__be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *,
|
||||||
struct nlm_lock *, struct nlm_lock *, struct nlm_cookie *);
|
struct nlm_host *, struct nlm_lock *,
|
||||||
|
struct nlm_lock *, struct nlm_cookie *);
|
||||||
__be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
|
__be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
|
||||||
unsigned long nlmsvc_retry_blocked(void);
|
unsigned long nlmsvc_retry_blocked(void);
|
||||||
void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
|
void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
|
||||||
|
|
Loading…
Reference in New Issue