filelock: convert more internal functions to use file_lock_core
authorJeff Layton <jlayton@kernel.org>
Wed, 31 Jan 2024 23:02:00 +0000 (18:02 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 5 Feb 2024 12:11:38 +0000 (13:11 +0100)
Convert more internal fs/locks.c functions to take and deal with struct
file_lock_core instead of struct file_lock:

- locks_dump_ctx_list
- locks_check_ctx_file_list
- locks_release_private
- locks_owner_has_blockers

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

index f418c6e312199c0522167a2e6f3642b71058bcdc..5d25a3f53c9df8745b21f4e1e8e31da6cc858b50 100644 (file)
@@ -197,13 +197,12 @@ out:
 static void
 locks_dump_ctx_list(struct list_head *list, char *list_type)
 {
-       struct file_lock *fl;
+       struct file_lock_core *flc;
 
-       list_for_each_entry(fl, list, c.flc_list) {
-               pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type,
-                       fl->c.flc_owner, fl->c.flc_flags,
-                       fl->c.flc_type, fl->c.flc_pid);
-       }
+       list_for_each_entry(flc, list, flc_list)
+               pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
+                       list_type, flc->flc_owner, flc->flc_flags,
+                       flc->flc_type, flc->flc_pid);
 }
 
 static void
@@ -224,20 +223,19 @@ locks_check_ctx_lists(struct inode *inode)
 }
 
 static void
-locks_check_ctx_file_list(struct file *filp, struct list_head *list,
-                               char *list_type)
+locks_check_ctx_file_list(struct file *filp, struct list_head *list, char *list_type)
 {
-       struct file_lock *fl;
+       struct file_lock_core *flc;
        struct inode *inode = file_inode(filp);
 
-       list_for_each_entry(fl, list, c.flc_list)
-               if (fl->c.flc_file == filp)
+       list_for_each_entry(flc, list, flc_list)
+               if (flc->flc_file == filp)
                        pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx "
                                " fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n",
                                list_type, MAJOR(inode->i_sb->s_dev),
                                MINOR(inode->i_sb->s_dev), inode->i_ino,
-                               fl->c.flc_owner, fl->c.flc_flags,
-                               fl->c.flc_type, fl->c.flc_pid);
+                               flc->flc_owner, flc->flc_flags,
+                               flc->flc_type, flc->flc_pid);
 }
 
 void
@@ -274,11 +272,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock);
 
 void locks_release_private(struct file_lock *fl)
 {
-       BUG_ON(waitqueue_active(&fl->c.flc_wait));
-       BUG_ON(!list_empty(&fl->c.flc_list));
-       BUG_ON(!list_empty(&fl->c.flc_blocked_requests));
-       BUG_ON(!list_empty(&fl->c.flc_blocked_member));
-       BUG_ON(!hlist_unhashed(&fl->c.flc_link));
+       struct file_lock_core *flc = &fl->c;
+
+       BUG_ON(waitqueue_active(&flc->flc_wait));
+       BUG_ON(!list_empty(&flc->flc_list));
+       BUG_ON(!list_empty(&flc->flc_blocked_requests));
+       BUG_ON(!list_empty(&flc->flc_blocked_member));
+       BUG_ON(!hlist_unhashed(&flc->flc_link));
 
        if (fl->fl_ops) {
                if (fl->fl_ops->fl_release_private)
@@ -288,8 +288,8 @@ void locks_release_private(struct file_lock *fl)
 
        if (fl->fl_lmops) {
                if (fl->fl_lmops->lm_put_owner) {
-                       fl->fl_lmops->lm_put_owner(fl->c.flc_owner);
-                       fl->c.flc_owner = NULL;
+                       fl->fl_lmops->lm_put_owner(flc->flc_owner);
+                       flc->flc_owner = NULL;
                }
                fl->fl_lmops = NULL;
        }
@@ -305,16 +305,15 @@ EXPORT_SYMBOL_GPL(locks_release_private);
  *   %true: @owner has at least one blocker
  *   %false: @owner has no blockers
  */
-bool locks_owner_has_blockers(struct file_lock_context *flctx,
-               fl_owner_t owner)
+bool locks_owner_has_blockers(struct file_lock_context *flctx, fl_owner_t owner)
 {
-       struct file_lock *fl;
+       struct file_lock_core *flc;
 
        spin_lock(&flctx->flc_lock);
-       list_for_each_entry(fl, &flctx->flc_posix, c.flc_list) {
-               if (fl->c.flc_owner != owner)
+       list_for_each_entry(flc, &flctx->flc_posix, flc_list) {
+               if (flc->flc_owner != owner)
                        continue;
-               if (!list_empty(&fl->c.flc_blocked_requests)) {
+               if (!list_empty(&flc->flc_blocked_requests)) {
                        spin_unlock(&flctx->flc_lock);
                        return true;
                }