Skip to content

Commit

Permalink
fsnotify: Move fsnotify_destroy_marks()
Browse files Browse the repository at this point in the history
Move fsnotify_destroy_marks() to be later in the fs/notify/mark.c. It
will need some functions that are declared after its current
declaration. No functional change.

Reviewed-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
jankara committed Apr 10, 2017
1 parent 755b5bc commit 0810b4f
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions fs/notify/mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,42 +224,6 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
fsnotify_free_mark(mark);
}

void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn,
spinlock_t *lock)
{
struct fsnotify_mark *mark;

if (!conn)
return;

while (1) {
/*
* We have to be careful since we can race with e.g.
* fsnotify_clear_marks_by_group() and once we drop 'lock',
* mark can get removed from the obj_list and destroyed. But
* we are holding mark reference so mark cannot be freed and
* calling fsnotify_destroy_mark() more than once is fine.
*/
spin_lock(lock);
if (hlist_empty(&conn->list)) {
spin_unlock(lock);
break;
}
mark = hlist_entry(conn->list.first, struct fsnotify_mark,
obj_list);
/*
* We don't update i_fsnotify_mask / mnt_fsnotify_mask here
* since inode / mount is going away anyway. So just remove
* mark from the list.
*/
hlist_del_init_rcu(&mark->obj_list);
fsnotify_get_mark(mark);
spin_unlock(lock);
fsnotify_destroy_mark(mark, mark->group);
fsnotify_put_mark(mark);
}
}

void fsnotify_connector_free(struct fsnotify_mark_connector **connp)
{
if (*connp) {
Expand Down Expand Up @@ -580,6 +544,42 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group)
}
}

void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn,
spinlock_t *lock)
{
struct fsnotify_mark *mark;

if (!conn)
return;

while (1) {
/*
* We have to be careful since we can race with e.g.
* fsnotify_clear_marks_by_group() and once we drop 'lock',
* mark can get removed from the obj_list and destroyed. But
* we are holding mark reference so mark cannot be freed and
* calling fsnotify_destroy_mark() more than once is fine.
*/
spin_lock(lock);
if (hlist_empty(&conn->list)) {
spin_unlock(lock);
break;
}
mark = hlist_entry(conn->list.first, struct fsnotify_mark,
obj_list);
/*
* We don't update i_fsnotify_mask / mnt_fsnotify_mask here
* since inode / mount is going away anyway. So just remove
* mark from the list.
*/
hlist_del_init_rcu(&mark->obj_list);
fsnotify_get_mark(mark);
spin_unlock(lock);
fsnotify_destroy_mark(mark, mark->group);
fsnotify_put_mark(mark);
}
}

/*
* Nothing fancy, just initialize lists and locks and counters.
*/
Expand Down

0 comments on commit 0810b4f

Please sign in to comment.