This patch uses the FL_SLEEP flag in struct file_lock to check if it's a blocking request in case if the request coming from nfs lockd process indicated by lm_grant() is set. IF FL_SLEEP is set a asynchronous blocking request is being made and it's waiting for lm_grant() callback being called to signal the lock was granted. If it's not set a synchronous non-blocking request is being made. Signed-off-by: Alexander Aring <aahringo@xxxxxxxxxx> --- fs/dlm/plock.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c index 0094fa4004cc..524771002a2f 100644 --- a/fs/dlm/plock.c +++ b/fs/dlm/plock.c @@ -140,7 +140,6 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, op->info.optype = DLM_PLOCK_OP_LOCK; op->info.pid = fl->fl_pid; op->info.ex = (fl->fl_type == F_WRLCK); - op->info.wait = IS_SETLKW(cmd); op->info.fsid = ls->ls_global_id; op->info.number = number; op->info.start = fl->fl_start; @@ -148,24 +147,31 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, op->info.owner = (__u64)(long)fl->fl_owner; /* async handling */ if (fl->fl_lmops && fl->fl_lmops->lm_grant) { - op_data = kzalloc(sizeof(*op_data), GFP_NOFS); - if (!op_data) { - dlm_release_plock_op(op); - rv = -ENOMEM; - goto out; - } + if (fl->fl_flags & FL_SLEEP) { + op_data = kzalloc(sizeof(*op_data), GFP_NOFS); + if (!op_data) { + dlm_release_plock_op(op); + rv = -ENOMEM; + goto out; + } - op_data->callback = fl->fl_lmops->lm_grant; - locks_init_lock(&op_data->flc); - locks_copy_lock(&op_data->flc, fl); - op_data->fl = fl; - op_data->file = file; + op->info.wait = 1; + op_data->callback = fl->fl_lmops->lm_grant; + locks_init_lock(&op_data->flc); + locks_copy_lock(&op_data->flc, fl); + op_data->fl = fl; + op_data->file = file; - op->data = op_data; + op->data = op_data; - send_op(op); - rv = FILE_LOCK_DEFERRED; - goto out; + send_op(op); + rv = FILE_LOCK_DEFERRED; + goto out; + } else { + op->info.wait = 0; + } + } else { + op->info.wait = IS_SETLKW(cmd); } send_op(op); -- 2.31.1