2002-01-30 23:12:00

by Kris Urquhart

[permalink] [raw]
Subject: PROBLEM: ext2/mount - multiple mounts corrupts inodes

I have investigated this problem to the best of my resources. If someone
would
please direct me down some more avenues of discovery, I would greatly
appreciate
it. If someone would take the time and effort to duplicate this problem in
a
different environment, I would be even more grateful. Thanks. -Kris

[1.] One line summary of the problem:
A mount of an already mounted ext2 partition corrupts inodes if there have
been
recent writes without an intervening sync.

[2.] Full description of the problem/report:
I have a script that is not sure if an ext2 partition will already be
mounted, so
it tries the mount and is happy if the exit status is 0 or 32 (already
mounted).
This worked fine with the 2.2.17 kernel, but I started getting corrupted
inodes
when I migrated to 2.4.

I see this problem only when I compile my own kernel, but not when I use a
stock
RedHat kernel. I have searched the web, the RedHat kernel source rpm
patches,
and the RedHat Bugzilla database, but I can't find anything useful.

My .config is very stripped down (see end of email).

I can easily recreate this problem on two very different hardware setups,
with
two different compilers, and with multiple versions of the 2.4 kernel.

[3.] Keywords (i.e., modules, networking, kernel):
ext2, mount, file systems, kernel

[4.] Kernel version (from /proc/version):
Linux version 2.4.10 ([email protected]) (gcc version
egcs-2.91.66
19990314/Linux (egcs-1.1.2 release)) #1 Wed Jan 30 09:46:52 PST 2002

- I have also tried kernel versions 2.4.7 and 2.4.17, as well as gcc 2.96,
but no
change.

[6.] A small shell script or example program which triggers the problem (if
possible)
#!/bin/bash
DEVICE=./loopdev
MOUNT=/mnt/hd
umount $MOUNT
dd if=/dev/zero of=$DEVICE bs=1k count=5000
mke2fs -F $DEVICE
rm -rf $MOUNT
mkdir -p $MOUNT
mount -t ext2 -o loop $DEVICE $MOUNT
cp -r /bin/tar $MOUNT
cp -r /bin/zcat $MOUNT
#sleep 5
#sync
mount -t ext2 -o loop $DEVICE $MOUNT
find $MOUNT -ls
umount $MOUNT
umount $MOUNT

- A real block device can be used in place of the loop device, but is
obviously
destructive. I have tried local IDE drives (both solid state and magnetic),
as
well as NFS mounted SCSI drives.

- If either the sleep or the sync line is uncommented, then all is fine.

- Here is the output:
umount: /mnt/hd: not mounted
5000+0 records in
5000+0 records out
mke2fs 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
1256 inodes, 5000 blocks
250 blocks (5.00%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
1256 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
2 1 drwxr-xr-x 3 root root 1024 Jan 1 01:11 /mnt/hd
11 12 drwxr-xr-x 2 root root 12288 Jan 1 01:11
/mnt/hd/lost+found
find: /mnt/hd/tar: Input/output error
find: /mnt/hd/zcat: Input/output error

- When a loop device is used, e2fsck finds nothing wrong after the two
umount commands,
but does find problems if the second umount is commented out.
- If a real block device is used, e2fsck finds problems in either case:
% e2fsck -f /dev/hda3
e2fsck 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Entry 'tar' in / (2) has deleted/unused inode 12. Clear<y>? yes

Entry 'zcat' in / (2) has deleted/unused inode 13. Clear<y>? yes

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: -230 -231 -232 -233 -234 -235 -236 -237 -238 -239
-240
-241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255
-256
-257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271
-272
-273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287
-288
-289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303
-304
-305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319
-320
-321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335
-336
-337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351
-352
-353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367
-368
-369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383
-384
-385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399
-400
-401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415
-416
-417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430
Fix<y>? yes

Free blocks count wrong for group #0 (7762, counted=7963).
Fix<y>? yes

Free blocks count wrong (12919, counted=13120).
Fix<y>? yes

Inode bitmap differences: -12 -13
Fix<y>? yes

Free inodes count wrong for group #0 (1683, counted=1685).
Fix<y>? yes

Free inodes count wrong (3379, counted=3381).
Fix<y>? yes


/dev/hda3: ***** FILE SYSTEM WAS MODIFIED *****
/dev/hda3: 11/3392 files (0.0% non-contiguous), 446/13566 blocks

[7.] Environment
I have this problem on two very different systems: an AMD 586 133MHz 32Mb
RAM with a 16Mb flash drive, and an Intel Celeron 600MHz 128Mb RAM with
large
IDE drives. I can provide more details if desired.

[X.] Other notes, patches, fixes, workarounds:
Non-comment lines of .config for 2.4.10:
CONFIG_X86=y
CONFIG_ISA=y
CONFIG_UID16=y
CONFIG_MODULES=y
CONFIG_M486=y
CONFIG_X86_WP_WORKS_OK=y
CONFIG_X86_INVLPG=y
CONFIG_X86_CMPXCHG=y
CONFIG_X86_XADD=y
CONFIG_X86_BSWAP=y
CONFIG_X86_POPAD_OK=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_X86_L1_CACHE_SHIFT=4
CONFIG_X86_USE_STRING_486=y
CONFIG_X86_ALIGNMENT_16=y
CONFIG_NOHIGHMEM=y
CONFIG_NET=y
CONFIG_SYSVIPC=y
CONFIG_SYSCTL=y
CONFIG_KCORE_ELF=y
CONFIG_BINFMT_ELF=y
CONFIG_PARPORT=y
CONFIG_PARPORT_PC=y
CONFIG_PARPORT_PC_CML1=y
CONFIG_BLK_DEV_FD=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=20000
CONFIG_BLK_DEV_INITRD=y
CONFIG_PACKET=y
CONFIG_NETLINK=y
CONFIG_RTNETLINK=y
CONFIG_NETLINK_DEV=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_NETDEVICES=y
CONFIG_NET_ETHERNET=y
CONFIG_NET_PCI=y
CONFIG_CS89x0=y
CONFIG_PPP=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_BSDCOMP=y
CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_SERIAL_CONSOLE=y
CONFIG_UNIX98_PTYS=y
CONFIG_UNIX98_PTY_COUNT=2048
CONFIG_RTC=y
CONFIG_PROC_FS=y
CONFIG_DEVPTS_FS=y
CONFIG_EXT2_FS=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
CONFIG_SUNRPC=y
CONFIG_LOCKD=y
CONFIG_LOCKD_V4=y
CONFIG_MSDOS_PARTITION=y
CONFIG_VGA_CONSOLE=y
CONFIG_VIDEO_SELECT=y


2002-01-31 00:15:15

by Alexander Viro

[permalink] [raw]
Subject: Re: PROBLEM: ext2/mount - multiple mounts corrupts inodes



On Wed, 30 Jan 2002, Andreas Dilger wrote:

> On Jan 30, 2002 15:07 -0800, Kris Urquhart wrote:
> > [1.] One line summary of the problem:
> > A mount of an already mounted ext2 partition corrupts inodes if there have
> > been recent writes without an intervening sync.
>
> This _should_ be handled OK by the kernel simply by not mounting the
> filesystem the second time. If you try and mount it a second time it
> _should_ just do a "bind" mount instead of a real mount, I think.

Which is what actually happens. I suspect that he ends up forgetting to
umount it...

Anyway, try to reproduce it on 2.4.16 or later and give the contents of
/proc/mounts before and after your script.

2002-01-31 01:32:18

by Kris Urquhart

[permalink] [raw]
Subject: RE: PROBLEM: ext2/mount - multiple mounts corrupts inodes



> -----Original Message-----
> From: Alexander Viro [mailto:[email protected]]
> Sent: Wednesday, January 30, 2002 4:15 PM
> To: Andreas Dilger
> Cc: Kris Urquhart; '[email protected]'
> Subject: Re: PROBLEM: ext2/mount - multiple mounts corrupts inodes
>
>
>
>
> On Wed, 30 Jan 2002, Andreas Dilger wrote:
>
> > On Jan 30, 2002 15:07 -0800, Kris Urquhart wrote:
> > > [1.] One line summary of the problem:
> > > A mount of an already mounted ext2 partition corrupts
> inodes if there have
> > > been recent writes without an intervening sync.
> >
> > This _should_ be handled OK by the kernel simply by not mounting the
> > filesystem the second time. If you try and mount it a
> second time it
> > _should_ just do a "bind" mount instead of a real mount, I think.
>
> Which is what actually happens. I suspect that he ends up
> forgetting to
> umount it...
>
> Anyway, try to reproduce it on 2.4.16 or later and give the
> contents of
> /proc/mounts before and after your script.
>

I upgraded to 2.4.17, and inserted "cat /proc/mounts"
several places in my script.

The results are below, and definitely insightful.

When using a loop device, the second mount creates a
new loop device that reads a device file that is in an
unpredictable state since the first loop device is
still mounted with that device file as a source. Makes
sense to me; GIGO.

When using a disk partition, however, the second mount
appears to fail, but then yields the exact same results
as the loop device example. It appears that the second
mount actually replaced the first one, without giving the
first one a chance to sync to disk?

----------------- loop device --------------------------
+ DEVICE=./loopdev
+ MOUNT=/mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
+ umount /mnt/hd
umount: /mnt/hd: not mounted
+ dd if=/dev/zero of=./loopdev bs=1k count=5000
5000+0 records in
5000+0 records out
+ mke2fs -F ./loopdev
mke2fs 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
1256 inodes, 5000 blocks
250 blocks (5.00%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
1256 inodes per group

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
+ rm -rf /mnt/hd
+ mkdir -p /mnt/hd
+ mount -t ext2 -o loop ./loopdev /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
/dev/loop0 /mnt/hd ext2 rw 0 0
+ cp -r /bin/tar /mnt/hd
+ cp -r /bin/zcat /mnt/hd
+ mount -t ext2 -o loop ./loopdev /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
/dev/loop0 /mnt/hd ext2 rw 0 0
/dev/loop1 /mnt/hd ext2 rw 0 0
+ find /mnt/hd -ls
2 1 drwxr-xr-x 3 root root 1024 Dec 31 15:25 /mnt/hd
11 12 drwxr-xr-x 2 root root 12288 Dec 31 15:25
/mnt/hd/lost+found
find: /mnt/hd/tar: Input/output error
find: /mnt/hd/zcat: Input/output error
+ umount /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
/dev/loop0 /mnt/hd ext2 rw 0 0
+ umount /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd

---------------- disk partition ------------------------
+ DEVICE=/dev/hda3
+ MOUNT=/mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
+ umount /mnt/hd
umount: /mnt/hd: not mounted
+ dd if=/dev/zero of=/dev/hda3 bs=1k count=5000
5000+0 records in
5000+0 records out
+ mke2fs -F /dev/hda3
mke2fs 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
3392 inodes, 13566 blocks
678 blocks (5.00%) reserved for the super user
First data block=1
2 block groups
8192 blocks per group, 8192 fragments per group
1696 inodes per group
Superblock backups stored on blocks:
8193

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
+ rm -rf /mnt/hd
+ mkdir -p /mnt/hd
+ mount -t ext2 /dev/hda3 /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
/dev/hda3 /mnt/hd ext2 rw 0 0
+ cp -r /bin/tar /mnt/hd
+ cp -r /bin/zcat /mnt/hd
+ mount -t ext2 /dev/hda3 /mnt/hd
mount: /dev/hda3 already mounted or /mnt/hd busy
mount: according to mtab, /dev/hda3 is already mounted on /mnt/hd
+ grep /mnt/hd
+ cat /proc/mounts
/dev/hda3 /mnt/hd ext2 rw 0 0
+ find /mnt/hd -ls
2 1 drwxr-xr-x 3 root root 1024 Dec 31 15:17 /mnt/hd
11 12 drwxr-xr-x 2 root root 12288 Dec 31 15:17
/mnt/hd/lost+found
find: /mnt/hd/tar: Input/output error
find: /mnt/hd/zcat: Input/output error
+ umount /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
+ umount /mnt/hd
umount: /mnt/hd: not mounted
+ cat /proc/mounts
+ grep /mnt/hd

2002-01-30 23:42:44

by Andreas Dilger

[permalink] [raw]
Subject: Re: PROBLEM: ext2/mount - multiple mounts corrupts inodes

On Jan 30, 2002 15:07 -0800, Kris Urquhart wrote:
> [1.] One line summary of the problem:
> A mount of an already mounted ext2 partition corrupts inodes if there have
> been recent writes without an intervening sync.

This _should_ be handled OK by the kernel simply by not mounting the
filesystem the second time. If you try and mount it a second time it
_should_ just do a "bind" mount instead of a real mount, I think.

<stating the obvious>
Rather than mounting the device to try and see if it is already
mounted, use /proc/mounts or /etc/mtab or "df" or "mount" output
instead. Doctor, it hurts when I do this... ;-).
</stating the obvious>

Granted, this does appear to be a bug so the above will only work
around it and not fix it. Al Viro is the one to pester about it.
Hopefully he will see this email and reply (== fix the problem).

> [4.] Kernel version (from /proc/version):
> Linux version 2.4.10 ([email protected]) (gcc version
> egcs-2.91.66
> 19990314/Linux (egcs-1.1.2 release)) #1 Wed Jan 30 09:46:52 PST 2002

The 2.4.10 kernel is a bad one to use for several reasons, don't use it.

Cheers, Andreas

PS - nice bug report, if only all of them were this useful.
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

2002-01-31 04:47:03

by Andreas Dilger

[permalink] [raw]
Subject: Re: PROBLEM: ext2/mount - multiple mounts corrupts inodes

On Jan 30, 2002 17:27 -0800, Kris Urquhart wrote:
> When using a disk partition, however, the second mount
> appears to fail, but then yields the exact same results
> as the loop device example. It appears that the second
> mount actually replaced the first one, without giving the
> first one a chance to sync to disk?

It shouldn't have done so.

> + find /mnt/hd -ls
> 2 1 drwxr-xr-x 3 root root 1024 Dec 31 15:17 /mnt/hd
> 11 12 drwxr-xr-x 2 root root 12288 Dec 31 15:17
> /mnt/hd/lost+found
> find: /mnt/hd/tar: Input/output error
> find: /mnt/hd/zcat: Input/output error

Any interesting output in 'dmesg' when this happens?

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

2002-01-31 05:05:26

by Alexander Viro

[permalink] [raw]
Subject: RE: PROBLEM: ext2/mount - multiple mounts corrupts inodes



On Wed, 30 Jan 2002, Kris Urquhart wrote:

> + DEVICE=/dev/hda3
> + MOUNT=/mnt/hd
> + cat /proc/mounts
> + grep /mnt/hd
> + umount /mnt/hd
> umount: /mnt/hd: not mounted
[created fs on hda3]
> + rm -rf /mnt/hd
> + mkdir -p /mnt/hd
> + mount -t ext2 /dev/hda3 /mnt/hd
> + cat /proc/mounts
> + grep /mnt/hd
> /dev/hda3 /mnt/hd ext2 rw 0 0
> + cp -r /bin/tar /mnt/hd
> + cp -r /bin/zcat /mnt/hd
> + mount -t ext2 /dev/hda3 /mnt/hd
> mount: /dev/hda3 already mounted or /mnt/hd busy
> mount: according to mtab, /dev/hda3 is already mounted on /mnt/hd

Complains about mounting same fs on the same spot, refuses to mount.

> + grep /mnt/hd
> + cat /proc/mounts
> /dev/hda3 /mnt/hd ext2 rw 0 0
> + find /mnt/hd -ls
> 2 1 drwxr-xr-x 3 root root 1024 Dec 31 15:17 /mnt/hd
> 11 12 drwxr-xr-x 2 root root 12288 Dec 31 15:17
> /mnt/hd/lost+found
> find: /mnt/hd/tar: Input/output error
> find: /mnt/hd/zcat: Input/output error

WTF??? Very interesting... What about kernel messages? It looks like
stat(2) failing.

Just in case - could you put the same find before the second attempt of
mount?

2002-01-31 06:36:24

by H. Peter Anvin

[permalink] [raw]
Subject: Re: PROBLEM: ext2/mount - multiple mounts corrupts inodes

Followup to: <[email protected]>
By author: Andreas Dilger <[email protected]>
In newsgroup: linux.dev.kernel
>
> <stating the obvious>
> Rather than mounting the device to try and see if it is already
> mounted, use /proc/mounts or /etc/mtab or "df" or "mount" output
> instead. Doctor, it hurts when I do this... ;-).
> </stating the obvious>
>

ENOTATOMIC

Might not matter for a human user, but for a daemon like autofs it's
vital that atomicity is preserved.

-hpa
--
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <[email protected]>

2002-01-31 13:55:53

by Ishan O. Jayawardena

[permalink] [raw]
Subject: Re: PROBLEM: ext2/mount - multiple mounts corrupts inodes

Greetings everyone,

I'm afraid that try as I may, I couldn't reproduce Kris's symptoms.
This is with 2.4.18pre7aa1, No HIGHMEM, Plus a patch from _Andreas
Dilger_ (appended below), e2fsprogs 1.25, single IDE disk. Everything
works as expected.

Alexander Viro wrote:
> WTF??? Very interesting... What about kernel messages? It looks like
> stat(2) failing.

> Just in case - could you put the same find before the second attempt of
> mount?

Did that. Still No Problem. Gentlemen, this is a low end (real) IBM
machine with 64 MB SDRAM, 333 MHz Celeron (pre-Coppermine), 128 kb L2
cache (16 kb (*2?) L1), on sloooow vesafb, in X, while compiling
gcc-3.0.3 for C only :)

(I even did away with the umounts after the first runs were
successful... then just kept mounting over and over on the same
directory.) I'm afraid I can't test with plain 2.4.18-pre7 or anything
else as this is the only 2.4 kernel I have, and Kris did say the faults
were not reproducible on 2.2. Everything was done as root.

