aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/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/mark.c
parent33d3dfff451a2ab6fe2f6aaabed9b24e91aad109 (diff)
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/mark.c')
-rw-r--r--fs/notify/mark.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index d296ec9ffb2a..0ebc3fd7089b 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -168,7 +168,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
168 * is just a lazy update (and could be a perf win...) 168 * is just a lazy update (and could be a perf win...)
169 */ 169 */
170 170
171 if (inode) 171 if (inode && (mark->flags & FSNOTIFY_MARK_FLAG_OBJECT_PINNED))
172 iput(inode); 172 iput(inode);
173 173
174 /* 174 /*
@@ -180,6 +180,17 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
180 fsnotify_final_destroy_group(group); 180 fsnotify_final_destroy_group(group);
181} 181}
182 182
183void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask)
184{
185 assert_spin_locked(&mark->lock);
186
187 mark->mask = mask;
188
189 if (mark->flags & FSNOTIFY_MARK_FLAG_INODE)
190 fsnotify_set_inode_mark_mask_locked(mark, mask);
191}
192
193
183/* 194/*
184 * Attach an initialized mark to a given group and fs object. 195 * Attach an initialized mark to a given group and fs object.
185 * These marks may be used for the fsnotify backend to determine which 196 * These marks may be used for the fsnotify backend to determine which
@@ -230,6 +241,10 @@ int fsnotify_add_mark(struct fsnotify_mark *mark,
230 } 241 }
231 242
232 spin_unlock(&group->mark_lock); 243 spin_unlock(&group->mark_lock);
244
245 /* this will pin the object if appropriate */
246 fsnotify_set_mark_mask_locked(mark, mark->mask);
247
233 spin_unlock(&mark->lock); 248 spin_unlock(&mark->lock);
234 249
235 if (inode) 250 if (inode)