Commit dc0474be3e27463d4d4a2793f82366eed906f223
1 parent
357f8e658b
Exists in
master
and in
4 other branches
fs: dcache rationalise dget variants
dget_locked was a shortcut to avoid the lazy lru manipulation when we already held dcache_lock (lru manipulation was relatively cheap at that point). However, how that the lru lock is an innermost one, we never hold it at any caller, so the lock cost can now be avoided. We already have well working lazy dcache LRU, so it should be fine to defer LRU manipulations to scan time. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Showing 12 changed files with 24 additions and 47 deletions Side-by-side Diff
arch/powerpc/platforms/cell/spufs/inode.c
... | ... | @@ -161,7 +161,7 @@ |
161 | 161 | list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) { |
162 | 162 | spin_lock(&dentry->d_lock); |
163 | 163 | if (!(d_unhashed(dentry)) && dentry->d_inode) { |
164 | - dget_locked_dlock(dentry); | |
164 | + dget_dlock(dentry); | |
165 | 165 | __d_drop(dentry); |
166 | 166 | spin_unlock(&dentry->d_lock); |
167 | 167 | simple_unlink(dir->d_inode, dentry); |
drivers/infiniband/hw/ipath/ipath_fs.c
drivers/infiniband/hw/qib/qib_fs.c
drivers/staging/smbfs/cache.c
fs/configfs/inode.c
... | ... | @@ -252,7 +252,7 @@ |
252 | 252 | if (dentry) { |
253 | 253 | spin_lock(&dentry->d_lock); |
254 | 254 | if (!(d_unhashed(dentry) && dentry->d_inode)) { |
255 | - dget_locked_dlock(dentry); | |
255 | + dget_dlock(dentry); | |
256 | 256 | __d_drop(dentry); |
257 | 257 | spin_unlock(&dentry->d_lock); |
258 | 258 | simple_unlink(parent->d_inode, dentry); |
fs/dcache.c
... | ... | @@ -429,33 +429,18 @@ |
429 | 429 | EXPORT_SYMBOL(d_invalidate); |
430 | 430 | |
431 | 431 | /* This must be called with d_lock held */ |
432 | -static inline struct dentry * __dget_locked_dlock(struct dentry *dentry) | |
432 | +static inline void __dget_dlock(struct dentry *dentry) | |
433 | 433 | { |
434 | 434 | dentry->d_count++; |
435 | - dentry_lru_del(dentry); | |
436 | - return dentry; | |
437 | 435 | } |
438 | 436 | |
439 | -/* This must be called with d_lock held */ | |
440 | -static inline struct dentry * __dget_locked(struct dentry *dentry) | |
437 | +static inline void __dget(struct dentry *dentry) | |
441 | 438 | { |
442 | 439 | spin_lock(&dentry->d_lock); |
443 | - __dget_locked_dlock(dentry); | |
440 | + __dget_dlock(dentry); | |
444 | 441 | spin_unlock(&dentry->d_lock); |
445 | - return dentry; | |
446 | 442 | } |
447 | 443 | |
448 | -struct dentry * dget_locked_dlock(struct dentry *dentry) | |
449 | -{ | |
450 | - return __dget_locked_dlock(dentry); | |
451 | -} | |
452 | - | |
453 | -struct dentry * dget_locked(struct dentry *dentry) | |
454 | -{ | |
455 | - return __dget_locked(dentry); | |
456 | -} | |
457 | -EXPORT_SYMBOL(dget_locked); | |
458 | - | |
459 | 444 | struct dentry *dget_parent(struct dentry *dentry) |
460 | 445 | { |
461 | 446 | struct dentry *ret; |
... | ... | @@ -512,7 +497,7 @@ |
512 | 497 | (alias->d_flags & DCACHE_DISCONNECTED)) { |
513 | 498 | discon_alias = alias; |
514 | 499 | } else if (!want_discon) { |
515 | - __dget_locked_dlock(alias); | |
500 | + __dget_dlock(alias); | |
516 | 501 | spin_unlock(&alias->d_lock); |
517 | 502 | return alias; |
518 | 503 | } |
... | ... | @@ -525,7 +510,7 @@ |
525 | 510 | if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { |
526 | 511 | if (IS_ROOT(alias) && |
527 | 512 | (alias->d_flags & DCACHE_DISCONNECTED)) { |
528 | - __dget_locked_dlock(alias); | |
513 | + __dget_dlock(alias); | |
529 | 514 | spin_unlock(&alias->d_lock); |
530 | 515 | return alias; |
531 | 516 | } |
... | ... | @@ -561,7 +546,7 @@ |
561 | 546 | list_for_each_entry(dentry, &inode->i_dentry, d_alias) { |
562 | 547 | spin_lock(&dentry->d_lock); |
563 | 548 | if (!dentry->d_count) { |
564 | - __dget_locked_dlock(dentry); | |
549 | + __dget_dlock(dentry); | |
565 | 550 | __d_drop(dentry); |
566 | 551 | spin_unlock(&dentry->d_lock); |
567 | 552 | spin_unlock(&dcache_inode_lock); |
... | ... | @@ -1257,7 +1242,8 @@ |
1257 | 1242 | * don't need child lock because it is not subject |
1258 | 1243 | * to concurrency here |
1259 | 1244 | */ |
1260 | - dentry->d_parent = dget_dlock(parent); | |
1245 | + __dget_dlock(parent); | |
1246 | + dentry->d_parent = parent; | |
1261 | 1247 | dentry->d_sb = parent->d_sb; |
1262 | 1248 | list_add(&dentry->d_u.d_child, &parent->d_subdirs); |
1263 | 1249 | spin_unlock(&parent->d_lock); |
... | ... | @@ -1360,7 +1346,7 @@ |
1360 | 1346 | continue; |
1361 | 1347 | if (memcmp(qstr->name, name, len)) |
1362 | 1348 | continue; |
1363 | - dget_locked(alias); | |
1349 | + __dget(alias); | |
1364 | 1350 | return alias; |
1365 | 1351 | } |
1366 | 1352 | |
... | ... | @@ -1613,7 +1599,7 @@ |
1613 | 1599 | * reference to it, move it in place and use it. |
1614 | 1600 | */ |
1615 | 1601 | new = list_entry(inode->i_dentry.next, struct dentry, d_alias); |
1616 | - dget_locked(new); | |
1602 | + __dget(new); | |
1617 | 1603 | spin_unlock(&dcache_inode_lock); |
1618 | 1604 | security_d_instantiate(found, inode); |
1619 | 1605 | d_move(new, found); |
... | ... | @@ -1789,7 +1775,7 @@ |
1789 | 1775 | list_for_each_entry(child, &dparent->d_subdirs, d_u.d_child) { |
1790 | 1776 | if (dentry == child) { |
1791 | 1777 | spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); |
1792 | - __dget_locked_dlock(dentry); | |
1778 | + __dget_dlock(dentry); | |
1793 | 1779 | spin_unlock(&dentry->d_lock); |
1794 | 1780 | spin_unlock(&dparent->d_lock); |
1795 | 1781 | return 1; |
fs/exportfs/expfs.c
fs/ncpfs/dir.c
fs/ocfs2/dcache.c
include/linux/dcache.h
... | ... | @@ -287,23 +287,17 @@ |
287 | 287 | /* Allocation counts.. */ |
288 | 288 | |
289 | 289 | /** |
290 | - * dget, dget_locked - get a reference to a dentry | |
290 | + * dget, dget_dlock - get a reference to a dentry | |
291 | 291 | * @dentry: dentry to get a reference to |
292 | 292 | * |
293 | 293 | * Given a dentry or %NULL pointer increment the reference count |
294 | 294 | * if appropriate and return the dentry. A dentry will not be |
295 | - * destroyed when it has references. dget() should never be | |
296 | - * called for dentries with zero reference counter. For these cases | |
297 | - * (preferably none, functions in dcache.c are sufficient for normal | |
298 | - * needs and they take necessary precautions) you should hold d_lock | |
299 | - * and call dget_dlock() instead of dget(). | |
295 | + * destroyed when it has references. | |
300 | 296 | */ |
301 | 297 | static inline struct dentry *dget_dlock(struct dentry *dentry) |
302 | 298 | { |
303 | - if (dentry) { | |
304 | - BUG_ON(!dentry->d_count); | |
299 | + if (dentry) | |
305 | 300 | dentry->d_count++; |
306 | - } | |
307 | 301 | return dentry; |
308 | 302 | } |
309 | 303 | |
... | ... | @@ -316,9 +310,6 @@ |
316 | 310 | } |
317 | 311 | return dentry; |
318 | 312 | } |
319 | - | |
320 | -extern struct dentry * dget_locked(struct dentry *); | |
321 | -extern struct dentry * dget_locked_dlock(struct dentry *); | |
322 | 313 | |
323 | 314 | extern struct dentry *dget_parent(struct dentry *dentry); |
324 | 315 |
kernel/cgroup.c
... | ... | @@ -887,7 +887,7 @@ |
887 | 887 | /* This should never be called on a cgroup |
888 | 888 | * directory with child cgroups */ |
889 | 889 | BUG_ON(d->d_inode->i_mode & S_IFDIR); |
890 | - dget_locked_dlock(d); | |
890 | + dget_dlock(d); | |
891 | 891 | spin_unlock(&d->d_lock); |
892 | 892 | spin_unlock(&dentry->d_lock); |
893 | 893 | d_delete(d); |
security/selinux/selinuxfs.c