PERFORCE change 178290 for review
Zheng Liu
lz at FreeBSD.org
Sat May 15 05:36:41 UTC 2010
http://p4web.freebsd.org/@@178290?ac=10
Change 178290 by lz at gnehzuil-freebsd on 2010/05/15 05:36:20
Fix some bugs and Implement allocation in other groups.
* Now it can allocate a free block in other groups when it can not allocate
a block in preference cylinder group.
[problem]
* The performance need to be improved.
Affected files ...
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#9 edit
Differences ...
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#9 (text+ko) ====
@@ -281,7 +281,6 @@
}
}
} else {
-repeat:
search_rsv = ext2_search_rsv_win(&fs->e2fs_rsv_tree, bpref);
ret = ext2_find_next_rsv_win(search_rsv, rp, fs, bpref, cg);
@@ -310,8 +309,9 @@
if (loc == end) {
mtx_lock_spin(&fs->e2fs_rsv_lock);
- search_rsv = rp;
- goto repeat;
+ ext2_remove_rsv_win(fs, rp);
+ mtx_unlock_spin(&fs->e2fs_rsv_lock);
+ return -1;
}
}
@@ -340,19 +340,23 @@
ump = ip->i_ump;
bbp = (char *)bp->b_data;
if (rp != NULL && rp->rw_end != EXT2_RWI_NOT_ALLOCATED)
- start = dtogd(fs, rp->rw_start + rp->rw_alloc_hit) / NBBY;
+ start = dtogd(fs, rp->rw_start + rp->rw_alloc_hit);
else
return 0;
- if (bbp[start] == 0) {
- bno = start * NBBY;
+ if (isclr(bbp, start)) {
+ bno = start;
goto gotit;
}
+
+ mtx_lock_spin(&fs->e2fs_rsv_lock);
+ ext2_remove_rsv_win(fs, rp);
+ mtx_unlock_spin(&fs->e2fs_rsv_lock);
return 0;
gotit:
- bno += rp->rw_alloc_hit++;
+ rp->rw_alloc_hit++;
setbit(bbp, (daddr_t)bno);
EXT2_LOCK(ump);
fs->e2fs->e2fs_fbcount--;
@@ -451,11 +455,27 @@
/* TODO: Just need to try to allocate a free block from rest groups.
* Now just use old allocation algorihtm.
*/
-/*
- for (i = cg + 1; i < fs->e2fs_gcount; i++) {
+ for (i = 0; i < fs->e2fs_gcount; i++) {
+ /* Read block bitmap from buffer */
+ EXT2_UNLOCK(ump);
+ error = bread(ip->i_devvp,
+ fsbtodb(fs, fs->e2fs_gd[i].ext2bgd_b_bitmap),
+ (int)fs->e2fs_bsize, NOCRED, &bp);
+ if (error) {
+ brelse(bp);
+ goto ioerror;
+ }
+
+ EXT2_IRSV_LOCK(ip);
+ bno = ext2_rsvalloc(fs, ip, i, bp, bpref, size);
+ EXT2_IRSV_UNLOCK(ip);
+ if (bno > 0)
+ goto allocated;
+
+ brelse(bp);
+ EXT2_LOCK(ump);
}
-*/
- i = 1;
+
bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize, ext2_alloccg);
allocated:
More information about the p4-projects
mailing list