PERFORCE change 189657 for review
Zheng Liu
lz at FreeBSD.org
Mon Mar 7 10:39:38 UTC 2011
http://p4web.freebsd.org/@@189657?ac=10
Change 189657 by lz at freebsd-dev on 2011/03/07 10:38:51
Improve sweep loop in ext2_clusteralloc() like in ffs.
Affected files ...
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#36 edit
Differences ...
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#36 (text+ko) ====
@@ -1309,16 +1309,13 @@
int error, i, got, run;
char *bbp;
daddr_t bno;
+ int bit, map;
+ unsigned char *mapp;
fs = ip->i_e2fs;
ump = ip->i_ump;
- /*
- * TODO: we need to define a new member in m_ext2fs structure
- * to save max cluster. But for simplicity, we assume that the
- * max cluster is equal to the number of blocks per group.
- */
- if (fs->e2fs_gd[cg].ext2bgd_nbfree < len)
+ if (fs->e2fs_maxcluster[cg] < len)
return (0);
EXT2_UNLOCK(ump);
@@ -1340,25 +1337,35 @@
bpref = 0;
if (bpref != 0)
bpref = dtogd(fs, bpref);
-
+ mapp = &bbp[bpref / NBBY];
+ map = *mapp++;
+ bit = 1 << (bpref % NBBY);
for (run = 0, got = bpref; got < fs->e2fs_bpg; got++) {
- if (!isclr(bbp, got))
+ if (!((map & bit) == 0)) {
run = 0;
- else {
+ } else {
run++;
if (run == len)
break;
}
+ if ((got & (NBBY - 1)) != (NBBY - 1)) {
+ bit <<= 1;
+ } else {
+ map = *mapp++;
+ bit = 1;
+ }
}
if (got >= fs->e2fs_bpg)
goto fail_lock;
+
/*
* Allocate the cluster that we have found.
*/
for (i = 1; i <= len; i++)
if (!isclr(bbp, got - run + i))
panic("ext2_clusteralloc: map mismatch");
+
bno = got - run + 1;
if (bno >= fs->e2fs_bpg)
panic("ext2_clusteralloc: allocated out of group");
More information about the p4-projects
mailing list