From owner-p4-projects@FreeBSD.ORG Mon Mar 7 07:51:01 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8E53B1065676; Mon, 7 Mar 2011 07:51:01 +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 345F81065674 for ; Mon, 7 Mar 2011 07:51:01 +0000 (UTC) (envelope-from lz@FreeBSD.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 21BEE8FC17 for ; Mon, 7 Mar 2011 07:51:01 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p277p1s8025318 for ; Mon, 7 Mar 2011 07:51:01 GMT (envelope-from lz@FreeBSD.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p277p0gn025312 for perforce@freebsd.org; Mon, 7 Mar 2011 07:51:00 GMT (envelope-from lz@FreeBSD.org) Date: Mon, 7 Mar 2011 07:51:00 GMT Message-Id: <201103070751.p277p0gn025312@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to lz@FreeBSD.org using -f From: Zheng Liu To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 189649 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2011 07:51:02 -0000 http://p4web.freebsd.org/@@189649?ac=10 Change 189649 by lz@freebsd-dev on 2011/03/07 07:50:40 Add three members in m_ext2fs structure for reallocblks and initialize them in ext2_mountfs(). Affected files ... .. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_vfsops.c#10 edit .. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2fs.h#7 edit Differences ... ==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_vfsops.c#10 (text+ko) ==== @@ -395,6 +395,7 @@ fs->e2fs_maxfilesize = 0x7fffffff; else fs->e2fs_maxfilesize = 0x7fffffffffffffff; + return (0); } @@ -421,6 +422,8 @@ struct ext2fs *es; struct m_ext2fs *fs; int error; + int i; + int32_t *lp; if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EINVAL); @@ -451,6 +454,12 @@ brelse(bp); return (error); } + + if (fs->e2fs_contigsumsize > 0) { + lp = fs->e2fs_maxcluster; + for (i = 0; i < fs->e2fs_gdbcount; i++) + *lp++ = fs->e2fs_contigsumsize; + } #ifdef UNKLAR if (fs->fs_sbsize < SBSIZE) bp->b_flags |= B_INVAL; @@ -514,6 +523,8 @@ struct bufobj *bo; int error; int ronly; + int i, size; + int32_t *lp; ronly = vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0); /* XXX: use VOP_ACESS to check FS perms */ @@ -591,6 +602,27 @@ M_EXT2MNT, M_WAITOK | M_ZERO); RB_INIT(ump->um_e2fs->e2fs_rsv_tree); + /* + * We calculate the max contiguous blks and size of cluster summary + * array. In ffs, these works are done in newfs. But superblock in + * ext2fs doesn't have these variables. So we just can calculate them + * in here. + */ + ump->um_e2fs->e2fs_maxcontig = MAX(1, MAXPHYS / ump->um_e2fs->e2fs_bsize); + if (ump->um_e2fs->e2fs_maxcontig > 0) + ump->um_e2fs->e2fs_contigsumsize = + MIN(ump->um_e2fs->e2fs_maxcontig, EXT2_MAXCONTIG); + else + ump->um_e2fs->e2fs_contigsumsize = 0; + ump->um_e2fs->e2fs_maxcluster = NULL; + if (ump->um_e2fs->e2fs_contigsumsize > 0) { + size = ump->um_e2fs->e2fs_gdbcount * sizeof(int32_t); + ump->um_e2fs->e2fs_maxcluster = malloc(size, M_EXT2MNT, M_WAITOK); + lp = ump->um_e2fs->e2fs_maxcluster; + for (i = 0; i < ump->um_e2fs->e2fs_gdbcount; i++) + *lp++ = ump->um_e2fs->e2fs_contigsumsize; + } + brelse(bp); bp = NULL; fs = ump->um_e2fs; @@ -690,6 +722,7 @@ g_topology_unlock(); PICKUP_GIANT(); vrele(ump->um_devvp); + free(fs->e2fs_maxcluster, M_EXT2MNT); free(fs->e2fs_rsv_tree, M_EXT2MNT); mtx_destroy(&fs->e2fs_rsv_lock); free(fs->e2fs_gd, M_EXT2MNT); ==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2fs.h#7 (text+ko) ==== @@ -46,6 +46,14 @@ #define EXT2_LINK_MAX 32000 /* + * A summary of contiguous blocks of various sizes in maintained + * in each cylinder group. Normally this is set by the initial + * value of fs_maxcontig. To conserve space, a maximum summary size + * is set by FS_MAXCONTIG. + */ +#define EXT2_MAXCONTIG 16 + +/* * Constants relative to the data blocks */ #define EXT2_NDIR_BLOCKS 12 @@ -144,6 +152,10 @@ struct mtx e2fs_rsv_lock; /* Protect reservation window RB tree */ struct ext2_rsv_win_tree *e2fs_rsv_tree; /* Reservation window index */ + + int32_t e2fs_maxcontig; /* max number of contiguous blks */ + int32_t e2fs_contigsumsize; /* size of cluster summary array */ + int32_t *e2fs_maxcluster; /* max cluster in each cyl group */ }; /*