Skip to content

Commit a03e2e4

Browse files
committed
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>
1 parent f06fd98 commit a03e2e4

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎fs/notify/fsnotify.h‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@ extern struct inode *fsnotify_destroy_inode_mark(struct fsnotify_mark *mark);
2626
extern struct fsnotify_mark *fsnotify_find_mark(
2727
struct fsnotify_mark_connector *conn,
2828
struct fsnotify_group *group);
29-
/* Destroy all marks connected via given connector protected by 'lock' */
30-
extern void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn,
31-
spinlock_t *lock);
29+
/* Destroy all marks connected via given connector */
30+
extern void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn);
3231
/* run the list of all marks associated with inode and destroy them */
3332
static inline void fsnotify_clear_marks_by_inode(struct inode *inode)
3433
{
35-
fsnotify_destroy_marks(inode->i_fsnotify_marks, &inode->i_lock);
34+
fsnotify_destroy_marks(inode->i_fsnotify_marks);
3635
}
3736
/* run the list of all marks associated with vfsmount and destroy them */
3837
static inline void fsnotify_clear_marks_by_mount(struct vfsmount *mnt)
3938
{
40-
fsnotify_destroy_marks(real_mount(mnt)->mnt_fsnotify_marks,
41-
&mnt->mnt_root->d_lock);
39+
fsnotify_destroy_marks(real_mount(mnt)->mnt_fsnotify_marks);
4240
}
4341
/* prepare for freeing all marks associated with given group */
4442
extern void fsnotify_detach_group_marks(struct fsnotify_group *group);

‎fs/notify/mark.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,19 @@ void fsnotify_detach_group_marks(struct fsnotify_group *group)
572572
}
573573
}
574574

575-
void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn,
576-
spinlock_t *lock)
575+
void fsnotify_destroy_marks(struct fsnotify_mark_connector *conn)
577576
{
578577
struct fsnotify_mark *mark;
578+
spinlock_t *lock;
579579

580580
if (!conn)
581581
return;
582582

583+
if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
584+
lock = &conn->inode->i_lock;
585+
else
586+
lock = &conn->mnt->mnt_root->d_lock;
587+
583588
while (1) {
584589
/*
585590
* We have to be careful since we can race with e.g.

0 commit comments

Comments
 (0)