Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262076
b: refs/heads/master
c: c6627c6
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Al Viro committed Aug 1, 2011
1 parent 85c91eb commit ee9e9c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 35f40ef00204c456f5c181c0e7f54e25bb93cd49
refs/heads/master: c6627c60c07c43b51ef88e352627fa786d1e1592
48 changes: 24 additions & 24 deletions trunk/fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,27 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent)
return parent;
}

/*
* Unhash a dentry without inserting an RCU walk barrier or checking that
* dentry->d_lock is locked. The caller must take care of that, if
* appropriate.
*/
static void __d_shrink(struct dentry *dentry)
{
if (!d_unhashed(dentry)) {
struct hlist_bl_head *b;
if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED))
b = &dentry->d_sb->s_anon;
else
b = d_hash(dentry->d_parent, dentry->d_name.hash);

hlist_bl_lock(b);
__hlist_bl_del(&dentry->d_hash);
dentry->d_hash.pprev = NULL;
hlist_bl_unlock(b);
}
}

/**
* d_drop - drop a dentry
* @dentry: dentry to drop
Expand All @@ -319,17 +340,7 @@ static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent)
void __d_drop(struct dentry *dentry)
{
if (!d_unhashed(dentry)) {
struct hlist_bl_head *b;
if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED))
b = &dentry->d_sb->s_anon;
else
b = d_hash(dentry->d_parent, dentry->d_name.hash);

hlist_bl_lock(b);
__hlist_bl_del(&dentry->d_hash);
dentry->d_hash.pprev = NULL;
hlist_bl_unlock(b);

__d_shrink(dentry);
dentry_rcuwalk_barrier(dentry);
}
}
Expand Down Expand Up @@ -832,10 +843,8 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
BUG_ON(!IS_ROOT(dentry));

/* detach this root from the system */
spin_lock(&dentry->d_lock);
dentry_lru_del(dentry);
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
__d_shrink(dentry);

for (;;) {
/* descend to the first leaf in the current subtree */
Expand All @@ -844,16 +853,11 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)

/* this is a branch with children - detach all of them
* from the system in one go */
spin_lock(&dentry->d_lock);
list_for_each_entry(loop, &dentry->d_subdirs,
d_u.d_child) {
spin_lock_nested(&loop->d_lock,
DENTRY_D_LOCK_NESTED);
dentry_lru_del(loop);
__d_drop(loop);
spin_unlock(&loop->d_lock);
__d_shrink(loop);
}
spin_unlock(&dentry->d_lock);

/* move to the first child */
dentry = list_entry(dentry->d_subdirs.next,
Expand Down Expand Up @@ -885,10 +889,8 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
list_del(&dentry->d_u.d_child);
} else {
parent = dentry->d_parent;
spin_lock(&parent->d_lock);
parent->d_count--;
list_del(&dentry->d_u.d_child);
spin_unlock(&parent->d_lock);
}

inode = dentry->d_inode;
Expand Down Expand Up @@ -935,9 +937,7 @@ void shrink_dcache_for_umount(struct super_block *sb)

dentry = sb->s_root;
sb->s_root = NULL;
spin_lock(&dentry->d_lock);
dentry->d_count--;
spin_unlock(&dentry->d_lock);
shrink_dcache_for_umount_subtree(dentry);

while (!hlist_bl_empty(&sb->s_anon)) {
Expand Down

0 comments on commit ee9e9c8

Please sign in to comment.