* 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
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
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))