Skip to content

Commit

Permalink
Push BKL down into ->remount_fs()
Browse files Browse the repository at this point in the history
[xfs, btrfs, capifs, shmem don't need BKL, exempt]

Signed-off-by: Alessio Igor Bogani <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Alessio Igor Bogani authored and Al Viro committed Jun 12, 2009
1 parent 4195f73 commit 337eb00
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 13 deletions.
5 changes: 5 additions & 0 deletions drivers/usb/core/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <linux/parser.h>
#include <linux/notifier.h>
#include <linux/seq_file.h>
#include <linux/smp_lock.h>
#include <asm/byteorder.h>
#include "usb.h"
#include "hcd.h"
Expand Down Expand Up @@ -265,9 +266,13 @@ static int remount(struct super_block *sb, int *flags, char *data)
return -EINVAL;
}

lock_kernel();

if (usbfs_mount && usbfs_mount->mnt_sb)
update_sb(usbfs_mount->mnt_sb);

unlock_kernel();

return 0;
}

Expand Down
7 changes: 6 additions & 1 deletion fs/affs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/parser.h>
#include <linux/magic.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
#include "affs.h"

extern struct timezone sys_tz;
Expand Down Expand Up @@ -512,15 +513,18 @@ affs_remount(struct super_block *sb, int *flags, char *data)
kfree(new_opts);
return -EINVAL;
}
lock_kernel();
replace_mount_options(sb, new_opts);

sbi->s_flags = mount_flags;
sbi->s_mode = mode;
sbi->s_uid = uid;
sbi->s_gid = gid;

if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
unlock_kernel();
return 0;
}
if (*flags & MS_RDONLY) {
sb->s_dirt = 1;
while (sb->s_dirt)
Expand All @@ -529,6 +533,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
} else
res = affs_init_bitmap(sb, flags);

unlock_kernel();
return res;
}

Expand Down
12 changes: 10 additions & 2 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
unsigned long old_sb_flags;
int err;

lock_kernel();

/* Store the old options */
old_sb_flags = sb->s_flags;
old_opts.s_mount_opt = sbi->s_mount_opt;
Expand Down Expand Up @@ -1197,12 +1199,16 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
}
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
unlock_kernel();
return 0;
}
if (*flags & MS_RDONLY) {
if (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||
!(sbi->s_mount_state & EXT2_VALID_FS))
!(sbi->s_mount_state & EXT2_VALID_FS)) {
unlock_kernel();
return 0;
}
/*
* OK, we are remounting a valid rw partition rdonly, so set
* the rdonly flag and then mark the partition as valid again.
Expand All @@ -1229,12 +1235,14 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
sb->s_flags &= ~MS_RDONLY;
}
ext2_sync_super(sb, es);
unlock_kernel();
return 0;
restore_opts:
sbi->s_mount_opt = old_opts.s_mount_opt;
sbi->s_resuid = old_opts.s_resuid;
sbi->s_resgid = old_opts.s_resgid;
sb->s_flags = old_sb_flags;
unlock_kernel();
return err;
}

Expand Down
4 changes: 4 additions & 0 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,8 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
int i;
#endif

lock_kernel();

/* Store the original options */
lock_super(sb);
old_sb_flags = sb->s_flags;
Expand Down Expand Up @@ -2600,6 +2602,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
kfree(old_opts.s_qf_names[i]);
#endif
unlock_super(sb);
unlock_kernel();
return 0;
restore_opts:
sb->s_flags = old_sb_flags;
Expand All @@ -2617,6 +2620,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
}
#endif
unlock_super(sb);
unlock_kernel();
return err;
}

Expand Down
4 changes: 4 additions & 0 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3422,6 +3422,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
int i;
#endif

lock_kernel();

/* Store the original options */
lock_super(sb);
old_sb_flags = sb->s_flags;
Expand Down Expand Up @@ -3558,6 +3560,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
kfree(old_opts.s_qf_names[i]);
#endif
unlock_super(sb);
unlock_kernel();
return 0;

restore_opts:
Expand All @@ -3578,6 +3581,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
}
#endif
unlock_super(sb);
unlock_kernel();
return err;
}

Expand Down
4 changes: 4 additions & 0 deletions fs/hpfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/statfs.h>
#include <linux/magic.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>

/* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */

Expand Down Expand Up @@ -398,6 +399,7 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)

*flags |= MS_NOATIME;

lock_kernel();
lock_super(s);
uid = sbi->sb_uid; gid = sbi->sb_gid;
umask = 0777 & ~sbi->sb_mode;
Expand Down Expand Up @@ -432,10 +434,12 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
replace_mount_options(s, new_opts);

unlock_super(s);
unlock_kernel();
return 0;

out_err:
unlock_super(s);
unlock_kernel();
kfree(new_opts);
return -EINVAL;
}
Expand Down
3 changes: 3 additions & 0 deletions fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/vmalloc.h>
#include <linux/vfs.h>
#include <linux/crc32.h>
#include <linux/smp_lock.h>
#include "nodelist.h"

static int jffs2_flash_setup(struct jffs2_sb_info *c);
Expand Down Expand Up @@ -387,6 +388,7 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
This also catches the case where it was stopped and this
is just a remount to restart it.
Flush the writebuffer, if neccecary, else we loose it */
lock_kernel();
if (!(sb->s_flags & MS_RDONLY)) {
jffs2_stop_garbage_collect_thread(c);
mutex_lock(&c->alloc_sem);
Expand All @@ -399,6 +401,7 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)

