PERFORCE change 178861 for review

Zheng Liu lz at FreeBSD.org
Thu May 27 08:56:29 UTC 2010


http://p4web.freebsd.org/@@178861?ac=10

Change 178861 by lz at gnehzuil-freebsd on 2010/05/27 08:55:59

	       Modify the search method.

Affected files ...

.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#17 edit

Differences ...

==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#17 (text+ko) ====

@@ -239,7 +239,7 @@
         struct ext2_rsv_win *search_rsv;
         struct ext2mount *ump;
         int size, ret;
-        int start, end, loc, i;
+        int start, end, loc, len, i, map;
         char *bbp;
 
         ump = ip->i_ump;
@@ -251,10 +251,7 @@
         /* If tree is empty, then try to alloc according to bpref */
         if (RB_EMPTY(&fs->e2fs_rsv_tree)) {
                 EXT2_TREE_UNLOCK(fs);
-                /* 
-                 * bpref is not in this cylinder group.
-                 * So try to allocate it in other group.
-                 */
+
                 if (dtog(fs, bpref) != cg)
                         bpref = 0;
                 if (bpref != 0) {
@@ -302,36 +299,33 @@
                 }
                 EXT2_TREE_UNLOCK(fs);
 
-                start = rp->rsv_start;
-                for (i = 1; ;i++) {
-                        if (dtog(fs, start) != cg) {
-                                EXT2_TREE_LOCK(fs);
-                                if (rp->rsv_end != EXT2_RSV_NOT_ALLOCATED)
-                                        ext2_remove_rsv_win(fs, rp);
-                                EXT2_TREE_UNLOCK(fs);
+                start = dtogd(fs, rp->rsv_start) / NBBY;
+                len = howmany(fs->e2fs->e2fs_fpg, NBBY) - start;
+                loc = skpc(0xff, len, &bbp[start]);
+                if (loc == 0) {
+                        EXT2_TREE_LOCK(fs);
+                        if (rp->rsv_end != EXT2_RSV_NOT_ALLOCATED)
+                                ext2_remove_rsv_win(fs, rp);
+                        EXT2_TREE_UNLOCK(fs);
 
-                                bpref = ext2_mapsearch(fs, bbp, bpref);
-                                if (bpref < 0)
-                                        return (0);
-                                goto allocated1;
-                        }
-
-                        start = dtogd(fs, start);
-                        if (isset(bbp, start)) {
-                                start = rp->rsv_start + i;
-                                continue;
-                        }
-
-                        break;
+                        bpref = ext2_mapsearch(fs, bbp, bpref);
+                        if (bpref < 0)
+                                return (0);
+                        goto allocated1;
                 }
+                i = start + len - loc;
+                map = bbp[i];
+                bpref = i * NBBY;
+                for (i = 1; i < (1 << NBBY); i <<= 1, bpref++)
+                        if ((map & i) == 0)
+                                break;
 
-                if (cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + start >= rp->rsv_start &&
-                    cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + start < rp->rsv_end) {
-                        bpref = start;
+                start = cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + bpref;
+                if (start >= rp->rsv_start &&
+                    start < rp->rsv_end)
                         goto allocated;
-                }
 
-                bpref = cg * fs->e2fs->e2fs_fpg + fs->e2fs->e2fs_first_dblock + start;
+                bpref = start;
                 search_rsv = rp;
                 EXT2_TREE_LOCK(fs);
                 goto repeat;
@@ -348,8 +342,6 @@
 allocated:
         rp->rsv_alloc_hit++;
 allocated1:
-        if (isset(bbp, bpref))
-                return (0);
         setbit(bbp, (daddr_t)bpref);
         EXT2_LOCK(ump);
         fs->e2fs->e2fs_fbcount--;


More information about the p4-projects mailing list