Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fsnotify: remove destroy_list from fsnotify_mark

destroy_list is used to track marks which still need waiting for srcu
period end before they can be freed. However by the time mark is added to
destroy_list it isn't in group's list of marks anymore and thus we can
reuse fsnotify_mark->g_list for queueing into destroy_list. This saves
two pointers for each fsnotify_mark.

Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Eric Paris <eparis@redhat.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Kara and committed by
Linus Torvalds
37d469e7 0809ab69

+9 -6
+4 -4
fs/notify/mark.c
··· 161 161 mutex_unlock(&group->mark_mutex); 162 162 163 163 spin_lock(&destroy_lock); 164 - list_add(&mark->destroy_list, &destroy_list); 164 + list_add(&mark->g_list, &destroy_list); 165 165 spin_unlock(&destroy_lock); 166 166 wake_up(&destroy_waitq); 167 167 /* ··· 370 370 spin_unlock(&mark->lock); 371 371 372 372 spin_lock(&destroy_lock); 373 - list_add(&mark->destroy_list, &destroy_list); 373 + list_add(&mark->g_list, &destroy_list); 374 374 spin_unlock(&destroy_lock); 375 375 wake_up(&destroy_waitq); 376 376 ··· 469 469 470 470 synchronize_srcu(&fsnotify_mark_srcu); 471 471 472 - list_for_each_entry_safe(mark, next, &private_destroy_list, destroy_list) { 473 - list_del_init(&mark->destroy_list); 472 + list_for_each_entry_safe(mark, next, &private_destroy_list, g_list) { 473 + list_del_init(&mark->g_list); 474 474 fsnotify_put_mark(mark); 475 475 } 476 476
+5 -2
include/linux/fsnotify_backend.h
··· 212 212 * in kernel that found and may be using this mark. */ 213 213 atomic_t refcnt; /* active things looking at this mark */ 214 214 struct fsnotify_group *group; /* group this mark is for */ 215 - struct list_head g_list; /* list of marks by group->i_fsnotify_marks */ 215 + struct list_head g_list; /* list of marks by group->i_fsnotify_marks 216 + * Also reused for queueing mark into 217 + * destroy_list when it's waiting for 218 + * the end of SRCU period before it can 219 + * be freed */ 216 220 spinlock_t lock; /* protect group and inode */ 217 221 struct hlist_node obj_list; /* list of marks for inode / vfsmount */ 218 222 struct list_head free_list; /* tmp list used when freeing this mark */ ··· 231 227 #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY 0x08 232 228 #define FSNOTIFY_MARK_FLAG_ALIVE 0x10 233 229 unsigned int flags; /* vfsmount or inode mark? */ 234 - struct list_head destroy_list; 235 230 void (*free_mark)(struct fsnotify_mark *mark); /* called on final put+free */ 236 231 }; 237 232