@@ -5530,22 +5530,6 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
5530
5530
return err ;
5531
5531
}
5532
5532
5533
- #define NFS4_LOCK_MINTIMEOUT (1 * HZ)
5534
- #define NFS4_LOCK_MAXTIMEOUT (30 * HZ)
5535
-
5536
- /*
5537
- * sleep, with exponential backoff, and retry the LOCK operation.
5538
- */
5539
- static unsigned long
5540
- nfs4_set_lock_task_retry (unsigned long timeout )
5541
- {
5542
- freezable_schedule_timeout_interruptible (timeout );
5543
- timeout <<= 1 ;
5544
- if (timeout > NFS4_LOCK_MAXTIMEOUT )
5545
- return NFS4_LOCK_MAXTIMEOUT ;
5546
- return timeout ;
5547
- }
5548
-
5549
5533
static int _nfs4_proc_getlk (struct nfs4_state * state , int cmd , struct file_lock * request )
5550
5534
{
5551
5535
struct inode * inode = state -> inode ;
@@ -6178,12 +6162,32 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *
6178
6162
return err ;
6179
6163
}
6180
6164
6165
+ #define NFS4_LOCK_MINTIMEOUT (1 * HZ)
6166
+ #define NFS4_LOCK_MAXTIMEOUT (30 * HZ)
6167
+
6168
+ static int
6169
+ nfs4_retry_setlk (struct nfs4_state * state , int cmd , struct file_lock * request )
6170
+ {
6171
+ int status = - ERESTARTSYS ;
6172
+ unsigned long timeout = NFS4_LOCK_MINTIMEOUT ;
6173
+
6174
+ while (!signalled ()) {
6175
+ status = nfs4_proc_setlk (state , cmd , request );
6176
+ if ((status != - EAGAIN ) || IS_SETLK (cmd ))
6177
+ break ;
6178
+ freezable_schedule_timeout_interruptible (timeout );
6179
+ timeout *= 2 ;
6180
+ timeout = min_t (unsigned long , NFS4_LOCK_MAXTIMEOUT , timeout );
6181
+ status = - ERESTARTSYS ;
6182
+ }
6183
+ return status ;
6184
+ }
6185
+
6181
6186
static int
6182
6187
nfs4_proc_lock (struct file * filp , int cmd , struct file_lock * request )
6183
6188
{
6184
6189
struct nfs_open_context * ctx ;
6185
6190
struct nfs4_state * state ;
6186
- unsigned long timeout = NFS4_LOCK_MINTIMEOUT ;
6187
6191
int status ;
6188
6192
6189
6193
/* verify open state */
@@ -6233,16 +6237,7 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
6233
6237
if (status != 0 )
6234
6238
return status ;
6235
6239
6236
- do {
6237
- status = nfs4_proc_setlk (state , cmd , request );
6238
- if ((status != - EAGAIN ) || IS_SETLK (cmd ))
6239
- break ;
6240
- timeout = nfs4_set_lock_task_retry (timeout );
6241
- status = - ERESTARTSYS ;
6242
- if (signalled ())
6243
- break ;
6244
- } while (status < 0 );
6245
- return status ;
6240
+ return nfs4_retry_setlk (state , cmd , request );
6246
6241
}
6247
6242
6248
6243
int nfs4_lock_delegation_recall (struct file_lock * fl , struct nfs4_state * state , const nfs4_stateid * stateid )
0 commit comments