Bug 124621 - [ext3] [patch] Cannot mount ext2fs partition
Summary: [ext3] [patch] Cannot mount ext2fs partition
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-15 21:30 UTC by Paul Floyd
Modified: 2010-12-15 18:18 UTC (History)
0 users

See Also:


Attachments
ext2fs.diff (2.09 KB, patch)
2008-09-04 18:16 UTC, josh.carroll
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2008-06-15 21:30:01 UTC
Fedora 9 (and perhaps other distros) has changed ext2fs in a way that is not backwards compatible (changing the inode size from 128bytes to 256bytes). This renders ext2fs partitions unmountable by FreeBSD.

Fix: 

Formatted the partition with gparted (under debian etch) prior to running the Fedora 9 installer, and made sure to not format the partition during the installation.
How-To-Repeat: Install Fedora 9 and les the installer format its destination partition as ext3
Comment 1 Gavin Atkinson freebsd_committer freebsd_triage 2008-06-16 01:03:20 UTC
Responsible Changed
From-To: freebsd-i386->freebsd-fs

This doesn't sound -i386 specific
Comment 2 josh.carroll 2008-09-03 19:28:58 UTC
Here is a simple patch that queries the inode size, rather than assuming 128.

This may be a rather naive way to do this (querying it every time from
(s)->s_es->s_inode_size), but it does seem to work. Perhaps there is a
smarter way of doing this (setting something at mount time?).

I tested this with mke2fs -I 128, mke2fs (defaults to -I 256 with the
latest e2fsprogs port), and -I 512.

Thanks,
Josh


diff -ud ext2fs.orig/ext2_fs.h ext2fs/ext2_fs.h
--- ext2fs.orig/ext2_fs.h       2005-06-16 06:51:38.000000000 +0000
+++ ext2fs/ext2_fs.h    2008-09-03 14:10:27.000000000 +0000
@@ -150,7 +150,7 @@
 #else /* !notyet */
 #define        EXT2_INODES_PER_BLOCK(s)        ((s)->s_inodes_per_block)
 /* Should be sizeof(struct ext2_inode): */
-#define EXT2_INODE_SIZE                        128
+#define EXT2_INODE_SIZE(s)             ((s)->s_es->s_inode_size)
 #define EXT2_FIRST_INO                 11
 #endif /* notyet */

diff -ud ext2fs.orig/ext2_inode.c ext2fs/ext2_inode.c
--- ext2fs.orig/ext2_inode.c    2006-09-26 04:15:58.000000000 +0000
+++ ext2fs/ext2_inode.c 2008-09-03 13:54:49.000000000 +0000
@@ -91,7 +91,7 @@
                return (error);
        }
        ext2_i2ei(ip, (struct ext2_inode *)((char *)bp->b_data +
-           EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)));
+           EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)));
        if (waitfor && (vp->v_mount->mnt_kern_flag & MNTK_ASYNC) == 0)
                return (bwrite(bp));
        else {
diff -ud ext2fs.orig/ext2_vfsops.c ext2fs/ext2_vfsops.c
--- ext2fs.orig/ext2_vfsops.c   2008-04-03 18:51:13.000000000 +0000
+++ ext2fs/ext2_vfsops.c        2008-09-03 13:55:37.000000000 +0000
@@ -424,7 +424,7 @@
     V(s_frags_per_group)
     fs->s_inodes_per_group = es->s_inodes_per_group;
     V(s_inodes_per_group)
-    fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE;
+    fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE(fs);
     V(s_inodes_per_block)
     fs->s_itb_per_group = fs->s_inodes_per_group /fs->s_inodes_per_block;
     V(s_itb_per_group)
@@ -578,7 +578,7 @@
                        return (error);
                }
                ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data +
-                   EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)), ip);
+                   EXT2_INODE_SIZE(fs) * ino_to_fsbo(fs, ip->i_number)), ip);
                brelse(bp);
                VOP_UNLOCK(vp, 0, td);
                vrele(vp);
@@ -1013,7 +1013,7 @@
                return (error);
        }
        /* convert ext2 inode to dinode */
-       ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE *
+       ext2_ei2i((struct ext2_inode *) ((char *)bp->b_data +
EXT2_INODE_SIZE(fs) *
                        ino_to_fsbo(fs, ino)), ip);
        ip->i_block_group = ino_to_cg(fs, ino);
        ip->i_next_alloc_block = 0;
Comment 3 josh.carroll 2008-09-04 18:16:55 UTC
Sorry, it appears the previous patch was munged by gmail.

I'm trying it as an attachment this time. I apologize in advance if
this attempt is also munged.

Josh
Comment 4 josh.carroll 2008-09-04 18:42:36 UTC
Sigh. Apologies again.

Let's try it this way. Here is the patch:

