Skip to content

Commit

Permalink
push BKL down into ->put_super
Browse files Browse the repository at this point in the history
Move BKL into ->put_super from the only caller.  A couple of
filesystems had trivial enough ->put_super (only kfree and NULLing of
s_fs_info + stuff in there) to not get any locking: coda, cramfs, efs,
hugetlbfs, omfs, qnx4, shmem, all others got the full treatment.  Most
of them probably don't need it, but I'd rather sort that out individually.
Preferably after all the other BKL pushdowns in that area.

[AV: original used to move lock_super() down as well; these changes are
removed since we don't do lock_super() at all in generic_shutdown_super()
now]
[AV: fuse, btrfs and xfs are known to need no damn BKL, exempt]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Jun 12, 2009
1 parent a9e220f commit 6cfd014
Show file tree
Hide file tree
Showing 33 changed files with 133 additions and 12 deletions.
4 changes: 4 additions & 0 deletions fs/adfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ static void adfs_put_super(struct super_block *sb)
int i;
struct adfs_sb_info *asb = ADFS_SB(sb);

lock_kernel();

for (i = 0; i < asb->s_map_size; i++)
brelse(asb->s_map[i].dm_bh);
kfree(asb->s_map);
kfree(asb);
sb->s_fs_info = NULL;

unlock_kernel();
}

static int adfs_show_options(struct seq_file *seq, struct vfsmount *mnt)
Expand Down
5 changes: 4 additions & 1 deletion fs/affs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ affs_put_super(struct super_block *sb)
struct affs_sb_info *sbi = AFFS_SB(sb);
pr_debug("AFFS: put_super()\n");

lock_kernel();

if (!(sb->s_flags & MS_RDONLY)) {
AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(1);
secs_to_datestamp(get_seconds(),
Expand All @@ -42,7 +44,8 @@ affs_put_super(struct super_block *sb)
affs_brelse(sbi->s_root_bh);
kfree(sbi);
sb->s_fs_info = NULL;
return;

unlock_kernel();
}

static void
Expand Down
4 changes: 4 additions & 0 deletions fs/afs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,12 @@ static void afs_put_super(struct super_block *sb)

_enter("");

lock_kernel();

afs_put_volume(as->volume);

unlock_kernel();

_leave("");
}

Expand Down
5 changes: 4 additions & 1 deletion fs/befs/linuxvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ parse_options(char *options, befs_mount_options * opts)
static void
befs_put_super(struct super_block *sb)
{
lock_kernel();

kfree(BEFS_SB(sb)->mount_opts.iocharset);
BEFS_SB(sb)->mount_opts.iocharset = NULL;

Expand All @@ -747,7 +749,8 @@ befs_put_super(struct super_block *sb)

kfree(sb->s_fs_info);
sb->s_fs_info = NULL;
return;

unlock_kernel();
}

