Skip to content

Commit

Permalink
fsnotify: move s_fsnotify_connectors into fsnotify_sb_info
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
amir73il authored and jankara committed Apr 4, 2024
1 parent 07a3b8d commit cb5d4f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 0 additions & 6 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 7 additions & 1 deletion include/linux/fsnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
/* 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);
}

/*
Expand Down
7 changes: 6 additions & 1 deletion include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}

/*
Expand Down

0 comments on commit cb5d4f4

Please sign in to comment.