http://pflog.net/~floyd/ext2fs.diff

Thanks,
Josh
Comment 5 Wesley Shields freebsd_committer 2008-09-04 18:50:07 UTC
From reading of the release notes it looks like this change was made in
January 2008.

http://e2fsprogs.sourceforge.net/e2fsprogs-release.html#1.40.10

I tested the patch that is online from Josh and it works.  Is anyone
willing to step up and commit this?  Seems like a simple enough fix and
will start to hit more and more people as updated versions of e2fsprogs
becomes more common.

Thanks, Josh, for providing a fix for this.

-- WXS
Comment 6 Helio Loureiro 2009-01-12 16:34:16 UTC
Hi,

I'm facing the same issue.  I have an external HD, where I installed
Linux Ubuntu a long time ago.  I performed recently an upgrade to
latest Ubuntu, what reformatted partition da0s1.  Old partitions, like
da0s2 (home), remain working fine w/ FreeBSD.

I checked Inode size paramenter in both:

musashi# tune2fs -l /dev/da0s1 | grep -i "inode size"
Inode size:               256
musashi# tune2fs -l /dev/da0s2 | grep -i "inode size"
Inode size:               128

I'm using the e2fsprogs version you recommended, 1.41.0, in a FreeBSD-7.1:

musashi# pkg_glob "*e2fs*"
e2fsprogs-1.41.0
musashi# uname -a
FreeBSD musashi.br.am.ericsson.se 7.1-RELEASE FreeBSD 7.1-RELEASE #23:
Sat Jan  3 23:41:26 BRST 2009
root@musashi.br.am.ericsson.se:/usr/obj/usr/src/sys/MUSASHI  i386


So programs like fsck.ext3 are working fine, finding and checking filesyste=
ms:

e2fsck 1.41.0 (10-Jul-2008)
/dev/da0s1: clean, 130703/305824 files, 796572/1220932 blocks
musashi# /usr/local/sbin/fsck.ext3 /dev/da0s2
e2fsck 1.41.0 (10-Jul-2008)
/dev/da0s2: clean, 219500/12222464 files, 21270465/24414783 blocks

So da0s1 isn't accessible while da0s2 is:

musashi# mkdir /mnt/da0s{1,2}
musashi# mount_ext2fs /dev/da0s1 /mnt/da0s1
musashi# mount_ext2fs /dev/da0s2 /mnt/da0s2
musashi# ls /mnt/da0s1
ls: /mnt/da0s1: Bad file descriptor
musashi# ls /mnt/da0s2
backup          fotos           helio           lost+found      tmp
         x

I even tried to unload/load ext2fs.ko module, but I didn't see any
progress on that.

So I believe the issue is reproducible and remains despite the new
e2fsprogs release.

I'll try the suggested patch and see if it works.
--=20
[]=B4s
Helio Loureiro
Comment 7 Stanislav Sedov freebsd_committer 2009-01-18 17:23:22 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, Paul!

Can you check, please, if recent current suffers from the same
problem? The patch I've committed today should solve this issue.
I can give you a patch for 7.1 if you're in position to rebuild
the kernel.

Thanks!
- -- 
Stanislav Sedov
ST4096-RIPE
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAklzZYoACgkQK/VZk+smlYGE/ACdE+ybZzJxb/5Nb1Qi1CyILVtW
6aAAnieoGkMpBCoFvwKAE1yVWgxu5pbA
=Nn7G
-----END PGP SIGNATURE-----

!DSPAM:49736588967004808450424!
Comment 8 Stanislav Sedov freebsd_committer 2009-01-18 17:26:15 UTC
State Changed
From-To: open->feedback

Ask for submitter test.
Comment 9 jflemer 2009-07-04 03:23:53 UTC
Environment:
FreeBSD cage.local 7.1-STABLE FreeBSD 7.1-STABLE #1: Thu Jan  8
20:10:28 PST 2009
root@cage.local:/mnt/space/usr/obj.i386/mnt/space/usr/src/sys/CAGE7-SMP
 i386

Just another data point, the patch
(http://pflog.net/~floyd/ext2fs.diff,
md5:3dd5125eeb591e9c53930beb216d523e) fixes mounting a ext3 partition
from an Ubuntu 9.4 install.  Confirmed with tune2fs that the partition
has 256-byte inode size.  Tested by applying patch and rebuilding in
/usr/src/sys/modules/ext2fs.
Comment 10 Jaakko Heinonen freebsd_committer 2009-10-31 14:41:11 UTC
State Changed
From-To: feedback->patched

Patched in head / stable/8 by r187395 and in stable/7 by r194495.
Comment 11 Jaakko Heinonen freebsd_committer 2010-12-15 18:18:06 UTC
State Changed
From-To: patched->closed

Fixed in all supported branches.