From owner-p4-projects@FreeBSD.ORG Fri Jun 12 19:00:50 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E33FF1065691; Fri, 12 Jun 2009 19:00:49 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E55A106566B for ; Fri, 12 Jun 2009 19:00:49 +0000 (UTC) (envelope-from truncs@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 621338FC1F for ; Fri, 12 Jun 2009 19:00:49 +0000 (UTC) (envelope-from truncs@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5CJ0nUJ023701 for ; Fri, 12 Jun 2009 19:00:49 GMT (envelope-from truncs@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5CJ0nIQ023699 for perforce@freebsd.org; Fri, 12 Jun 2009 19:00:49 GMT (envelope-from truncs@FreeBSD.org) Date: Fri, 12 Jun 2009 19:00:49 GMT Message-Id: <200906121900.n5CJ0nIQ023699@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to truncs@FreeBSD.org using -f From: Aditya Sarawgi To: Perforce Change Reviews Cc: Subject: PERFORCE change 164197 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jun 2009 19:00:50 -0000 http://perforce.freebsd.org/chv.cgi?CH=164197 Change 164197 by truncs@aditya on 2009/06/12 19:00:40 EXT2_INODES_* is an old hack for accesses to the s_inodes_per_block field. It works even for old file system as this field is is in the in-core superblock and is always initialized from other data. No macro is required for this as suggested by bde@ Affected files ... .. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_fs.h#15 edit .. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c#6 edit .. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/fs.h#6 edit Differences ... ==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_fs.h#15 (text+ko) ==== @@ -153,7 +153,6 @@ #define EXT2_ADDR_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_addr_per_block_bits) #define EXT2_INODE_SIZE(s) (EXT2_SB(s)->e2fs_isize) #define EXT2_FIRST_INO(s) (EXT2_SB(s)->e2fs_first_inode) -#define EXT2_INODES_PER_BLOCK(s) ((s)->e2fs_ipb) #else #define EXT2_INODE_SIZE(s) (((s)->s_rev_level == E2FS_REV0) ? \ E2FS_REV0 : (s)->s_inode_size) @@ -218,12 +217,11 @@ #if defined(__KERNEL__) || defined(_KERNEL) # define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->e2fs_bpg) # define EXT2_DESC_PER_BLOCK(s) (EXT2_SB(s)->e2fs_descpb) -# define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->e2fs_ipg) # define EXT2_DESC_PER_BLOCK_BITS(s) (EXT2_SB(s)->s_desc_per_block_bits) #else # define EXT2_BLOCKS_PER_GROUP(s) ((s)->e2fs_bpg) # define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) -# define EXT2_INODES_PER_GROUP(s) ((s)->s_ipg) + #endif /* ==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c#6 (text+ko) ==== @@ -231,8 +231,8 @@ return; } es = sb->e2fs; - block_group = (inode->i_number - 1) / EXT2_INODES_PER_GROUP(sb); - bit = (inode->i_number - 1) % EXT2_INODES_PER_GROUP(sb); + block_group = (inode->i_number - 1) / sb->e2fs_ipg; + bit = (inode->i_number - 1) % sb->e2fs_ipg; bitmap_nr = load_inode_bitmap (ITOV(inode)->v_mount, block_group); bh = sb->e2fs_ib[bitmap_nr]; if (!clear_bit (bit, bh->b_data)) @@ -273,8 +273,7 @@ struct ext2_inode * raw_inode; inode_block = gdp->bg_inode_table + (((inode->i_number - 1) % - EXT2_INODES_PER_GROUP(inode->i_sb)) / - EXT2_INODES_PER_BLOCK(inode->i_sb)); + (inode->i_sb->e2fs_ipg) /(inode->i_sb->e2fs_ipb))); bh = bread (inode->i_sb->s_dev, inode_block, inode->i_sb->e2fs_bsize); if (!bh) { printf ("inc_inode_version Cannot load inode table block - " @@ -285,8 +284,7 @@ } raw_inode = ((struct ext2_inode *) bh->b_data) + (((inode->i_number - 1) % - EXT2_INODES_PER_GROUP(inode->i_sb)) % - EXT2_INODES_PER_BLOCK(inode->i_sb)); + (inode->i_sb->e2fs_ipg)) % (inode->i_sb->e2fs_ipb)); raw_inode->i_version++; inode->u.ext2_i.i_version = raw_inode->i_version; bdwrite (bh); @@ -408,8 +406,7 @@ bitmap_nr = load_inode_bitmap (ITOV(dir)->v_mount, i); bh = sb->e2fs_ib[bitmap_nr]; if ((j = find_first_zero_bit ((unsigned long *) bh->b_data, - EXT2_INODES_PER_GROUP(sb))) < - EXT2_INODES_PER_GROUP(sb)) { + (sb->e2fs_ipg) < (sb->e2fs_ipg)))) { if (set_bit (j, bh->b_data)) { printf ( "ext2_new_inode:" "bit already set for inode %d", j); @@ -433,7 +430,7 @@ } goto repeat; } - j += i * EXT2_INODES_PER_GROUP(sb) + 1; + j += i * (sb->e2fs_ipg) + 1; if (j < EXT2_FIRST_INO(sb) || j > es->e2fs_icount) { printf ( "ext2_new_inode:" "reserved inode or inode > inodes count - " @@ -473,7 +470,7 @@ desc_count += gdp->bg_free_inodes_count; bitmap_nr = load_inode_bitmap (mp, i); x = ext2_count_free (sb->e2fs_ib[bitmap_nr], - EXT2_INODES_PER_GROUP(sb) / 8); + (sb->e2fs_ipg) / 8); ext2_debug ("group %d: stored = %d, counted = %lu\n", i, gdp->bg_free_inodes_count, x); bitmap_count += x; @@ -507,7 +504,7 @@ desc_count += gdp->bg_free_inodes_count; bitmap_nr = load_inode_bitmap (sb, i); x = ext2_count_free (sb->u.ext2_sb.e2fs_ib[bitmap_nr], - EXT2_INODES_PER_GROUP(sb) / 8); + (sb->e2fs_ipg) / 8); if (gdp->bg_free_inodes_count != x) printf ( "ext2_check_inodes_bitmap:" "Wrong free inodes count in group %d, " ==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/fs.h#6 (text+ko) ==== @@ -80,14 +80,14 @@ #define dbtofsb(fs, b) ((b) >> ((fs)->e2fs_fsbtodb)) /* get group containing inode */ -#define ino_to_cg(fs, x) (((x) - 1) / EXT2_INODES_PER_GROUP(fs)) +#define ino_to_cg(fs, x) (((x) - 1) / (fs->e2fs_ipg)) /* get block containing inode from its number x */ #define ino_to_fsba(fs, x) fs_cs(fs, ino_to_cg(fs, x)).bg_inode_table + \ - (((x)-1) % EXT2_INODES_PER_GROUP(fs))/EXT2_INODES_PER_BLOCK(fs) + (((x)-1) % (fs->e2fs_ipg))/(fs->e2fs_ipb) /* get offset for inode in block */ -#define ino_to_fsbo(fs, x) ((x-1) % EXT2_INODES_PER_BLOCK(fs)) +#define ino_to_fsbo(fs, x) ((x-1) % (fs->e2fs_ipb)) /* * Give cylinder group number for a file system block. @@ -129,7 +129,7 @@ /* * INOPB is the number of inodes in a secondary storage block. */ -#define INOPB(fs) EXT2_INODES_PER_BLOCK(fs) +#define INOPB(fs) (fs->e2fs_ipb) /* * NINDIR is the number of indirects in a file system block.