Skip to content

Commit 2420067

Browse files
author
Al Viro
committed
struct dentry: make ->d_u anonymous
Making ->d_rcu and (then) ->d_child overlapping dates back to 2006; anon unions support had been added to gcc only in 4.6 (2011) and the minimal gcc version hadn't been bumped to that until 4.19 (2018). These days there's no reason not to keep that union named. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 408d8af commit 2420067

6 files changed

Lines changed: 30 additions & 30 deletions

File tree

fs/ceph/mds_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4608,7 +4608,7 @@ static struct dentry* d_find_primary(struct inode *inode)
46084608
goto out_unlock;
46094609

46104610
if (S_ISDIR(inode->i_mode)) {
4611-
alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
4611+
alias = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
46124612
if (!IS_ROOT(alias))
46134613
dn = dget(alias);
46144614
goto out_unlock;

fs/dcache.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/*
4141
* Usage:
4242
* dcache->d_inode->i_lock protects:
43-
* - i_dentry, d_u.d_alias, d_inode of aliases
43+
* - i_dentry, d_alias, d_inode of aliases
4444
* dcache_hash_bucket lock protects:
4545
* - the dcache hash table
4646
* s_roots bl list spinlock protects:
@@ -55,7 +55,7 @@
5555
* - d_unhashed()
5656
* - d_parent and d_chilren
5757
* - childrens' d_sib and d_parent
58-
* - d_u.d_alias, d_inode
58+
* - d_alias, d_inode
5959
*
6060
* Ordering:
6161
* dentry->d_inode->i_lock
@@ -341,14 +341,14 @@ static inline struct external_name *external_name(struct dentry *dentry)
341341

342342
static void __d_free(struct rcu_head *head)
343343
{
344-
struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
344+
struct dentry *dentry = container_of(head, struct dentry, d_rcu);
345345

346346
kmem_cache_free(dentry_cache, dentry);
347347
}
348348

349349
static void __d_free_external(struct rcu_head *head)
350350
{
351-
struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
351+
struct dentry *dentry = container_of(head, struct dentry, d_rcu);
352352
kfree(external_name(dentry));
353353
kmem_cache_free(dentry_cache, dentry);
354354
}
@@ -428,19 +428,19 @@ static inline void __d_clear_type_and_inode(struct dentry *dentry)
428428

429429
static void dentry_free(struct dentry *dentry)
430430
{
431-
WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias));
431+
WARN_ON(!hlist_unhashed(&dentry->d_alias));
432432
if (unlikely(dname_external(dentry))) {
433433
struct external_name *p = external_name(dentry);
434434
if (likely(atomic_dec_and_test(&p->count))) {
435-
call_rcu(&dentry->d_u.d_rcu, __d_free_external);
435+
call_rcu(&dentry->d_rcu, __d_free_external);
436436
return;
437437
}
438438
}
439439
/* if dentry was never visible to RCU, immediate free is OK */
440440
if (dentry->d_flags & DCACHE_NORCU)
441-
__d_free(&dentry->d_u.d_rcu);
441+
__d_free(&dentry->d_rcu);
442442
else
443-
call_rcu(&dentry->d_u.d_rcu, __d_free);
443+
call_rcu(&dentry->d_rcu, __d_free);
444444
}
445445