*flags |= MS_NOATIME;

unlock_kernel();
return 0;
}

Expand Down
22 changes: 18 additions & 4 deletions fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/crc32.h>
#include <asm/uaccess.h>
#include <linux/seq_file.h>
#include <linux/smp_lock.h>

#include "jfs_incore.h"
#include "jfs_filsys.h"
Expand Down Expand Up @@ -375,19 +376,24 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
s64 newLVSize = 0;
int rc = 0;
int flag = JFS_SBI(sb)->flag;
int ret;

if (!parse_options(data, sb, &newLVSize, &flag)) {
return -EINVAL;
}
lock_kernel();
if (newLVSize) {
if (sb->s_flags & MS_RDONLY) {
printk(KERN_ERR
"JFS: resize requires volume to be mounted read-write\n");
unlock_kernel();
return -EROFS;
}
rc = jfs_extendfs(sb, newLVSize, 0);
if (rc)
if (rc) {
unlock_kernel();
return rc;
}
}

if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
Expand All @@ -398,23 +404,31 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
truncate_inode_pages(JFS_SBI(sb)->direct_inode->i_mapping, 0);

JFS_SBI(sb)->flag = flag;
return jfs_mount_rw(sb, 1);
ret = jfs_mount_rw(sb, 1);
unlock_kernel();
return ret;
}
if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
rc = jfs_umount_rw(sb);
JFS_SBI(sb)->flag = flag;
unlock_kernel();
return rc;
}
if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY))
if (!(sb->s_flags & MS_RDONLY)) {
rc = jfs_umount_rw(sb);
if (rc)
if (rc) {
unlock_kernel();
return rc;
}
JFS_SBI(sb)->flag = flag;
return jfs_mount_rw(sb, 1);
ret = jfs_mount_rw(sb, 1);
unlock_kernel();
return ret;
}
JFS_SBI(sb)->flag = flag;

unlock_kernel();
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
if (data == NULL)
return -ENOMEM;

lock_kernel();
/* fill out struct with values from existing mount */
data->flags = nfss->flags;
data->rsize = nfss->rsize;
Expand All @@ -1837,6 +1838,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
error = nfs_compare_remount_data(nfss, data);
out:
kfree(data);
unlock_kernel();
return error;
}

Expand Down
4 changes: 4 additions & 0 deletions fs/nilfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
struct nilfs_mount_options old_opts;
int err;

lock_kernel();

old_sb_flags = sb->s_flags;
old_opts.mount_opt = sbi->s_mount_opt;
old_opts.snapshot_cno = sbi->s_snapshot_cno;
Expand Down Expand Up @@ -985,6 +987,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
up(&sb->s_bdev->bd_mount_sem);
}
out:
unlock_kernel();
return 0;

rw_remount_failed:
Expand All @@ -993,6 +996,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
sb->s_flags = old_sb_flags;
sbi->s_mount_opt = old_opts.mount_opt;
sbi->s_snapshot_cno = old_opts.snapshot_cno;
unlock_kernel();
return err;
}

Expand Down
15 changes: 14 additions & 1 deletion fs/ntfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
ntfs_volume *vol = NTFS_SB(sb);

ntfs_debug("Entering with remount options string: %s", opt);

lock_kernel();
#ifndef NTFS_RW
/* For read-only compiled driver, enforce read-only flag. */
*flags |= MS_RDONLY;
Expand All @@ -466,27 +468,32 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
if (NVolErrors(vol)) {
ntfs_error(sb, "Volume has errors and is read-only%s",
es);
unlock_kernel();
return -EROFS;
}
if (vol->vol_flags & VOLUME_IS_DIRTY) {
ntfs_error(sb, "Volume is dirty and read-only%s", es);
unlock_kernel();
return -EROFS;
}
if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) {
ntfs_error(sb, "Volume has been modified by chkdsk "
"and is read-only%s", es);
unlock_kernel();
return -EROFS;
}
if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
ntfs_error(sb, "Volume has unsupported flags set "
"(0x%x) and is read-only%s",
(unsigned)le16_to_cpu(vol->vol_flags),
es);
unlock_kernel();
return -EROFS;
}
if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
ntfs_error(sb, "Failed to set dirty bit in volume "
"information flags%s", es);
unlock_kernel();
return -EROFS;
}
#if 0
Expand All @@ -506,18 +513,21 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
ntfs_error(sb, "Failed to empty journal $LogFile%s",
es);
NVolSetErrors(vol);
unlock_kernel();
return -EROFS;
}
if (!ntfs_mark_quotas_out_of_date(vol)) {
ntfs_error(sb, "Failed to mark quotas out of date%s",
es);
NVolSetErrors(vol);
unlock_kernel();
return -EROFS;
}
if (!ntfs_stamp_usnjrnl(vol)) {
ntfs_error(sb, "Failed to stamp transation log "
"($UsnJrnl)%s", es);
NVolSetErrors(vol);
unlock_kernel();
return -EROFS;
}
} else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) {
Expand All @@ -533,8 +543,11 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)

// TODO: Deal with *flags.

if (!parse_options(vol, opt))
if (!parse_options(vol, opt)) {
unlock_kernel();
return -EINVAL;
}
unlock_kernel();
ntfs_debug("Done.");
return 0;
}
Expand Down
Loading

0 comments on commit 337eb00

Please sign in to comment.