My Script:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/bash
DEVICE=./loopdev
MOUNT=/mnt/tmp

# umount $MOUNT

dd if=/dev/zero of=$DEVICE bs=1k count=1000
mke2fs -v -F $DEVICE
# rm -rf $MOUNT
# mkdir -p $MOUNT
mount -v -t ext2 -o loop $DEVICE $MOUNT
cp -vr /bin/tar $MOUNT
cp -vr /bin/zcat $MOUNT
#sleep 5
#sync

find $MOUNT -ls

mount -t ext2 -o loop $DEVICE $MOUNT

find $MOUNT -ls
# umount $MOUNT
# umount $MOUNT

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Andreas's patch (adopted for 2.4.1[78])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN PATCH
--- linux/fs/ext2/super.c Mon Jan 28 14:10:16 2002
+++ linux/fs/ext2/super.c.mod Mon Jan 28 13:41:06 2002
@@ -286,14 +286,14 @@ static int ext2_setup_super (struct supe
struct ext2_super_block * es,
int read_only)
{
- int res = 0;
+ if (read_only)
+ return 0;
if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
printk ("EXT2-fs warning: revision level too high, "
"forcing read-only mode\n");
- res = MS_RDONLY;
+ sb->s_flags |= MS_RDONLY;
+ return MS_RDONLY;
}
- if (read_only)
- return res;
if (!(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS))
printk ("EXT2-fs warning: mounting unchecked fs, "
"running e2fsck is recommended\n");
@@ -328,7 +328,7 @@ static int ext2_setup_super (struct supe
ext2_check_inodes_bitmap (sb);
}
#endif
- return res;
+ return 0;
}

