move d_rcu from overlapping d_child to overlapping d_alias

commit 946e51f2bf upstream.

move d_rcu from overlapping d_child to overlapping d_alias

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Ben Hutchings <ben@decadent.org.uk>
[hujianyang: Backported to 3.14 refer to the work of Ben Hutchings in 3.2:
 - Apply name changes in all the different places we use d_alias and d_child
 - Move the WARN_ON() in __d_free() to d_free() as we don't have dentry_free()]
Signed-off-by: hujianyang <hujianyang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Al Viro 2014-10-26 19:19:16 -04:00 committed by Greg Kroah-Hartman
parent ce5996929f
commit 5c48ea64a8
25 changed files with 77 additions and 77 deletions

View File

@ -164,7 +164,7 @@ static void spufs_prune_dir(struct dentry *dir)
struct dentry *dentry, *tmp; struct dentry *dentry, *tmp;
mutex_lock(&dir->d_inode->i_mutex); mutex_lock(&dir->d_inode->i_mutex);
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) { list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (!(d_unhashed(dentry)) && dentry->d_inode) { if (!(d_unhashed(dentry)) && dentry->d_inode) {
dget_dlock(dentry); dget_dlock(dentry);

View File

@ -278,7 +278,7 @@ void ll_invalidate_aliases(struct inode *inode)
inode->i_ino, inode->i_generation, inode); inode->i_ino, inode->i_generation, inode);
ll_lock_dcache(inode); ll_lock_dcache(inode);
ll_d_hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) { ll_d_hlist_for_each_entry(dentry, p, &inode->i_dentry, d_u.d_alias) {
CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p " CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p "
"inode %p flags %d\n", dentry->d_name.len, "inode %p flags %d\n", dentry->d_name.len,
dentry->d_name.name, dentry, dentry->d_parent, dentry->d_name.name, dentry, dentry->d_parent,

View File

@ -678,7 +678,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur)
return; return;
list_for_each(tmp, &dentry->d_subdirs) { list_for_each(tmp, &dentry->d_subdirs) {
struct dentry *d = list_entry(tmp, struct dentry, d_u.d_child); struct dentry *d = list_entry(tmp, struct dentry, d_child);
lustre_dump_dentry(d, recur - 1); lustre_dump_dentry(d, recur - 1);
} }
} }

View File

