[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090319180553.17449.71990.stgit@paris.rdu.redhat.com>
Date: Thu, 19 Mar 2009 14:05:53 -0400
From: Eric Paris <eparis@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: viro@...iv.linux.org.uk, hch@...radead.org,
alan@...rguk.ukuu.org.uk, sfr@...b.auug.org.au,
john@...nmccutchan.com, rlove@...ve.org, akpm@...ux-foundation.org
Subject: [PATCH 11/13] 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: Eric Paris <eparis@...hat.com>
---
fs/notify/inode_mark.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index 144b09a..362b04c 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -159,6 +159,8 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry)
group->ops->freeing_mark(entry, group);
fsnotify_update_dentry_child_flags(inode);
+
+ iput(inode);
}
void fsnotify_clear_marks_by_group(struct fsnotify_group *group)
@@ -228,11 +230,16 @@ void fsnotify_init_mark(struct fsnotify_mark_entry *entry, void (*free_mark)(str
entry->free_mark = free_mark;
}
-int fsnotify_add_mark(struct fsnotify_mark_entry *entry, struct fsnotify_group *group, struct inode *inode)
+int fsnotify_add_mark(struct fsnotify_mark_entry *entry, struct fsnotify_group *group, struct inode *in_inode)
{
struct fsnotify_mark_entry *lentry;
+ struct inode *inode;
int ret = 0;
+ inode = igrab(in_inode);
+ if (unlikely(!inode))
+ return -EINVAL;
+
/*
* LOCKING ORDER!!!!
* entry->lock
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists