提交 5160ee6f 编写于 作者: E Eric Dumazet 提交者: Linus Torvalds

[PATCH] shrink dentry struct

Some long time ago, dentry struct was carefully tuned so that on 32 bits
UP, sizeof(struct dentry) was exactly 128, ie a power of 2, and a multiple
of memory cache lines.

Then RCU was added and dentry struct enlarged by two pointers, with nice
results for SMP, but not so good on UP, because breaking the above tuning
(128 + 8 = 136 bytes)

This patch reverts this unwanted side effect, by using an union (d_u),
where d_rcu and d_child are placed so that these two fields can share their
memory needs.

At the time d_free() is called (and d_rcu is really used), d_child is known
to be empty and not touched by the dentry freeing.

Lockless lookups only access d_name, d_parent, d_lock, d_op, d_flags (so
the previous content of d_child is not needed if said dentry was unhashed
but still accessed by a CPU because of RCU constraints)

As dentry cache easily contains millions of entries, a size reduction is
worth the extra complexity of the ugly C union.
Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
Cc: Dipankar Sarma <dipankar@in.ibm.com>
Cc: Maneesh Soni <maneesh@in.ibm.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: Ian Kent <raven@themaw.net>
Cc: Paul Jackson <pj@sgi.com>
Cc: Al Viro <viro@ftp.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Cc: James Morris <jmorris@namei.org>
Cc: Stephen Smalley <sds@epoch.ncsc.mil>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 21b6bf14
...@@ -186,7 +186,7 @@ static void update_bus(struct dentry *bus) ...@@ -186,7 +186,7 @@ static void update_bus(struct dentry *bus)
down(&bus->d_inode->i_sem); down(&bus->d_inode->i_sem);
list_for_each_entry(dev, &bus->d_subdirs, d_child) list_for_each_entry(dev, &bus->d_subdirs, d_u.d_child)
if (dev->d_inode) if (dev->d_inode)
update_dev(dev); update_dev(dev);
...@@ -203,7 +203,7 @@ static void update_sb(struct super_block *sb) ...@@ -203,7 +203,7 @@ static void update_sb(struct super_block *sb)
down(&root->d_inode->i_sem); down(&root->d_inode->i_sem);
list_for_each_entry(bus, &root->d_subdirs, d_child) { list_for_each_entry(bus, &root->d_subdirs, d_u.d_child) {
if (bus->d_inode) { if (bus->d_inode) {
switch (S_IFMT & bus->d_inode->i_mode) { switch (S_IFMT & bus->d_inode->i_mode) {
case S_IFDIR: case S_IFDIR:
...@@ -319,7 +319,7 @@ static int usbfs_empty (struct dentry *dentry) ...@@ -319,7 +319,7 @@ static int usbfs_empty (struct dentry *dentry)
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_for_each(list, &dentry->d_subdirs) { list_for_each(list, &dentry->d_subdirs) {
struct dentry *de = list_entry(list, struct dentry, d_child); struct dentry *de = list_entry(list, struct dentry, d_u.d_child);
if (usbfs_positive(de)) { if (usbfs_positive(de)) {
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
return 0; return 0;
......
...@@ -209,7 +209,7 @@ static inline int simple_empty_nolock(struct dentry *dentry) ...@@ -209,7 +209,7 @@ static inline int simple_empty_nolock(struct dentry *dentry)
struct dentry *child; struct dentry *child;
int ret = 0; int ret = 0;
list_for_each_entry(child, &dentry->d_subdirs, d_child) list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child)
if (simple_positive(child)) if (simple_positive(child))
goto out; goto out;
ret = 1; ret = 1;
......
...@@ -105,7 +105,7 @@ static int autofs4_check_tree(struct vfsmount *mnt, ...@@ -105,7 +105,7 @@ static int autofs4_check_tree(struct vfsmount *mnt,
next = this_parent->d_subdirs.next; next = this_parent->d_subdirs.next;
resume: resume:
while (next != &this_parent->d_subdirs) { while (next != &this_parent->d_subdirs) {
struct dentry *dentry = list_entry(next, struct dentry, d_child); struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child);
/* Negative dentry - give up */ /* Negative dentry - give up */
if (!simple_positive(dentry)) { if (!simple_positive(dentry)) {
...@@ -138,7 +138,7 @@ static int autofs4_check_tree(struct vfsmount *mnt, ...@@ -138,7 +138,7 @@ static int autofs4_check_tree(struct vfsmount *mnt,
} }
if (this_parent != top) { if (this_parent != top) {
next = this_parent->d_child.next; next = this_parent->d_u.d_child.next;
this_parent = this_parent->d_parent; this_parent = this_parent->d_parent;
goto resume; goto resume;
} }
...@@ -163,7 +163,7 @@ static struct dentry *autofs4_check_leaves(struct vfsmount *mnt, ...@@ -163,7 +163,7 @@ static struct dentry *autofs4_check_leaves(struct vfsmount *mnt,
next = this_parent->d_subdirs.next; next = this_parent->d_subdirs.next;
resume: resume:
while (next != &this_parent->d_subdirs) { while (next != &this_parent->d_subdirs) {
struct dentry *dentry = list_entry(next, struct dentry, d_child); struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child);
/* Negative dentry - give up */ /* Negative dentry - give up */
if (!simple_positive(dentry)) { if (!simple_positive(dentry)) {
...@@ -199,7 +199,7 @@ static struct dentry *autofs4_check_leaves(struct vfsmount *mnt, ...@@ -199,7 +199,7 @@ static struct dentry *autofs4_check_leaves(struct vfsmount *mnt,
} }
if (this_parent != parent) { if (this_parent != parent) {
next = this_parent->d_child.next; next = this_parent->d_u.d_child.next;
this_parent = this_parent->d_parent; this_parent = this_parent->d_parent;
goto resume; goto resume;
} }
...@@ -238,7 +238,7 @@ static struct dentry *autofs4_expire(struct super_block *sb, ...@@ -238,7 +238,7 @@ static struct dentry *autofs4_expire(struct super_block *sb,
/* On exit from the loop expire is set to a dgot dentry /* On exit from the loop expire is set to a dgot dentry
* to expire or it's NULL */ * to expire or it's NULL */
while ( next != &root->d_subdirs ) { while ( next != &root->d_subdirs ) {
struct dentry *dentry = list_entry(next, struct dentry, d_child); struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child);
/* Negative dentry - give up */ /* Negative dentry - give up */
if ( !simple_positive(dentry) ) { if ( !simple_positive(dentry) ) {
...@@ -302,7 +302,7 @@ static struct dentry *autofs4_expire(struct super_block *sb, ...@@ -302,7 +302,7 @@ static struct dentry *autofs4_expire(struct super_block *sb,
expired, (int)expired->d_name.len, expired->d_name.name); expired, (int)expired->d_name.len, expired->d_name.name);
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_del(&expired->d_parent->d_subdirs); list_del(&expired->d_parent->d_subdirs);
list_add(&expired->d_parent->d_subdirs, &expired->d_child); list_add(&expired->d_parent->d_subdirs, &expired->d_u.d_child);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
return expired; return expired;
} }
......
...@@ -91,7 +91,7 @@ static void autofs4_force_release(struct autofs_sb_info *sbi) ...@@ -91,7 +91,7 @@ static void autofs4_force_release(struct autofs_sb_info *sbi)
next = this_parent->d_subdirs.next; next = this_parent->d_subdirs.next;
resume: resume:
while (next != &this_parent->d_subdirs) { while (next != &this_parent->d_subdirs) {
struct dentry *dentry = list_entry(next, struct dentry, d_child); struct dentry *dentry = list_entry(next, struct dentry, d_u.d_child);
/* Negative dentry - don`t care */ /* Negative dentry - don`t care */
if (!simple_positive(dentry)) { if (!simple_positive(dentry)) {
...@@ -117,7 +117,7 @@ static void autofs4_force_release(struct autofs_sb_info *sbi) ...@@ -117,7 +117,7 @@ static void autofs4_force_release(struct autofs_sb_info *sbi)
if (this_parent != sbi->root) { if (this_parent != sbi->root) {
struct dentry *dentry = this_parent; struct dentry *dentry = this_parent;
next = this_parent->d_child.next; next = this_parent->d_u.d_child.next;
this_parent = this_parent->d_parent; this_parent = this_parent->d_parent;
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
DPRINTK("parent dentry %p %.*s", DPRINTK("parent dentry %p %.*s",
......
...@@ -143,7 +143,8 @@ static int autofs4_dcache_readdir(struct file * filp, void * dirent, filldir_t f ...@@ -143,7 +143,8 @@ static int autofs4_dcache_readdir(struct file * filp, void * dirent, filldir_t f
} }
while(1) { while(1) {
struct dentry *de = list_entry(list, struct dentry, d_child); struct dentry *de = list_entry(list,
struct dentry, d_u.d_child);
if (!d_unhashed(de) && de->d_inode) { if (!d_unhashed(de) && de->d_inode) {
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
......
...@@ -93,7 +93,7 @@ static void coda_flag_children(struct dentry *parent, int flag) ...@@ -93,7 +93,7 @@ static void coda_flag_children(struct dentry *parent, int flag)
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_for_each(child, &parent->d_subdirs) list_for_each(child, &parent->d_subdirs)
{ {
de = list_entry(child, struct dentry, d_child); de = list_entry(child, struct dentry, d_u.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 )
continue; continue;
......
...@@ -71,7 +71,7 @@ struct dentry_stat_t dentry_stat = { ...@@ -71,7 +71,7 @@ struct dentry_stat_t dentry_stat = {
static void d_callback(struct rcu_head *head) static void d_callback(struct rcu_head *head)
{ {
struct dentry * dentry = container_of(head, struct dentry, d_rcu); struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
if (dname_external(dentry)) if (dname_external(dentry))
kfree(dentry->d_name.name); kfree(dentry->d_name.name);
...@@ -86,7 +86,7 @@ static void d_free(struct dentry *dentry) ...@@ -86,7 +86,7 @@ static void d_free(struct dentry *dentry)
{ {
if (dentry->d_op && dentry->d_op->d_release) if (dentry->d_op && dentry->d_op->d_release)
dentry->d_op->d_release(dentry); dentry->d_op->d_release(dentry);
call_rcu(&dentry->d_rcu, d_callback); call_rcu(&dentry->d_u.d_rcu, d_callback);
} }
/* /*
...@@ -193,7 +193,7 @@ kill_it: { ...@@ -193,7 +193,7 @@ kill_it: {
list_del(&dentry->d_lru); list_del(&dentry->d_lru);
dentry_stat.nr_unused--; dentry_stat.nr_unused--;
} }
list_del(&dentry->d_child); list_del(&dentry->d_u.d_child);
dentry_stat.nr_dentry--; /* For d_free, below */ dentry_stat.nr_dentry--; /* For d_free, below */
/*drops the locks, at that point nobody can reach this dentry */ /*drops the locks, at that point nobody can reach this dentry */
dentry_iput(dentry); dentry_iput(dentry);
...@@ -367,7 +367,7 @@ static inline void prune_one_dentry(struct dentry * dentry) ...@@ -367,7 +367,7 @@ static inline void prune_one_dentry(struct dentry * dentry)
struct dentry * parent; struct dentry * parent;
__d_drop(dentry); __d_drop(dentry);
list_del(&dentry->d_child); list_del(&dentry->d_u.d_child);
dentry_stat.nr_dentry--; /* For d_free, below */ dentry_stat.nr_dentry--; /* For d_free, below */
dentry_iput(dentry); dentry_iput(dentry);
parent = dentry->d_parent; parent = dentry->d_parent;
...@@ -518,7 +518,7 @@ int have_submounts(struct dentry *parent) ...@@ -518,7 +518,7 @@ int have_submounts(struct dentry *parent)
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_child); struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child);
next = tmp->next; next = tmp->next;
/* Have we found a mount point ? */ /* Have we found a mount point ? */
if (d_mountpoint(dentry)) if (d_mountpoint(dentry))
...@@ -532,7 +532,7 @@ int have_submounts(struct dentry *parent) ...@@ -532,7 +532,7 @@ int have_submounts(struct dentry *parent)
* All done at this level ... ascend and resume the search. * All done at this level ... ascend and resume the search.
*/ */
if (this_parent != parent) { if (this_parent != parent) {
next = this_parent->d_child.next; next = this_parent->d_u.d_child.next;
this_parent = this_parent->d_parent; this_parent = this_parent->d_parent;
goto resume; goto resume;
} }
...@@ -569,7 +569,7 @@ static int select_parent(struct dentry * parent) ...@@ -569,7 +569,7 @@ static int select_parent(struct dentry * parent)
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_child); struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child);
next = tmp->next; next = tmp->next;
if (!list_empty(&dentry->d_lru)) { if (!list_empty(&dentry->d_lru)) {
...@@ -610,7 +610,7 @@ dentry->d_parent->d_name.name, dentry->d_name.name, found); ...@@ -610,7 +610,7 @@ dentry->d_parent->d_name.name, dentry->d_name.name, found);
* All done at this level ... ascend and resume the search. * All done at this level ... ascend and resume the search.
*/ */
if (this_parent != parent) { if (this_parent != parent) {
next = this_parent->d_child.next; next = this_parent->d_u.d_child.next;
this_parent = this_parent->d_parent; this_parent = this_parent->d_parent;
#ifdef DCACHE_DEBUG #ifdef DCACHE_DEBUG
printk(KERN_DEBUG "select_parent: ascending to %s/%s, found=%d\n", printk(KERN_DEBUG "select_parent: ascending to %s/%s, found=%d\n",
...@@ -753,12 +753,12 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) ...@@ -753,12 +753,12 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
dentry->d_parent = dget(parent); dentry->d_parent = dget(parent);
dentry->d_sb = parent->d_sb; dentry->d_sb = parent->d_sb;
} else { } else {
INIT_LIST_HEAD(&dentry->d_child); INIT_LIST_HEAD(&dentry->d_u.d_child);
} }
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (parent) if (parent)
list_add(&dentry->d_child, &parent->d_subdirs); list_add(&dentry->d_u.d_child, &parent->d_subdirs);
dentry_stat.nr_dentry++; dentry_stat.nr_dentry++;
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
...@@ -1310,8 +1310,8 @@ void d_move(struct dentry * dentry, struct dentry * target) ...@@ -1310,8 +1310,8 @@ 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_child); list_del(&dentry->d_u.d_child);
list_del(&target->d_child); list_del(&target->d_u.d_child);
/* Switch the names.. */ /* Switch the names.. */
switch_names(dentry, target); switch_names(dentry, target);
...@@ -1322,15 +1322,15 @@ void d_move(struct dentry * dentry, struct dentry * target) ...@@ -1322,15 +1322,15 @@ 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_child); INIT_LIST_HEAD(&target->d_u.d_child);
} else { } else {
do_switch(dentry->d_parent, target->d_parent); do_switch(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_child, &target->d_parent->d_subdirs); list_add(&target->d_u.d_child, &target->d_parent->d_subdirs);
} }
list_add(&dentry->d_child, &dentry->d_parent->d_subdirs); list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs);
spin_unlock(&target->d_lock); spin_unlock(&target->d_lock);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
write_sequnlock(&rename_lock); write_sequnlock(&rename_lock);
...@@ -1568,7 +1568,7 @@ void d_genocide(struct dentry *root) ...@@ -1568,7 +1568,7 @@ void d_genocide(struct dentry *root)
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_child); struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child);
next = tmp->next; next = tmp->next;
if (d_unhashed(dentry)||!dentry->d_inode) if (d_unhashed(dentry)||!dentry->d_inode)
continue; continue;
...@@ -1579,7 +1579,7 @@ void d_genocide(struct dentry *root) ...@@ -1579,7 +1579,7 @@ void d_genocide(struct dentry *root)
atomic_dec(&dentry->d_count); atomic_dec(&dentry->d_count);
} }
if (this_parent != root) { if (this_parent != root) {
next = this_parent->d_child.next; next = this_parent->d_u.d_child.next;
atomic_dec(&this_parent->d_count); atomic_dec(&this_parent->d_count);
this_parent = this_parent->d_parent; this_parent = this_parent->d_parent;
goto resume; goto resume;
......
...@@ -93,16 +93,16 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin) ...@@ -93,16 +93,16 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
loff_t n = file->f_pos - 2; loff_t n = file->f_pos - 2;
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_del(&cursor->d_child); list_del(&cursor->d_u.d_child);
p = file->f_dentry->d_subdirs.next; p = file->f_dentry->d_subdirs.next;
while (n && p != &file->f_dentry->d_subdirs) { while (n && p != &file->f_dentry->d_subdirs) {
struct dentry *next; struct dentry *next;
next = list_entry(p, struct dentry, d_child); next = list_entry(p, struct dentry, d_u.d_child);
if (!d_unhashed(next) && next->d_inode) if (!d_unhashed(next) && next->d_inode)
n--; n--;
p = p->next; p = p->next;
} }
list_add_tail(&cursor->d_child, p); list_add_tail(&cursor->d_u.d_child, p);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
} }
} }
...@@ -126,7 +126,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -126,7 +126,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
{ {
struct dentry *dentry = filp->f_dentry; struct dentry *dentry = filp->f_dentry;
struct dentry *cursor = filp->private_data; struct dentry *cursor = filp->private_data;
struct list_head *p, *q = &cursor->d_child; struct list_head *p, *q = &cursor->d_u.d_child;
ino_t ino; ino_t ino;
int i = filp->f_pos; int i = filp->f_pos;
...@@ -153,7 +153,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) ...@@ -153,7 +153,7 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
} }
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; struct dentry *next;
next = list_entry(p, struct dentry, d_child); next = list_entry(p, struct dentry, d_u.d_child);
if (d_unhashed(next) || !next->d_inode) if (d_unhashed(next) || !next->d_inode)
continue; continue;
...@@ -261,7 +261,7 @@ int simple_empty(struct dentry *dentry) ...@@ -261,7 +261,7 @@ int simple_empty(struct dentry *dentry)
int ret = 0; int ret = 0;
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_for_each_entry(child, &dentry->d_subdirs, d_child) list_for_each_entry(child, &dentry->d_subdirs, d_u.d_child)
if (simple_positive(child)) if (simple_positive(child))
goto out; goto out;
ret = 1; ret = 1;
......
...@@ -365,7 +365,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) ...@@ -365,7 +365,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
spin_lock(&dcache_lock); spin_lock(&dcache_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_child); dent = list_entry(next, struct dentry, d_u.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_locked(dent); dget_locked(dent);
......
...@@ -196,7 +196,7 @@ ncp_renew_dentries(struct dentry *parent) ...@@ -196,7 +196,7 @@ ncp_renew_dentries(struct dentry *parent)
spin_lock(&dcache_lock); spin_lock(&dcache_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_child); dentry = list_entry(next, struct dentry, d_u.d_child);
if (dentry->d_fsdata == NULL) if (dentry->d_fsdata == NULL)
ncp_age_dentry(server, dentry); ncp_age_dentry(server, dentry);
...@@ -218,7 +218,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent) ...@@ -218,7 +218,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent)
spin_lock(&dcache_lock); spin_lock(&dcache_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_child); dentry = list_entry(next, struct dentry, d_u.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;
......
...@@ -66,7 +66,7 @@ smb_invalidate_dircache_entries(struct dentry *parent) ...@@ -66,7 +66,7 @@ smb_invalidate_dircache_entries(struct dentry *parent)
spin_lock(&dcache_lock); spin_lock(&dcache_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_child); dentry = list_entry(next, struct dentry, d_u.d_child);
dentry->d_fsdata = NULL; dentry->d_fsdata = NULL;
smb_age_dentry(server, dentry); smb_age_dentry(server, dentry);
next = next->next; next = next->next;
...@@ -100,7 +100,7 @@ smb_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) ...@@ -100,7 +100,7 @@ smb_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
spin_lock(&dcache_lock); spin_lock(&dcache_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_child); dent = list_entry(next, struct dentry, d_u.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_locked(dent); dget_locked(dent);
......
...@@ -95,14 +95,19 @@ struct dentry { ...@@ -95,14 +95,19 @@ struct dentry {
struct qstr d_name; struct qstr d_name;
struct list_head d_lru; /* LRU list */ struct list_head d_lru; /* LRU list */
struct list_head d_child; /* child of parent list */ /*
* d_child and d_rcu can share memory
*/
union {
struct list_head d_child; /* child of parent list */
struct rcu_head d_rcu;
} d_u;
struct list_head d_subdirs; /* our children */ struct list_head d_subdirs; /* our children */
struct list_head d_alias; /* inode alias list */ struct list_head d_alias; /* inode alias list */
unsigned long d_time; /* used by d_revalidate */ unsigned long d_time; /* used by d_revalidate */
struct dentry_operations *d_op; struct dentry_operations *d_op;
struct super_block *d_sb; /* The root of the dentry tree */ struct super_block *d_sb; /* The root of the dentry tree */
void *d_fsdata; /* fs-specific data */ void *d_fsdata; /* fs-specific data */
struct rcu_head d_rcu;
struct dcookie_struct *d_cookie; /* cookie, if any */ struct dcookie_struct *d_cookie; /* cookie, if any */
int d_mounted; int d_mounted;
unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
......
...@@ -331,7 +331,7 @@ static void cpuset_d_remove_dir(struct dentry *dentry) ...@@ -331,7 +331,7 @@ static void cpuset_d_remove_dir(struct dentry *dentry)
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
node = dentry->d_subdirs.next; node = dentry->d_subdirs.next;
while (node != &dentry->d_subdirs) { while (node != &dentry->d_subdirs) {
struct dentry *d = list_entry(node, struct dentry, d_child); struct dentry *d = list_entry(node, struct dentry, d_u.d_child);
list_del_init(node); list_del_init(node);
if (d->d_inode) { if (d->d_inode) {
d = dget_locked(d); d = dget_locked(d);
...@@ -343,7 +343,7 @@ static void cpuset_d_remove_dir(struct dentry *dentry) ...@@ -343,7 +343,7 @@ static void cpuset_d_remove_dir(struct dentry *dentry)
} }
node = dentry->d_subdirs.next; node = dentry->d_subdirs.next;
} }
list_del_init(&dentry->d_child); list_del_init(&dentry->d_u.d_child);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
remove_dir(dentry); remove_dir(dentry);
} }
......
...@@ -495,7 +495,7 @@ rpc_depopulate(struct dentry *parent) ...@@ -495,7 +495,7 @@ rpc_depopulate(struct dentry *parent)
repeat: repeat:
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
list_for_each_safe(pos, next, &parent->d_subdirs) { list_for_each_safe(pos, next, &parent->d_subdirs) {
dentry = list_entry(pos, struct dentry, d_child); dentry = list_entry(pos, struct dentry, d_u.d_child);
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (!d_unhashed(dentry)) { if (!d_unhashed(dentry)) {
dget_locked(dentry); dget_locked(dentry);
......
...@@ -889,7 +889,7 @@ static void sel_remove_bools(struct dentry *de) ...@@ -889,7 +889,7 @@ static void sel_remove_bools(struct dentry *de)
spin_lock(&dcache_lock); spin_lock(&dcache_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_child); struct dentry *d = list_entry(node, struct dentry, d_u.d_child);
list_del_init(node); list_del_init(node);
if (d->d_inode) { if (d->d_inode) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册