NetBSD Problem Report #40936

From www@NetBSD.org  Sun Mar  1 14:50:55 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 2333063C1DC
	for <gnats-bugs@gnats.netbsd.org>; Sun,  1 Mar 2009 14:50:55 +0000 (UTC)
Message-Id: <20090301145054.E4CF863C1DB@www.NetBSD.org>
Date: Sun,  1 Mar 2009 14:50:54 +0000 (UTC)
From: frederik.sausmikat@gmx.de
Reply-To: frederik.sausmikat@gmx.de
To: gnats-bugs@NetBSD.org
Subject: ext2fs: add support for inodes > 128 bytes
X-Send-Pr-Version: www-1.0

>Number:         40936
>Category:       kern
>Synopsis:       ext2fs: add support for inodes > 128 bytes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 01 14:55:00 +0000 2009
>Closed-Date:    Sun Mar 01 16:00:41 +0000 2009
>Last-Modified:  Mon Jan 17 12:50:01 +0000 2011
>Originator:     Frederik Sausmikat
>Release:        4.0.1
>Organization:
>Environment:
>Description:
In recent Linux distributions it has become common practice to create ext2/ext3 filesystems with inode sizes of 256 bytes (or more) which NetBSD doesn't support since the ext2fs code is fixed to 128 bytes/inode.

I'm not aware what the additional space in the inode actually is used for but a quick search on Google indicated this had been done in preparation for the upcoming ext4 filesystem.

The attached patch, which applies against CURRENT, is essentially copy & pasted (with minor adjustments) from a patch that was commited to the OpenBSD source tree about three months ago which in turn had been posted in a PR for FreeBSD.

I've tested it with a 4.0.1 and CURRENT kernel and it seems to work without problems so far.

For some more information on the patch see:
<http://www.nabble.com/ext2-with-inode-size-other-than-128b-td20550369.html>
and
<http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/124621>

>How-To-Repeat:
Try to mount an ext2/ext3 filesystem whose inode size is greater than 128 bytes.
>Fix:
Index: ext2fs_dinode.h
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_dinode.h,v
retrieving revision 1.17
diff -u -r1.17 ext2fs_dinode.h
--- ext2fs_dinode.h	23 Nov 2008 10:09:25 -0000	1.17
+++ ext2fs_dinode.h	1 Mar 2009 11:04:16 -0000
@@ -154,7 +154,7 @@
 #define EXT2_NODUMP		0x00000040	/* do not dump file */

 /* Size of on-disk inode. */
