Commit 1ef5f13c authored by Eric Paris's avatar Eric Paris

fsnotify: fsnotify marks on inodes pin them in core

This patch pins any inodes with an fsnotify mark in core.  The idea is that
as soon as the mark is removed from the inode->fsnotify_mark_entries list
the inode will be iput.  In reality is doesn't quite work exactly this way.
The igrab will happen when the mark is added to an inode, but the iput will
happen when the inode pointer is NULL'd inside the mark.

It's possible that 2 racing things will try to remove the mark from
different directions.  One may try to remove the mark because of an
explicit request and one might try to remove it because the inode was
deleted.  It's possible that the removal because of inode deletion will
remove the mark from the inode's list, but the removal by explicit request
will actually set entry->inode == NULL; and call the iput.  This is safe.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
parent e4aff117
...@@ -204,6 +204,8 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) ...@@ -204,6 +204,8 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry)
*/ */
iput(inode);
/* /*
* it's possible that this group tried to destroy itself, but this * it's possible that this group tried to destroy itself, but this
* this mark was simultaneously being freed by inode. If that's the * this mark was simultaneously being freed by inode. If that's the
...@@ -306,6 +308,10 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry, ...@@ -306,6 +308,10 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry,
struct fsnotify_mark_entry *lentry; struct fsnotify_mark_entry *lentry;
int ret = 0; int ret = 0;
inode = igrab(inode);
if (unlikely(!inode))
return -EINVAL;
/* /*
* LOCKING ORDER!!!! * LOCKING ORDER!!!!
* entry->lock * entry->lock
...@@ -337,6 +343,7 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry, ...@@ -337,6 +343,7 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry,
if (lentry) { if (lentry) {
ret = -EEXIST; ret = -EEXIST;
iput(inode);
fsnotify_put_mark(lentry); fsnotify_put_mark(lentry);
} else { } else {
__fsnotify_update_child_dentry_flags(inode); __fsnotify_update_child_dentry_flags(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment