[PATCH] Re: mount corrupts ramdisk

Kurt Garloff (K.Garloff@ping.de)
Mon, 22 Feb 1999 13:03:16 +0100


--/NkBOFFp2J2Af1nK
Content-Type: multipart/mixed; boundary=qMm9M+Fa2AknHoGS

--qMm9M+Fa2AknHoGS
Content-Type: text/plain; charset=us-ascii

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]

--qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Description: 221-ramdisk.fix Content-Disposition: attachment; filename="221-ramdisk.fix"

--- 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.

--qMm9M+Fa2AknHoGS--

--/NkBOFFp2J2Af1nK Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE----- Version: 2.6.3in

iQCVAwUBNtFHgxaQN/7O/JIVAQFhxgP/QMzyU4xwIeXYcfTwFV3FRsITSVMU7dkJ 6xZXniniIvDUqtDp5Jlbn0USOSyZz7MxkZ5KzMpPvR04+te4OHhoBSFTPBRi/1Sr HOOdobRDsx0wSedIhGzDBaZB04m2w/unEiUE/5xr2FrVpT0SDw8TPDXojArvciYt m34t9ibgedE= =eyJM -----END PGP SIGNATURE-----

--/NkBOFFp2J2Af1nK--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/