Skip to content

Commit b840be2

Browse files
J. Bruce Fieldschucklever
authored andcommitted
lockd: don't attempt blocking locks on nfs reexports
As in the v4 case, it doesn't work well to block waiting for a lock on an nfs filesystem. As in the v4 case, that means we're depending on the client to poll. It's probably incorrect to depend on that, but I *think* clients do poll in practice. In any case, it's an improvement over hanging the lockd thread indefinitely as we currently are. Signed-off-by: J. Bruce Fields <[email protected]> Acked-by: Anna Schumaker <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent f657f8e commit b840be2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/lockd/svclock.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/lockd/nlm.h>
3232
#include <linux/lockd/lockd.h>
3333
#include <linux/kthread.h>
34+
#include <linux/exportfs.h>
3435

3536
#define NLMDBG_FACILITY NLMDBG_SVCLOCK
3637

@@ -470,18 +471,24 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
470471
struct nlm_cookie *cookie, int reclaim)
471472
{
472473
struct nlm_block *block = NULL;
474+
struct inode *inode = nlmsvc_file_inode(file);
473475
int error;
474476
int mode;
477+
int async_block = 0;
475478
__be32 ret;
476479

477480
dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
478-
nlmsvc_file_inode(file)->i_sb->s_id,
479-
nlmsvc_file_inode(file)->i_ino,
481+
inode->i_sb->s_id, inode->i_ino,
480482
lock->fl.fl_type, lock->fl.fl_pid,
481483
(long long)lock->fl.fl_start,
482484
(long long)lock->fl.fl_end,
483485
wait);
484486

487+
if (inode->i_sb->s_export_op->flags & EXPORT_OP_SYNC_LOCKS) {
488+
async_block = wait;
489+
wait = 0;
490+
}
491+
485492
/* Lock file against concurrent access */
486493
mutex_lock(&file->f_mutex);
487494
/* Get existing block (in case client is busy-waiting)
@@ -542,7 +549,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
542549
*/
543550
if (wait)
544551
break;
545-
ret = nlm_lck_denied;
552+
ret = async_block ? nlm_lck_blocked : nlm_lck_denied;
546553
goto out;
547554
case FILE_LOCK_DEFERRED:
548555
if (wait)

0 commit comments

Comments
 (0)