static int ext2_check_descriptors (struct super_block * sb)
@@ -751,8 +751,9 @@ int ext2_remount (struct super_block * s
* by e2fsck since we originally mounted the partition.)
*/
sb->u.ext2_sb.s_mount_state = le16_to_cpu(es->s_state);
- if (!ext2_setup_super (sb, es, 0))
- sb->s_flags &= ~MS_RDONLY;
+ if (ext2_setup_super (sb, es, 0))
+ return -EROFS;
+ sb->s_flags &= ~MS_RDONLY;
}
ext2_sync_super(sb, es);
return 0;
~~~~~~~~~~~~~~~~~~~~~ END PATCH

Hope this helps...

Cheerio!
alvin
~~~~
We build a virtual shell around us to keep away the sorrows of life.
Most of us are very good at it... Those who aren't good enough, become
saints.
.

2002-01-31 17:33:06

by Kris Urquhart

[permalink] [raw]
Subject: RE: PROBLEM: ext2/mount - multiple mounts corrupts inodes

> From: Andreas Dilger [mailto:[email protected]]
> Sent: Wednesday, January 30, 2002 8:46 PM
>
> > + find /mnt/hd -ls
> > 2 1 drwxr-xr-x 3 root root 1024 Dec
> 31 15:17 /mnt/hd
> > 11 12 drwxr-xr-x 2 root root 12288 Dec 31 15:17
> > /mnt/hd/lost+found
> > find: /mnt/hd/tar: Input/output error
> > find: /mnt/hd/zcat: Input/output error
>
> Any interesting output in 'dmesg' when this happens?
>

Dec 31 23:42:41 jumptec kernel: VFS: Disk change detected on device
ide0(3,3)
Dec 31 23:42:41 jumptec kernel: VFS: Disk change detected on device
ide0(3,3)
Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
Dec 31 23:42:41 jumptec kernel: invalidate: busy buffer
Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
Dec 31 23:42:41 jumptec kernel: invalidate: busy buffer
Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
Dec 31 23:42:41 jumptec kernel: invalidate: busy buffer
Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
Dec 31 23:42:41 jumptec kernel: invalidate: busy buffer
Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
Dec 31 23:42:41 jumptec kernel: VFS: busy inodes on changed media.

2002-01-31 17:36:15

by Kris Urquhart

[permalink] [raw]
Subject: RE: PROBLEM: ext2/mount - multiple mounts corrupts inodes

> From: Alexander Viro [mailto:[email protected]]
> Sent: Wednesday, January 30, 2002 9:05 PM
>
> > + grep /mnt/hd
> > + cat /proc/mounts
> > /dev/hda3 /mnt/hd ext2 rw 0 0
> > + find /mnt/hd -ls
> > 2 1 drwxr-xr-x 3 root root 1024 Dec
> 31 15:17 /mnt/hd
> > 11 12 drwxr-xr-x 2 root root 12288 Dec 31 15:17
> > /mnt/hd/lost+found
> > find: /mnt/hd/tar: Input/output error
> > find: /mnt/hd/zcat: Input/output error
>
> WTF??? Very interesting... What about kernel messages? It
> looks like
> stat(2) failing.

Yes, please see my recent reply to Andreas Dilger.

> Just in case - could you put the same find before the second
> attempt of
> mount?
>

+ find /mnt/hd -ls
2 1 drwxr-xr-x 3 root root 1024 Dec 31 23:42 /mnt/hd
11 12 drwxr-xr-x 2 root root 12288 Dec 31 23:42
/mnt/hd/lost+found
12 149 -rwxr-xr-x 1 root root 150796 Dec 31 23:42
/mnt/hd/tar
13 52 -rwxr-xr-x 1 root root 51228 Dec 31 23:42
/mnt/hd/zcat
+ mount -t ext2 /dev/hda3 /mnt/hd
mount: /dev/hda3 already mounted or /mnt/hd busy
mount: according to mtab, /dev/hda3 is already mounted on /mnt/hd
+ cat /proc/mounts
+ grep /mnt/hd
/dev/hda3 /mnt/hd ext2 rw 0 0
+ find /mnt/hd -ls
2 1 drwxr-xr-x 3 root root 1024 Dec 31 23:42 /mnt/hd
11 12 drwxr-xr-x 2 root root 12288 Dec 31 23:42
/mnt/hd/lost+found
find: /mnt/hd/tar: Input/output error
find: /mnt/hd/zcat: Input/output error

2002-01-31 21:58:03

by Alexander Viro

[permalink] [raw]
Subject: RE: PROBLEM: ext2/mount - multiple mounts corrupts inodes



On Thu, 31 Jan 2002, Kris Urquhart wrote:

> Dec 31 23:42:41 jumptec kernel: VFS: Disk change detected on device
> ide0(3,3)
> Dec 31 23:42:41 jumptec kernel: VFS: Disk change detected on device
> ide0(3,3)
> Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer

I'd say... Looks like a broken disk change check and everything after
that is not a surprise.

What patches do you have applied and what chipset it is?

2002-01-31 23:52:27

by Kris Urquhart

[permalink] [raw]
Subject: RE: PROBLEM: ext2/mount - multiple mounts corrupts inodes

> -----Original Message-----
> From: Alexander Viro [mailto:[email protected]]
> Sent: Thursday, January 31, 2002 1:58 PM

> On Thu, 31 Jan 2002, Kris Urquhart wrote:
>
> > Dec 31 23:42:41 jumptec kernel: VFS: Disk change detected on device
> > ide0(3,3)
> > Dec 31 23:42:41 jumptec kernel: VFS: Disk change detected on device
> > ide0(3,3)
> > Dec 31 23:42:41 jumptec kernel: invalidate: dirty buffer
>
> I'd say... Looks like a broken disk change check and everything after
> that is not a surprise.
>
> What patches do you have applied and what chipset it is?
>

No patches - linux-2.4.17 right off of http://www.linux.org.

The chipset is an ALI 1487/1489.
The disk itself is a JUMPtec DISKchip with a SanDisk 20-99-00024-1 on it.

The relevant lines from dmesg are:
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
hda: SunDisk SDTB-128, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hda: 31360 sectors (16 MB) w/1KiB Cache, CHS=490/2/32
Partition check:
hda: hda1 hda2 hda3

% cat /proc/ide/driver
ide-disk version 1.10

There is a CONFIG_BLK_DEV_ALI14XX, but apparently it only turns on
support for the second channel. I tried it anyway (along with the
ide0=ali14xx boot parameter), but the disk was then not recognized
at boot time (busy/timeout during partition check). A google search
did not turn up any problems with ali14xx.c since 2.0.

What else should I try?

Thanks.

-Kris



2002-02-01 02:14:45

by Alexander Viro

[permalink] [raw]
Subject: false positives on disk change checks



On Thu, 31 Jan 2002, Kris Urquhart wrote:

> No patches - linux-2.4.17 right off of http://www.linux.org.
>
> The chipset is an ALI 1487/1489.
> The disk itself is a JUMPtec DISKchip with a SanDisk 20-99-00024-1 on it.
>
> The relevant lines from dmesg are:
> Uniform Multi-Platform E-IDE driver Revision: 6.31
> ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
> hda: SunDisk SDTB-128, ATA DISK drive
> ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
> hda: 31360 sectors (16 MB) w/1KiB Cache, CHS=490/2/32
> Partition check:
> hda: hda1 hda2 hda3
>
> % cat /proc/ide/driver
> ide-disk version 1.10
>
> There is a CONFIG_BLK_DEV_ALI14XX, but apparently it only turns on
> support for the second channel. I tried it anyway (along with the
> ide0=ali14xx boot parameter), but the disk was then not recognized
> at boot time (busy/timeout during partition check). A google search
> did not turn up any problems with ali14xx.c since 2.0.

