Date: Mon, 22 Jun 2009 20:28:46 GMT From: Aditya Sarawgi <truncs@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 164900 for review Message-ID: <200906222028.n5MKSk7Z059398@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=164900 Change 164900 by truncs@aditya on 2009/06/22 20:28:46 ext2_nodealloccg is used for allocating a inode. ext2_dirpref searches for a cylinder group that has more free inodes than the average number of free inodes per cylinder group. Affected files ... .. //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#8 edit Differences ... ==== //depot/projects/soc2009/soc_ext2fs/src/sys/gnu/fs/ext2fs/ext2_alloc.c#8 (text+ko) ==== @@ -50,12 +50,13 @@ #include <gnu/fs/ext2fs/fs.h> #include <gnu/fs/ext2fs/ext2_extern.h> -static void ext2_fserr(struct m_ext2fs *, u_int, char *); static daddr_t ext2_alloccg(struct inode *, int, daddr_t, int); static ino_t ext2_dirpref(struct m_ext2fs *); +static void ext2_fserr(struct m_ext2fs *, u_int, char *); static ino_t ext2_hashalloc(struct inode *, int, long, int, daddr_t (*)(struct inode *, int, daddr_t, int)); +static daddr_t ext2fs_nodealloccg(struct inode *, int, daddr_t. int); /* * Linux calls this functions at the following locations: * (1) the inode is freed @@ -536,3 +537,29 @@ log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->e2fs_fsmnt, cp); } + +/* + * Find a cylinder to place a directory. + * + * The policy implemented by this algorithm is to select from + * among those cylinder groups with above the average number of + * free inodes, the one with the smallest number of directories. + */ +static ino_t +ext2fs_dirpref(struct m_ext2fs *fs) +{ + int maxspace, avgifree; + ino_t cg, mincg; + avgifree = fs->e2fs.e2fs_ficount / fs->e2fs_ncg; + maxspace = 0; + mincg = -1; + for (cg = 0; cg < fs->e2fs_ncg; cg++) + if ( fs->e2fs_gd[cg].ext2bgd_nifree >= avgifree) { + if (mincg == -1 || fs->e2fs_gd[cg].ext2bgd_nbfree > maxspace) { + mincg = cg; + maxspace = fs->e2fs_gd[cg].ext2bgd_nbfree; + } + } + return mincg; +} +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906222028.n5MKSk7Z059398>