diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-22 20:42:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-22 20:42:14 -0500 |
commit | be5e6616dd74e17fdd8e16ca015cfef94d49b467 (patch) | |
tree | a18826e557f0d6636f1e05a4ec30d584ed981a2b /fs/super.c | |
parent | 90c453ca2214394eec602d98e6cb92d151908493 (diff) | |
parent | 0a280962dc6e117e0e4baa668453f753579265d9 (diff) |
Merge branch 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more vfs updates from Al Viro:
"Assorted stuff from this cycle. The big ones here are multilayer
overlayfs from Miklos and beginning of sorting ->d_inode accesses out
from David"
* 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (51 commits)
autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allocation
procfs: fix race between symlink removals and traversals
debugfs: leave freeing a symlink body until inode eviction
Documentation/filesystems/Locking: ->get_sb() is long gone
trylock_super(): replacement for grab_super_passive()
fanotify: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
SELinux: Use d_is_positive() rather than testing dentry->d_inode
Smack: Use d_is_positive() rather than testing dentry->d_inode
TOMOYO: Use d_is_dir() rather than d_inode and S_ISDIR()
Apparmor: Use d_is_positive/negative() rather than testing dentry->d_inode
Apparmor: mediated_filesystem() should use dentry->d_sb not inode->i_sb
VFS: Split DCACHE_FILE_TYPE into regular and special types
VFS: Add a fallthrough flag for marking virtual dentries
VFS: Add a whiteout dentry type
VFS: Introduce inode-getting helpers for layered/unioned fs environments
Infiniband: Fix potential NULL d_inode dereference
posix_acl: fix reference leaks in posix_acl_create
autofs4: Wrong format for printing dentry
...
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/fs/super.c b/fs/super.c index 65a53efc1cf4..2b7dc90ccdbb 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -71,7 +71,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink, | |||
71 | if (!(sc->gfp_mask & __GFP_FS)) | 71 | if (!(sc->gfp_mask & __GFP_FS)) |
72 | return SHRINK_STOP; | 72 | return SHRINK_STOP; |
73 | 73 | ||
74 | if (!grab_super_passive(sb)) | 74 | if (!trylock_super(sb)) |
75 | return SHRINK_STOP; | 75 | return SHRINK_STOP; |
76 | 76 | ||
77 | if (sb->s_op->nr_cached_objects) | 77 | if (sb->s_op->nr_cached_objects) |
@@ -105,7 +105,7 @@ static unsigned long super_cache_scan(struct shrinker *shrink, | |||
105 | freed += sb->s_op->free_cached_objects(sb, sc); | 105 | freed += sb->s_op->free_cached_objects(sb, sc); |
106 | } | 106 | } |
107 | 107 | ||
108 | drop_super(sb); | 108 | up_read(&sb->s_umount); |
109 | return freed; | 109 | return freed; |
110 | } | 110 | } |
111 | 111 | ||
@@ -118,7 +118,7 @@ static unsigned long super_cache_count(struct shrinker *shrink, | |||
118 | sb = container_of(shrink, struct super_block, s_shrink); | 118 | sb = container_of(shrink, struct super_block, s_shrink); |
119 | 119 | ||
120 | /* | 120 | /* |
121 | * Don't call grab_super_passive as it is a potential | 121 | * Don't call trylock_super as it is a potential |
122 | * scalability bottleneck. The counts could get updated | 122 | * scalability bottleneck. The counts could get updated |
123 | * between super_cache_count and super_cache_scan anyway. | 123 | * between super_cache_count and super_cache_scan anyway. |
124 | * Call to super_cache_count with shrinker_rwsem held | 124 | * Call to super_cache_count with shrinker_rwsem held |
@@ -348,35 +348,31 @@ static int grab_super(struct super_block *s) __releases(sb_lock) | |||
348 | } | 348 | } |
349 | 349 | ||
350 | /* | 350 | /* |
351 | * grab_super_passive - acquire a passive reference | 351 | * trylock_super - try to grab ->s_umount shared |
352 | * @sb: reference we are trying to grab | 352 | * @sb: reference we are trying to grab |
353 | * | 353 | * |
354 | * Tries to acquire a passive reference. This is used in places where we | 354 | * Try to prevent fs shutdown. This is used in places where we |
355 | * cannot take an active reference but we need to ensure that the | 355 | * cannot take an active reference but we need to ensure that the |
356 | * superblock does not go away while we are working on it. It returns | 356 | * filesystem is not shut down while we are working on it. It returns |
357 | * false if a reference was not gained, and returns true with the s_umount | 357 | * false if we cannot acquire s_umount or if we lose the race and |
358 | * lock held in read mode if a reference is gained. On successful return, | 358 | * filesystem already got into shutdown, and returns true with the s_umount |
359 | * the caller must drop the s_umount lock and the passive reference when | 359 | * lock held in read mode in case of success. On successful return, |
360 | * done. | 360 | * the caller must drop the s_umount lock when done. |
361 | * | ||
362 | * Note that unlike get_super() et.al. this one does *not* bump ->s_count. | ||
363 | * The reason why it's safe is that we are OK with doing trylock instead | ||
364 | * of down_read(). There's a couple of places that are OK with that, but | ||
365 | * it's very much not a general-purpose interface. | ||
361 | */ | 366 | */ |
362 | bool grab_super_passive(struct super_block *sb) | 367 | bool trylock_super(struct super_block *sb) |
363 | { | 368 | { |
364 | spin_lock(&sb_lock); | ||
365 | if (hlist_unhashed(&sb->s_instances)) { | ||
366 | spin_unlock(&sb_lock); | ||
367 | return false; | ||
368 | } | ||
369 | |||
370 | sb->s_count++; | ||
371 | spin_unlock(&sb_lock); | ||
372 | |||
373 | if (down_read_trylock(&sb->s_umount)) { | 369 | if (down_read_trylock(&sb->s_umount)) { |
374 | if (sb->s_root && (sb->s_flags & MS_BORN)) | 370 | if (!hlist_unhashed(&sb->s_instances) && |
371 | sb->s_root && (sb->s_flags & MS_BORN)) | ||
375 | return true; | 372 | return true; |
376 | up_read(&sb->s_umount); | 373 | up_read(&sb->s_umount); |
377 | } | 374 | } |
378 | 375 | ||
379 | put_super(sb); | ||
380 | return false; | 376 | return false; |
381 | } | 377 | } |
382 | 378 | ||