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