summaryrefslogtreecommitdiffstats
path: root/fs/notify/inode_mark.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-12-17 21:24:33 -0500
committerEric Paris <eparis@redhat.com>2010-07-28 09:58:59 -0400
commit90b1e7a57880fb66437ab7db39e1e65ca0372822 (patch)
tree61b7195c84d9dfd057ed3dcb07c5fc831db6a3a9 /fs/notify/inode_mark.c
parent33d3dfff451a2ab6fe2f6aaabed9b24e91aad109 (diff)
downloadblackbird-op-linux-90b1e7a57880fb66437ab7db39e1e65ca0372822.tar.gz
blackbird-op-linux-90b1e7a57880fb66437ab7db39e1e65ca0372822.zip
fsnotify: allow marks to not pin inodes in core
inotify marks must pin inodes in core. dnotify doesn't technically need to since they are closed when the directory is closed. fanotify also need to pin inodes in core as it works today. But the next step is to introduce the concept of 'ignored masks' which is actually a mask of events for an inode of no interest. I claim that these should be liberally sent to the kernel and should not pin the inode in core. If the inode is brought back in the listener will get an event it may have thought excluded, but this is not a serious situation and one any listener should deal with. This patch lays the ground work for non-pinning inode marks by using lazy inode pinning. We do not pin a mark until it has a non-zero mask entry. If a listener new sets a mask we never pin the inode. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/inode_mark.c')
-rw-r--r--fs/notify/inode_mark.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index c925579ba011..4292f9e23ae8 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -141,7 +141,32 @@ struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group,
}
/*
- * Attach an initialized mark mark to a given group and inode.
+ * If we are setting a mark mask on an inode mark we should pin the inode
+ * in memory.
+ */
+void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *mark,
+ __u32 mask)
+{
+ struct inode *inode;
+
+ assert_spin_locked(&mark->lock);
+
+ if (mask &&
+ mark->i.inode &&
+ !(mark->flags & FSNOTIFY_MARK_FLAG_OBJECT_PINNED)) {
+ mark->flags |= FSNOTIFY_MARK_FLAG_OBJECT_PINNED;
+ inode = igrab(mark->i.inode);
+ /*
+ * we shouldn't be able to get here if the inode wasn't
+ * already safely held in memory. But bug in case it
+ * ever is wrong.
+ */
+ BUG_ON(!inode);
+ }
+}
+
+/*
+ * Attach an initialized mark to a given group and inode.
* These marks may be used for the fsnotify backend to determine which
* event types should be delivered to which group and for which inodes.
*/
@@ -152,10 +177,6 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
struct fsnotify_mark *lmark = NULL;
int ret = 0;
- inode = igrab(inode);
- if (unlikely(!inode))
- return -EINVAL;
-
mark->flags = FSNOTIFY_MARK_FLAG_INODE;
assert_spin_locked(&mark->lock);
@@ -175,10 +196,8 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
spin_unlock(&inode->i_lock);
- if (lmark) {
+ if (lmark)
ret = -EEXIST;
- iput(inode);
- }
return ret;
}
OpenPOWER on IntegriCloud