diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-02-23 21:02:31 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-03-12 11:59:14 -0400 |
commit | c19457f0aed7fae73bb40e68ffcc72f36e3966a5 (patch) | |
tree | d2fc8be41a6fb201d6038c6ce6f3180ad3d81ad0 /fs/dcache.c | |
parent | c1d0c1a2b51e86124b7ba8ff9054698e2036d8e7 (diff) |
d_delete(): get rid of trylock loop
just grab ->i_lock first; we have a positive dentry, nothing's going
to happen to inode
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r-- | fs/dcache.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 01c0432ec83a..1684b6b262de 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -2377,32 +2377,22 @@ EXPORT_SYMBOL(d_hash_and_lookup); | |||
2377 | 2377 | ||
2378 | void d_delete(struct dentry * dentry) | 2378 | void d_delete(struct dentry * dentry) |
2379 | { | 2379 | { |
2380 | struct inode *inode; | 2380 | struct inode *inode = dentry->d_inode; |
2381 | int isdir = 0; | 2381 | int isdir = d_is_dir(dentry); |
2382 | |||
2383 | spin_lock(&inode->i_lock); | ||
2384 | spin_lock(&dentry->d_lock); | ||
2382 | /* | 2385 | /* |
2383 | * Are we the only user? | 2386 | * Are we the only user? |
2384 | */ | 2387 | */ |
2385 | again: | ||
2386 | spin_lock(&dentry->d_lock); | ||
2387 | inode = dentry->d_inode; | ||
2388 | isdir = S_ISDIR(inode->i_mode); | ||
2389 | if (dentry->d_lockref.count == 1) { | 2388 | if (dentry->d_lockref.count == 1) { |
2390 | if (!spin_trylock(&inode->i_lock)) { | ||
2391 | spin_unlock(&dentry->d_lock); | ||
2392 | cpu_relax(); | ||
2393 | goto again; | ||
2394 | } | ||
2395 | dentry->d_flags &= ~DCACHE_CANT_MOUNT; | 2389 | dentry->d_flags &= ~DCACHE_CANT_MOUNT; |
2396 | dentry_unlink_inode(dentry); | 2390 | dentry_unlink_inode(dentry); |
2397 | fsnotify_nameremove(dentry, isdir); | 2391 | } else { |
2398 | return; | ||
2399 | } | ||
2400 | |||
2401 | if (!d_unhashed(dentry)) | ||
2402 | __d_drop(dentry); | 2392 | __d_drop(dentry); |
2403 | 2393 | spin_unlock(&dentry->d_lock); | |
2404 | spin_unlock(&dentry->d_lock); | 2394 | spin_unlock(&inode->i_lock); |
2405 | 2395 | } | |
2406 | fsnotify_nameremove(dentry, isdir); | 2396 | fsnotify_nameremove(dentry, isdir); |
2407 | } | 2397 | } |
2408 | EXPORT_SYMBOL(d_delete); | 2398 | EXPORT_SYMBOL(d_delete); |