Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207716
b: refs/heads/master
c: c1e5c95
h: refs/heads/master
v: v3
  • Loading branch information
Eric Paris committed Jul 28, 2010
1 parent ae966f7 commit cf2d6e9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3bcf3860a4ff9bbc522820b4b765e65e4deceb3e
refs/heads/master: c1e5c954020e123d30b4abf4038ce501861bcf9f
9 changes: 9 additions & 0 deletions trunk/fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ static void __fput(struct file *file)
might_sleep();

fsnotify_close(file);

/*
* fsnotify_create_event may have taken one or more references on this
* file. If it did so it left one reference for us to drop to make sure
* its calls to fput could not prematurely destroy the file.
*/
if (atomic_long_read(&file->f_count))
return fput(file);

/*
* The function eventpoll_release() should be the first called
* in the file cleanup chain.
Expand Down
13 changes: 13 additions & 0 deletions trunk/fs/notify/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,19 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
switch (data_type) {
case FSNOTIFY_EVENT_FILE: {
event->file = data;
/*
* if this file is about to disappear hold an extra reference
* until we return to __fput so we don't have to worry about
* future get/put destroying the file under us or generating
* additional events. Notice that we change f_mode without
* holding f_lock. This is safe since this is the only possible
* reference to this object in the kernel (it was about to be
* freed, remember?)
*/
if (!atomic_long_read(&event->file->f_count)) {
event->file->f_mode |= FMODE_NONOTIFY;
get_file(event->file);
}
get_file(event->file);
break;
}
Expand Down

0 comments on commit cf2d6e9

Please sign in to comment.