fsnotify: Move locking into fsnotify_find_mark()
[sfrench/cifs-2.6.git] / fs / notify / vfsmount_mark.c
index a8fcab68faef1cdc826103d095b5b387895dfb20..3476ee44b2c5a3783bc7c01a9af484777bf51d1b 100644 (file)
 
 void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group)
 {
-       fsnotify_clear_marks_by_group_flags(group, FSNOTIFY_MARK_FLAG_VFSMOUNT);
+       fsnotify_clear_marks_by_group_flags(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT);
 }
 
-/*
- * Recalculate the mnt->mnt_fsnotify_mask, or the mask of all FS_* event types
- * any notifier is interested in hearing for this mount point
- */
 void fsnotify_recalc_vfsmount_mask(struct vfsmount *mnt)
 {
-       struct mount *m = real_mount(mnt);
-
-       spin_lock(&mnt->mnt_root->d_lock);
-       m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks);
-       spin_unlock(&mnt->mnt_root->d_lock);
+       fsnotify_recalc_mask(real_mount(mnt)->mnt_fsnotify_marks);
 }
 
 void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark)
 {
-       struct vfsmount *mnt = mark->mnt;
+       struct vfsmount *mnt = mark->connector->mnt;
        struct mount *m = real_mount(mnt);
 
        BUG_ON(!mutex_is_locked(&mark->group->mark_mutex));
@@ -58,10 +50,11 @@ void fsnotify_destroy_vfsmount_mark(struct fsnotify_mark *mark)
        spin_lock(&mnt->mnt_root->d_lock);
 
        hlist_del_init_rcu(&mark->obj_list);
-       mark->mnt = NULL;
+       mark->connector = NULL;
 
-       m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks);
        spin_unlock(&mnt->mnt_root->d_lock);
+
+       fsnotify_recalc_mask(m->mnt_fsnotify_marks);
 }
 
 /*
@@ -72,37 +65,6 @@ struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group,
                                                  struct vfsmount *mnt)
 {
        struct mount *m = real_mount(mnt);
-       struct fsnotify_mark *mark;
-
-       spin_lock(&mnt->mnt_root->d_lock);
-       mark = fsnotify_find_mark(&m->mnt_fsnotify_marks, group);
-       spin_unlock(&mnt->mnt_root->d_lock);
-
-       return mark;
-}
-
-/*
- * Attach an initialized mark to a given group and vfsmount.
- * These marks may be used for the fsnotify backend to determine which
- * event types should be delivered to which groups.
- */
-int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
-                              struct fsnotify_group *group, struct vfsmount *mnt,
-                              int allow_dups)
-{
-       struct mount *m = real_mount(mnt);
-       int ret;
-
-       mark->flags |= FSNOTIFY_MARK_FLAG_VFSMOUNT;
-
-       BUG_ON(!mutex_is_locked(&group->mark_mutex));
-       assert_spin_locked(&mark->lock);
-
-       spin_lock(&mnt->mnt_root->d_lock);
-       mark->mnt = mnt;
-       ret = fsnotify_add_mark_list(&m->mnt_fsnotify_marks, mark, allow_dups);
-       m->mnt_fsnotify_mask = fsnotify_recalc_mask(&m->mnt_fsnotify_marks);
-       spin_unlock(&mnt->mnt_root->d_lock);
 
-       return ret;
+       return fsnotify_find_mark(m->mnt_fsnotify_marks, group);
 }