diff options
author | John Baldwin <jhb@FreeBSD.org> | 2011-02-24 22:11:36 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2011-02-24 22:11:36 +0000 |
commit | 056c6c933c8b65bfd965174bfdb1a6ad961d1900 (patch) | |
tree | 58aff3aa80c108929fb0bc775169ccf53600f78c /sys/fs | |
parent | b7f8a68b044adfff3aeb4bc166760880d365327c (diff) | |
download | src-056c6c933c8b65bfd965174bfdb1a6ad961d1900.tar.gz src-056c6c933c8b65bfd965174bfdb1a6ad961d1900.zip |
Use ffs() to locate free bits in the inode and block bitmaps rather than
loops with bit shifts.
Notes
Notes:
svn path=/head/; revision=219012
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/ext2fs/ext2_alloc.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/sys/fs/ext2fs/ext2_alloc.c b/sys/fs/ext2fs/ext2_alloc.c index 7abfe2b2bf09..293517771bcc 100644 --- a/sys/fs/ext2fs/ext2_alloc.c +++ b/sys/fs/ext2fs/ext2_alloc.c @@ -815,16 +815,12 @@ ext2_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode) } } i = start + len - loc; - map = ibp[i]; - ipref = i * NBBY; - for (i = 1; i < (1 << NBBY); i <<= 1, ipref++) { - if ((map & i) == 0) { - goto gotit; - } + map = ibp[i] ^ 0xff; + if (map == 0) { + printf("fs = %s\n", fs->e2fs_fsmnt); + panic("ext2fs_nodealloccg: block not in map"); } - printf("fs = %s\n", fs->e2fs_fsmnt); - panic("ext2fs_nodealloccg: block not in map"); - /* NOTREACHED */ + ipref = i * NBBY + ffs(map) - 1; gotit: setbit(ibp, ipref); EXT2_LOCK(ump); @@ -952,7 +948,6 @@ ext2_vfree(pvp, ino, mode) static daddr_t ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t bpref) { - daddr_t bno; int start, len, loc, i, map; /* @@ -977,15 +972,12 @@ ext2_mapsearch(struct m_ext2fs *fs, char *bbp, daddr_t bpref) } } i = start + len - loc; - map = bbp[i]; - bno = i * NBBY; - for (i = 1; i < (1 << NBBY); i <<= 1, bno++) { - if ((map & i) == 0) - return (bno); + map = bbp[i] ^ 0xff; + if (map == 0) { + printf("fs = %s\n", fs->e2fs_fsmnt); + panic("ext2fs_mapsearch: block not in map"); } - printf("fs = %s\n", fs->e2fs_fsmnt); - panic("ext2fs_mapsearch: block not in map"); - /* NOTREACHED */ + return (i * NBBY + ffs(map) - 1); } /* |