Andre, looks like setup above gives false positives on disk change check...


2002-02-01 09:34:14

by Joerg

[permalink] [raw]
Subject: RE: false positives on disk change checks

Alexander Viro <[email protected]> wrote:

> Andre, looks like setup above gives false positives on disk change
> check...

I don't know the original posters problem, but I suspect I see something
similar. On a to be embedded system with a Geode (Cyrix) CPU and with a
ATA compatible CompactFlash drive I get the following messages on bootup:

invalidate: busy buffer
VFS: busy inodes on changed media.

This seems to happen while the system tries to remount the root fs rw.

My Boot messages (plain Marcello 2.4.17):

LILO 21.7 boot:
Loading linux.........
Linux version 2.4.17 (jpo@crt-kref) (gcc version 2.95.3 20010315 (SuSE))
#3 Mit
Jan 30 18:52:57 CET 2002
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 00000000000a0000 (usable)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 0000000007e80000 (usable)
BIOS-e820: 00000000ffff0000 - 0000000100000000 (reserved)
On node 0 totalpages: 32384
zone(0): 4096 pages.
zone(1): 28288 pages.
zone(2): 0 pages.
Kernel command line: BOOT_IMAGE=linux root=1641 console=ttyS0,38400
console=tty0Initializing CPU#0
Working around Cyrix MediaGX virtual DMA bugs.
Console: colour VGA+ 80x25
Calibrating delay loop... 95.84 BogoMIPS
Memory: 125812k/129536k available (746k kernel code, 3340k reserved, 161k
data,
68k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode...
Ok.
Dentry-cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode-cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
Working around Cyrix MediaGX virtual DMA bugs.
CPU: Cyrix Geode(TM) Integrated Processor by National Semi stepping 01
Checking 'hlt' instruction... OK.
POSIX conformance testing by UNIFIX
PCI: PCI BIOS revision 2.10 entry at 0xfae70, last bus=0
PCI: Using configuration type 1
PCI: Probing PCI hardware
PCI: Using IRQ router NatSemi [1078/0100] at 00:12.0
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Detected PS/2 Mouse Port.
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ
SERIAL_PCI enabled
ttyS00 at 0x03f8 (irq = 4) is a 16550A
ttyS01 at 0x02f8 (irq = 3) is a 16550A
block: 128 slots per queue, batch=32
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 33MHz system bus speed for PIO modes; override with
idebus=xx
CS5530: IDE controller on PCI bus 00 dev 92
CS5530: chipset revision 0
CS5530: not 100% native mode: will probe irqs later
hdd: Key Technology Corp. ATA-KUO WizardPlus, ATA DISK drive
ide1 at 0x170-0x177,0x376 on irq 15
hdd: 251904 sectors (129 MB) w/0KiB Cache, CHS=984/16/16
Partition check:
hdd:spurious 8259A interrupt: IRQ7.
hdd1 hdd2
Floppy drive(s): fd0 is 1.44M
FDC 0 is a post-1991 82077
PPP generic driver version 2.4.1
8139too Fast Ethernet driver 0.9.22
PCI: Found IRQ 11 for device 00:0c.0
eth0: RealTek RTL8139 Fast Ethernet at 0xc8800000, 00:e0:4c:71:05:92, IRQ
11
PCI: Found IRQ 10 for device 00:0d.0
eth1: RealTek RTL8139 Fast Ethernet at 0xc8802000, 00:e0:4c:71:05:91, IRQ
10
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 8192 bind 8192)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
hdd: hdd1 hdd2
hdd: hdd1 hdd2
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 68k freed
invalidate: busy buffer
VFS: busy inodes on changed media.

Regards
Joerg

=====
--
Regards
Joerg


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com

2002-02-01 10:28:19

by Joerg

[permalink] [raw]
Subject: RE: false positives on disk change checks

I wrote:

> I don't know the original posters problem, but I suspect I see something
> similar. On a to be embedded system with a Geode (Cyrix) CPU and with a
> ATA compatible CompactFlash drive I get the following messages on
> bootup:
>
> invalidate: busy buffer
> VFS: busy inodes on changed media.
>
> This seems to happen while the system tries to remount the root fs rw.

The following patch works around the problem for me:

diff -ruN linux/drivers/ide/ide-probe.c
linux-scorpio/drivers/ide/ide-probe.c
--- linux/drivers/ide/ide-probe.c Mon Nov 26 14:29:17 2001
+++ linux-scorpio/drivers/ide/ide-probe.c Fri Feb 1 12:06:59 2002
@@ -154,11 +154,14 @@
return;
}

