Skip to content

Commit

Permalink
fsnotify: split generic and inode specific mark code
Browse files Browse the repository at this point in the history
currently all marking is done by functions in inode-mark.c.  Some of this
is pretty generic and should be instead done in a generic function and we
should only put the inode specific code in inode-mark.c

Signed-off-by: Eric Paris <[email protected]>
  • Loading branch information
eparis committed Jul 28, 2010
1 parent 32c3263 commit 5444e29
Show file tree
Hide file tree
Showing 12 changed files with 347 additions and 252 deletions.
3 changes: 2 additions & 1 deletion fs/notify/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
obj-$(CONFIG_FSNOTIFY) += fsnotify.o notification.o group.o inode_mark.o
obj-$(CONFIG_FSNOTIFY) += fsnotify.o notification.o group.o inode_mark.o \
mark.o

obj-y += dnotify/
obj-y += inotify/
Expand Down
12 changes: 6 additions & 6 deletions fs/notify/dnotify/dnotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int dnotify_handle_event(struct fsnotify_group *group,

to_tell = event->to_tell;

fsn_mark = fsnotify_find_mark(group, to_tell);
fsn_mark = fsnotify_find_inode_mark(group, to_tell);
if (unlikely(!fsn_mark))
return 0;
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
Expand Down Expand Up @@ -143,14 +143,14 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
if (!S_ISDIR(inode->i_mode))
return false;

fsn_mark = fsnotify_find_mark(group, inode);
fsn_mark = fsnotify_find_inode_mark(group, inode);
if (!fsn_mark)
return false;

mask = (mask & ~FS_EVENT_ON_CHILD);
send = (mask & fsn_mark->mask);

fsnotify_put_mark(fsn_mark); /* matches fsnotify_find_mark */
fsnotify_put_mark(fsn_mark); /* matches fsnotify_find_inode_mark */

return send;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
if (!S_ISDIR(inode->i_mode))
return;

fsn_mark = fsnotify_find_mark(dnotify_group, inode);
fsn_mark = fsnotify_find_inode_mark(dnotify_group, inode);
if (!fsn_mark)
return;
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
Expand Down Expand Up @@ -346,12 +346,12 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
mutex_lock(&dnotify_mark_mutex);

/* add the new_fsn_mark or find an old one. */
fsn_mark = fsnotify_find_mark(dnotify_group, inode);
fsn_mark = fsnotify_find_inode_mark(dnotify_group, inode);
if (fsn_mark) {
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
spin_lock(&fsn_mark->lock);
} else {
fsnotify_add_mark(new_fsn_mark, dnotify_group, inode, 0);
fsnotify_add_mark(new_fsn_mark, dnotify_group, inode, NULL, 0);
spin_lock(&new_fsn_mark->lock);
fsn_mark = new_fsn_mark;
dn_mark = new_dn_mark;
Expand Down
2 changes: 1 addition & 1 deletion fs/notify/fanotify/fanotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static bool fanotify_should_send_event(struct fsnotify_group *group, struct inod
if (data_type != FSNOTIFY_EVENT_PATH)
return false;

fsn_mark = fsnotify_find_mark(group, inode);
fsn_mark = fsnotify_find_inode_mark(group, inode);
if (!fsn_mark)
return false;

Expand Down
8 changes: 4 additions & 4 deletions fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static int fanotify_remove_mark(struct fsnotify_group *group,
pr_debug("%s: group=%p inode=%p mask=%x\n", __func__,
group, inode, mask);

fsn_mark = fsnotify_find_mark(group, inode);
fsn_mark = fsnotify_find_inode_mark(group, inode);
if (!fsn_mark)
return -ENOENT;

Expand All @@ -321,7 +321,7 @@ static int fanotify_remove_mark(struct fsnotify_group *group,

fsnotify_recalc_group_mask(group);

/* matches the fsnotify_find_mark() */
/* matches the fsnotify_find_inode_mark() */
fsnotify_put_mark(fsn_mark);

return 0;
Expand All @@ -338,7 +338,7 @@ static int fanotify_add_mark(struct fsnotify_group *group,
pr_debug("%s: group=%p inode=%p mask=%x\n", __func__,
group, inode, mask);

fsn_mark = fsnotify_find_mark(group, inode);
fsn_mark = fsnotify_find_inode_mark(group, inode);
if (!fsn_mark) {
struct fsnotify_mark *new_fsn_mark;

Expand All @@ -348,7 +348,7 @@ static int fanotify_add_mark(struct fsnotify_group *group,
goto out;

fsnotify_init_mark(new_fsn_mark, fanotify_free_mark);
ret = fsnotify_add_mark(new_fsn_mark, group, inode, 0);
ret = fsnotify_add_mark(new_fsn_mark, group, inode, NULL, 0);
if (ret) {
fanotify_free_mark(new_fsn_mark);
goto out;
Expand Down
7 changes: 7 additions & 0 deletions fs/notify/fsnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ extern __u32 fsnotify_vfsmount_mask;
/* destroy all events sitting in this groups notification queue */
extern void fsnotify_flush_notify(struct fsnotify_group *group);

/* add a mark to an inode */
extern int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
struct fsnotify_group *group, struct inode *inode,
int allow_dups);

/* add a group to the inode group list */
extern void fsnotify_add_inode_group(struct fsnotify_group *group);
/* add a group to the vfsmount group list */
extern void fsnotify_add_vfsmount_group(struct fsnotify_group *group);
/* final kfree of a group */
extern void fsnotify_final_destroy_group(struct fsnotify_group *group);

/* inode specific destruction of a mark */
extern void fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
/* run the list of all marks associated with inode and flag them to be freed */
extern void fsnotify_clear_marks_by_inode(struct inode *inode);
/*
Expand Down
Loading

0 comments on commit 5444e29

Please sign in to comment.