Skip to content

Commit

Permalink
dlm: avoid unnecessary posix unlock
Browse files Browse the repository at this point in the history
When the kernel clears flocks/plocks during close, it calls posix
unlock when there are flocks but no posix locks.  Without this
patch, that unnecessary posix unlock is passed to userland
(dlm_controld), across the cluster, and back to the kernel.
This can create a lot of plock activity, even when no posix
locks had been used.

This patch copies the nfs approach, and skips the full posix
unlock if there is no plock found during the vfs unlock phase.

Signed-off-by: David Teigland <[email protected]>
  • Loading branch information
teigland committed Apr 8, 2013
1 parent 31880c3 commit 9000831
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions fs/dlm/plock.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
struct dlm_ls *ls;
struct plock_op *op;
int rv;
unsigned char fl_flags = fl->fl_flags;

ls = dlm_find_lockspace_local(lockspace);
if (!ls)
Expand All @@ -258,9 +259,18 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
goto out;
}

if (posix_lock_file_wait(file, fl) < 0)
log_error(ls, "dlm_posix_unlock: vfs unlock error %llx",
(unsigned long long)number);
/* cause the vfs unlock to return ENOENT if lock is not found */
fl->fl_flags |= FL_EXISTS;

rv = posix_lock_file_wait(file, fl);
if (rv == -ENOENT) {
rv = 0;
goto out_free;
}
if (rv < 0) {
log_error(ls, "dlm_posix_unlock: vfs unlock error %d %llx",
rv, (unsigned long long)number);
}

op->info.optype = DLM_PLOCK_OP_UNLOCK;
op->info.pid = fl->fl_pid;
Expand Down Expand Up @@ -296,9 +306,11 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
if (rv == -ENOENT)
rv = 0;

out_free:
kfree(op);
out:
dlm_put_lockspace(ls);
fl->fl_flags = fl_flags;
return rv;
}
EXPORT_SYMBOL_GPL(dlm_posix_unlock);
Expand Down

0 comments on commit 9000831

Please sign in to comment.