fsnotify: Determine lock in fsnotify_destroy_marks()

Instead of passing spinlock into fsnotify_destroy_marks() determine it
directly in that function from the connector type. This will reduce code
churn when changing lock protecting list of marks.

Reviewed-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Jan Kara 2017-03-15 09:41:15 +01:00
parent f06fd98759
commit a03e2e4f07
2 changed files with 11 additions and 8 deletions

View file

@ -26,19 +26,17 @@ extern struct inode *fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
extern struct fsnotify_mark *fsnotify_find_mark( extern struct fsnotify_mark *fsnotify_find_mark(
struct fsnotify_mark_connector *conn, struct fsnotify_mark_connector *conn,
struct fsnotify_group *group); struct fsnotify_group *group);
/* Destroy all marks connected via given connector protected by 'lock' */ /* Destroy all marks connected via given connector */
extern void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn, extern void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn);
spinlock_t *lock);
/* run the list of all marks associated with inode and destroy them */ /* run the list of all marks associated with inode and destroy them */
static inline void fsnotify_clear_marks_by_inode(struct inode *inode) static inline void fsnotify_clear_marks_by_inode(struct inode *inode)
{ {
fsnotify_destroy_marks(inode->i_fsnotify_marks, &inode->i_lock); fsnotify_destroy_marks(inode->i_fsnotify_marks);
} }
/* run the list of all marks associated with vfsmount and destroy them */ /* run the list of all marks associated with vfsmount and destroy them */
static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt) static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
{ {
fsnotify_destroy_marks(real_mount(mnt)->mnt_fsnotify_marks, fsnotify_destroy_marks(real_mount(mnt)->mnt_fsnotify_marks);
&mnt->mnt_root->d_lock);
} }
/* prepare for freeing all marks associated with given group */ /* prepare for freeing all marks associated with given group */
extern void fsnotify_detach_group_marks(struct fsnotify_group *group); extern void fsnotify_detach_group_marks(struct fsnotify_group *group);

View file

@ -572,14 +572,19 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group)
} }
} }
void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn, void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn)
spinlock_t *lock)
{ {
struct fsnotify_mark *mark; struct fsnotify_mark *mark;
spinlock_t *lock;
if (!conn) if (!conn)
return; return;
if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
lock = &conn->inode->i_lock;
else
lock = &conn->mnt->mnt_root->d_lock;
while (1) { while (1) {
/* /*
* We have to be careful since we can race with e.g. * We have to be careful since we can race with e.g.