Skip to content

Commit 9d8cd30

Browse files
author
Al Viro
committed
__d_move(): fold manipulations with ->d_child/->d_subdirs
list_del() + list_add() is a slightly pessimised list_move() list_del() + INIT_LIST_HEAD() is a slightly pessimised list_del_init() Interleaving those makes the resulting code even worse. And harder to follow... Signed-off-by: Al Viro <[email protected]>
1 parent 8527dd7 commit 9d8cd30

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fs/dcache.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,8 +2506,6 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
25062506
d_hash(dentry->d_parent, dentry->d_name.hash));
25072507
}
25082508

2509-
list_del(&dentry->d_u.d_child);
2510-
list_del(&target->d_u.d_child);
25112509

25122510
/* Switch the names.. */
25132511
switch_names(dentry, target);
@@ -2517,15 +2515,15 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
25172515
if (IS_ROOT(dentry)) {
25182516
dentry->d_parent = target->d_parent;
25192517
target->d_parent = target;
2520-
INIT_LIST_HEAD(&target->d_u.d_child);
2518+
list_del_init(&target->d_u.d_child);
25212519
} else {
25222520
swap(dentry->d_parent, target->d_parent);
25232521

25242522
/* And add them back to the (new) parent lists */
2525-
list_add(&target->d_u.d_child, &target->d_parent->d_subdirs);
2523+
list_move(&target->d_u.d_child, &target->d_parent->d_subdirs);
25262524
}
25272525

2528-
list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs);
2526+
list_move(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs);
25292527

25302528
write_seqcount_end(&target->d_seq);
25312529
write_seqcount_end(&dentry->d_seq);

0 commit comments

Comments
 (0)