@@ -150,13 +150,20 @@ void fsnotify_destroy_mark_locked(struct fsnotify_mark *mark,
150
150
151
151
spin_unlock (& mark -> lock );
152
152
153
+ if (inode && (mark -> flags & FSNOTIFY_MARK_FLAG_OBJECT_PINNED ))
154
+ iput (inode );
153
155
/* release lock temporarily */
154
156
mutex_unlock (& group -> mark_mutex );
155
157
156
158
spin_lock (& destroy_lock );
157
159
list_add (& mark -> destroy_list , & destroy_list );
158
160
spin_unlock (& destroy_lock );
159
161
wake_up (& destroy_waitq );
162
+ /*
163
+ * We don't necessarily have a ref on mark from caller so the above destroy
164
+ * may have actually freed it, unless this group provides a 'freeing_mark'
165
+ * function which must be holding a reference.
166
+ */
160
167
161
168
/*
162
169
* Some groups like to know that marks are being freed. This is a
@@ -178,22 +185,15 @@ void fsnotify_destroy_mark_locked(struct fsnotify_mark *mark,
178
185
* is just a lazy update (and could be a perf win...)
179
186
*/
180
187
181
- if (inode && (mark -> flags & FSNOTIFY_MARK_FLAG_OBJECT_PINNED ))
182
- iput (inode );
183
- /*
184
- * We don't necessarily have a ref on mark from caller so the above iput
185
- * may have already destroyed it. Don't touch from now on.
186
- */
187
-
188
188
atomic_dec (& group -> num_marks );
189
189
190
- mutex_lock (& group -> mark_mutex );
190
+ mutex_lock_nested (& group -> mark_mutex , SINGLE_DEPTH_NESTING );
191
191
}
192
192
193
193
void fsnotify_destroy_mark (struct fsnotify_mark * mark ,
194
194
struct fsnotify_group * group )
195
195
{
196
- mutex_lock (& group -> mark_mutex );
196
+ mutex_lock_nested (& group -> mark_mutex , SINGLE_DEPTH_NESTING );
197
197
fsnotify_destroy_mark_locked (mark , group );
198
198
mutex_unlock (& group -> mark_mutex );
199
199
}
@@ -300,7 +300,7 @@ void fsnotify_clear_marks_by_group_flags(struct fsnotify_group *group,
300
300
{
301
301
struct fsnotify_mark * lmark , * mark ;
302
302
303
- mutex_lock (& group -> mark_mutex );
303
+ mutex_lock_nested (& group -> mark_mutex , SINGLE_DEPTH_NESTING );
304
304
list_for_each_entry_safe (mark , lmark , & group -> marks_list , g_list ) {
305
305
if (mark -> flags & flags ) {
306
306
fsnotify_get_mark (mark );
0 commit comments