diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-12 17:23:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-12 17:23:04 -0400 |
commit | 2069601b3f0ea38170d4b509b89f3ca0a373bdc1 (patch) | |
tree | 647002d4c3814bd3d95d16ef7edef1757de8554f /include/linux | |
parent | ad41a1e0cab07c5125456e8d38e5b1ab148d04aa (diff) |
Revert "fsnotify: store struct file not struct path"
This reverts commit 3bcf3860a4ff9bbc522820b4b765e65e4deceb3e (and the
accompanying commit c1e5c954020e "vfs/fsnotify: fsnotify_close can delay
the final work in fput" that was a horribly ugly hack to make it work at
all).
The 'struct file' approach not only causes that disgusting hack, it
somehow breaks pulseaudio, probably due to some other subtlety with
f_count handling.
Fix up various conflicts due to later fsnotify work.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/fsnotify.h | 37 | ||||
-rw-r--r-- | include/linux/fsnotify_backend.h | 16 |
2 files changed, 29 insertions, 24 deletions
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index e4e2204187ee..59d0df43ff9d 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -26,18 +26,19 @@ static inline void fsnotify_d_instantiate(struct dentry *dentry, | |||
26 | } | 26 | } |
27 | 27 | ||
28 | /* Notify this dentry's parent about a child's events. */ | 28 | /* Notify this dentry's parent about a child's events. */ |
29 | static inline void fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) | 29 | static inline void fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) |
30 | { | 30 | { |
31 | if (!dentry) | 31 | if (!dentry) |
32 | dentry = file->f_path.dentry; | 32 | dentry = path->dentry; |
33 | 33 | ||
34 | __fsnotify_parent(file, dentry, mask); | 34 | __fsnotify_parent(path, dentry, mask); |
35 | } | 35 | } |
36 | 36 | ||
37 | /* simple call site for access decisions */ | 37 | /* simple call site for access decisions */ |
38 | static inline int fsnotify_perm(struct file *file, int mask) | 38 | static inline int fsnotify_perm(struct file *file, int mask) |
39 | { | 39 | { |
40 | struct inode *inode = file->f_path.dentry->d_inode; | 40 | struct path *path = &file->f_path; |
41 | struct inode *inode = path->dentry->d_inode; | ||
41 | __u32 fsnotify_mask = 0; | 42 | __u32 fsnotify_mask = 0; |
42 | 43 | ||
43 | if (file->f_mode & FMODE_NONOTIFY) | 44 | if (file->f_mode & FMODE_NONOTIFY) |
@@ -51,7 +52,7 @@ static inline int fsnotify_perm(struct file *file, int mask) | |||
51 | else | 52 | else |
52 | BUG(); | 53 | BUG(); |
53 | 54 | ||
54 | return fsnotify(inode, fsnotify_mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 55 | return fsnotify(inode, fsnotify_mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
55 | } | 56 | } |
56 | 57 | ||
57 | /* | 58 | /* |
@@ -186,15 +187,16 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) | |||
186 | */ | 187 | */ |
187 | static inline void fsnotify_access(struct file *file) | 188 | static inline void fsnotify_access(struct file *file) |
188 | { | 189 | { |
189 | struct inode *inode = file->f_path.dentry->d_inode; | 190 | struct path *path = &file->f_path; |
191 | struct inode *inode = path->dentry->d_inode; | ||
190 | __u32 mask = FS_ACCESS; | 192 | __u32 mask = FS_ACCESS; |
191 | 193 | ||
192 | if (S_ISDIR(inode->i_mode)) | 194 | if (S_ISDIR(inode->i_mode)) |
193 | mask |= FS_IN_ISDIR; | 195 | mask |= FS_IN_ISDIR; |
194 | 196 | ||
195 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 197 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
196 | fsnotify_parent(file, NULL, mask); | 198 | fsnotify_parent(path, NULL, mask); |
197 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 199 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
198 | } | 200 | } |
199 | } | 201 | } |
200 | 202 | ||
@@ -203,15 +205,16 @@ static inline void fsnotify_access(struct file *file) | |||
203 | */ | 205 | */ |
204 | static inline void fsnotify_modify(struct file *file) | 206 | static inline void fsnotify_modify(struct file *file) |
205 | { | 207 | { |
206 | struct inode *inode = file->f_path.dentry->d_inode; | 208 | struct path *path = &file->f_path; |
209 | struct inode *inode = path->dentry->d_inode; | ||
207 | __u32 mask = FS_MODIFY; | 210 | __u32 mask = FS_MODIFY; |
208 | 211 | ||
209 | if (S_ISDIR(inode->i_mode)) | 212 | if (S_ISDIR(inode->i_mode)) |
210 | mask |= FS_IN_ISDIR; | 213 | mask |= FS_IN_ISDIR; |
211 | 214 | ||
212 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 215 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
213 | fsnotify_parent(file, NULL, mask); | 216 | fsnotify_parent(path, NULL, mask); |
214 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 217 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
215 | } | 218 | } |
216 | } | 219 | } |
217 | 220 | ||
@@ -220,15 +223,16 @@ static inline void fsnotify_modify(struct file *file) | |||
220 | */ | 223 | */ |
221 | static inline void fsnotify_open(struct file *file) | 224 | static inline void fsnotify_open(struct file *file) |
222 | { | 225 | { |
223 | struct inode *inode = file->f_path.dentry->d_inode; | 226 | struct path *path = &file->f_path; |
227 | struct inode *inode = path->dentry->d_inode; | ||
224 | __u32 mask = FS_OPEN; | 228 | __u32 mask = FS_OPEN; |
225 | 229 | ||
226 | if (S_ISDIR(inode->i_mode)) | 230 | if (S_ISDIR(inode->i_mode)) |
227 | mask |= FS_IN_ISDIR; | 231 | mask |= FS_IN_ISDIR; |
228 | 232 | ||
229 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 233 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
230 | fsnotify_parent(file, NULL, mask); | 234 | fsnotify_parent(path, NULL, mask); |
231 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 235 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
232 | } | 236 | } |
233 | } | 237 | } |
234 | 238 | ||
@@ -237,6 +241,7 @@ static inline void fsnotify_open(struct file *file) | |||
237 | */ | 241 | */ |
238 | static inline void fsnotify_close(struct file *file) | 242 | static inline void fsnotify_close(struct file *file) |
239 | { | 243 | { |
244 | struct path *path = &file->f_path; | ||
240 | struct inode *inode = file->f_path.dentry->d_inode; | 245 | struct inode *inode = file->f_path.dentry->d_inode; |
241 | fmode_t mode = file->f_mode; | 246 | fmode_t mode = file->f_mode; |
242 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; | 247 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
@@ -245,8 +250,8 @@ static inline void fsnotify_close(struct file *file) | |||
245 | mask |= FS_IN_ISDIR; | 250 | mask |= FS_IN_ISDIR; |
246 | 251 | ||
247 | if (!(file->f_mode & FMODE_NONOTIFY)) { | 252 | if (!(file->f_mode & FMODE_NONOTIFY)) { |
248 | fsnotify_parent(file, NULL, mask); | 253 | fsnotify_parent(path, NULL, mask); |
249 | fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0); | 254 | fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); |
250 | } | 255 | } |
251 | } | 256 | } |
252 | 257 | ||
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 9bbfd7204b04..ed36fb57c426 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -203,20 +203,20 @@ struct fsnotify_event { | |||
203 | /* to_tell may ONLY be dereferenced during handle_event(). */ | 203 | /* to_tell may ONLY be dereferenced during handle_event(). */ |
204 | struct inode *to_tell; /* either the inode the event happened to or its parent */ | 204 | struct inode *to_tell; /* either the inode the event happened to or its parent */ |
205 | /* | 205 | /* |
206 | * depending on the event type we should have either a file or inode | 206 | * depending on the event type we should have either a path or inode |
207 | * We hold a reference on file, but NOT on inode. Since we have the ref on | 207 | * We hold a reference on path, but NOT on inode. Since we have the ref on |
208 | * the file, it may be dereferenced at any point during this object's | 208 | * the path, it may be dereferenced at any point during this object's |
209 | * lifetime. That reference is dropped when this object's refcnt hits | 209 | * lifetime. That reference is dropped when this object's refcnt hits |
210 | * 0. If this event contains an inode instead of a file, the inode may | 210 | * 0. If this event contains an inode instead of a path, the inode may |
211 | * ONLY be used during handle_event(). | 211 | * ONLY be used during handle_event(). |
212 | */ | 212 | */ |
213 | union { | 213 | union { |
214 | struct file *file; | 214 | struct path path; |
215 | struct inode *inode; | 215 | struct inode *inode; |
216 | }; | 216 | }; |
217 | /* when calling fsnotify tell it if the data is a path or inode */ | 217 | /* when calling fsnotify tell it if the data is a path or inode */ |
218 | #define FSNOTIFY_EVENT_NONE 0 | 218 | #define FSNOTIFY_EVENT_NONE 0 |
219 | #define FSNOTIFY_EVENT_FILE 1 | 219 | #define FSNOTIFY_EVENT_PATH 1 |
220 | #define FSNOTIFY_EVENT_INODE 2 | 220 | #define FSNOTIFY_EVENT_INODE 2 |
221 | int data_type; /* which of the above union we have */ | 221 | int data_type; /* which of the above union we have */ |
222 | atomic_t refcnt; /* how many groups still are using/need to send this event */ | 222 | atomic_t refcnt; /* how many groups still are using/need to send this event */ |
@@ -293,7 +293,7 @@ struct fsnotify_mark { | |||
293 | /* main fsnotify call to send events */ | 293 | /* main fsnotify call to send events */ |
294 | extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, | 294 | extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, |
295 | const unsigned char *name, u32 cookie); | 295 | const unsigned char *name, u32 cookie); |
296 | extern void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask); | 296 | extern void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask); |
297 | extern void __fsnotify_inode_delete(struct inode *inode); | 297 | extern void __fsnotify_inode_delete(struct inode *inode); |
298 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); | 298 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); |
299 | extern u32 fsnotify_get_cookie(void); | 299 | extern u32 fsnotify_get_cookie(void); |
@@ -422,7 +422,7 @@ static inline int fsnotify(struct inode *to_tell, __u32 mask, void *data, int da | |||
422 | return 0; | 422 | return 0; |
423 | } | 423 | } |
424 | 424 | ||
425 | static inline void __fsnotify_parent(struct file *file, struct dentry *dentry, __u32 mask) | 425 | static inline void __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) |
426 | {} | 426 | {} |
427 | 427 | ||
428 | static inline void __fsnotify_inode_delete(struct inode *inode) | 428 | static inline void __fsnotify_inode_delete(struct inode *inode) |