Commit c0b88a09 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] restoring block size upon umount

get_sb_bdev() stores original block size in ->s_old_blocksize and
kill_block_super() restores it.

This kills 99% of crap with "oh, I've mounted/umounted that device and
its behaviour had changed" (remaining 1% can be dealt in pretty similar
ways; ideally I'd like to see ioctls that get/set block size dead and
gone).
parent 0d9d0576
...@@ -177,7 +177,6 @@ void fat_put_super(struct super_block *sb) ...@@ -177,7 +177,6 @@ void fat_put_super(struct super_block *sb)
fat_clusters_flush(sb); fat_clusters_flush(sb);
} }
fat_cache_inval_dev(sb); fat_cache_inval_dev(sb);
set_blocksize (sb->s_dev,BLOCK_SIZE);
if (sbi->nls_disk) { if (sbi->nls_disk) {
unload_nls(sbi->nls_disk); unload_nls(sbi->nls_disk);
sbi->nls_disk = NULL; sbi->nls_disk = NULL;
......
...@@ -176,9 +176,6 @@ static void hfs_put_super(struct super_block *sb) ...@@ -176,9 +176,6 @@ static void hfs_put_super(struct super_block *sb)
/* release the MDB's resources */ /* release the MDB's resources */
hfs_mdb_put(mdb, sb->s_flags & MS_RDONLY); hfs_mdb_put(mdb, sb->s_flags & MS_RDONLY);
/* restore default blocksize for the device */
set_blocksize(sb->s_dev, BLOCK_SIZE);
kfree(sb->u.generic_sbp); kfree(sb->u.generic_sbp);
sb->u.generic_sbp = NULL; sb->u.generic_sbp = NULL;
} }
...@@ -449,7 +446,6 @@ int hfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -449,7 +446,6 @@ int hfs_fill_super(struct super_block *s, void *data, int silent)
struct hfs_sb_info *sbi; struct hfs_sb_info *sbi;
struct hfs_mdb *mdb; struct hfs_mdb *mdb;
struct hfs_cat_key key; struct hfs_cat_key key;
kdev_t dev = s->s_dev;
hfs_s32 part_size, part_start; hfs_s32 part_size, part_start;
struct inode *root_inode; struct inode *root_inode;
int part; int part;
...@@ -462,7 +458,7 @@ int hfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -462,7 +458,7 @@ int hfs_fill_super(struct super_block *s, void *data, int silent)
if (!parse_options((char *)data, sbi, &part)) { if (!parse_options((char *)data, sbi, &part)) {
hfs_warn("hfs_fs: unable to parse mount options.\n"); hfs_warn("hfs_fs: unable to parse mount options.\n");
goto bail3; goto bail2;
} }
/* set the device driver to 512-byte blocks */ /* set the device driver to 512-byte blocks */
...@@ -530,8 +526,6 @@ int hfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -530,8 +526,6 @@ int hfs_fill_super(struct super_block *s, void *data, int silent)
bail1: bail1:
hfs_mdb_put(mdb, s->s_flags & MS_RDONLY); hfs_mdb_put(mdb, s->s_flags & MS_RDONLY);
bail2: bail2:
set_blocksize(dev, BLOCK_SIZE);
bail3:
kfree(sbi); kfree(sbi);
s->u.generic_sbp = NULL; s->u.generic_sbp = NULL;
return -EINVAL; return -EINVAL;
......
...@@ -991,7 +991,6 @@ int function2code (hashf_t func) ...@@ -991,7 +991,6 @@ int function2code (hashf_t func)
// //
static int reiserfs_fill_super(struct super_block *s, void *data, int silent) static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
{ {
int size;
struct inode *root_inode; struct inode *root_inode;
int j; int j;
struct reiserfs_transaction_handle th ; struct reiserfs_transaction_handle th ;
...@@ -1013,9 +1012,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -1013,9 +1012,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
return -EINVAL; return -EINVAL;
} }
size = block_size(s->s_dev);
sb_set_blocksize(s, size);
/* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */ /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
if (!read_super_block (s, REISERFS_OLD_DISK_OFFSET_IN_BYTES)) if (!read_super_block (s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
old_format = 1; old_format = 1;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
#include <linux/acct.h> #include <linux/acct.h>
#include <linux/blkdev.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
void get_filesystem(struct file_system_type *fs); void get_filesystem(struct file_system_type *fs);
...@@ -513,6 +514,8 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type, ...@@ -513,6 +514,8 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
} else { } else {
s->s_flags = flags; s->s_flags = flags;
strncpy(s->s_id, bdevname(dev), sizeof(s->s_id)); strncpy(s->s_id, bdevname(dev), sizeof(s->s_id));
s->s_old_blocksize = block_size(dev);
sb_set_blocksize(s, s->s_old_blocksize);
error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0); error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
if (error) { if (error) {
up_write(&s->s_umount); up_write(&s->s_umount);
...@@ -535,6 +538,7 @@ void kill_block_super(struct super_block *sb) ...@@ -535,6 +538,7 @@ void kill_block_super(struct super_block *sb)
{ {
struct block_device *bdev = sb->s_bdev; struct block_device *bdev = sb->s_bdev;
generic_shutdown_super(sb); generic_shutdown_super(sb);
set_blocksize(to_kdev_t(bdev->bd_dev), sb->s_old_blocksize);
bd_release(bdev); bd_release(bdev);
blkdev_put(bdev, BDEV_FS); blkdev_put(bdev, BDEV_FS);
} }
......
...@@ -664,6 +664,7 @@ struct super_block { ...@@ -664,6 +664,7 @@ struct super_block {
kdev_t s_dev; kdev_t s_dev;
unsigned long s_blocksize; unsigned long s_blocksize;
unsigned char s_blocksize_bits; unsigned char s_blocksize_bits;
unsigned long s_old_blocksize;
unsigned char s_dirt; unsigned char s_dirt;
unsigned long long s_maxbytes; /* Max file size */ unsigned long long s_maxbytes; /* Max file size */
struct file_system_type *s_type; struct file_system_type *s_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment