Skip to content

Commit 9a8d5bb

Browse files
Wu Fengguangtorvalds
authored andcommitted
generic swap(): dcache: use swap() instead of private do_switch()
Use the new generic implementation. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent df4927b commit 9a8d5bb

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

‎fs/dcache.c‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,10 +1567,6 @@ void d_rehash(struct dentry * entry)
15671567
spin_unlock(&dcache_lock);
15681568
}
15691569

1570-
#define do_switch(x,y) do { \
1571-
__typeof__ (x) __tmp = x; \
1572-
x = y; y = __tmp; } while (0)
1573-
15741570
/*
15751571
* When switching names, the actual string doesn't strictly have to
15761572
* be preserved in the target - because we're dropping the target
@@ -1589,7 +1585,7 @@ static void switch_names(struct dentry *dentry, struct dentry *target)
15891585
/*
15901586
* Both external: swap the pointers
15911587
*/
1592-
do_switch(target->d_name.name, dentry->d_name.name);
1588+
swap(target->d_name.name, dentry->d_name.name);
15931589
} else {
15941590
/*
15951591
* dentry:internal, target:external. Steal target's
@@ -1620,7 +1616,7 @@ static void switch_names(struct dentry *dentry, struct dentry *target)
16201616
return;
16211617
}
16221618
}
1623-
do_switch(dentry->d_name.len, target->d_name.len);
1619+
swap(dentry->d_name.len, target->d_name.len);
16241620
}
16251621

16261622
/*
@@ -1680,15 +1676,15 @@ static void d_move_locked(struct dentry * dentry, struct dentry * target)
16801676

16811677
/* Switch the names.. */
16821678
switch_names(dentry, target);
1683-
do_switch(dentry->d_name.hash, target->d_name.hash);
1679+
swap(dentry->d_name.hash, target->d_name.hash);
16841680

16851681
/* ... and switch the parents */
16861682
if (IS_ROOT(dentry)) {
16871683
dentry->d_parent = target->d_parent;
16881684
target->d_parent = target;
16891685
INIT_LIST_HEAD(&target->d_u.d_child);
16901686
} else {
1691-
do_switch(dentry->d_parent, target->d_parent);
1687+
swap(dentry->d_parent, target->d_parent);
16921688

16931689
/* And add them back to the (new) parent lists */
16941690
list_add(&target->d_u.d_child, &target->d_parent->d_subdirs);
@@ -1789,7 +1785,7 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon)
17891785
struct dentry *dparent, *aparent;
17901786

17911787
switch_names(dentry, anon);
1792-
do_switch(dentry->d_name.hash, anon->d_name.hash);
1788+
swap(dentry->d_name.hash, anon->d_name.hash);
17931789

17941790
dparent = dentry->d_parent;
17951791
aparent = anon->d_parent;

0 commit comments

Comments
 (0)