Date: Mon, 7 Mar 2011 07:51:00 GMT From: Zheng Liu <lz@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 189649 for review Message-ID: <201103070751.p277p0gn025312@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 */ }; /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103070751.p277p0gn025312>