diff options
-rw-r--r-- | fs/exportfs/expfs.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 085d6c547f44..166d8ca9eaea 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c | |||
@@ -70,6 +70,27 @@ find_acceptable_alias(struct dentry *result, | |||
70 | return NULL; | 70 | return NULL; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* | ||
74 | * Find root of a disconnected subtree and return a reference to it. | ||
75 | */ | ||
76 | static struct dentry * | ||
77 | find_disconnected_root(struct dentry *dentry) | ||
78 | { | ||
79 | dget(dentry); | ||
80 | spin_lock(&dentry->d_lock); | ||
81 | while (!IS_ROOT(dentry) && | ||
82 | (dentry->d_parent->d_flags & DCACHE_DISCONNECTED)) { | ||
83 | struct dentry *parent = dentry->d_parent; | ||
84 | dget(parent); | ||
85 | spin_unlock(&dentry->d_lock); | ||
86 | dput(dentry); | ||
87 | dentry = parent; | ||
88 | spin_lock(&dentry->d_lock); | ||
89 | } | ||
90 | spin_unlock(&dentry->d_lock); | ||
91 | return dentry; | ||
92 | } | ||
93 | |||
73 | /** | 94 | /** |
74 | * find_exported_dentry - helper routine to implement export_operations->decode_fh | 95 | * find_exported_dentry - helper routine to implement export_operations->decode_fh |
75 | * @sb: The &super_block identifying the filesystem | 96 | * @sb: The &super_block identifying the filesystem |
@@ -164,23 +185,9 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, | |||
164 | * the noprogress counter. If we go through the loop 10 times (2 is | 185 | * the noprogress counter. If we go through the loop 10 times (2 is |
165 | * probably enough) without getting anywhere, we just give up | 186 | * probably enough) without getting anywhere, we just give up |
166 | */ | 187 | */ |
167 | noprogress= 0; | 188 | noprogress = 0; |
168 | while (target_dir->d_flags & DCACHE_DISCONNECTED && noprogress++ < 10) { | 189 | while (target_dir->d_flags & DCACHE_DISCONNECTED && noprogress++ < 10) { |
169 | struct dentry *pd = target_dir; | 190 | struct dentry *pd = find_disconnected_root(target_dir); |
170 | |||
171 | dget(pd); | ||
172 | spin_lock(&pd->d_lock); | ||
173 | while (!IS_ROOT(pd) && | ||
174 | (pd->d_parent->d_flags&DCACHE_DISCONNECTED)) { | ||
175 | struct dentry *parent = pd->d_parent; | ||
176 | |||
177 | dget(parent); | ||
178 | spin_unlock(&pd->d_lock); | ||
179 | dput(pd); | ||
180 | pd = parent; | ||
181 | spin_lock(&pd->d_lock); | ||
182 | } | ||
183 | spin_unlock(&pd->d_lock); | ||
184 | 191 | ||
185 | if (!IS_ROOT(pd)) { | 192 | if (!IS_ROOT(pd)) { |
186 | /* must have found a connected parent - great */ | 193 | /* must have found a connected parent - great */ |