Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 226711
b: refs/heads/master
c: 58db63d
h: refs/heads/master
i:
  226709: 279642b
  226707: 13b1e04
  226703: 09cb840
v: v3
  • Loading branch information
Nick Piggin committed Jan 7, 2011
1 parent 6c68a85 commit 994552b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 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: b5c84bf6f6fa3a7dfdcb556023a62953574b60ee
refs/heads/master: 58db63d086790eec2ed433f9d8c4962239809cf8
56 changes: 42 additions & 14 deletions trunk/fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,11 @@ int have_submounts(struct dentry *parent)
struct dentry *this_parent;
struct list_head *next;
unsigned seq;
int locked = 0;

rename_retry:
this_parent = parent;
seq = read_seqbegin(&rename_lock);
again:
this_parent = parent;

if (d_mountpoint(parent))
goto positive;
Expand Down Expand Up @@ -1021,7 +1022,7 @@ int have_submounts(struct dentry *parent)
/* might go back up the wrong parent if we have had a rename
* or deletion */
if (this_parent != child->d_parent ||
read_seqretry(&rename_lock, seq)) {
(!locked && read_seqretry(&rename_lock, seq))) {
spin_unlock(&this_parent->d_lock);
rcu_read_unlock();
goto rename_retry;
Expand All @@ -1031,13 +1032,22 @@ int have_submounts(struct dentry *parent)
goto resume;
}
spin_unlock(&this_parent->d_lock);
if (read_seqretry(&rename_lock, seq))
if (!locked && read_seqretry(&rename_lock, seq))
goto rename_retry;
if (locked)
write_sequnlock(&rename_lock);
return 0; /* No mount points found in tree */
positive:
if (read_seqretry(&rename_lock, seq))
if (!locked && read_seqretry(&rename_lock, seq))
goto rename_retry;
if (locked)
write_sequnlock(&rename_lock);
return 1;

rename_retry:
locked = 1;
write_seqlock(&rename_lock);
goto again;
}
EXPORT_SYMBOL(have_submounts);

Expand All @@ -1061,11 +1071,11 @@ static int select_parent(struct dentry * parent)
struct list_head *next;
unsigned seq;
int found = 0;
int locked = 0;

rename_retry:
this_parent = parent;
seq = read_seqbegin(&rename_lock);

again:
this_parent = parent;
spin_lock(&this_parent->d_lock);
repeat:
next = this_parent->d_subdirs.next;
Expand Down Expand Up @@ -1127,7 +1137,7 @@ static int select_parent(struct dentry * parent)
/* might go back up the wrong parent if we have had a rename
* or deletion */
if (this_parent != child->d_parent ||
read_seqretry(&rename_lock, seq)) {
(!locked && read_seqretry(&rename_lock, seq))) {
spin_unlock(&this_parent->d_lock);
rcu_read_unlock();
goto rename_retry;
Expand All @@ -1138,9 +1148,18 @@ static int select_parent(struct dentry * parent)
}
out:
spin_unlock(&this_parent->d_lock);
if (read_seqretry(&rename_lock, seq))
if (!locked && read_seqretry(&rename_lock, seq))
goto rename_retry;
if (locked)
write_sequnlock(&rename_lock);
return found;

rename_retry:
if (found)
return found;
locked = 1;
write_seqlock(&rename_lock);
goto again;
}

/**
Expand Down Expand Up @@ -2655,10 +2674,11 @@ void d_genocide(struct dentry *root)
struct dentry *this_parent;
struct list_head *next;
unsigned seq;
int locked = 0;

rename_retry:
this_parent = root;
seq = read_seqbegin(&rename_lock);
again:
this_parent = root;
spin_lock(&this_parent->d_lock);
repeat:
next = this_parent->d_subdirs.next;
Expand Down Expand Up @@ -2703,7 +2723,7 @@ void d_genocide(struct dentry *root)
/* might go back up the wrong parent if we have had a rename
* or deletion */
if (this_parent != child->d_parent ||
read_seqretry(&rename_lock, seq)) {
(!locked && read_seqretry(&rename_lock, seq))) {
spin_unlock(&this_parent->d_lock);
rcu_read_unlock();
goto rename_retry;
Expand All @@ -2713,8 +2733,16 @@ void d_genocide(struct dentry *root)
goto resume;
}
spin_unlock(&this_parent->d_lock);
if (read_seqretry(&rename_lock, seq))
if (!locked && read_seqretry(&rename_lock, seq))
goto rename_retry;
if (locked)
write_sequnlock(&rename_lock);
return;

rename_retry:
locked = 1;
write_seqlock(&rename_lock);
goto again;
}

/**
Expand Down

0 comments on commit 994552b

Please sign in to comment.