446446
/*
@@ -455,7 +455,7 @@ static void dentry_unlink_inode(struct dentry * dentry)
455455

456456
raw_write_seqcount_begin(&dentry->d_seq);
457457
__d_clear_type_and_inode(dentry);
458-
hlist_del_init(&dentry->d_u.d_alias);
458+
hlist_del_init(&dentry->d_alias);
459459
raw_write_seqcount_end(&dentry->d_seq);
460460
spin_unlock(&dentry->d_lock);
461461
spin_unlock(&inode->i_lock);
@@ -1010,7 +1010,7 @@ static struct dentry * __d_find_any_alias(struct inode *inode)
10101010

10111011
if (hlist_empty(&inode->i_dentry))
10121012
return NULL;
1013-
alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
1013+
alias = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
10141014
lockref_get(&alias->d_lockref);
10151015
return alias;
10161016
}
@@ -1093,9 +1093,9 @@ struct dentry *d_find_alias_rcu(struct inode *inode)
10931093
// used without having I_FREEING set, which means no aliases left
10941094
if (likely(!(inode_state_read(inode) & I_FREEING) && !hlist_empty(l))) {
10951095
if (S_ISDIR(inode->i_mode)) {
1096-
de = hlist_entry(l->first, struct dentry, d_u.d_alias);
1096+
de = hlist_entry(l->first, struct dentry, d_alias);
10971097
} else {
1098-
hlist_for_each_entry(de, l, d_u.d_alias)
1098+
hlist_for_each_entry(de, l, d_alias)
10991099
if (!d_unhashed(de))
11001100
break;
11011101
}
@@ -1787,7 +1787,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
17871787
INIT_HLIST_BL_NODE(&dentry->d_hash);
17881788
INIT_LIST_HEAD(&dentry->d_lru);
17891789
INIT_HLIST_HEAD(&dentry->d_children);
1790-
INIT_HLIST_NODE(&dentry->d_u.d_alias);
1790+
INIT_HLIST_NODE(&dentry->d_alias);
17911791
INIT_HLIST_NODE(&dentry->d_sib);
17921792

17931793
if (dentry->d_op && dentry->d_op->d_init) {
@@ -1980,7 +1980,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
19801980
if ((dentry->d_flags &
19811981
(DCACHE_LRU_LIST|DCACHE_SHRINK_LIST)) == DCACHE_LRU_LIST)
19821982
this_cpu_dec(nr_dentry_negative);
1983-
hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
1983+
hlist_add_head(&dentry->d_alias, &inode->i_dentry);
19841984
raw_write_seqcount_begin(&dentry->d_seq);
19851985
__d_set_inode_and_type(dentry, inode, add_flags);
19861986
raw_write_seqcount_end(&dentry->d_seq);
@@ -2004,7 +2004,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
20042004

20052005
void d_instantiate(struct dentry *entry, struct inode * inode)
20062006
{
2007-
BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
2007+
BUG_ON(!hlist_unhashed(&entry->d_alias));
20082008
if (inode) {
20092009
security_d_instantiate(entry, inode);
20102010
spin_lock(&inode->i_lock);
@@ -2024,7 +2024,7 @@ EXPORT_SYMBOL(d_instantiate);
20242024
*/
20252025
void d_instantiate_new(struct dentry *entry, struct inode *inode)
20262026
{
2027-
BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
2027+
BUG_ON(!hlist_unhashed(&entry->d_alias));
20282028
BUG_ON(!inode);
20292029
lockdep_annotate_inode_mutex_key(inode);
20302030
security_d_instantiate(entry, inode);
@@ -2087,7 +2087,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected)
20872087

