fsnotify: move s_fsnotify_connectors into fsnotify_sb_info
authorAmir Goldstein <amir73il@gmail.com>
Sun, 17 Mar 2024 18:41:52 +0000 (20:41 +0200)
committerJan Kara <jack@suse.cz>
Thu, 4 Apr 2024 14:24:16 +0000 (16:24 +0200)
Move the s_fsnotify_connectors counter into the per-sb fsnotify state.

Suggested-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20240317184154.1200192-9-amir73il@gmail.com>

include/linux/fs.h
include/linux/fsnotify.h
include/linux/fsnotify_backend.h

index 7f40b592f7119459da1656dd4d495b310b7d0cfd..c36c2f8fdbe30a5b3295e3e1d7b3bab321ba0cc6 100644 (file)
@@ -1302,12 +1302,6 @@ struct super_block {
        /* Number of inodes with nlink == 0 but still referenced */
        atomic_long_t s_remove_count;
 
-       /*
-        * Number of inode/mount/sb objects that are being watched, note that
-        * inodes objects are currently double-accounted.
-        */
-       atomic_long_t s_fsnotify_connectors;
-
        /* Read-only state of the superblock is being changed */
        int s_readonly_remount;
 
index e470bb67c9a337ca903517715a8e198db93e3f4d..48dc657024151fadb24fef9b883b8c70191f42ec 100644 (file)
 /* Are there any inode/mount/sb objects that are being watched at all? */
 static inline bool fsnotify_sb_has_watchers(struct super_block *sb)
 {
-       return atomic_long_read(fsnotify_sb_watched_objects(sb));
+       struct fsnotify_sb_info *sbinfo = fsnotify_sb_info(sb);
+
+       /* Were any marks ever added to any object on this sb? */
+       if (!sbinfo)
+               return false;
+
+       return atomic_long_read(&sbinfo->watched_objects);
 }
 
 /*
index c9f2b2f6b49383064f375b0d84234aeb3c23e0ad..ec592aeadfa3fd7383a608328db1494501b22166 100644 (file)
@@ -483,6 +483,11 @@ struct fsnotify_mark_connector {
  */
 struct fsnotify_sb_info {
        struct fsnotify_mark_connector __rcu *sb_marks;
+       /*
+        * Number of inode/mount/sb objects that are being watched in this sb.
+        * Note that inodes objects are currently double-accounted.
+        */
+       atomic_long_t watched_objects;
 };
 
 static inline struct fsnotify_sb_info *fsnotify_sb_info(struct super_block *sb)
@@ -496,7 +501,7 @@ static inline struct fsnotify_sb_info *fsnotify_sb_info(struct super_block *sb)
 
 static inline atomic_long_t *fsnotify_sb_watched_objects(struct super_block *sb)
 {
-       return &sb->s_fsnotify_connectors;
+       return &fsnotify_sb_info(sb)->watched_objects;
 }
 
 /*