Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfs: move fsnotify junk to struct mount

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro c63181e6 52ba1621

+47 -42
+4 -1
fs/mount.h
··· 19 19 #endif 20 20 struct list_head mnt_mounts; /* list of children, anchored here */ 21 21 struct list_head mnt_child; /* and going through their mnt_child */ 22 - /* yet to be moved - fsnotify ones go here */ 23 22 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ 24 23 struct list_head mnt_list; 25 24 struct list_head mnt_expire; /* link in fs-specific expiry list */ ··· 27 28 struct list_head mnt_slave; /* slave list entry */ 28 29 struct mount *mnt_master; /* slave is on master->mnt_slave_list */ 29 30 struct mnt_namespace *mnt_ns; /* containing namespace */ 31 + #ifdef CONFIG_FSNOTIFY 32 + struct hlist_head mnt_fsnotify_marks; 33 + __u32 mnt_fsnotify_mask; 34 + #endif 30 35 int mnt_id; /* mount identifier */ 31 36 int mnt_group_id; /* peer group identifier */ 32 37 int mnt_expiry_mark; /* true if marked for expiry */
+22 -23
fs/namespace.c
··· 173 173 174 174 static struct mount *alloc_vfsmnt(const char *name) 175 175 { 176 - struct mount *p = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); 177 - if (p) { 178 - struct vfsmount *mnt = &p->mnt; 176 + struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); 177 + if (mnt) { 179 178 int err; 180 179 181 - err = mnt_alloc_id(p); 180 + err = mnt_alloc_id(mnt); 182 181 if (err) 183 182 goto out_free_cache; 184 183 185 184 if (name) { 186 - p->mnt_devname = kstrdup(name, GFP_KERNEL); 187 - if (!p->mnt_devname) 185 + mnt->mnt_devname = kstrdup(name, GFP_KERNEL); 186 + if (!mnt->mnt_devname) 188 187 goto out_free_id; 189 188 } 190 189 191 190 #ifdef CONFIG_SMP 192 - p->mnt_pcp = alloc_percpu(struct mnt_pcp); 193 - if (!p->mnt_pcp) 191 + mnt->mnt_pcp = alloc_percpu(struct mnt_pcp); 192 + if (!mnt->mnt_pcp) 194 193 goto out_free_devname; 195 194 196 - this_cpu_add(p->mnt_pcp->mnt_count, 1); 195 + this_cpu_add(mnt->mnt_pcp->mnt_count, 1); 197 196 #else 198 - p->mnt_count = 1; 199 - p->mnt_writers = 0; 197 + mnt->mnt_count = 1; 198 + mnt->mnt_writers = 0; 200 199 #endif 201 200 202 - INIT_LIST_HEAD(&p->mnt_hash); 203 - INIT_LIST_HEAD(&p->mnt_child); 204 - INIT_LIST_HEAD(&p->mnt_mounts); 205 - INIT_LIST_HEAD(&p->mnt_list); 206 - INIT_LIST_HEAD(&p->mnt_expire); 207 - INIT_LIST_HEAD(&p->mnt_share); 208 - INIT_LIST_HEAD(&p->mnt_slave_list); 209 - INIT_LIST_HEAD(&p->mnt_slave); 201 + INIT_LIST_HEAD(&mnt->mnt_hash); 202 + INIT_LIST_HEAD(&mnt->mnt_child); 203 + INIT_LIST_HEAD(&mnt->mnt_mounts); 204 + INIT_LIST_HEAD(&mnt->mnt_list); 205 + INIT_LIST_HEAD(&mnt->mnt_expire); 206 + INIT_LIST_HEAD(&mnt->mnt_share); 207 + INIT_LIST_HEAD(&mnt->mnt_slave_list); 208 + INIT_LIST_HEAD(&mnt->mnt_slave); 210 209 #ifdef CONFIG_FSNOTIFY 211 210 INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); 212 211 #endif 213 212 } 214 - return p; 213 + return mnt; 215 214 216 215 #ifdef CONFIG_SMP 217 216 out_free_devname: 218 - kfree(p->mnt_devname); 217 + kfree(mnt->mnt_devname); 219 218 #endif 220 219 out_free_id: 221 - mnt_free_id(p); 220 + mnt_free_id(mnt); 222 221 out_free_cache: 223 - kmem_cache_free(mnt_cache, p); 222 + kmem_cache_free(mnt_cache, mnt); 224 223 return NULL; 225 224 } 226 225
+4 -2
fs/notify/fanotify/fanotify_user.c
··· 16 16 17 17 #include <asm/ioctls.h> 18 18 19 + #include "../../mount.h" 20 + 19 21 #define FANOTIFY_DEFAULT_MAX_EVENTS 16384 20 22 #define FANOTIFY_DEFAULT_MAX_MARKS 8192 21 23 #define FANOTIFY_DEFAULT_MAX_LISTENERS 128 ··· 548 546 549 547 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags); 550 548 fsnotify_put_mark(fsn_mark); 551 - if (removed & mnt->mnt_fsnotify_mask) 549 + if (removed & real_mount(mnt)->mnt_fsnotify_mask) 552 550 fsnotify_recalc_vfsmount_mask(mnt); 553 551 554 552 return 0; ··· 625 623 } 626 624 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); 627 625 628 - if (added & ~mnt->mnt_fsnotify_mask) 626 + if (added & ~real_mount(mnt)->mnt_fsnotify_mask) 629 627 fsnotify_recalc_vfsmount_mask(mnt); 630 628 err: 631 629 fsnotify_put_mark(fsn_mark);
+5 -4
fs/notify/fsnotify.c
··· 26 26 27 27 #include <linux/fsnotify_backend.h> 28 28 #include "fsnotify.h" 29 + #include "../mount.h" 29 30 30 31 /* 31 32 * Clear all of the marks on an inode when it is being evicted from core ··· 206 205 struct fsnotify_mark *inode_mark = NULL, *vfsmount_mark = NULL; 207 206 struct fsnotify_group *inode_group, *vfsmount_group; 208 207 struct fsnotify_event *event = NULL; 209 - struct vfsmount *mnt; 208 + struct mount *mnt; 210 209 int idx, ret = 0; 211 210 /* global tests shouldn't care about events on child only the specific event */ 212 211 __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); 213 212 214 213 if (data_is == FSNOTIFY_EVENT_PATH) 215 - mnt = ((struct path *)data)->mnt; 214 + mnt = real_mount(((struct path *)data)->mnt); 216 215 else 217 216 mnt = NULL; 218 217 ··· 263 262 /* we didn't use the vfsmount_mark */ 264 263 vfsmount_group = NULL; 265 264 } else if (vfsmount_group > inode_group) { 266 - ret = send_to_group(to_tell, mnt, NULL, vfsmount_mark, mask, data, 265 + ret = send_to_group(to_tell, &mnt->mnt, NULL, vfsmount_mark, mask, data, 267 266 data_is, cookie, file_name, &event); 268 267 inode_group = NULL; 269 268 } else { 270 - ret = send_to_group(to_tell, mnt, inode_mark, vfsmount_mark, 269 + ret = send_to_group(to_tell, &mnt->mnt, inode_mark, vfsmount_mark, 271 270 mask, data, data_is, cookie, file_name, 272 271 &event); 273 272 }
+12 -7
fs/notify/vfsmount_mark.c
··· 28 28 29 29 #include <linux/fsnotify_backend.h> 30 30 #include "fsnotify.h" 31 + #include "../mount.h" 31 32 32 33 void fsnotify_clear_marks_by_mount(struct vfsmount *mnt) 33 34 { 34 35 struct fsnotify_mark *mark, *lmark; 35 36 struct hlist_node *pos, *n; 37 + struct mount *m = real_mount(mnt); 36 38 LIST_HEAD(free_list); 37 39 38 40 spin_lock(&mnt->mnt_root->d_lock); 39 - hlist_for_each_entry_safe(mark, pos, n, &mnt->mnt_fsnotify_marks, m.m_list) { 41 + hlist_for_each_entry_safe(mark, pos, n, &m->mnt_fsnotify_marks, m.m_list) { 40 42 list_add(&mark->m.free_m_list, &free_list); 41 43 hlist_del_init_rcu(&mark->m.m_list); 42 44 fsnotify_get_mark(mark); ··· 61 59 */ 62 60 static void fsnotify_recalc_vfsmount_mask_locked(struct vfsmount *mnt) 63 61 { 62 + struct mount *m = real_mount(mnt); 64 63 struct fsnotify_mark *mark; 65 64 struct hlist_node *pos; 66 65 __u32 new_mask = 0; 67 66 68 67 assert_spin_locked(&mnt->mnt_root->d_lock); 69 68 70 - hlist_for_each_entry(mark, pos, &mnt->mnt_fsnotify_marks, m.m_list) 69 + hlist_for_each_entry(mark, pos, &m->mnt_fsnotify_marks, m.m_list) 71 70 new_mask |= mark->mask; 72 - mnt->mnt_fsnotify_mask = new_mask; 71 + m->mnt_fsnotify_mask = new_mask; 73 72 } 74 73 75 74 /* ··· 104 101 static struct fsnotify_mark *fsnotify_find_vfsmount_mark_locked(struct fsnotify_group *group, 105 102 struct vfsmount *mnt) 106 103 { 104 + struct mount *m = real_mount(mnt); 107 105 struct fsnotify_mark *mark; 108 106 struct hlist_node *pos; 109 107 110 108 assert_spin_locked(&mnt->mnt_root->d_lock); 111 109 112 - hlist_for_each_entry(mark, pos, &mnt->mnt_fsnotify_marks, m.m_list) { 110 + hlist_for_each_entry(mark, pos, &m->mnt_fsnotify_marks, m.m_list) { 113 111 if (mark->group == group) { 114 112 fsnotify_get_mark(mark); 115 113 return mark; ··· 144 140 struct fsnotify_group *group, struct vfsmount *mnt, 145 141 int allow_dups) 146 142 { 143 + struct mount *m = real_mount(mnt); 147 144 struct fsnotify_mark *lmark; 148 145 struct hlist_node *node, *last = NULL; 149 146 int ret = 0; ··· 159 154 mark->m.mnt = mnt; 160 155 161 156 /* is mark the first mark? */ 162 - if (hlist_empty(&mnt->mnt_fsnotify_marks)) { 163 - hlist_add_head_rcu(&mark->m.m_list, &mnt->mnt_fsnotify_marks); 157 + if (hlist_empty(&m->mnt_fsnotify_marks)) { 158 + hlist_add_head_rcu(&mark->m.m_list, &m->mnt_fsnotify_marks); 164 159 goto out; 165 160 } 166 161 167 162 /* should mark be in the middle of the current list? */ 168 - hlist_for_each_entry(lmark, node, &mnt->mnt_fsnotify_marks, m.m_list) { 163 + hlist_for_each_entry(lmark, node, &m->mnt_fsnotify_marks, m.m_list) { 169 164 last = node; 170 165 171 166 if ((lmark->group == group) && !allow_dups) {
-5
include/linux/mount.h
··· 51 51 struct dentry *mnt_root; /* root of the mounted tree */ 52 52 struct super_block *mnt_sb; /* pointer to superblock */ 53 53 int mnt_flags; 54 - /* 4 bytes hole on 64bits arches without fsnotify */ 55 - #ifdef CONFIG_FSNOTIFY 56 - __u32 mnt_fsnotify_mask; 57 - struct hlist_head mnt_fsnotify_marks; 58 - #endif 59 54 }; 60 55 61 56 struct file; /* forward dec */