@ -175,14 +175,14 @@ static void ll_invalidate_negative_children(struct inode *dir)
struct ll_d_hlist_node *p; struct ll_d_hlist_node *p;
ll_lock_dcache(dir); ll_lock_dcache(dir);
ll_d_hlist_for_each_entry(dentry, p, &dir->i_dentry, d_alias) { ll_d_hlist_for_each_entry(dentry, p, &dir->i_dentry, d_u.d_alias) {
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (!list_empty(&dentry->d_subdirs)) { if (!list_empty(&dentry->d_subdirs)) {
struct dentry *child; struct dentry *child;
list_for_each_entry_safe(child, tmp_subdir, list_for_each_entry_safe(child, tmp_subdir,
&dentry->d_subdirs, &dentry->d_subdirs,
d_u.d_child) { d_child) {
if (child->d_inode == NULL) if (child->d_inode == NULL)
d_lustre_invalidate(child, 1); d_lustre_invalidate(child, 1);
} }
@ -364,7 +364,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry)
discon_alias = invalid_alias = NULL; discon_alias = invalid_alias = NULL;
ll_lock_dcache(inode); ll_lock_dcache(inode);
ll_d_hlist_for_each_entry(alias, p, &inode->i_dentry, d_alias) { ll_d_hlist_for_each_entry(alias, p, &inode->i_dentry, d_u.d_alias) {
LASSERT(alias != dentry); LASSERT(alias != dentry);
spin_lock(&alias->d_lock); spin_lock(&alias->d_lock);
@ -953,7 +953,7 @@ static void ll_get_child_fid(struct inode * dir, struct qstr *name,
{ {
struct dentry *parent, *child; struct dentry *parent, *child;
parent = ll_d_hlist_entry(dir->i_dentry, struct dentry, d_alias); parent = ll_d_hlist_entry(dir->i_dentry, struct dentry, d_u.d_alias);
child = d_lookup(parent, name); child = d_lookup(parent, name);
if (child) { if (child) {
if (child->d_inode) if (child->d_inode)

View File

@ -126,7 +126,7 @@ affs_fix_dcache(struct inode *inode, u32 entry_ino)
{ {
struct dentry *dentry; struct dentry *dentry;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
if (entry_ino == (u32)(long)dentry->d_fsdata) { if (entry_ino == (u32)(long)dentry->d_fsdata) {
dentry->d_fsdata = (void *)inode->i_ino; dentry->d_fsdata = (void *)inode->i_ino;
break; break;

View File

@ -91,7 +91,7 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,
spin_lock(&root->d_lock); spin_lock(&root->d_lock);
if (prev) if (prev)
next = prev->d_u.d_child.next; next = prev->d_child.next;
else { else {
prev = dget_dlock(root); prev = dget_dlock(root);
next = prev->d_subdirs.next; next = prev->d_subdirs.next;
@ -105,13 +105,13 @@ cont:
return NULL; return NULL;
} }
q = list_entry(next, struct dentry, d_u.d_child); q = list_entry(next, struct dentry, d_child);
spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&q->d_lock, DENTRY_D_LOCK_NESTED);
/* Already gone or negative dentry (under construction) - try next */ /* Already gone or negative dentry (under construction) - try next */
if (!d_count(q) || !simple_positive(q)) { if (!d_count(q) || !simple_positive(q)) {
spin_unlock(&q->d_lock); spin_unlock(&q->d_lock);
next = q->d_u.d_child.next; next = q->d_child.next;
goto cont; goto cont;
} }
dget_dlock(q); dget_dlock(q);
@ -161,13 +161,13 @@ again:
goto relock; goto relock;
} }
spin_unlock(&p->d_lock); spin_unlock(&p->d_lock);
next = p->d_u.d_child.next; next = p->d_child.next;
p = parent; p = parent;
if (next != &parent->d_subdirs) if (next != &parent->d_subdirs)
break; break;
} }
} }
ret = list_entry(next, struct dentry, d_u.d_child); ret = list_entry(next, struct dentry, d_child);
spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED);
/* Negative dentry - try next */ /* Negative dentry - try next */
@ -461,7 +461,7 @@ found:
spin_lock(&sbi->lookup_lock); spin_lock(&sbi->lookup_lock);
spin_lock(&expired->d_parent->d_lock); spin_lock(&expired->d_parent->d_lock);
spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&expired->d_lock, DENTRY_D_LOCK_NESTED);
list_move(&expired->d_parent->d_subdirs, &expired->d_u.d_child); list_move(&expired->d_parent->d_subdirs, &expired->d_child);
spin_unlock(&expired->d_lock); spin_unlock(&expired->d_lock);
spin_unlock(&expired->d_parent->d_lock); spin_unlock(&expired->d_parent->d_lock);
spin_unlock(&sbi->lookup_lock); spin_unlock(&sbi->lookup_lock);

View File

@ -655,7 +655,7 @@ static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
/* only consider parents below dentrys in the root */ /* only consider parents below dentrys in the root */
if (IS_ROOT(parent->d_parent)) if (IS_ROOT(parent->d_parent))
return; return;
d_child = &dentry->d_u.d_child; d_child = &dentry->d_child;
/* Set parent managed if it's becoming empty */ /* Set parent managed if it's becoming empty */
if (d_child->next == &parent->d_subdirs && if (d_child->next == &parent->d_subdirs &&
d_child->prev == &parent->d_subdirs) d_child->prev == &parent->d_subdirs)

View File

@ -111,7 +111,7 @@ static int fpos_cmp(loff_t l, loff_t r)
/* /*
* When possible, we try to satisfy a readdir by peeking at the * When possible, we try to satisfy a readdir by peeking at the
* dcache. We make this work by carefully ordering dentries on * dcache. We make this work by carefully ordering dentries on
* d_u.d_child when we initially get results back from the MDS, and * d_child when we initially get results back from the MDS, and
* falling back to a "normal" sync readdir if any dentries in the dir * falling back to a "normal" sync readdir if any dentries in the dir
* are dropped. * are dropped.
* *
@ -146,11 +146,11 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx)
p = parent->d_subdirs.prev; p = parent->d_subdirs.prev;
dout(" initial p %p/%p\n", p->prev, p->next); dout(" initial p %p/%p\n", p->prev, p->next);
} else { } else {
p = last->d_u.d_child.prev; p = last->d_child.prev;
} }
more: more:
dentry = list_entry(p, struct dentry, d_u.d_child); dentry = list_entry(p, struct dentry, d_child);
di = ceph_dentry(dentry); di = ceph_dentry(dentry);
while (1) { while (1) {
dout(" p %p/%p %s d_subdirs %p/%p\n", p->prev, p->next, dout(" p %p/%p %s d_subdirs %p/%p\n", p->prev, p->next,
@ -172,7 +172,7 @@ more:
!dentry->d_inode ? " null" : ""); !dentry->d_inode ? " null" : "");
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
p = p->prev; p = p->prev;
dentry = list_entry(p, struct dentry, d_u.d_child); dentry = list_entry(p, struct dentry, d_child);
di = ceph_dentry(dentry); di = ceph_dentry(dentry);
} }

View File

@ -1289,7 +1289,7 @@ retry_lookup:
/* reorder parent's d_subdirs */ /* reorder parent's d_subdirs */
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED);
list_move(&dn->d_u.d_child, &parent->d_subdirs); list_move(&dn->d_child, &parent->d_subdirs);
spin_unlock(&dn->d_lock); spin_unlock(&dn->d_lock);
spin_unlock(&parent->d_lock); spin_unlock(&parent->d_lock);
} }

View File

@ -883,7 +883,7 @@ inode_has_hashed_dentries(struct inode *inode)
struct dentry *dentry; struct dentry *dentry;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
if (!d_unhashed(dentry) || IS_ROOT(dentry)) { if (!d_unhashed(dentry) || IS_ROOT(dentry)) {
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
return true; return true;

View File

@ -92,7 +92,7 @@ static void coda_flag_children(struct dentry *parent, int flag)
struct dentry *de; struct dentry *de;
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
list_for_each_entry(de, &parent->d_subdirs, d_u.d_child) { list_for_each_entry(de, &parent->d_subdirs, d_child) {
/* don't know what to do with negative dentries */ /* don't know what to do with negative dentries */
if (de->d_inode ) if (de->d_inode )
coda_flag_inode(de->d_inode, flag); coda_flag_inode(de->d_inode, flag);

View File

@ -44,7 +44,7 @@
/* /*
* Usage: * Usage:
* dcache->d_inode->i_lock protects: * dcache->d_inode->i_lock protects:
* - i_dentry, d_alias, d_inode of aliases * - i_dentry, d_u.d_alias, d_inode of aliases
* dcache_hash_bucket lock protects: * dcache_hash_bucket lock protects:
* - the dcache hash table * - the dcache hash table
* s_anon bl list spinlock protects: * s_anon bl list spinlock protects:
@ -59,7 +59,7 @@
* - d_unhashed() * - d_unhashed()
* - d_parent and d_subdirs * - d_parent and d_subdirs
* - childrens' d_child and d_parent * - childrens' d_child and d_parent
* - d_alias, d_inode * - d_u.d_alias, d_inode
* *
* Ordering: * Ordering:
* dentry->d_inode->i_lock * dentry->d_inode->i_lock
@ -239,7 +239,6 @@ static void __d_free(struct rcu_head *head)
{ {
struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
WARN_ON(!hlist_unhashed(&dentry->d_alias));
if (dname_external(dentry)) if (dname_external(dentry))
kfree(dentry->d_name.name); kfree(dentry->d_name.name);
kmem_cache_free(dentry_cache, dentry); kmem_cache_free(dentry_cache, dentry);
@ -250,6 +249,7 @@ static void __d_free(struct rcu_head *head)
*/ */
static void d_free(struct dentry *dentry) static void d_free(struct dentry *dentry)
{ {
WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias));
BUG_ON((int)dentry->d_lockref.count > 0); BUG_ON((int)dentry->d_lockref.count > 0);
this_cpu_dec(nr_dentry); this_cpu_dec(nr_dentry);
if (dentry->d_op && dentry->d_op->d_release) if (dentry->d_op && dentry->d_op->d_release)
@ -288,7 +288,7 @@ static void dentry_iput(struct dentry * dentry)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
if (inode) { if (inode) {
dentry->d_inode = NULL; dentry->d_inode = NULL;
hlist_del_init(&dentry->d_alias); hlist_del_init(&dentry->d_u.d_alias);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
if (!inode->i_nlink) if (!inode->i_nlink)
@ -313,7 +313,7 @@ static void dentry_unlink_inode(struct dentry * dentry)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
__d_clear_type(dentry); __d_clear_type(dentry);
dentry->d_inode = NULL; dentry->d_inode = NULL;
hlist_del_init(&dentry->d_alias); hlist_del_init(&dentry->d_u.d_alias);
dentry_rcuwalk_barrier(dentry); dentry_rcuwalk_barrier(dentry);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
@ -435,7 +435,7 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent)
__releases(parent->d_lock) __releases(parent->d_lock)
__releases(dentry->d_inode->i_lock) __releases(dentry->d_inode->i_lock)
{ {
list_del(&dentry->d_u.d_child); list_del(&dentry->d_child);
/* /*
* Inform d_walk() that we are no longer attached to the * Inform d_walk() that we are no longer attached to the
* dentry tree * dentry tree
@ -737,7 +737,7 @@ static struct dentry *__d_find_alias(struct inode *inode, int want_discon)
again: again:
discon_alias = NULL; discon_alias = NULL;
hlist_for_each_entry(alias, &inode->i_dentry, d_alias) { hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
spin_lock(&alias->d_lock); spin_lock(&alias->d_lock);
if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) {
if (IS_ROOT(alias) && if (IS_ROOT(alias) &&
@ -790,7 +790,7 @@ void d_prune_aliases(struct inode *inode)
struct dentry *dentry; struct dentry *dentry;
restart: restart:
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (!dentry->d_lockref.count) { if (!dentry->d_lockref.count) {
/* /*
@ -1091,7 +1091,7 @@ repeat:
resume: resume:
while (next != &this_parent->d_subdirs) { while (next != &this_parent->d_subdirs) {
struct list_head *tmp = next; struct list_head *tmp = next;
struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child); struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
next = tmp->next; next = tmp->next;
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
@ -1143,7 +1143,7 @@ resume:
goto rename_retry; goto rename_retry;
} }
rcu_read_unlock(); rcu_read_unlock();
next = child->d_u.d_child.next; next = child->d_child.next;
goto resume; goto resume;
} }
if (need_seqretry(&rename_lock, seq)) { if (need_seqretry(&rename_lock, seq)) {
@ -1524,8 +1524,8 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
INIT_HLIST_BL_NODE(&dentry->d_hash); INIT_HLIST_BL_NODE(&dentry->d_hash);
INIT_LIST_HEAD(&dentry->d_lru); INIT_LIST_HEAD(&dentry->d_lru);
INIT_LIST_HEAD(&dentry->d_subdirs); INIT_LIST_HEAD(&dentry->d_subdirs);
INIT_HLIST_NODE(&dentry->d_alias); INIT_HLIST_NODE(&dentry->d_u.d_alias);
INIT_LIST_HEAD(&dentry->d_u.d_child); INIT_LIST_HEAD(&dentry->d_child);
d_set_d_op(dentry, dentry->d_sb->s_d_op); d_set_d_op(dentry, dentry->d_sb->s_d_op);
this_cpu_inc(nr_dentry); this_cpu_inc(nr_dentry);
@ -1555,7 +1555,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
*/ */
__dget_dlock(parent); __dget_dlock(parent);
dentry->d_parent = parent; dentry->d_parent = parent;
list_add(&dentry->d_u.d_child, &parent->d_subdirs); list_add(&dentry->d_child, &parent->d_subdirs);
spin_unlock(&parent->d_lock); spin_unlock(&parent->d_lock);
return dentry; return dentry;
@ -1648,7 +1648,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
__d_set_type(dentry, add_flags); __d_set_type(dentry, add_flags);
if (inode) if (inode)
hlist_add_head(&dentry->d_alias, &inode->i_dentry); hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
dentry->d_inode = inode; dentry->d_inode = inode;
dentry_rcuwalk_barrier(dentry); dentry_rcuwalk_barrier(dentry);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
@ -1672,7 +1672,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
void d_instantiate(struct dentry *entry, struct inode * inode) void d_instantiate(struct dentry *entry, struct inode * inode)
{ {
BUG_ON(!hlist_unhashed(&entry->d_alias)); BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
if (inode) if (inode)
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
__d_instantiate(entry, inode); __d_instantiate(entry, inode);
@ -1711,7 +1711,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
return NULL; return NULL;
} }
hlist_for_each_entry(alias, &inode->i_dentry, d_alias) { hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
/* /*
* Don't need alias->d_lock here, because aliases with * Don't need alias->d_lock here, because aliases with
* d_parent == entry->d_parent are not subject to name or * d_parent == entry->d_parent are not subject to name or
@ -1737,7 +1737,7 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode)
{ {
struct dentry *result; struct dentry *result;
BUG_ON(!hlist_unhashed(&entry->d_alias)); BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
if (inode) if (inode)
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
@ -1768,7 +1768,7 @@ EXPORT_SYMBOL(d_instantiate_unique);
*/ */
int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode)
{ {
BUG_ON(!hlist_unhashed(&entry->d_alias)); BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) {
@ -1807,7 +1807,7 @@ static struct dentry * __d_find_any_alias(struct inode *inode)
if (hlist_empty(&inode->i_dentry)) if (hlist_empty(&inode->i_dentry))
return NULL; return NULL;
alias = hlist_entry(inode->i_dentry.first, struct dentry, d_alias); alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
__dget(alias); __dget(alias);
return alias; return alias;
} }
@ -1884,7 +1884,7 @@ struct dentry *d_obtain_alias(struct inode *inode)
spin_lock(&tmp->d_lock); spin_lock(&tmp->d_lock);
tmp->d_inode = inode; tmp->d_inode = inode;
tmp->d_flags |= add_flags; tmp->d_flags |= add_flags;
hlist_add_head(&tmp->d_alias, &inode->i_dentry); hlist_add_head(&tmp->d_u.d_alias, &inode->i_dentry);
hlist_bl_lock(&tmp->d_sb->s_anon); hlist_bl_lock(&tmp->d_sb->s_anon);
hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon); hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon);
hlist_bl_unlock(&tmp->d_sb->s_anon); hlist_bl_unlock(&tmp->d_sb->s_anon);
@ -2327,7 +2327,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent)
struct dentry *child; struct dentry *child;
spin_lock(&dparent->d_lock); spin_lock(&dparent->d_lock);
list_for_each_entry(child, &dparent->d_subdirs, d_u.d_child) { list_for_each_entry(child, &dparent->d_subdirs, d_child) {
if (dentry == child) { if (dentry == child) {
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
__dget_dlock(dentry); __dget_dlock(dentry);
@ -2574,8 +2574,8 @@ static void __d_move(struct dentry * dentry, struct dentry * target)
/* Unhash the target: dput() will then get rid of it */ /* Unhash the target: dput() will then get rid of it */
__d_drop(target); __d_drop(target);
list_del(&dentry->d_u.d_child); list_del(&dentry->d_child);
list_del(&target->d_u.d_child); list_del(&target->d_child);
/* Switch the names.. */ /* Switch the names.. */
switch_names(dentry, target); switch_names(dentry, target);
@ -2585,15 +2585,15 @@ static void __d_move(struct dentry * dentry, struct dentry * target)
if (IS_ROOT(dentry)) { if (IS_ROOT(dentry)) {
dentry->d_parent = target->d_parent; dentry->d_parent = target->d_parent;
target->d_parent = target; target->d_parent = target;
INIT_LIST_HEAD(&target->d_u.d_child); INIT_LIST_HEAD(&target->d_child);
} else { } else {
swap(dentry->d_parent, target->d_parent); swap(dentry->d_parent, target->d_parent);
/* And add them back to the (new) parent lists */ /* And add them back to the (new) parent lists */
list_add(&target->d_u.d_child, &target->d_parent->d_subdirs); list_add(&target->d_child, &target->d_parent->d_subdirs);
} }
list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs); list_add(&dentry->d_child, &dentry->d_parent->d_subdirs);
write_seqcount_end(&target->d_seq); write_seqcount_end(&target->d_seq);
write_seqcount_end(&dentry->d_seq); write_seqcount_end(&dentry->d_seq);
@ -2700,9 +2700,9 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon)
swap(dentry->d_name.hash, anon->d_name.hash); swap(dentry->d_name.hash, anon->d_name.hash);
dentry->d_parent = dentry; dentry->d_parent = dentry;
list_del_init(&dentry->d_u.d_child); list_del_init(&dentry->d_child);
anon->d_parent = dparent; anon->d_parent = dparent;
list_move(&anon->d_u.d_child, &dparent->d_subdirs); list_move(&anon->d_child, &dparent->d_subdirs);
write_seqcount_end(&dentry->d_seq); write_seqcount_end(&dentry->d_seq);
write_seqcount_end(&anon->d_seq); write_seqcount_end(&anon->d_seq);
@ -3333,7 +3333,7 @@ void d_tmpfile(struct dentry *dentry, struct inode *inode)
{ {
inode_dec_link_count(inode); inode_dec_link_count(inode);
BUG_ON(dentry->d_name.name != dentry->d_iname || BUG_ON(dentry->d_name.name != dentry->d_iname ||
!hlist_unhashed(&dentry->d_alias) || !hlist_unhashed(&dentry->d_u.d_alias) ||
!d_unlinked(dentry)); !d_unlinked(dentry));
spin_lock(&dentry->d_parent->d_lock); spin_lock(&dentry->d_parent->d_lock);
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);

View File

@ -552,7 +552,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
* use the d_u.d_child as the rcu head and corrupt this list. * use the d_u.d_child as the rcu head and corrupt this list.
*/ */
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
list_for_each_entry(child, &parent->d_subdirs, d_u.d_child) { list_for_each_entry(child, &parent->d_subdirs, d_child) {
if (!debugfs_positive(child)) if (!debugfs_positive(child))
continue; continue;

View File

@ -50,7 +50,7 @@ find_acceptable_alias(struct dentry *result,
inode = result->d_inode; inode = result->d_inode;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
dget(dentry); dget(dentry);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
if (toput) if (toput)

View File

@ -113,18 +113,18 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
/* d_lock not required for cursor */ /* d_lock not required for cursor */
list_del(&cursor->d_u.d_child); list_del(&cursor->d_child);
p = dentry->d_subdirs.next; p = dentry->d_subdirs.next;
while (n && p != &dentry->d_subdirs) { while (n && p != &dentry->d_subdirs) {
struct dentry *next; struct dentry *next;
next = list_entry(p, struct dentry, d_u.d_child); next = list_entry(p, struct dentry, d_child);
spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
if (simple_positive(next)) if (simple_positive(next))
n--; n--;
spin_unlock(&next->d_lock); spin_unlock(&next->d_lock);
p = p->next; p = p->next;
} }
list_add_tail(&cursor->d_u.d_child, p); list_add_tail(&cursor->d_child, p);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
} }
} }
@ -149,7 +149,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
{ {
struct dentry *dentry = file->f_path.dentry; struct dentry *dentry = file->f_path.dentry;
struct dentry *cursor = file->private_data; struct dentry *cursor = file->private_data;
struct list_head *p, *q = &cursor->d_u.d_child; struct list_head *p, *q = &cursor->d_child;
if (!dir_emit_dots(file, ctx)) if (!dir_emit_dots(file, ctx))
return 0; return 0;
@ -158,7 +158,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
list_move(q, &dentry->d_subdirs); list_move(q, &dentry->d_subdirs);
for (p = q->next; p != &dentry->d_subdirs; p = p->next) { for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
struct dentry *next = list_entry(p, struct dentry, d_u.d_child); struct dentry *next = list_entry(p, struct dentry, d_child);
spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
if (!simple_positive(next)) { if (!simple_positive(next)) {
spin_unlock(&next->d_lock); spin_unlock(&next->d_lock);
@ -286,7 +286,7 @@ int simple_empty(struct dentry *dentry)
int ret = 0; int ret = 0;
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child) { list_for_each_entry(child, &dentry->d_subdirs, d_child) {
spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED);
if (simple_positive(child)) { if (simple_positive(child)) {
spin_unlock(&child->d_lock); spin_unlock(&child->d_lock);

View File

@ -406,7 +406,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
next = parent->d_subdirs.next; next = parent->d_subdirs.next;
while (next != &parent->d_subdirs) { while (next != &parent->d_subdirs) {
dent = list_entry(next, struct dentry, d_u.d_child); dent = list_entry(next, struct dentry, d_child);
if ((unsigned long)dent->d_fsdata == fpos) { if ((unsigned long)dent->d_fsdata == fpos) {
if (dent->d_inode) if (dent->d_inode)
dget(dent); dget(dent);

View File

@ -194,7 +194,7 @@ ncp_renew_dentries(struct dentry *parent)
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
next = parent->d_subdirs.next; next = parent->d_subdirs.next;
while (next != &parent->d_subdirs) { while (next != &parent->d_subdirs) {
dentry = list_entry(next, struct dentry, d_u.d_child); dentry = list_entry(next, struct dentry, d_child);
if (dentry->d_fsdata == NULL) if (dentry->d_fsdata == NULL)
ncp_age_dentry(server, dentry); ncp_age_dentry(server, dentry);
@ -216,7 +216,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent)
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
next = parent->d_subdirs.next; next = parent->d_subdirs.next;
while (next != &parent->d_subdirs) { while (next != &parent->d_subdirs) {
dentry = list_entry(next, struct dentry, d_u.d_child); dentry = list_entry(next, struct dentry, d_child);
dentry->d_fsdata = NULL; dentry->d_fsdata = NULL;
ncp_age_dentry(server, dentry); ncp_age_dentry(server, dentry);
next = next->next; next = next->next;

View File

@ -58,7 +58,7 @@ static int nfs_superblock_set_dummy_root(struct super_block *sb, struct inode *i
*/ */
spin_lock(&sb->s_root->d_inode->i_lock); spin_lock(&sb->s_root->d_inode->i_lock);
spin_lock(&sb->s_root->d_lock); spin_lock(&sb->s_root->d_lock);
hlist_del_init(&sb->s_root->d_alias); hlist_del_init(&sb->s_root->d_u.d_alias);
spin_unlock(&sb->s_root->d_lock); spin_unlock(&sb->s_root->d_lock);
spin_unlock(&sb->s_root->d_inode->i_lock); spin_unlock(&sb->s_root->d_inode->i_lock);
} }

View File

@ -63,14 +63,14 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode)
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
/* run all of the dentries associated with this inode. Since this is a /* run all of the dentries associated with this inode. Since this is a
* directory, there damn well better only be one item on this list */ * directory, there damn well better only be one item on this list */
hlist_for_each_entry(alias, &inode->i_dentry, d_alias) { hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
struct dentry *child; struct dentry *child;
/* run all of the children of the original inode and fix their /* run all of the children of the original inode and fix their
* d_flags to indicate parental interest (their parent is the * d_flags to indicate parental interest (their parent is the
* original inode) */ * original inode) */
spin_lock(&alias->d_lock); spin_lock(&alias->d_lock);
list_for_each_entry(child, &alias->d_subdirs, d_u.d_child) { list_for_each_entry(child, &alias->d_subdirs, d_child) {
if (!child->d_inode) if (!child->d_inode)
continue; continue;

View File

@ -173,7 +173,7 @@ struct dentry *ocfs2_find_local_alias(struct inode *inode,
struct dentry *dentry; struct dentry *dentry;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) {
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) { if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) {
trace_ocfs2_find_local_alias(dentry->d_name.len, trace_ocfs2_find_local_alias(dentry->d_name.len,

View File

@ -124,15 +124,15 @@ struct dentry {
void *d_fsdata; /* fs-specific data */ void *d_fsdata; /* fs-specific data */
struct list_head d_lru; /* LRU list */ struct list_head d_lru; /* LRU list */
struct list_head d_child; /* child of parent list */
struct list_head d_subdirs; /* our children */
/* /*
* d_child and d_rcu can share memory * d_alias and d_rcu can share memory
*/ */
union { union {
struct list_head d_child; /* child of parent list */ struct hlist_node d_alias; /* inode alias list */
struct rcu_head d_rcu; struct rcu_head d_rcu;
} d_u; } d_u;
struct list_head d_subdirs; /* our children */
struct hlist_node d_alias; /* inode alias list */
}; };
/* /*

View File

@ -971,7 +971,7 @@ static void cgroup_d_remove_dir(struct dentry *dentry)
parent = dentry->d_parent; parent = dentry->d_parent;
spin_lock(&parent->d_lock); spin_lock(&parent->d_lock);
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
list_del_init(&dentry->d_u.d_child); list_del_init(&dentry->d_child);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
spin_unlock(&parent->d_lock); spin_unlock(&parent->d_lock);
remove_dir(dentry); remove_dir(dentry);

View File

@ -6158,7 +6158,7 @@ static int instance_mkdir (struct inode *inode, struct dentry *dentry, umode_t m
int ret; int ret;
/* Paranoid: Make sure the parent is the "instances" directory */ /* Paranoid: Make sure the parent is the "instances" directory */
parent = hlist_entry(inode->i_dentry.first, struct dentry, d_alias); parent = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
if (WARN_ON_ONCE(parent != trace_instance_dir)) if (WARN_ON_ONCE(parent != trace_instance_dir))
return -ENOENT; return -ENOENT;
@ -6185,7 +6185,7 @@ static int instance_rmdir(struct inode *inode, struct dentry *dentry)
int ret; int ret;
/* Paranoid: Make sure the parent is the "instances" directory */ /* Paranoid: Make sure the parent is the "instances" directory */
parent = hlist_entry(inode->i_dentry.first, struct dentry, d_alias); parent = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
if (WARN_ON_ONCE(parent != trace_instance_dir)) if (WARN_ON_ONCE(parent != trace_instance_dir))
return -ENOENT; return -ENOENT;

View File

@ -428,7 +428,7 @@ static void remove_event_file_dir(struct ftrace_event_file *file)
if (dir) { if (dir) {
spin_lock(&dir->d_lock); /* probably unneeded */ spin_lock(&dir->d_lock); /* probably unneeded */
list_for_each_entry(child, &dir->d_subdirs, d_u.d_child) { list_for_each_entry(child, &dir->d_subdirs, d_child) {
if (child->d_inode) /* probably unneeded */ if (child->d_inode) /* probably unneeded */
child->d_inode->i_private = NULL; child->d_inode->i_private = NULL;
} }

View File

@ -1200,7 +1200,7 @@ static void sel_remove_entries(struct dentry *de)
spin_lock(&de->d_lock); spin_lock(&de->d_lock);
node = de->d_subdirs.next; node = de->d_subdirs.next;
while (node != &de->d_subdirs) { while (node != &de->d_subdirs) {
struct dentry *d = list_entry(node, struct dentry, d_u.d_child); struct dentry *d = list_entry(node, struct dentry, d_child);
spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED); spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
list_del_init(node); list_del_init(node);
@ -1674,12 +1674,12 @@ static void sel_remove_classes(void)
list_for_each(class_node, &class_dir->d_subdirs) { list_for_each(class_node, &class_dir->d_subdirs) {
struct dentry *class_subdir = list_entry(class_node, struct dentry *class_subdir = list_entry(class_node,
struct dentry, d_u.d_child); struct dentry, d_child);
struct list_head *class_subdir_node; struct list_head *class_subdir_node;
list_for_each(class_subdir_node, &class_subdir->d_subdirs) { list_for_each(class_subdir_node, &class_subdir->d_subdirs) {
struct dentry *d = list_entry(class_subdir_node, struct dentry *d = list_entry(class_subdir_node,
struct dentry, d_u.d_child); struct dentry, d_child);
if (d->d_inode) if (d->d_inode)
if (d->d_inode->i_mode & S_IFDIR) if (d->d_inode->i_mode & S_IFDIR)