-#define	EXT2_DINODE_SIZE	(sizeof(struct ext2fs_dinode))	/* 128 */
+#define EXT2_DINODE_SIZE(s)	(s)->e2fs.e2fs_inode_size

 /*
  * The e2di_blocks fields may be overlaid with other information for
Index: ext2fs_inode.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_inode.c,v
retrieving revision 1.67
diff -u -r1.67 ext2fs_inode.c
--- ext2fs_inode.c	17 Dec 2008 20:51:38 -0000	1.67
+++ ext2fs_inode.c	1 Mar 2009 11:04:16 -0000
@@ -221,7 +221,7 @@
 	}
 	ip->i_flag &= ~(IN_MODIFIED | IN_ACCESSED);
 	cp = (char *)bp->b_data +
-	    (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE);
+	    (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
 	e2fs_isave(ip->i_din.e2fs_din, (struct ext2fs_dinode *)cp);
 	if ((updflags & (UPDATE_WAIT|UPDATE_DIROP)) != 0 &&
 	    (flags & IN_MODIFIED) != 0 &&
Index: ext2fs_vfsops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_vfsops.c,v
retrieving revision 1.141
diff -u -r1.141 ext2fs_vfsops.c
--- ext2fs_vfsops.c	8 Dec 2008 11:34:30 -0000	1.141
+++ ext2fs_vfsops.c	1 Mar 2009 11:04:17 -0000
@@ -572,7 +572,7 @@
 	fs->e2fs_bmask = ~fs->e2fs_qbmask;
 	fs->e2fs_ngdb =
 	    howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd));
-	fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE;
+	fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE(fs);
 	fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb;

 	/*
@@ -640,7 +640,7 @@
 			break;
 		}
 		cp = (char *)bp->b_data +
-		    (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE);
+		    (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
 		e2fs_iload((struct ext2fs_dinode *)cp, ip->i_din.e2fs_din);
 		ext2fs_set_inode_guid(ip);
 		brelse(bp, 0);
@@ -690,8 +690,7 @@
 	ump = NULL;

 #ifdef DEBUG_EXT2
-	printf("sb size: %d ino size %d\n", sizeof(struct ext2fs),
-	    EXT2_DINODE_SIZE);
+	printf("ext2 sb size: %d\n", sizeof(struct ext2fs));
 #endif
 	error = bread(devvp, (SBOFF / size), SBSIZE, cred, 0, &bp);
 	if (error)
@@ -711,6 +710,10 @@
 	bp = NULL;
 	m_fs = ump->um_e2fs;
 	m_fs->e2fs_ronly = ronly;
+
+#ifdef DEBUG_EXT2
+	printf("ext2 ino size %d\n", EXT2_DINODE_SIZE(m_fs));
+#endif
 	if (ronly == 0) {
 		if (m_fs->e2fs.e2fs_state == E2FS_ISCLEAN)
 			m_fs->e2fs.e2fs_state = 0;
@@ -731,7 +734,7 @@
 	m_fs->e2fs_bmask = ~m_fs->e2fs_qbmask;
 	m_fs->e2fs_ngdb =
 	    howmany(m_fs->e2fs_ncg, m_fs->e2fs_bsize / sizeof(struct ext2_gd));
-	m_fs->e2fs_ipb = m_fs->e2fs_bsize / EXT2_DINODE_SIZE;
+	m_fs->e2fs_ipb = m_fs->e2fs_bsize / EXT2_DINODE_SIZE(m_fs);
 	m_fs->e2fs_itpg = m_fs->e2fs.e2fs_ipg / m_fs->e2fs_ipb;

 	m_fs->e2fs_gd = malloc(m_fs->e2fs_ngdb * m_fs->e2fs_bsize,
@@ -1072,7 +1075,7 @@
 		*vpp = NULL;
 		return (error);
 	}
-	cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE);
+	cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs));
 	ip->i_din.e2fs_din = pool_get(&ext2fs_dinode_pool, PR_WAITOK);
 	e2fs_iload((struct ext2fs_dinode *)cp, ip->i_din.e2fs_din);
 	ext2fs_set_inode_guid(ip);
@@ -1253,9 +1256,8 @@
 		return (EINVAL);	   /* XXX needs translation */
 	}
 	if (fs2h32(fs->e2fs_rev) > E2FS_REV0) {
-		if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO ||
-		    fs2h16(fs->e2fs_inode_size) != EXT2_DINODE_SIZE) {
-			printf("Ext2 fs: unsupported inode size\n");
+		if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) {
+			printf("Ext2 fs: unsupported first inode position\n");
 			return (EINVAL);      /* XXX needs translation */
 		}
 		if (fs2h32(fs->e2fs_features_incompat) &

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: christos@NetBSD.org
State-Changed-When: Sun, 01 Mar 2009 11:00:41 -0500
State-Changed-Why:
applied, thanks


From: Kurt Schreiner <ks@ub.uni-mainz.de>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: "kern-bug-people@netbsd.org" <kern-bug-people@NetBSD.org>,
   "netbsd-bugs@netbsd.org" <netbsd-bugs@NetBSD.org>,
   "gnats-admin@netbsd.org" <gnats-admin@NetBSD.org>,
   "christos@NetBSD.org" <christos@NetBSD.org>,
   "frederik.sausmikat@gmx.de" <frederik.sausmikat@gmx.de>
Subject: Re: kern/40936 (ext2fs: add support for inodes > 128 bytes)
Date: Sun, 1 Mar 2009 20:31:50 +0100

 On Sun, Mar 01, 2009 at 05:00:44PM +0100, christos@NetBSD.org wrote:
 > Synopsis: ext2fs: add support for inodes > 128 bytes
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: christos@NetBSD.org
 > State-Changed-When: Sun, 01 Mar 2009 11:00:41 -0500
 > State-Changed-Why:
 > applied, thanks

 Hm! Related?

 /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c: In function 'rea
 d_sblock':
 /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c:434: error: 'EXT2
 _DINODE_SIZE' undeclared (first use in this function)
 /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c:434: error: (Each
  undeclared identifier is reported only once
 /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c:434: error: for e
 ach function it appears in.)
 --- ext2fs.o ---
 *** [ext2fs.o] Error code 1
 1 error

 nbmake: stopped in /u/NetBSD/arch/amd64/obj/sys/arch/i386/stand/boot/lib/sa

 Kurt

From: christos@zoulas.com (Christos Zoulas)
To: ks@ub.uni-mainz.de, "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: "kern-bug-people@netbsd.org" <kern-bug-people@NetBSD.org>, 
	"netbsd-bugs@netbsd.org" <netbsd-bugs@NetBSD.org>, 
	"gnats-admin@netbsd.org" <gnats-admin@NetBSD.org>, 
	"frederik.sausmikat@gmx.de" <frederik.sausmikat@gmx.de>
Subject: Re: kern/40936 (ext2fs: add support for inodes > 128 bytes)
Date: Sun, 1 Mar 2009 14:37:42 -0500

 On Mar 1,  8:31pm, ks@ub.uni-mainz.de (Kurt Schreiner) wrote:
 -- Subject: Re: kern/40936 (ext2fs: add support for inodes > 128 bytes)

 | On Sun, Mar 01, 2009 at 05:00:44PM +0100, christos@NetBSD.org wrote:
 | > Synopsis: ext2fs: add support for inodes > 128 bytes
 | > 
 | > State-Changed-From-To: open->closed
 | > State-Changed-By: christos@NetBSD.org
 | > State-Changed-When: Sun, 01 Mar 2009 11:00:41 -0500
 | > State-Changed-Why:
 | > applied, thanks
 | 
 | Hm! Related?
 | 
 | /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c: In function 'rea
 | d_sblock':
 | /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c:434: error: 'EXT2
 | _DINODE_SIZE' undeclared (first use in this function)
 | /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c:434: error: (Each
 |  undeclared identifier is reported only once
 | /u/NetBSD/src/sys/arch/i386/stand/boot/biosboot/../../../../..//lib/libsa/ext2fs.c:434: error: for e
 | ach function it appears in.)
 | --- ext2fs.o ---
 | *** [ext2fs.o] Error code 1
 | 1 error

 Of course. Fixed.

 christos

From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40936 CVS commit: [netbsd-5] src
Date: Sun, 16 Jan 2011 12:38:28 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sun Jan 16 12:38:28 UTC 2011

 Modified Files:
 	src/sbin/fsck_ext2fs [netbsd-5]: inode.c setup.c
 	src/sbin/newfs_ext2fs [netbsd-5]: mke2fs.c newfs_ext2fs.8
 	    newfs_ext2fs.c
 	src/sys/lib/libsa [netbsd-5]: ext2fs.c
 	src/sys/ufs/ext2fs [netbsd-5]: ext2fs_dinode.h ext2fs_inode.c
 	    ext2fs_vfsops.c

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1486):
 	sbin/fsck_ext2fs/setup.c: revision 1.26
 	sbin/newfs_ext2fs/mke2fs.c: revision 1.10
 	sbin/newfs_ext2fs/mke2fs.c: revision 1.11
 	sbin/newfs_ext2fs/mke2fs.c: revision 1.12
 	sbin/fsck_ext2fs/inode.c: revision 1.24
 	sys/lib/libsa/ext2fs.c: revision 1.6
 	sbin/newfs_ext2fs/extern.h: revision 1.3
 	sbin/fsck_ext2fs/inode.c: revision 1.25
 	sys/lib/libsa/ext2fs.c: revision 1.7
 	sbin/fsck_ext2fs/inode.c: revision 1.26
 	sys/ufs/ext2fs/ext2fs_inode.c: revision 1.68
 	sbin/fsck_ext2fs/inode.c: revision 1.27
 	sbin/fsck_ext2fs/inode.c: revision 1.28
 	sys/ufs/ext2fs/ext2fs_dinode.h: revision 1.18
 	sys/ufs/ext2fs/ext2fs_dinode.h: revision 1.19
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.5
 	sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.2
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.6
 	sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.3
 	sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.142
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.7
 	sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.4
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.8
 PR/40936: Frederik Sausmikat: ext2fs: add support for inodes > 128 bytes
 Support variable inode sizes.
 catch up with variable inode size.
 Don't use e2fs_inode_size in superblock on E2FS_REV0 file system.
 - accept only EXT2_REV0_DINODE_SIZE inodesize on -O 0
 - use inodesize to get offset of inode, not struct ext2fs_dinode array
 Replace a magic number with a new EXT2_REV0_DINODE_SIZE macro.
 Use EXT2_DINODE_SIZE() to get offset of inode, not struct ext2fs_dinode array.
 Fix botched logic in inodesize check.
 Use inodesize to get offset of inode in one more place.
 - add a sanity check for e2fs_inode_size in readsb()
 - use EXT2_DINODE_SIZE() rather than sizeof(struct ext2fs_dinode) or
   struct ext2fs_dinode array/pointer to see e2fs_ipb and inode offsets
 Sort options.
 New sentence, new line.
 Sort options in usage.
 - unsigned -> unsigned int
 - remove unnecessary casts from malloc(3) and free(3)
 - fix a bogus indent
 Use "size > INT32_MAX" rather than "size >= 0x80000000U" to check 2GB limit.
 Add missed byteswap ops against ext2fs_dinode members.
 Handle 32 bit uid field on E2FS_REV1.


 To generate a diff of this commit:
 cvs rdiff -u -r1.23 -r1.23.2.1 src/sbin/fsck_ext2fs/inode.c
 cvs rdiff -u -r1.25 -r1.25.6.1 src/sbin/fsck_ext2fs/setup.c
 cvs rdiff -u -r1.9 -r1.9.2.1 src/sbin/newfs_ext2fs/mke2fs.c
 cvs rdiff -u -r1.1 -r1.1.16.1 src/sbin/newfs_ext2fs/newfs_ext2fs.8
 cvs rdiff -u -r1.4 -r1.4.2.1 src/sbin/newfs_ext2fs/newfs_ext2fs.c
 cvs rdiff -u -r1.4 -r1.4.36.1 src/sys/lib/libsa/ext2fs.c
 cvs rdiff -u -r1.16.28.1 -r1.16.28.2 src/sys/ufs/ext2fs/ext2fs_dinode.h
 cvs rdiff -u -r1.66.8.1 -r1.66.8.2 src/sys/ufs/ext2fs/ext2fs_inode.c
 cvs rdiff -u -r1.137.6.5 -r1.137.6.6 src/sys/ufs/ext2fs/ext2fs_vfsops.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Julian Coleman" <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40936 CVS commit: [netbsd-5] src/sbin/newfs_ext2fs