20882088
spin_lock(&new->d_lock);
20892089
__d_set_inode_and_type(new, inode, add_flags);
2090-
hlist_add_head(&new->d_u.d_alias, &inode->i_dentry);
2090+
hlist_add_head(&new->d_alias, &inode->i_dentry);
20912091
if (!disconnected) {
20922092
hlist_bl_lock(&sb->s_roots);
20932093
hlist_bl_add_head(&new->d_hash, &sb->s_roots);
@@ -2658,7 +2658,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent,
26582658
* we unlock the chain. All fields are stable in everything
26592659
* we encounter.
26602660
*/
2661-
hlist_bl_for_each_entry(dentry, node, b, d_u.d_in_lookup_hash) {
2661+
hlist_bl_for_each_entry(dentry, node, b, d_in_lookup_hash) {
26622662
if (dentry->d_name.hash != hash)
26632663
continue;
26642664
if (dentry->d_parent != parent)
@@ -2700,7 +2700,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent,
27002700
}
27012701
rcu_read_unlock();
27022702
new->d_wait = wq;
2703-
hlist_bl_add_head(&new->d_u.d_in_lookup_hash, b);
2703+
hlist_bl_add_head(&new->d_in_lookup_hash, b);
27042704
hlist_bl_unlock(b);
27052705
return new;
27062706
mismatch:
@@ -2725,11 +2725,11 @@ static wait_queue_head_t *__d_lookup_unhash(struct dentry *dentry)
27252725
b = in_lookup_hash(dentry->d_parent, dentry->d_name.hash);
27262726
hlist_bl_lock(b);
27272727
dentry->d_flags &= ~DCACHE_PAR_LOOKUP;
2728-
__hlist_bl_del(&dentry->d_u.d_in_lookup_hash);
2728+
__hlist_bl_del(&dentry->d_in_lookup_hash);
27292729
d_wait = dentry->d_wait;
27302730
dentry->d_wait = NULL;
27312731
hlist_bl_unlock(b);
2732-
INIT_HLIST_NODE(&dentry->d_u.d_alias);
2732+
INIT_HLIST_NODE(&dentry->d_alias);
27332733
INIT_LIST_HEAD(&dentry->d_lru);
27342734
return d_wait;
27352735
}
@@ -2760,7 +2760,7 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode,
27602760
d_set_d_op(dentry, ops);
27612761
if (inode) {
27622762
unsigned add_flags = d_flags_for_inode(inode);
2763-
hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
2763+
hlist_add_head(&dentry->d_alias, &inode->i_dentry);
27642764
raw_write_seqcount_begin(&dentry->d_seq);
27652765
__d_set_inode_and_type(dentry, inode, add_flags);
27662766
raw_write_seqcount_end(&dentry->d_seq);
@@ -2795,7 +2795,7 @@ EXPORT_SYMBOL(d_add);
27952795

27962796
struct dentry *d_make_persistent(struct dentry *dentry, struct inode *inode)
27972797
{
2798-
WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias));
2798+
WARN_ON(!hlist_unhashed(&dentry->d_alias));
27992799
WARN_ON(!inode);
28002800
security_d_instantiate(dentry, inode);
28012801
spin_lock(&inode->i_lock);
@@ -3185,7 +3185,7 @@ void d_mark_tmpfile(struct file *file, struct inode *inode)
31853185
struct dentry *dentry = file->f_path.dentry;
31863186

31873187
BUG_ON(dname_external(dentry) ||
3188-
!hlist_unhashed(&dentry->d_u.d_alias) ||
3188+
!hlist_unhashed(&dentry->d_alias) ||
31893189
!d_unlinked(dentry));
31903190
spin_lock(&dentry->d_parent->d_lock);
31913191
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);

fs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ void dump_mapping(const struct address_space *mapping)
754754
return;
755755
}
756756

757-
dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias);
757+
dentry_ptr = container_of(dentry_first, struct dentry, d_alias);
758758
if (get_kernel_nofault(dentry, dentry_ptr) ||
759759
!dentry.d_parent || !dentry.d_name.name) {
760760
pr_warn("aops:%ps ino:%lx invalid dentry:%px\n",

fs/nfs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ static void nfs_clear_verifier_directory(struct inode *dir)
14901490
if (hlist_empty(&dir->i_dentry))
14911491
return;
14921492
this_parent =
1493-
hlist_entry(dir->i_dentry.first, struct dentry, d_u.d_alias);
1493+
hlist_entry(dir->i_dentry.first, struct dentry, d_alias);
14941494

14951495
spin_lock(&this_parent->d_lock);
14961496
nfs_unset_verifier_delegated(&this_parent->d_time);

fs/nfs/getroot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int nfs_superblock_set_dummy_root(struct super_block *sb, struct inode *i
5454
*/
5555
spin_lock(&d_inode(sb->s_root)->i_lock);
5656
spin_lock(&sb->s_root->d_lock);
57-
hlist_del_init(&sb->s_root->d_u.d_alias);
57+
hlist_del_init(&sb->s_root->d_alias);
5858
spin_unlock(&sb->s_root->d_lock);
5959
spin_unlock(&d_inode(sb->s_root)->i_lock);
6060
}

include/linux/dcache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct dentry {
128128
struct hlist_node d_alias; /* inode alias list */
129129
struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */
130130
struct rcu_head d_rcu;
131-
} d_u;
131+
};
132132
};
133133

134134
/*
@@ -617,6 +617,6 @@ void d_make_discardable(struct dentry *dentry);
617617

618618
/* inode->i_lock must be held over that */
619619
#define for_each_alias(dentry, inode) \
620-
hlist_for_each_entry(dentry, &(inode)->i_dentry, d_u.d_alias)
620+
hlist_for_each_entry(dentry, &(inode)->i_dentry, d_alias)
621621

622622
#endif /* __LINUX_DCACHE_H */

0 commit comments

Comments
 (0)