filelock: split common fields into struct file_lock_core
authorJeff Layton <jlayton@kernel.org>
Wed, 31 Jan 2024 23:01:58 +0000 (18:01 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 5 Feb 2024 12:11:38 +0000 (13:11 +0100)
In a future patch, we're going to split file leases into their own
structure. Since a lot of the underlying machinery uses the same fields
move those into a new file_lock_core, and embed that inside struct
file_lock.

For now, add some macros to ensure that we can continue to build while
the conversion is in progress.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-17-c6129007ee8d@kernel.org
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
24 files changed:
fs/9p/vfs_file.c
fs/afs/internal.h
fs/ceph/locks.c
fs/dlm/plock.c
fs/fuse/file.c
fs/gfs2/file.c
fs/lockd/clntproc.c
fs/locks.c
fs/nfs/file.c
fs/nfs/nfs4_fs.h
fs/nfs/write.c
fs/nfsd/netns.h
fs/ocfs2/locks.c
fs/ocfs2/stack_user.c
fs/open.c
fs/posix_acl.c
fs/smb/client/cifsglob.h
fs/smb/client/cifssmb.c
fs/smb/client/file.c
fs/smb/client/smb2file.c
fs/smb/server/smb2pdu.c
fs/smb/server/vfs.c
include/linux/filelock.h
include/linux/lockd/xdr.h

index 3df8aa1b599680e24193601d2742e4de2b3fd4f5..a1dabcf733806cbd7808a2f7e301c78f31f673e4 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/sched.h>
 #include <linux/file.h>
index 9c03fcf7ffaa84e9f7604444209bd934b64db466..f5dd428e40f4362551fdcef9e6141f2b286f9aa0 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/ktime.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/pagemap.h>
 #include <linux/rxrpc.h>
index 80ebe1d6c67d72f10501c3e676e918cf7cabaa49..ce773e9c0b791672d5d41ac03a2a09aa04e98d29 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "super.h"
 #include "mds_client.h"
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/ceph/pagelist.h>
 
index 42c596b900d4324aee788f9c2cc53a8a9d4f5875..fdcddbb96d40663243bd123b72b58045387614da 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/miscdevice.h>
 #include <linux/poll.h>
index 148a71b8b4d0e51037b6b59c754dabb9d3273173..2757870ee6acd4e228282414b2d38a79301ea5dc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/falloc.h>
 #include <linux/uio.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/splice.h>
 
index 6c25aea30f1bf364d4358dbf76f438b5fd356a52..d06488de1b3b3ed06ac083226219490cfe7a2adb 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mm.h>
 #include <linux/mount.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/falloc.h>
index cc596748e359bacd57e9b70f79f9faaa00970126..1f71260603b7f4aa33310406132f445dd121c477 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/nfs_fs.h>
 #include <linux/utsname.h>
index d685c3fdbea50f3cd00839140e9d03c58eb2a0b6..097254ab35d3d629a44874a04c3acd7b78765066 100644 (file)
@@ -48,6 +48,7 @@
  * children.
  *
  */
+#define _NEED_FILE_LOCK_FIELD_MACROS
 
 #include <linux/capability.h>
 #include <linux/file.h>
index 1a7a76d6055bb1011972a09dffad7f8c901a6229..0b6691e64d27aeb6f26adc09ea970ca7e08eac6f 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/swap.h>
 
 #include <linux/uaccess.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 
 #include "delegation.h"
index 581698f1b7b2441025d5421b3b00b4fba42b2ab8..752224a48f1c0a2062df4d2198de5237eb249025 100644 (file)
@@ -23,6 +23,7 @@
 #define NFS4_MAX_LOOP_ON_RECOVER (10)
 
 #include <linux/seqlock.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 
 struct idmap;
index d16f2b9d1765e026b1b7f63d3909bcde6003e274..13f2e10167ac1881c0321c842aee0a6ad2a7cabe 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/freezer.h>
 #include <linux/wait.h>
 #include <linux/iversion.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 
 #include <linux/uaccess.h>
index 74b4360779a1121b011c131167dea866ea8d0562..fd91125208be5ba6ffc06c7e280165a1abcb8155 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/percpu_counter.h>
 #include <linux/siphash.h>
index ef4fd91b586e4a443422387aea4fb86fc37732d0..84ad403b5998ac82b70b600d739bdf581a68630a 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/fcntl.h>
 
index c11406cd87a88e5329d78a8bd252a180d810e361..39b7e47a861860c37889e6845cd190e6b50c8685 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/miscdevice.h>
 #include <linux/mutex.h>
index a84d21e55c391eebdf662c7fa8c9d5b2aef8efd2..0a73afe04d34b15ae14f9b3e5177ac206290f6da 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -1364,7 +1364,7 @@ struct file *filp_open(const char *filename, int flags, umode_t mode)
 {
        struct filename *name = getname_kernel(filename);
        struct file *file = ERR_CAST(name);
-       
+
        if (!IS_ERR(name)) {
                file = file_open_name(name, flags, mode);
                putname(name);
index e1af20893ebe1ed400acb7c7215377868f623bbf..6bf587d1a9b873ca708ac598a70b8e6fea6bc469 100644 (file)
@@ -786,12 +786,12 @@ struct posix_acl *posix_acl_from_xattr(struct user_namespace *userns,
                return ERR_PTR(count);
        if (count == 0)
                return NULL;
-       
+
        acl = posix_acl_alloc(count, GFP_NOFS);
        if (!acl)
                return ERR_PTR(-ENOMEM);
        acl_e = acl->a_entries;
-       
+
        for (end = entry + count; entry != end; acl_e++, entry++) {
                acl_e->e_tag  = le16_to_cpu(entry->e_tag);
                acl_e->e_perm = le16_to_cpu(entry->e_perm);
index 20036fb16cececeaa3acffb78d81691ac86b1ec3..fcda4c77c6493b201915a4c22845207e1f5a9c35 100644 (file)
@@ -26,6 +26,7 @@
 #include <uapi/linux/cifs/cifs_mount.h>
 #include "../common/smb2pdu.h"
 #include "smb2pdu.h"
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 
 #define SMB_PATH_MAX 260
index 01e89070df5ab2a38c1d041556e959419ec40fb4..e19ecf692c200b5457474c8d527b17f73295879e 100644 (file)
@@ -15,6 +15,7 @@
  /* want to reuse a stale file handle and only the caller knows the file info */
 
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/kernel.h>
 #include <linux/vfs.h>
index c26f8ed14065f32356c49daa7f943ff8dbec275d..d3f5969c3a86004235cc07f30cd576470f81eb6d 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/backing-dev.h>
 #include <linux/stat.h>
@@ -2951,7 +2952,7 @@ skip_write:
                        continue;
                }
 
-               folio_batch_release(&fbatch);           
+               folio_batch_release(&fbatch);
                cond_resched();
        } while (wbc->nr_to_write > 0);
 
index e0ee96d69d495216090d65817360c8fef6159419..cd225d15a7c5acca5bba45ac3540dce16ecada00 100644 (file)
@@ -7,6 +7,7 @@
  *
  */
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/stat.h>
 #include <linux/slab.h>
index e170b96d5ac045fd9793a7904111adae335d450a..11cc2871958263d20fa24918fe9d2fc66f7819e2 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/ethtool.h>
 #include <linux/falloc.h>
 #include <linux/mount.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 
 #include "glob.h"
index 449cfa9ed31caba09243473a6de313a1c5c0d4b2..5dc87649400b9c4551622a4e9de8d2de529028a1 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/kernel.h>
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/uaccess.h>
 #include <linux/backing-dev.h>
index a3cb59b7922a298529a1d7fb8d5add8751bd8058..d1fba98744a77bf76be0f822d3af5a2e6591b2eb 100644 (file)
@@ -85,23 +85,28 @@ bool opens_in_grace(struct net *);
  *
  * Obviously, the last two criteria only matter for POSIX locks.
  */
-struct file_lock {
-       struct file_lock *fl_blocker;   /* The lock, that is blocking us */
-       struct list_head fl_list;       /* link into file_lock_context */
-       struct hlist_node fl_link;      /* node in global lists */
-       struct list_head fl_blocked_requests;   /* list of requests with
+
+struct file_lock_core {
+       struct file_lock *flc_blocker;  /* The lock that is blocking us */
+       struct list_head flc_list;      /* link into file_lock_context */
+       struct hlist_node flc_link;     /* node in global lists */
+       struct list_head flc_blocked_requests;  /* list of requests with
                                                 * ->fl_blocker pointing here
                                                 */
-       struct list_head fl_blocked_member;     /* node in
+       struct list_head flc_blocked_member;    /* node in
                                                 * ->fl_blocker->fl_blocked_requests
                                                 */
-       fl_owner_t fl_owner;
-       unsigned int fl_flags;
-       unsigned char fl_type;
-       pid_t fl_pid;
-       int fl_link_cpu;                /* what cpu's list is this on? */
-       wait_queue_head_t fl_wait;
-       struct file *fl_file;
+       fl_owner_t flc_owner;
+       unsigned int flc_flags;
+       unsigned char flc_type;
+       pid_t flc_pid;
+       int flc_link_cpu;               /* what cpu's list is this on? */
+       wait_queue_head_t flc_wait;
+       struct file *flc_file;
+};
+
+struct file_lock {
+       struct file_lock_core c;
        loff_t fl_start;
        loff_t fl_end;
 
@@ -126,6 +131,22 @@ struct file_lock {
        } fl_u;
 } __randomize_layout;
 
+/* Temporary macros to allow building during coccinelle conversion */
+#ifdef _NEED_FILE_LOCK_FIELD_MACROS
+#define fl_list c.flc_list
+#define fl_blocker c.flc_blocker
+#define fl_link c.flc_link
+#define fl_blocked_requests c.flc_blocked_requests
+#define fl_blocked_member c.flc_blocked_member
+#define fl_owner c.flc_owner
+#define fl_flags c.flc_flags
+#define fl_type c.flc_type
+#define fl_pid c.flc_pid
+#define fl_link_cpu c.flc_link_cpu
+#define fl_wait c.flc_wait
+#define fl_file c.flc_file
+#endif
+
 struct file_lock_context {
        spinlock_t              flc_lock;
        struct list_head        flc_flock;
@@ -149,26 +170,26 @@ int fcntl_getlease(struct file *filp);
 
 static inline bool lock_is_unlock(struct file_lock *fl)
 {
-       return fl->fl_type == F_UNLCK;
+       return fl->c.flc_type == F_UNLCK;
 }
 
 static inline bool lock_is_read(struct file_lock *fl)
 {
-       return fl->fl_type == F_RDLCK;
+       return fl->c.flc_type == F_RDLCK;
 }
 
 static inline bool lock_is_write(struct file_lock *fl)
 {
-       return fl->fl_type == F_WRLCK;
+       return fl->c.flc_type == F_WRLCK;
 }
 
 static inline void locks_wake_up(struct file_lock *fl)
 {
-       wake_up(&fl->fl_wait);
+       wake_up(&fl->c.flc_wait);
 }
 
 /* for walking lists of file_locks linked by fl_list */
-#define for_each_file_lock(_fl, _head) list_for_each_entry(_fl, _head, fl_list)
+#define for_each_file_lock(_fl, _head) list_for_each_entry(_fl, _head, c.flc_list)
 
 /* fs/locks.c */
 void locks_free_lock_context(struct inode *inode);
index b60fbcd8cdfad5a5e607eb0c456e3afd559e0ec2..a3f068b0ca8629b78b592f181d49f2eab6642efa 100644 (file)
@@ -11,6 +11,7 @@
 #define LOCKD_XDR_H
 
 #include <linux/fs.h>
+#define _NEED_FILE_LOCK_FIELD_MACROS
 #include <linux/filelock.h>
 #include <linux/nfs.h>
 #include <linux/sunrpc/xdr.h>
@@ -52,7 +53,7 @@ struct nlm_lock {
  *     FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
  *     32 bytes.
  */
+
 struct nlm_cookie
 {
        unsigned char data[NLM_MAXCOOKIELEN];