/* Allocate private field of the superblock, fill it.
Expand Down
4 changes: 4 additions & 0 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ static void bfs_put_super(struct super_block *s)
if (!info)
return;

lock_kernel();

if (s->s_dirt)
bfs_write_super(s);

Expand All @@ -225,6 +227,8 @@ static void bfs_put_super(struct super_block *s)
kfree(info->si_imap);
kfree(info);
s->s_fs_info = NULL;

unlock_kernel();
}

static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf)
Expand Down
6 changes: 5 additions & 1 deletion fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ cifs_put_super(struct super_block *sb)
cFYI(1, ("Empty cifs superblock info passed to unmount"));
return;
}

lock_kernel();

rc = cifs_umount(sb, cifs_sb);
if (rc)
cERROR(1, ("cifs_umount failed with return code %d", rc));
Expand All @@ -216,7 +219,8 @@ cifs_put_super(struct super_block *sb)

unload_nls(cifs_sb->local_nls);
kfree(cifs_sb);
return;

unlock_kernel();
}

static int
Expand Down
5 changes: 5 additions & 0 deletions fs/ecryptfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/mount.h>
#include <linux/key.h>
#include <linux/seq_file.h>
#include <linux/smp_lock.h>
#include <linux/file.h>
#include <linux/crypto.h>
#include "ecryptfs_kernel.h"
Expand Down Expand Up @@ -120,9 +121,13 @@ static void ecryptfs_put_super(struct super_block *sb)
{
struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb);

lock_kernel();

ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
kmem_cache_free(ecryptfs_sb_info_cache, sb_info);
ecryptfs_set_superblock_private(sb, NULL);

unlock_kernel();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions fs/exofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ static void exofs_put_super(struct super_block *sb)
int num_pend;
struct exofs_sb_info *sbi = sb->s_fs_info;

lock_kernel();

if (sb->s_dirt)
exofs_write_super(sb);

Expand All @@ -274,6 +276,8 @@ static void exofs_put_super(struct super_block *sb)
osduld_put_device(sbi->s_dev);
kfree(sb->s_fs_info);
sb->s_fs_info = NULL;

unlock_kernel();
}

/*
Expand Down
4 changes: 3 additions & 1 deletion fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ static void ext2_put_super (struct super_block * sb)
int i;
struct ext2_sb_info *sbi = EXT2_SB(sb);

lock_kernel();

if (sb->s_dirt)
ext2_write_super(sb);

Expand All @@ -138,7 +140,7 @@ static void ext2_put_super (struct super_block * sb)
kfree(sbi->s_blockgroup_lock);
kfree(sbi);

return;
unlock_kernel();
}

static struct kmem_cache * ext2_inode_cachep;
Expand Down
5 changes: 4 additions & 1 deletion fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ static void ext3_put_super (struct super_block * sb)
struct ext3_super_block *es = sbi->s_es;
int i, err;

lock_kernel();

ext3_xattr_put_super(sb);
err = journal_destroy(sbi->s_journal);
sbi->s_journal = NULL;
Expand Down Expand Up @@ -446,7 +448,8 @@ static void ext3_put_super (struct super_block * sb)
sb->s_fs_info = NULL;
kfree(sbi->s_blockgroup_lock);
kfree(sbi);
return;

unlock_kernel();
}

static struct kmem_cache *ext3_inode_cachep;
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ static void ext4_put_super(struct super_block *sb)
int i, err;

lock_super(sb);
lock_kernel();
if (sb->s_dirt)
ext4_write_super(sb);

Expand Down Expand Up @@ -646,7 +647,6 @@ static void ext4_put_super(struct super_block *sb)
unlock_super(sb);
kobject_put(&sbi->s_kobj);
wait_for_completion(&sbi->s_kobj_unregister);
lock_kernel();
kfree(sbi->s_blockgroup_lock);
kfree(sbi);
}
Expand Down
4 changes: 4 additions & 0 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ static void fat_put_super(struct super_block *sb)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);

lock_kernel();

if (sb->s_dirt)
fat_write_super(sb);

Expand All @@ -470,6 +472,8 @@ static void fat_put_super(struct super_block *sb)

sb->s_fs_info = NULL;
kfree(sbi);

unlock_kernel();
}

static struct kmem_cache *fat_inode_cachep;
Expand Down
4 changes: 4 additions & 0 deletions fs/freevxfs/vxfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ vxfs_put_super(struct super_block *sbp)
{
struct vxfs_sb_info *infp = VXFS_SBI(sbp);

lock_kernel();

vxfs_put_fake_inode(infp->vsi_fship);
vxfs_put_fake_inode(infp->vsi_ilist);
vxfs_put_fake_inode(infp->vsi_stilist);

brelse(infp->vsi_bp);
kfree(infp);

unlock_kernel();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions fs/gfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ static void gfs2_put_super(struct super_block *sb)
int error;
struct gfs2_jdesc *jd;

lock_kernel();

/* Unfreeze the filesystem, if we need to */

mutex_lock(&sdp->sd_freeze_lock);
Expand Down Expand Up @@ -785,6 +787,8 @@ static void gfs2_put_super(struct super_block *sb)

/* At this point, we're through participating in the lockspace */
gfs2_sys_fs_del(sdp);

unlock_kernel();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions fs/hfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ static void hfs_write_super(struct super_block *sb)
*/
static void hfs_put_super(struct super_block *sb)
{
lock_kernel();

if (sb->s_dirt)
hfs_write_super(sb);
hfs_mdb_close(sb);
/* release the MDB's resources */
hfs_mdb_put(sb);

unlock_kernel();
}