+#if 0
/*
* Not an ATAPI device: looks like a "regular" hard disk
*/
if (id->config & (1<<7))
drive->removable = 1;
+#endif
+
/*
* Prevent long system lockup probing later for non-existant
* slave drive if the hwif is actually a flash memory card of some
variety:

It's obviously not a general solution but I know for sure that
the flashdisk is not removable in our setup.

Regards
Joerg

=====
--
Regards
Joerg


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com

2002-02-01 11:15:13

by Andre Hedrick

[permalink] [raw]
Subject: Re: false positives on disk change checks

On Thu, 31 Jan 2002, Alexander Viro wrote:

>
>
> On Thu, 31 Jan 2002, Kris Urquhart wrote:
>
> > No patches - linux-2.4.17 right off of http://www.linux.org.
> >
> > The chipset is an ALI 1487/1489.
> > The disk itself is a JUMPtec DISKchip with a SanDisk 20-99-00024-1 on it.
> >
> > The relevant lines from dmesg are:
> > Uniform Multi-Platform E-IDE driver Revision: 6.31
> > ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
> > hda: SunDisk SDTB-128, ATA DISK drive
> > ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
> > hda: 31360 sectors (16 MB) w/1KiB Cache, CHS=490/2/32
> > Partition check:
> > hda: hda1 hda2 hda3
> >
> > % cat /proc/ide/driver
> > ide-disk version 1.10
> >
> > There is a CONFIG_BLK_DEV_ALI14XX, but apparently it only turns on
> > support for the second channel. I tried it anyway (along with the
> > ide0=ali14xx boot parameter), but the disk was then not recognized
> > at boot time (busy/timeout during partition check). A google search
> > did not turn up any problems with ali14xx.c since 2.0.
>
> Andre, looks like setup above gives false positives on disk change check...

What do you expect w/ removable media.
Obivious it has to be reporting an media status event change.
Gawd knows where I could find a copy of the hardware to verify.
If it puts a patch of mine on it and it is still present there is a
problem, if it goes away with the patch, the kernel should take the patch.

Regards,

Andre Hedrick
Linux Disk Certification Project Linux ATA Development

2002-02-01 11:20:43

by Andre Hedrick

[permalink] [raw]
Subject: RE: false positives on disk change checks

On Fri, 1 Feb 2002, Joerg Pommnitz wrote:

> I wrote:
>
> > I don't know the original posters problem, but I suspect I see something
> > similar. On a to be embedded system with a Geode (Cyrix) CPU and with a
> > ATA compatible CompactFlash drive I get the following messages on
> > bootup:
> >
> > invalidate: busy buffer
> > VFS: busy inodes on changed media.
> >
> > This seems to happen while the system tries to remount the root fs rw.
>
> The following patch works around the problem for me:
>
> diff -ruN linux/drivers/ide/ide-probe.c
> linux-scorpio/drivers/ide/ide-probe.c
> --- linux/drivers/ide/ide-probe.c Mon Nov 26 14:29:17 2001
> +++ linux-scorpio/drivers/ide/ide-probe.c Fri Feb 1 12:06:59 2002
> @@ -154,11 +154,14 @@
> return;
> }
>
> +#if 0
> /*
> * Not an ATAPI device: looks like a "regular" hard disk
> */
> if (id->config & (1<<7))
> drive->removable = 1;
> +#endif
> +
> /*
> * Prevent long system lockup probing later for non-existant
> * slave drive if the hwif is actually a flash memory card of some
> variety:
>
> It's obviously not a general solution but I know for sure that
> the flashdisk is not removable in our setup.

REGARDLESS, it is removable media and this it reports so.
The driver will not change to create false reports, because CFA has its
own rules, and if you can figure them out great.

Removable media shall always report as Removable media.

If you purchase enough of the media, the OEM will allow you to alter the
identify page and this it will not longer report "Removable".

Regards,


Andre Hedrick
Linux Disk Certification Project Linux ATA Development

2002-02-01 17:38:25

by Kris Urquhart

[permalink] [raw]
Subject: RE: false positives on disk change checks



> -----Original Message-----
> From: Andre Hedrick [mailto:[email protected]]
> Sent: Friday, February 01,
> >
> > Andre, looks like setup above gives false positives on disk
> change check...
>
> What do you expect w/ removable media.
> Obivious it has to be reporting an media status event change.
> Gawd knows where I could find a copy of the hardware to verify.
> If it puts a patch of mine on it and it is still present there is a
> problem, if it goes away with the patch, the kernel should
> take the patch.
>

I tried ide.2.4.17.01192002.patch, with no change.
Is there a different patch you would like me to try?

Thanks.

-Kris