Whamcloud - gitweb
e2fsck: allow deleting or zeroing shared blocks
[tools/e2fsprogs.git] / e2fsck / ea_refcount.c
index 115bd6f..e66e636 100644 (file)
@@ -155,9 +155,7 @@ static struct ea_refcount_el *insert_refcount_el(ext2_refcount_t refcount,
 static struct ea_refcount_el *get_refcount_el(ext2_refcount_t refcount,
                                              blk_t blk, int create)
 {
-       float   range;
        int     low, high, mid;
-       blk_t   lowval, highval;
 
        if (!refcount || !refcount->list)
                return 0;
@@ -183,31 +181,7 @@ retry:
        printf("Non-cursor get_refcount_el: %u\n", blk);
 #endif
        while (low <= high) {
-#if 0
                mid = (low+high)/2;
-#else
-               if (low == high)
-                       mid = low;
-               else {
-                       /* Interpolate for efficiency */
-                       lowval = refcount->list[low].ea_blk;
-                       highval = refcount->list[high].ea_blk;
-
-                       if (blk < lowval)
-                               range = 0;
-                       else if (blk > highval)
-                               range = 1;
-                       else {
-                               range = ((float) (blk - lowval)) /
-                                       (highval - lowval);
-                               if (range > 0.9)
-                                       range = 0.9;
-                               if (range < 0.1)
-                                       range = 0.1;
-                       }
-                       mid = low + ((int) (range * (high-low)));
-               }
-#endif
                if (blk == refcount->list[mid].ea_blk) {
                        refcount->cursor = mid+1;
                        return &refcount->list[mid];
@@ -407,8 +381,8 @@ int main(int argc, char **argv)
                        size = bcode_program[i++];
                        retval = ea_refcount_create(size, &refcount);
                        if (retval) {
-                               com_err("ea_refcount_create",
-                                       retval, "");
+                               com_err("ea_refcount_create", retval,
+                                       "while creating size %d", size);
                                exit(1);
                        } else
                                printf("Creating refcount with size %d\n",
@@ -422,35 +396,35 @@ int main(int argc, char **argv)
                case BCODE_STORE:
                        blk = (blk_t) bcode_program[i++];
                        arg = bcode_program[i++];
-                       retval = ea_refcount_store(refcount, blk, arg);
                        printf("Storing blk %u with value %d\n", blk, arg);
+                       retval = ea_refcount_store(refcount, blk, arg);
                        if (retval)
-                               com_err("ea_refcount_store", retval, "");
+                               com_err("ea_refcount_store", retval,
+                                       "while storing blk %u", blk);
                        break;
                case BCODE_FETCH:
                        blk = (blk_t) bcode_program[i++];
                        retval = ea_refcount_fetch(refcount, blk, &arg);
                        if (retval)
-                               com_err("ea_refcount_fetch", retval, "");
+                               com_err("ea_refcount_fetch", retval,
+                                       "while fetching blk %u", blk);
                        else
                                printf("bcode_fetch(%u) returns %d\n",
                                       blk, arg);
                        break;
                case BCODE_INCR:
                        blk = (blk_t) bcode_program[i++];
-                       retval = ea_refcount_increment(refcount, blk,
-                                                          &arg);
+                       retval = ea_refcount_increment(refcount, blk, &arg);
                        if (retval)
                                com_err("ea_refcount_increment", retval,
-                                       "");
+                                       "while incrementing blk %u", blk);
                        else
                                printf("bcode_increment(%u) returns %d\n",
                                       blk, arg);
                        break;
                case BCODE_DECR:
                        blk = (blk_t) bcode_program[i++];
-                       retval = ea_refcount_decrement(refcount, blk,
-                                                          &arg);
+                       retval = ea_refcount_decrement(refcount, blk, &arg);
                        if (retval)
                                com_err("ea_refcount_decrement", retval,
                                        "while decrementing blk %u", blk);
@@ -461,20 +435,18 @@ int main(int argc, char **argv)
                case BCODE_VALIDATE:
                        retval = ea_refcount_validate(refcount, stderr);
                        if (retval)
-                               com_err("ea_refcount_validate",
-                                       retval, "");
+                               com_err("ea_refcount_validate", retval,
+                                       "while validating");
                        else
                                printf("Refcount validation OK.\n");
                        break;
                case BCODE_LIST:
                        ea_refcount_intr_begin(refcount);
                        while (1) {
-                               blk = ea_refcount_intr_next(refcount,
-                                                               &arg);
+                               blk = ea_refcount_intr_next(refcount, &arg);
                                if (!blk)
                                        break;
-                               printf("\tblk=%u, count=%d\n", blk,
-                                      arg);
+                               printf("\tblk=%u, count=%d\n", blk, arg);
                        }
                        break;
                case BCODE_COLLAPSE: