fsnotify: vfsmount marks generic functions
Much like inode-mark.c has all of the code dealing with marks on inodes
this patch adds a vfsmount-mark.c which has similar code but is intended
for marks on vfsmounts.
Signed-off-by: Eric Paris <eparis@redhat.com>
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 57bb1d7..d296ec9 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -115,15 +115,11 @@
void fsnotify_destroy_mark(struct fsnotify_mark *mark)
{
struct fsnotify_group *group;
- struct inode *inode;
+ struct inode *inode = NULL;
spin_lock(&mark->lock);
group = mark->group;
- inode = mark->i.inode;
-
- BUG_ON(group && !inode);
- BUG_ON(!group && inode);
/* if !group something else already marked this to die */
if (!group) {
@@ -136,8 +132,11 @@
spin_lock(&group->mark_lock);
- if (mark->flags & FSNOTIFY_MARK_FLAG_INODE)
+ if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
fsnotify_destroy_inode_mark(mark);
+ inode = mark->i.inode;
+ } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT)
+ fsnotify_destroy_vfsmount_mark(mark);
else
BUG();
@@ -169,8 +168,8 @@
* is just a lazy update (and could be a perf win...)
*/
-
- iput(inode);
+ if (inode)
+ iput(inode);
/*
* it's possible that this group tried to destroy itself, but this
@@ -192,7 +191,6 @@
{
int ret = 0;
- BUG_ON(mnt);
BUG_ON(inode && mnt);
BUG_ON(!inode && !mnt);
@@ -223,6 +221,10 @@
ret = fsnotify_add_inode_mark(mark, group, inode, allow_dups);
if (ret)
goto err;
+ } else if (mnt) {
+ ret = fsnotify_add_vfsmount_mark(mark, group, mnt, allow_dups);
+ if (ret)
+ goto err;
} else {
BUG();
}