Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207681
b: refs/heads/master
c: 90b1e7a
h: refs/heads/master
i:
  207679: 652f8c2
v: v3
  • Loading branch information
Eric Paris committed Jul 28, 2010
1 parent ee89d48 commit 986b7fd
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 33d3dfff451a2ab6fe2f6aaabed9b24e91aad109
refs/heads/master: 90b1e7a57880fb66437ab7db39e1e65ca0372822
2 changes: 1 addition & 1 deletion trunk/fs/notify/dnotify/dnotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
new_mask = 0;
for (dn = dn_mark->dn; dn != NULL; dn = dn->dn_next)
new_mask |= (dn->dn_mask & ~FS_DN_MULTISHOT);
fsn_mark->mask = new_mask;
fsnotify_set_mark_mask_locked(fsn_mark, new_mask);

if (old_mask == new_mask)
return;
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark, __u3

spin_lock(&fsn_mark->lock);
oldmask = fsn_mark->mask;
fsn_mark->mask = oldmask & ~mask;
fsnotify_set_mark_mask_locked(fsn_mark, (oldmask & ~mask));
spin_unlock(&fsn_mark->lock);

if (!(oldmask & ~mask))
Expand Down Expand Up @@ -359,7 +359,7 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark, __u32 mas

spin_lock(&fsn_mark->lock);
oldmask = fsn_mark->mask;
fsn_mark->mask = oldmask | mask;
fsnotify_set_mark_mask_locked(fsn_mark, (oldmask | mask));
spin_unlock(&fsn_mark->lock);

return mask & ~oldmask;
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/notify/fsnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern __u32 fsnotify_vfsmount_mask;
/* destroy all events sitting in this groups notification queue */
extern void fsnotify_flush_notify(struct fsnotify_group *group);

extern void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *fsn_mark,
__u32 mask);
/* add a mark to an inode */
extern int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
struct fsnotify_group *group, struct inode *inode,
Expand Down
35 changes: 27 additions & 8 deletions trunk/fs/notify/inode_mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
12 changes: 5 additions & 7 deletions trunk/fs/notify/inotify/inotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,11 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
spin_lock(&fsn_mark->lock);

old_mask = fsn_mark->mask;
if (add) {
fsn_mark->mask |= mask;
new_mask = fsn_mark->mask;
} else {
fsn_mark->mask = mask;
new_mask = fsn_mark->mask;
}
if (add)
fsnotify_set_mark_mask_locked(fsn_mark, (fsn_mark->mask | mask));
else
fsnotify_set_mark_mask_locked(fsn_mark, mask);
new_mask = fsn_mark->mask;

spin_unlock(&fsn_mark->lock);

Expand Down
17 changes: 16 additions & 1 deletion trunk/fs/notify/mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
* is just a lazy update (and could be a perf win...)
*/

if (inode)
if (inode && (mark->flags & FSNOTIFY_MARK_FLAG_OBJECT_PINNED))
iput(inode);

/*
Expand All @@ -180,6 +180,17 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
fsnotify_final_destroy_group(group);
}

void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask)
{
assert_spin_locked(&mark->lock);

mark->mask = mask;

if (mark->flags & FSNOTIFY_MARK_FLAG_INODE)
fsnotify_set_inode_mark_mask_locked(mark, mask);
}


/*
* Attach an initialized mark to a given group and fs object.
* These marks may be used for the fsnotify backend to determine which
Expand Down Expand Up @@ -230,6 +241,10 @@ int fsnotify_add_mark(struct fsnotify_mark *mark,
}

spin_unlock(&group->mark_lock);

/* this will pin the object if appropriate */
fsnotify_set_mark_mask_locked(mark, mark->mask);

spin_unlock(&mark->lock);

if (inode)
Expand Down
7 changes: 5 additions & 2 deletions trunk/include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,9 @@ struct fsnotify_mark {
struct fsnotify_vfsmount_mark m;
};
struct list_head free_g_list; /* tmp list used when freeing this mark */
#define FSNOTIFY_MARK_FLAG_INODE 0x01
#define FSNOTIFY_MARK_FLAG_VFSMOUNT 0x02
#define FSNOTIFY_MARK_FLAG_INODE 0x01
#define FSNOTIFY_MARK_FLAG_VFSMOUNT 0x02
#define FSNOTIFY_MARK_FLAG_OBJECT_PINNED 0x04
unsigned int flags; /* vfsmount or inode mark? */
void (*free_mark)(struct fsnotify_mark *mark); /* called on final put+free */
};
Expand Down Expand Up @@ -372,6 +373,8 @@ extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *gro
extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt);
/* copy the values from old into new */
extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old);
/* set the mask of a mark (might pin the object into memory */
extern void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask);
/* attach the mark to both the group and the inode */
extern int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
struct inode *inode, struct vfsmount *mnt, int allow_dups);
Expand Down

0 comments on commit 986b7fd

Please sign in to comment.