Date: Mon, 17 Jan 2011 12:45:01 +0000

 Module Name:	src
 Committed By:	jdc
 Date:		Mon Jan 17 12:45:00 UTC 2011

 Modified Files:
 	src/sbin/newfs_ext2fs [netbsd-5]: extern.h

 Log Message:
 Add change :
 	sbin/newfs_ext2fs/extern.h: revision 1.3
 required for ticket #1486.  Original commit message was:

 Pull up following revision(s) (requested by tsutsui in ticket #1486):
 	sbin/fsck_ext2fs/setup.c: revision 1.26
 	sbin/newfs_ext2fs/mke2fs.c: revision 1.10
 	sbin/newfs_ext2fs/mke2fs.c: revision 1.11
 	sbin/newfs_ext2fs/mke2fs.c: revision 1.12
 	sbin/fsck_ext2fs/inode.c: revision 1.24
 	sys/lib/libsa/ext2fs.c: revision 1.6
 	sbin/newfs_ext2fs/extern.h: revision 1.3
 	sbin/fsck_ext2fs/inode.c: revision 1.25
 	sys/lib/libsa/ext2fs.c: revision 1.7
 	sbin/fsck_ext2fs/inode.c: revision 1.26
 	sys/ufs/ext2fs/ext2fs_inode.c: revision 1.68
 	sbin/fsck_ext2fs/inode.c: revision 1.27
 	sbin/fsck_ext2fs/inode.c: revision 1.28
 	sys/ufs/ext2fs/ext2fs_dinode.h: revision 1.18
 	sys/ufs/ext2fs/ext2fs_dinode.h: revision 1.19
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.5
 	sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.2
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.6
 	sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.3
 	sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.142
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.7
 	sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.4
 	sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.8
 PR/40936: Frederik Sausmikat: ext2fs: add support for inodes > 128 bytes
 Support variable inode sizes.
 catch up with variable inode size.
 Don't use e2fs_inode_size in superblock on E2FS_REV0 file system.
 - accept only EXT2_REV0_DINODE_SIZE inodesize on -O 0
 - use inodesize to get offset of inode, not struct ext2fs_dinode array
 Replace a magic number with a new EXT2_REV0_DINODE_SIZE macro.
 Use EXT2_DINODE_SIZE() to get offset of inode, not struct ext2fs_dinode array.
 Fix botched logic in inodesize check.
 Use inodesize to get offset of inode in one more place.
 - add a sanity check for e2fs_inode_size in readsb()
 - use EXT2_DINODE_SIZE() rather than sizeof(struct ext2fs_dinode) or
   struct ext2fs_dinode array/pointer to see e2fs_ipb and inode offsets
 Sort options.
 New sentence, new line.
 Sort options in usage.
 - unsigned -> unsigned int
 - remove unnecessary casts from malloc(3) and free(3)
 - fix a bogus indent
 Use "size > INT32_MAX" rather than "size >= 0x80000000U" to check 2GB limit.
 Add missed byteswap ops against ext2fs_dinode members.
 Handle 32 bit uid field on E2FS_REV1.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.12.1 src/sbin/newfs_ext2fs/extern.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.