Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jan 2009 16:06:44 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Stanislav Sedov <stas@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r187395 - head/sys/gnu/fs/ext2fs
Message-ID:  <20090118140644.GT48057@deviant.kiev.zoral.com.ua>
In-Reply-To: <200901181404.n0IE4uXw075698@svn.freebsd.org>
References:  <200901181404.n0IE4uXw075698@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--Ayym4vmyMU9P4uDb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Jan 18, 2009 at 02:04:56PM +0000, Stanislav Sedov wrote:
> Author: stas
> Date: Sun Jan 18 14:04:56 2009
> New Revision: 187395
> URL: http://svn.freebsd.org/changeset/base/187395
>=20
> Log:
>   - Obtain inode sizes and location of the first inode based on the conte=
nts
>     of superblock rather than using hardcoded values. This fixes ext2fs on
>     filesystems with inode sized other than 128.
>  =20
>   Submitted by:	Alex Lyashkov <Alexey.Lyashkov@Sun.COM> (based on)
>   MFC after:	2 weeks
>=20
> Modified:
>   head/sys/gnu/fs/ext2fs/ext2_fs.h
>   head/sys/gnu/fs/ext2fs/ext2_fs_sb.h
>   head/sys/gnu/fs/ext2fs/ext2_inode.c
>   head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c
>   head/sys/gnu/fs/ext2fs/ext2_vfsops.c
>=20
> Modified: head/sys/gnu/fs/ext2fs/ext2_fs.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/gnu/fs/ext2fs/ext2_fs.h	Sun Jan 18 13:04:38 2009	(r187394)
> +++ head/sys/gnu/fs/ext2fs/ext2_fs.h	Sun Jan 18 14:04:56 2009	(r187395)
> @@ -150,8 +150,8 @@
>  #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_FIRST_INO			11
> +#define EXT2_INODE_SIZE(s)		((s)->s_inode_size)
> +#define EXT2_FIRST_INO(s)		((s)->s_first_inode)
>  #endif /* notyet */
> =20
>  /*
>=20
> Modified: head/sys/gnu/fs/ext2fs/ext2_fs_sb.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/gnu/fs/ext2fs/ext2_fs_sb.h	Sun Jan 18 13:04:38 2009	(r187394)
> +++ head/sys/gnu/fs/ext2fs/ext2_fs_sb.h	Sun Jan 18 14:04:56 2009	(r187395)
> @@ -63,6 +63,8 @@ struct ext2_sb_info {
>  	unsigned long s_db_per_group;	/* Number of descriptor blocks per group =
*/
>  	unsigned long s_desc_per_block;	/* Number of group descriptors per bloc=
k */
>  	unsigned long s_groups_count;	/* Number of groups in the fs */
> +	unsigned long s_first_inode;	/* First inode on fs */
> +	unsigned int s_inode_size;	/* Size for inode with extra data */
>  	struct buffer_head * s_sbh;	/* Buffer containing the super block */
>  	struct ext2_super_block * s_es;	/* Pointer to the super block in the bu=
ffer */
>  	struct buffer_head ** s_group_desc;
>=20
> Modified: head/sys/gnu/fs/ext2fs/ext2_inode.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/gnu/fs/ext2fs/ext2_inode.c	Sun Jan 18 13:04:38 2009	(r187394)
> +++ head/sys/gnu/fs/ext2fs/ext2_inode.c	Sun Jan 18 14:04:56 2009	(r187395)
> @@ -91,7 +91,7 @@ ext2_update(vp, waitfor)
>  		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) =3D=3D 0)
>  		return (bwrite(bp));
>  	else {
>=20
> Modified: head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c	Sun Jan 18 13:04:38 2009	(=
r187394)
> +++ head/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c	Sun Jan 18 14:04:56 2009	(=
r187395)
> @@ -225,7 +225,7 @@ void ext2_free_inode (struct inode * ino
> =20
>  	sb =3D inode->i_e2fs;
>  	lock_super (DEVVP(inode));
> -	if (inode->i_number < EXT2_FIRST_INO ||
> +	if (inode->i_number < EXT2_FIRST_INO(sb) ||
>  	    inode->i_number > sb->s_es->s_inodes_count) {
>  		printf ("free_inode reserved inode or nonexistent inode");
>  		unlock_super (DEVVP(inode));
> @@ -435,7 +435,7 @@ repeat:
>  		goto repeat;
>  	}
>  	j +=3D i * EXT2_INODES_PER_GROUP(sb) + 1;
> -	if (j < EXT2_FIRST_INO || j > es->s_inodes_count) {
> +	if (j < EXT2_FIRST_INO(sb) || j > es->s_inodes_count) {
>  		printf ( "ext2_new_inode:"
>  			    "reserved inode or inode > inodes count - "
>  			    "block_group =3D %d,inode=3D%d", i, j);
>=20
> Modified: head/sys/gnu/fs/ext2fs/ext2_vfsops.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/gnu/fs/ext2fs/ext2_vfsops.c	Sun Jan 18 13:04:38 2009	(r18739=
4)
> +++ head/sys/gnu/fs/ext2fs/ext2_vfsops.c	Sun Jan 18 14:04:56 2009	(r18739=
5)
> @@ -424,7 +424,11 @@ static int compute_sb_data(devvp, es, fs
>      V(s_frags_per_group)
>      fs->s_inodes_per_group =3D es->s_inodes_per_group;
>      V(s_inodes_per_group)
> -    fs->s_inodes_per_block =3D fs->s_blocksize / EXT2_INODE_SIZE;
> +    fs->s_inode_size =3D es->s_inode_size;
> +    V(s_inode_size)
> +    fs->s_first_inode =3D es->s_first_ino;
> +    V(s_first_inode);
> +    fs->s_inodes_per_block =3D fs->s_blocksize / EXT2_INODE_SIZE(fs);
>      V(s_inodes_per_block)
>      fs->s_itb_per_group =3D fs->s_inodes_per_group /fs->s_inodes_per_blo=
ck;
>      V(s_itb_per_group)
> @@ -578,7 +582,7 @@ loop:
>  			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);
>  		vrele(vp);
> @@ -1012,7 +1016,7 @@ printf("ext2_vget(%d) dbn=3D %d ", ino, fs
>  		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(f=
s) *
>  			ino_to_fsbo(fs, ino)), ip);
>  	ip->i_block_group =3D ino_to_cg(fs, ino);
>  	ip->i_next_alloc_block =3D 0;

Please see a discussion on the fs@ and reasoning why I declined to commit
the similar patch.

--Ayym4vmyMU9P4uDb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAklzN3MACgkQC3+MBN1Mb4i13QCgy52qspLplFQyfZL/0HY6b4vk
0iQAoIVa2IbBUbjUF5/KFqVSHTQLALDN
=Kg6Z
-----END PGP SIGNATURE-----

--Ayym4vmyMU9P4uDb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090118140644.GT48057>