Currently detached connectors have no association with the superblock for which they were created. This will get inconvenient when the detached connectors will be kept in a hash for later reconnection. So make detached connectors point to the superblock and fixup the two places using conn->obj for detecting detached connectors instead of conn->type. Signed-off-by: Jan Kara --- fs/notify/fsnotify.h | 2 ++ fs/notify/mark.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h index 5950c7a67f41..860a07ada7fd 100644 --- a/fs/notify/fsnotify.h +++ b/fs/notify/fsnotify.h @@ -49,6 +49,8 @@ static inline struct super_block *fsnotify_object_sb(void *obj, return ((struct vfsmount *)obj)->mnt_sb; case FSNOTIFY_OBJ_TYPE_SB: return (struct super_block *)obj; + case FSNOTIFY_OBJ_TYPE_DETACHED: + return (struct super_block *)obj; default: return NULL; } diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 798340db69d7..26faa2f640b9 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -176,7 +176,7 @@ static void fsnotify_update_sb_watchers(struct super_block *sb, struct fsnotify_mark *first_mark = NULL; unsigned int highest_prio = 0; - if (conn->obj) + if (conn->type != FSNOTIFY_OBJ_TYPE_DETACHED) first_mark = hlist_entry_safe(conn->list.first, struct fsnotify_mark, obj_list); if (first_mark) @@ -355,7 +355,8 @@ static void *fsnotify_detach_connector_from_object( } rcu_assign_pointer(*connp, NULL); - conn->obj = NULL; + /* We make detached connectors point to the superblock */ + conn->obj = sb; conn->type = FSNOTIFY_OBJ_TYPE_DETACHED; if (sb) fsnotify_update_sb_watchers(sb, conn); @@ -413,7 +414,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark) struct super_block *sb = fsnotify_connector_sb(conn); /* Update watched objects after detaching mark */ - if (sb) + if (conn->type != FSNOTIFY_OBJ_TYPE_DETACHED) fsnotify_update_sb_watchers(sb, conn); objp = __fsnotify_recalc_mask(conn); type = conn->type; -- 2.51.0