/*
Expand Down
5 changes: 5 additions & 0 deletions fs/hfsplus/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ static void hfsplus_put_super(struct super_block *sb)
dprint(DBG_SUPER, "hfsplus_put_super\n");
if (!sb->s_fs_info)
return;

lock_kernel();

if (sb->s_dirt)
hfsplus_write_super(sb);
if (!(sb->s_flags & MS_RDONLY) && HFSPLUS_SB(sb).s_vhdr) {
Expand All @@ -220,6 +223,8 @@ static void hfsplus_put_super(struct super_block *sb)
unload_nls(HFSPLUS_SB(sb).nls);
kfree(sb->s_fs_info);
sb->s_fs_info = NULL;

unlock_kernel();
}

static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
Expand Down
5 changes: 5 additions & 0 deletions fs/hpfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ int hpfs_stop_cycles(struct super_block *s, int key, int *c1, int *c2,
static void hpfs_put_super(struct super_block *s)
{
struct hpfs_sb_info *sbi = hpfs_sb(s);

lock_kernel();

kfree(sbi->sb_cp_table);
kfree(sbi->sb_bmp_dir);
unmark_dirty(s);
s->s_fs_info = NULL;
kfree(sbi);

unlock_kernel();
}

unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
Expand Down
5 changes: 5 additions & 0 deletions fs/isofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ static int isofs_dentry_cmp_ms(struct dentry *dentry, struct qstr *a, struct qst
static void isofs_put_super(struct super_block *sb)
{
struct isofs_sb_info *sbi = ISOFS_SB(sb);

#ifdef CONFIG_JOLIET
lock_kernel();

if (sbi->s_nls_iocharset) {
unload_nls(sbi->s_nls_iocharset);
sbi->s_nls_iocharset = NULL;
}

unlock_kernel();
#endif

kfree(sbi);
Expand Down
4 changes: 4 additions & 0 deletions fs/jffs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ static void jffs2_put_super (struct super_block *sb)

D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n"));

lock_kernel();

if (sb->s_dirt)
jffs2_write_super(sb);

Expand All @@ -195,6 +197,8 @@ static void jffs2_put_super (struct super_block *sb)
if (c->mtd->sync)
c->mtd->sync(c->mtd);

unlock_kernel();

D1(printk(KERN_DEBUG "jffs2_put_super returning\n"));
}

Expand Down
5 changes: 5 additions & 0 deletions fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ static void jfs_put_super(struct super_block *sb)
int rc;

jfs_info("In jfs_put_super");

lock_kernel();

rc = jfs_umount(sb);
if (rc)
jfs_err("jfs_umount failed with return code %d", rc);
Expand All @@ -195,6 +198,8 @@ static void jfs_put_super(struct super_block *sb)
sbi->direct_inode = NULL;

kfree(sbi);

unlock_kernel();
}

enum {
Expand Down
4 changes: 3 additions & 1 deletion fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ static void minix_put_super(struct super_block *sb)
int i;
struct minix_sb_info *sbi = minix_sb(sb);

lock_kernel();

if (!(sb->s_flags & MS_RDONLY)) {
if (sbi->s_version != MINIX_V3) /* s_state is now out from V3 sb */
sbi->s_ms->s_state = sbi->s_mount_state;
Expand All @@ -49,7 +51,7 @@ static void minix_put_super(struct super_block *sb)
sb->s_fs_info = NULL;
kfree(sbi);

return;
unlock_kernel();
}

static struct kmem_cache * minix_inode_cachep;
Expand Down
4 changes: 4 additions & 0 deletions fs/ncpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,8 @@ static void ncp_put_super(struct super_block *sb)
{
struct ncp_server *server = NCP_SBP(sb);

lock_kernel();

ncp_lock_server(server);
ncp_disconnect(server);
ncp_unlock_server(server);
Expand Down Expand Up @@ -769,6 +771,8 @@ static void ncp_put_super(struct super_block *sb)
vfree(server->packet);
sb->s_fs_info = NULL;
kfree(server);

unlock_kernel();
}

static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf)
Expand Down
Loading

0 comments on commit 6cfd014

Please sign in to comment.