diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-13 18:08:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-13 18:08:16 -0400 |
commit | d4c608115c6203efbab14befab90a6d1b61177d8 (patch) | |
tree | d063741d0f150e91320dcfb3d3950c4f0bcd7de0 /fs/notify | |
parent | 29c079caf584ad9a333c0d32292d036d1ae3205f (diff) | |
parent | 4d8e7055a4058ee191296699803c5090e14f0dff (diff) |
Merge tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull fsnotify fixes from Jan Kara:
"Two fsnotify fixes"
* tag 'fsnotify_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
fsnotify: fix unlink performance regression
fsnotify: Clarify connector assignment in fsnotify_add_mark_list()
Diffstat (limited to 'fs/notify')
-rw-r--r-- | fs/notify/fsnotify.c | 41 | ||||
-rw-r--r-- | fs/notify/mark.c | 5 |
2 files changed, 46 insertions, 0 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 5433e37fb0c5..8c7cbac7183c 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c | |||
@@ -108,6 +108,47 @@ void fsnotify_sb_delete(struct super_block *sb) | |||
108 | } | 108 | } |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * fsnotify_nameremove - a filename was removed from a directory | ||
112 | * | ||
113 | * This is mostly called under parent vfs inode lock so name and | ||
114 | * dentry->d_parent should be stable. However there are some corner cases where | ||
115 | * inode lock is not held. So to be on the safe side and be reselient to future | ||
116 | * callers and out of tree users of d_delete(), we do not assume that d_parent | ||
117 | * and d_name are stable and we use dget_parent() and | ||
118 | * take_dentry_name_snapshot() to grab stable references. | ||
119 | */ | ||
120 | void fsnotify_nameremove(struct dentry *dentry, int isdir) | ||
121 | { | ||
122 | struct dentry *parent; | ||
123 | struct name_snapshot name; | ||
124 | __u32 mask = FS_DELETE; | ||
125 | |||
126 | /* d_delete() of pseudo inode? (e.g. __ns_get_path() playing tricks) */ | ||
127 | if (IS_ROOT(dentry)) | ||
128 | return; | ||
129 | |||
130 | if (isdir) | ||
131 | mask |= FS_ISDIR; | ||
132 | |||
133 | parent = dget_parent(dentry); | ||
134 | /* Avoid unneeded take_dentry_name_snapshot() */ | ||
135 | if (!(d_inode(parent)->i_fsnotify_mask & FS_DELETE) && | ||
136 | !(dentry->d_sb->s_fsnotify_mask & FS_DELETE)) | ||
137 | goto out_dput; | ||
138 | |||
139 | take_dentry_name_snapshot(&name, dentry); | ||
140 | |||
141 | fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE, | ||
142 | &name.name, 0); | ||
143 | |||
144 | release_dentry_name_snapshot(&name); | ||
145 | |||
146 | out_dput: | ||
147 | dput(parent); | ||
148 | } | ||
149 | EXPORT_SYMBOL(fsnotify_nameremove); | ||
150 | |||
151 | /* | ||
111 | * Given an inode, first check if we care what happens to our children. Inotify | 152 | * Given an inode, first check if we care what happens to our children. Inotify |
112 | * and dnotify both tell their parents about events. If we care about any event | 153 | * and dnotify both tell their parents about events. If we care about any event |
113 | * on a child we run all of our children and set a dentry flag saying that the | 154 | * on a child we run all of our children and set a dentry flag saying that the |
diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 22acb0a79b53..b251105f646f 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c | |||
@@ -619,6 +619,11 @@ restart: | |||
619 | /* mark should be the last entry. last is the current last entry */ | 619 | /* mark should be the last entry. last is the current last entry */ |
620 | hlist_add_behind_rcu(&mark->obj_list, &last->obj_list); | 620 | hlist_add_behind_rcu(&mark->obj_list, &last->obj_list); |
621 | added: | 621 | added: |
622 | /* | ||
623 | * Since connector is attached to object using cmpxchg() we are | ||
624 | * guaranteed that connector initialization is fully visible by anyone | ||
625 | * seeing mark->connector set. | ||
626 | */ | ||
622 | WRITE_ONCE(mark->connector, conn); | 627 | WRITE_ONCE(mark->connector, conn); |
623 | out_err: | 628 | out_err: |
624 | spin_unlock(&conn->lock); | 629 | spin_unlock(&conn->lock); |