diff options
author | Nick Piggin <npiggin@kernel.dk> | 2011-01-07 01:49:34 -0500 |
---|---|---|
committer | Nick Piggin <npiggin@kernel.dk> | 2011-01-07 01:50:21 -0500 |
commit | 2fd6b7f50797f2e993eea59e0a0b8c6399c811dc (patch) | |
tree | ce33b94b34844c09103836cf4cfa4364b742f217 /fs/ncpfs | |
parent | da5029563a0a026c64821b09e8e7b4fd81d3fe1b (diff) |
fs: dcache scale subdirs
Protect d_subdirs and d_child with d_lock, except in filesystems that aren't
using dcache_lock for these anyway (eg. using i_mutex).
Note: if we change the locking rule in future so that ->d_child protection is
provided only with ->d_parent->d_lock, it may allow us to reduce some locking.
But it would be an exception to an otherwise regular locking scheme, so we'd
have to see some good results. Probably not worthwhile.
Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'fs/ncpfs')
-rw-r--r-- | fs/ncpfs/dir.c | 3 | ||||
-rw-r--r-- | fs/ncpfs/ncplib_kernel.h | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c index bbbf7922f422..102278ed38bd 100644 --- a/fs/ncpfs/dir.c +++ b/fs/ncpfs/dir.c | |||
@@ -392,6 +392,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) | |||
392 | 392 | ||
393 | /* If a pointer is invalid, we search the dentry. */ | 393 | /* If a pointer is invalid, we search the dentry. */ |
394 | spin_lock(&dcache_lock); | 394 | spin_lock(&dcache_lock); |
395 | spin_lock(&parent->d_lock); | ||
395 | next = parent->d_subdirs.next; | 396 | next = parent->d_subdirs.next; |
396 | while (next != &parent->d_subdirs) { | 397 | while (next != &parent->d_subdirs) { |
397 | dent = list_entry(next, struct dentry, d_u.d_child); | 398 | dent = list_entry(next, struct dentry, d_u.d_child); |
@@ -400,11 +401,13 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) | |||
400 | dget_locked(dent); | 401 | dget_locked(dent); |
401 | else | 402 | else |
402 | dent = NULL; | 403 | dent = NULL; |
404 | spin_unlock(&parent->d_lock); | ||
403 | spin_unlock(&dcache_lock); | 405 | spin_unlock(&dcache_lock); |
404 | goto out; | 406 | goto out; |
405 | } | 407 | } |
406 | next = next->next; | 408 | next = next->next; |
407 | } | 409 | } |
410 | spin_unlock(&parent->d_lock); | ||
408 | spin_unlock(&dcache_lock); | 411 | spin_unlock(&dcache_lock); |
409 | return NULL; | 412 | return NULL; |
410 | 413 | ||
diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h index 244d1b73fda7..c4b718ff9a6b 100644 --- a/fs/ncpfs/ncplib_kernel.h +++ b/fs/ncpfs/ncplib_kernel.h | |||
@@ -194,6 +194,7 @@ ncp_renew_dentries(struct dentry *parent) | |||
194 | struct dentry *dentry; | 194 | struct dentry *dentry; |
195 | 195 | ||
196 | spin_lock(&dcache_lock); | 196 | spin_lock(&dcache_lock); |
197 | spin_lock(&parent->d_lock); | ||
197 | next = parent->d_subdirs.next; | 198 | next = parent->d_subdirs.next; |
198 | while (next != &parent->d_subdirs) { | 199 | while (next != &parent->d_subdirs) { |
199 | dentry = list_entry(next, struct dentry, d_u.d_child); | 200 | dentry = list_entry(next, struct dentry, d_u.d_child); |
@@ -205,6 +206,7 @@ ncp_renew_dentries(struct dentry *parent) | |||
205 | 206 | ||
206 | next = next->next; | 207 | next = next->next; |
207 | } | 208 | } |
209 | spin_unlock(&parent->d_lock); | ||
208 | spin_unlock(&dcache_lock); | 210 | spin_unlock(&dcache_lock); |
209 | } | 211 | } |
210 | 212 | ||
@@ -216,6 +218,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent) | |||
216 | struct dentry *dentry; | 218 | struct dentry *dentry; |
217 | 219 | ||
218 | spin_lock(&dcache_lock); | 220 | spin_lock(&dcache_lock); |
221 | spin_lock(&parent->d_lock); | ||
219 | next = parent->d_subdirs.next; | 222 | next = parent->d_subdirs.next; |
220 | while (next != &parent->d_subdirs) { | 223 | while (next != &parent->d_subdirs) { |
221 | dentry = list_entry(next, struct dentry, d_u.d_child); | 224 | dentry = list_entry(next, struct dentry, d_u.d_child); |
@@ -223,6 +226,7 @@ ncp_invalidate_dircache_entries(struct dentry *parent) | |||
223 | ncp_age_dentry(server, dentry); | 226 | ncp_age_dentry(server, dentry); |
224 | next = next->next; | 227 | next = next->next; |
225 | } | 228 | } |
229 | spin_unlock(&parent->d_lock); | ||
226 | spin_unlock(&dcache_lock); | 230 | spin_unlock(&dcache_lock); |
227 | } | 231 | } |
228 | 232 | ||