Skip to content

Commit cb5d4f4

Browse files
amir73iljankara
authored andcommitted
fsnotify: move s_fsnotify_connectors into fsnotify_sb_info
Move the s_fsnotify_connectors counter into the per-sb fsnotify state. Suggested-by: Christian Brauner <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent 07a3b8d commit cb5d4f4

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

include/linux/fs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,12 +1302,6 @@ struct super_block {
13021302
/* Number of inodes with nlink == 0 but still referenced */
13031303
atomic_long_t s_remove_count;
13041304

1305-
/*
1306-
* Number of inode/mount/sb objects that are being watched, note that
1307-
* inodes objects are currently double-accounted.
1308-
*/
1309-
atomic_long_t s_fsnotify_connectors;
1310-
13111305
/* Read-only state of the superblock is being changed */
13121306
int s_readonly_remount;
13131307

include/linux/fsnotify.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
/* Are there any inode/mount/sb objects that are being watched at all? */
2121
static inline bool fsnotify_sb_has_watchers(struct super_block *sb)
2222
{
23-
return atomic_long_read(fsnotify_sb_watched_objects(sb));
23+
struct fsnotify_sb_info *sbinfo = fsnotify_sb_info(sb);
24+
25+
/* Were any marks ever added to any object on this sb? */
26+
if (!sbinfo)
27+
return false;
28+
29+
return atomic_long_read(&sbinfo->watched_objects);
2430
}
2531

2632
/*

include/linux/fsnotify_backend.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,11 @@ struct fsnotify_mark_connector {
483483
*/
484484
struct fsnotify_sb_info {
485485
struct fsnotify_mark_connector __rcu *sb_marks;
486+
/*
487+
* Number of inode/mount/sb objects that are being watched in this sb.
488+
* Note that inodes objects are currently double-accounted.
489+
*/
490+
atomic_long_t watched_objects;
486491
};
487492

488493
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)
496501

497502
static inline atomic_long_t *fsnotify_sb_watched_objects(struct super_block *sb)
498503
{
499-
return &sb->s_fsnotify_connectors;
504+
return &fsnotify_sb_info(sb)->watched_objects;
500505
}
501506

502507
/*

0 commit comments

Comments
 (0)