|
@@ -973,10 +973,11 @@ int have_submounts(struct dentry *parent)
|
|
struct dentry *this_parent;
|
|
struct dentry *this_parent;
|
|
struct list_head *next;
|
|
struct list_head *next;
|
|
unsigned seq;
|
|
unsigned seq;
|
|
|
|
+ int locked = 0;
|
|
|
|
|
|
-rename_retry:
|
|
|
|
- this_parent = parent;
|
|
|
|
seq = read_seqbegin(&rename_lock);
|
|
seq = read_seqbegin(&rename_lock);
|
|
|
|
+again:
|
|
|
|
+ this_parent = parent;
|
|
|
|
|
|
if (d_mountpoint(parent))
|
|
if (d_mountpoint(parent))
|
|
goto positive;
|
|
goto positive;
|
|
@@ -1021,7 +1022,7 @@ resume:
|
|
/* might go back up the wrong parent if we have had a rename
|
|
/* might go back up the wrong parent if we have had a rename
|
|
* or deletion */
|
|
* or deletion */
|
|
if (this_parent != child->d_parent ||
|
|
if (this_parent != child->d_parent ||
|
|
- read_seqretry(&rename_lock, seq)) {
|
|
|
|
|
|
+ (!locked && read_seqretry(&rename_lock, seq))) {
|
|
spin_unlock(&this_parent->d_lock);
|
|
spin_unlock(&this_parent->d_lock);
|
|
rcu_read_unlock();
|
|
rcu_read_unlock();
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
@@ -1031,13 +1032,22 @@ resume:
|
|
goto resume;
|
|
goto resume;
|
|
}
|
|
}
|
|
spin_unlock(&this_parent->d_lock);
|
|
spin_unlock(&this_parent->d_lock);
|
|
- if (read_seqretry(&rename_lock, seq))
|
|
|
|
|
|
+ if (!locked && read_seqretry(&rename_lock, seq))
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
|
|
+ if (locked)
|
|
|
|
+ write_sequnlock(&rename_lock);
|
|
return 0; /* No mount points found in tree */
|
|
return 0; /* No mount points found in tree */
|
|
positive:
|
|
positive:
|
|
- if (read_seqretry(&rename_lock, seq))
|
|
|
|
|
|
+ if (!locked && read_seqretry(&rename_lock, seq))
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
|
|
+ if (locked)
|
|
|
|
+ write_sequnlock(&rename_lock);
|
|
return 1;
|
|
return 1;
|
|
|
|
+
|
|
|
|
+rename_retry:
|
|
|
|
+ locked = 1;
|
|
|
|
+ write_seqlock(&rename_lock);
|
|
|
|
+ goto again;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(have_submounts);
|
|
EXPORT_SYMBOL(have_submounts);
|
|
|
|
|
|
@@ -1061,11 +1071,11 @@ static int select_parent(struct dentry * parent)
|
|
struct list_head *next;
|
|
struct list_head *next;
|
|
unsigned seq;
|
|
unsigned seq;
|
|
int found = 0;
|
|
int found = 0;
|
|
|
|
+ int locked = 0;
|
|
|
|
|
|
-rename_retry:
|
|
|
|
- this_parent = parent;
|
|
|
|
seq = read_seqbegin(&rename_lock);
|
|
seq = read_seqbegin(&rename_lock);
|
|
-
|
|
|
|
|
|
+again:
|
|
|
|
+ this_parent = parent;
|
|
spin_lock(&this_parent->d_lock);
|
|
spin_lock(&this_parent->d_lock);
|
|
repeat:
|
|
repeat:
|
|
next = this_parent->d_subdirs.next;
|
|
next = this_parent->d_subdirs.next;
|
|
@@ -1127,7 +1137,7 @@ resume:
|
|
/* might go back up the wrong parent if we have had a rename
|
|
/* might go back up the wrong parent if we have had a rename
|
|
* or deletion */
|
|
* or deletion */
|
|
if (this_parent != child->d_parent ||
|
|
if (this_parent != child->d_parent ||
|
|
- read_seqretry(&rename_lock, seq)) {
|
|
|
|
|
|
+ (!locked && read_seqretry(&rename_lock, seq))) {
|
|
spin_unlock(&this_parent->d_lock);
|
|
spin_unlock(&this_parent->d_lock);
|
|
rcu_read_unlock();
|
|
rcu_read_unlock();
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
@@ -1138,9 +1148,18 @@ resume:
|
|
}
|
|
}
|
|
out:
|
|
out:
|
|
spin_unlock(&this_parent->d_lock);
|
|
spin_unlock(&this_parent->d_lock);
|
|
- if (read_seqretry(&rename_lock, seq))
|
|
|
|
|
|
+ if (!locked && read_seqretry(&rename_lock, seq))
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
|
|
+ if (locked)
|
|
|
|
+ write_sequnlock(&rename_lock);
|
|
return found;
|
|
return found;
|
|
|
|
+
|
|
|
|
+rename_retry:
|
|
|
|
+ if (found)
|
|
|
|
+ return found;
|
|
|
|
+ locked = 1;
|
|
|
|
+ write_seqlock(&rename_lock);
|
|
|
|
+ goto again;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2655,10 +2674,11 @@ void d_genocide(struct dentry *root)
|
|
struct dentry *this_parent;
|
|
struct dentry *this_parent;
|
|
struct list_head *next;
|
|
struct list_head *next;
|
|
unsigned seq;
|
|
unsigned seq;
|
|
|
|
+ int locked = 0;
|
|
|
|
|
|
-rename_retry:
|
|
|
|
- this_parent = root;
|
|
|
|
seq = read_seqbegin(&rename_lock);
|
|
seq = read_seqbegin(&rename_lock);
|
|
|
|
+again:
|
|
|
|
+ this_parent = root;
|
|
spin_lock(&this_parent->d_lock);
|
|
spin_lock(&this_parent->d_lock);
|
|
repeat:
|
|
repeat:
|
|
next = this_parent->d_subdirs.next;
|
|
next = this_parent->d_subdirs.next;
|
|
@@ -2703,7 +2723,7 @@ resume:
|
|
/* might go back up the wrong parent if we have had a rename
|
|
/* might go back up the wrong parent if we have had a rename
|
|
* or deletion */
|
|
* or deletion */
|
|
if (this_parent != child->d_parent ||
|
|
if (this_parent != child->d_parent ||
|
|
- read_seqretry(&rename_lock, seq)) {
|
|
|
|
|
|
+ (!locked && read_seqretry(&rename_lock, seq))) {
|
|
spin_unlock(&this_parent->d_lock);
|
|
spin_unlock(&this_parent->d_lock);
|
|
rcu_read_unlock();
|
|
rcu_read_unlock();
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
@@ -2713,8 +2733,16 @@ resume:
|
|
goto resume;
|
|
goto resume;
|
|
}
|
|
}
|
|
spin_unlock(&this_parent->d_lock);
|
|
spin_unlock(&this_parent->d_lock);
|
|
- if (read_seqretry(&rename_lock, seq))
|
|
|
|
|
|
+ if (!locked && read_seqretry(&rename_lock, seq))
|
|
goto rename_retry;
|
|
goto rename_retry;
|
|
|
|
+ if (locked)
|
|
|
|
+ write_sequnlock(&rename_lock);
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+rename_retry:
|
|
|
|
+ locked = 1;
|
|
|
|
+ write_seqlock(&rename_lock);
|
|
|
|
+ goto again;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|