Commit dc1efc3c authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull dcache updates from Al Viro:
 "Neil Brown's d_move()/d_path() race fix"

* 'work.dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  VFS: close race between getcwd() and d_move()
parents 73da9e1a 61647823
...@@ -466,9 +466,11 @@ static void dentry_lru_add(struct dentry *dentry) ...@@ -466,9 +466,11 @@ static void dentry_lru_add(struct dentry *dentry)
* d_drop() is used mainly for stuff that wants to invalidate a dentry for some * d_drop() is used mainly for stuff that wants to invalidate a dentry for some
* reason (NFS timeouts or autofs deletes). * reason (NFS timeouts or autofs deletes).
* *
* __d_drop requires dentry->d_lock. * __d_drop requires dentry->d_lock
* ___d_drop doesn't mark dentry as "unhashed"
* (dentry->d_hash.pprev will be LIST_POISON2, not NULL).
*/ */
void __d_drop(struct dentry *dentry) static void ___d_drop(struct dentry *dentry)
{ {
if (!d_unhashed(dentry)) { if (!d_unhashed(dentry)) {
struct hlist_bl_head *b; struct hlist_bl_head *b;
...@@ -484,12 +486,17 @@ void __d_drop(struct dentry *dentry) ...@@ -484,12 +486,17 @@ void __d_drop(struct dentry *dentry)
hlist_bl_lock(b); hlist_bl_lock(b);
__hlist_bl_del(&dentry->d_hash); __hlist_bl_del(&dentry->d_hash);
dentry->d_hash.pprev = NULL;
hlist_bl_unlock(b); hlist_bl_unlock(b);
/* After this call, in-progress rcu-walk path lookup will fail. */ /* After this call, in-progress rcu-walk path lookup will fail. */
write_seqcount_invalidate(&dentry->d_seq); write_seqcount_invalidate(&dentry->d_seq);
} }
} }
void __d_drop(struct dentry *dentry)
{
___d_drop(dentry);
dentry->d_hash.pprev = NULL;
}
EXPORT_SYMBOL(__d_drop); EXPORT_SYMBOL(__d_drop);
void d_drop(struct dentry *dentry) void d_drop(struct dentry *dentry)
...@@ -2380,7 +2387,7 @@ EXPORT_SYMBOL(d_delete); ...@@ -2380,7 +2387,7 @@ EXPORT_SYMBOL(d_delete);
static void __d_rehash(struct dentry *entry) static void __d_rehash(struct dentry *entry)
{ {
struct hlist_bl_head *b = d_hash(entry->d_name.hash); struct hlist_bl_head *b = d_hash(entry->d_name.hash);
BUG_ON(!d_unhashed(entry));
hlist_bl_lock(b); hlist_bl_lock(b);
hlist_bl_add_head_rcu(&entry->d_hash, b); hlist_bl_add_head_rcu(&entry->d_hash, b);
hlist_bl_unlock(b); hlist_bl_unlock(b);
...@@ -2815,9 +2822,9 @@ static void __d_move(struct dentry *dentry, struct dentry *target, ...@@ -2815,9 +2822,9 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED); write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED);
/* unhash both */ /* unhash both */
/* __d_drop does write_seqcount_barrier, but they're OK to nest. */ /* ___d_drop does write_seqcount_barrier, but they're OK to nest. */
__d_drop(dentry); ___d_drop(dentry);
__d_drop(target); ___d_drop(target);
/* Switch the names.. */ /* Switch the names.. */
if (exchange) if (exchange)
...@@ -2829,6 +2836,8 @@ static void __d_move(struct dentry *dentry, struct dentry *target, ...@@ -2829,6 +2836,8 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
__d_rehash(dentry); __d_rehash(dentry);
if (exchange) if (exchange)
__d_rehash(target); __d_rehash(target);
else
target->d_hash.pprev = NULL;
/* ... and switch them in the tree */ /* ... and switch them in the tree */
if (IS_ROOT(dentry)) { if (IS_ROOT(dentry)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment