NLM: Ensure that nlmclnt_cancel_callback() doesn't loop forever

If the server returns NLM_LCK_DENIED_NOLOCKS, we currently retry the
 entire NLM_CANCEL request. This may end up looping forever unless the
 server changes its mind (why would it do that, though?).

 Ensure that we limit the number of retries (to 3).

 See bug# 5957 in bugzilla.kernel.org.

 Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Trond Myklebust 2006-02-01 12:18:25 -05:00
parent 16fb24252a
commit aaaa99423b
2 changed files with 5 additions and 0 deletions

View file

@ -22,6 +22,7 @@
#define NLMDBG_FACILITY NLMDBG_CLIENT #define NLMDBG_FACILITY NLMDBG_CLIENT
#define NLMCLNT_GRACE_WAIT (5*HZ) #define NLMCLNT_GRACE_WAIT (5*HZ)
#define NLMCLNT_POLL_TIMEOUT (30*HZ) #define NLMCLNT_POLL_TIMEOUT (30*HZ)
#define NLMCLNT_MAX_RETRIES 3
static int nlmclnt_test(struct nlm_rqst *, struct file_lock *); static int nlmclnt_test(struct nlm_rqst *, struct file_lock *);
static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *); static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *);
@ -802,6 +803,9 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
return; return;
retry_cancel: retry_cancel:
/* Don't ever retry more than 3 times */
if (req->a_retries++ >= NLMCLNT_MAX_RETRIES)
goto die;
nlm_rebind_host(req->a_host); nlm_rebind_host(req->a_host);
rpc_restart_call(task); rpc_restart_call(task);
rpc_delay(task, 30 * HZ); rpc_delay(task, 30 * HZ);

View file

@ -84,6 +84,7 @@ struct nlm_rqst {
struct nlm_args a_args; /* arguments */ struct nlm_args a_args; /* arguments */
struct nlm_res a_res; /* result */ struct nlm_res a_res; /* result */
struct nlm_wait * a_block; struct nlm_wait * a_block;
unsigned int a_retries; /* Retry count */
char a_owner[NLMCLNT_OHSIZE]; char a_owner[NLMCLNT_OHSIZE];
}; };