]> git.neil.brown.name Git - LaFS.git/commitdiff
Remove sort_uninc
authorNeilBrown <neilb@suse.de>
Sun, 13 Jun 2010 10:19:38 +0000 (20:19 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 18 Jun 2010 11:16:49 +0000 (21:16 +1000)
We now keep the uninc table sorted, so we don't need to
sort it.

Signed-off-by: NeilBrown <neilb@suse.de>
modify.c

index c25b54436a5e82729119df7916ee6bf4c0b70614..648e57b620cd19d83386d532e23be736acaa79b1 100644 (file)
--- a/modify.c
+++ b/modify.c
  *  new pages early enough... We will have to worry about that later.
  */
 
-static int addr_cmp(const void *av, const void *bv)
-{
-       const struct addr *a = av;
-       const struct addr *b = bv;
-       return a->fileaddr - b->fileaddr;
-}
-
-static void swap(void *a, void *b, int len)
-{
-       char *ac = a;
-       char *bc = b;
-       while (len--) {
-               int t = *ac;
-               *ac++ = *bc;
-               *bc++ = t;
-       }
-}
-static int sort_addr(void *table, int cnt, int size,
-                int(*cmp)(const void *a, const void*b))
-{
-       /* simple quadratic sort for now...
-        */
-       int i, j;
-       for (i = 0; i < cnt; i++) {
-               /* the first i are sorted */
-               for (j = cnt-1; j > i ; j--) {
-                       /* table[j] is less that j+x */
-                       void *a = table + (j-1) * size;
-                       void *b = table + (j) * size;
-                       if (cmp(a, b) > 0)
-                               swap(a, b, size);
-               }
-       }
-       // FIXME need to check for overlapping extents and fail
-       return 1;
-}
-
-static void sort_uninc(struct uninc *uninc)
-{
-       sort_addr(uninc->pending_addr, uninc->pending_cnt,
-                 sizeof(struct addr), addr_cmp);
-}
-
 static void sort_blocks(struct block **blkp)
 {
        /* sort blocks list in *blkp by ->fileaddr
@@ -1756,7 +1713,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
                if (type == IBLK_INDIRECT &&
                    ib->uninc_table.pending_cnt > 0 &&
                    start > ib->uninc_table.pending_addr[0].fileaddr) {
-                       /* new extent before and indirect block.  We cannot
+                       /* new extent before an indirect block.  We cannot
                         * handle this reliably as it could require
                         * more than two new index blocks.  So for the
                         * indirect block to be reshuffled to a lower
@@ -1775,7 +1732,6 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
                        unmap_iblock(ib, buf-offset);
                        goto out;
                }
-               sort_uninc(&uit);
 
                if(!test_bit(B_Dirty, &ib->b.flags) &&
                   !test_bit(B_Realloc, &ib->b.flags))