| From | Sent On | Attachments |
|---|---|---|
| Zheng Liu | Mar 7, 2011 2:39 am |
| Subject: | PERFORCE change 189657 for review | |
|---|---|---|
| From: | Zheng Liu (lz...@FreeBSD.org) | |
| Date: | Mar 7, 2011 2:39:09 am | |
| List: | org.freebsd.p4-projects | |
http://p4web.freebsd.org/@@189657?ac=10
Change 189657 by lz@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");
_______________________________________________ p4-p...@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/p4-projects To unsubscribe, send any mail to "p4-p...@freebsd.org"





