dlm: convert to using new filelock helpers
authorJeff Layton <jlayton@kernel.org>
Wed, 31 Jan 2024 23:01:49 +0000 (18:01 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 5 Feb 2024 12:11:36 +0000 (13:11 +0100)
Convert to using the new file locking helper functions. Also, in later
patches we're going to introduce some temporary macros with names that
clash with the variable name in dlm_posix_unlock. Rename it.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-8-c6129007ee8d@kernel.org
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/dlm/plock.c

index d814c51213670bb8897701e30c01dc5b78ab6af9..42c596b900d4324aee788f9c2cc53a8a9d4f5875 100644 (file)
@@ -139,7 +139,7 @@ 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.ex             = (lock_is_write(fl));
        op->info.wait           = !!(fl->fl_flags & FL_SLEEP);
        op->info.fsid           = ls->ls_global_id;
        op->info.number         = number;
@@ -291,7 +291,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;
+       unsigned char saved_flags = fl->fl_flags;
 
        ls = dlm_find_lockspace_local(lockspace);
        if (!ls)
@@ -345,7 +345,7 @@ out_free:
        dlm_release_plock_op(op);
 out:
        dlm_put_lockspace(ls);
-       fl->fl_flags = fl_flags;
+       fl->fl_flags = saved_flags;
        return rv;
 }
 EXPORT_SYMBOL_GPL(dlm_posix_unlock);
@@ -376,7 +376,7 @@ int dlm_posix_cancel(dlm_lockspace_t *lockspace, u64 number, struct file *file,
 
        memset(&info, 0, sizeof(info));
        info.pid = fl->fl_pid;
-       info.ex = (fl->fl_type == F_WRLCK);
+       info.ex = (lock_is_write(fl));
        info.fsid = ls->ls_global_id;
        dlm_put_lockspace(ls);
        info.number = number;
@@ -438,7 +438,7 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
 
        op->info.optype         = DLM_PLOCK_OP_GET;
        op->info.pid            = fl->fl_pid;
-       op->info.ex             = (fl->fl_type == F_WRLCK);
+       op->info.ex             = (lock_is_write(fl));
        op->info.fsid           = ls->ls_global_id;
        op->info.number         = number;
        op->info.start          = fl->fl_start;