lkml.org 
[lkml]   [1999]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Re: mount corrupts ramdisk
On Thu, Feb 11, 1999 at 11:19:52AM +0000, Stephen C. Tweedie wrote:
> No. There is no way I'll support the idea of making set_blocksize
> preserve data in the buffer cache. That is just brain-dead. So if
> you want to go and change every filesystem in the kernel to support
> non-local blocksizes, go right ahead.
>
> The "right" fix is to make set_blocksize fail on an in-use ramdisk,
> NOT to support changing the blocksize for existing buffers. Allowing
> the user to set a correct blocksize via ioctl before mkfsing the
> device in the first place makes a ton of sense, however.

Appended is a patch which prevents the blocksize of ramdisks from being
changed with set_blocksize(). As the function is void and does not return
any error code, which could be checked, I added a check to fat_read_super().

Now, if I want to mount a FAT fs with blocksize==512, it fails:
Feb 22 12:51:17 kg1 kernel: Changing blocksize (dev 01:00) from 1024 to 512 not possible
Feb 22 12:51:17 kg1 kernel: fat_read_super: set_blocksize (dev 01:00) failed

The patch is not very nice, as
* it teaches buffer.c, that a ramdisk is not blocksize settable, while this
info should be contained in rd.c. However, there's no way to tell the
buffer code.
* it would be better not to have the check for failure of set_blocksize() by
accessing blksize_size[][], but by checking the return code of
set_blocksize().

However, the patch is the one with minimal changes and thus the right one
for 2.2.2, IMHO.
Maybe, Stephen will create a better one?


Patch appended.
--
Kurt Garloff <kurt@garloff.de> [Dortmund, FRG]
Plasma physics, high perf. computing [Linux-ix86,-axp, DUX]
PGP key: see mailheader [Linux SCSI driver: DC390]
--- linux/fs/buffer.c.orig Sat Feb 20 12:06:17 1999
+++ linux/fs/buffer.c Mon Feb 22 12:37:27 1999
@@ -648,6 +648,14 @@
}
if (blksize_size[MAJOR(dev)][MINOR(dev)] == size)
return;
+
+ /* kurt@garloff.de, 99/02/22: Prevent ramdisk's block size from being changed */
+ if (MAJOR(dev) == RAMDISK_MAJOR) {
+ printk ("Changing blocksize (dev %02x:%02x) from %i to %i not possible\n",
+ MAJOR(dev), MINOR(dev), blksize_size[MAJOR(dev)][MINOR(dev)], size);
+ return;
+ };
+
sync_buffers(dev, 2);
blksize_size[MAJOR(dev)][MINOR(dev)] = size;

--- linux/fs/fat/inode.c.orig Mon Jan 4 19:08:28 1999
+++ linux/fs/fat/inode.c Mon Feb 22 12:42:02 1999
@@ -329,6 +329,13 @@
goto out_no_bread;
}
set_blocksize(sb->s_dev, blksize);
+ /* kurt@garloff.de, 99/02/22: Check for failure of set_blocksize */
+ if (blksize != blksize_size[MAJOR(sb->s_dev)][MINOR(sb->s_dev)]) {
+ printk ("fat_read_super: set_blocksize (dev %02x:%02x) failed\n",
+ MAJOR(sb->s_dev), MINOR(sb->s_dev));
+ fat_brelse (sb, bh);
+ goto out_fail;
+ }

/*
* The DOS3 partition size limit is *not* 32M as many people think. [unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.079 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site