Commit 900083183959107159f962b83b3b439d53796499

Authored by David Teigland
1 parent 31880c37c1

dlm: avoid unnecessary posix unlock

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 <teigland@redhat.com>

Showing 1 changed file with 15 additions and 3 deletions Side-by-side Diff

... ... @@ -247,6 +247,7 @@
247 247 struct dlm_ls *ls;
248 248 struct plock_op *op;
249 249 int rv;
  250 + unsigned char fl_flags = fl->fl_flags;
250 251  
251 252 ls = dlm_find_lockspace_local(lockspace);
252 253 if (!ls)
253 254  
... ... @@ -258,10 +259,19 @@
258 259 goto out;
259 260 }
260 261  
261   - if (posix_lock_file_wait(file, fl) < 0)
262   - log_error(ls, "dlm_posix_unlock: vfs unlock error %llx",
263   - (unsigned long long)number);
  262 + /* cause the vfs unlock to return ENOENT if lock is not found */
  263 + fl->fl_flags |= FL_EXISTS;
264 264  
  265 + rv = posix_lock_file_wait(file, fl);
  266 + if (rv == -ENOENT) {
  267 + rv = 0;
  268 + goto out_free;
  269 + }
  270 + if (rv < 0) {
  271 + log_error(ls, "dlm_posix_unlock: vfs unlock error %d %llx",
  272 + rv, (unsigned long long)number);
  273 + }
  274 +
265 275 op->info.optype = DLM_PLOCK_OP_UNLOCK;
266 276 op->info.pid = fl->fl_pid;
267 277 op->info.fsid = ls->ls_global_id;
268 278  
... ... @@ -296,9 +306,11 @@
296 306 if (rv == -ENOENT)
297 307 rv = 0;
298 308  
  309 +out_free:
299 310 kfree(op);
300 311 out:
301 312 dlm_put_lockspace(ls);
  313 + fl->fl_flags = fl_flags;
302 314 return rv;
303 315 }
304 316 EXPORT_SYMBOL_GPL(dlm_posix_unlock);