]> git.neil.brown.name Git - LaFS.git/commitdiff
add_extent fixes.
authorNeilBrown <neilb@suse.de>
Tue, 8 Jun 2010 08:13:13 +0000 (18:13 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 8 Jun 2010 08:13:13 +0000 (18:13 +1000)
add_extent tries to detect consecutive extents being added
and merges them.  But it got it wrong.
So change last* to actually refer to the "next" and get it right.

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

index 505a0c8f5efb68dac612fd6daff49b6339fdbfc3..2d88024ffe33a1f89938fece98f45ccf45b0ca63 100644 (file)
--- a/modify.c
+++ b/modify.c
@@ -646,12 +646,12 @@ static int add_extent(void *data, u32 addr, u64 phys, int len)
                return 0;
        }
 
-       if (li->esize && li->lastaddr + 1 == addr &&
-           li->lastphys + 1 == phys) {
+       if (li->esize && li->lastaddr == addr &&
+           li->lastphys == phys) {
                /* just extend the extent */
                li->esize += len;
-               li->lastaddr = addr;
-               li->lastphys = phys;
+               li->lastaddr += len;
+               li->lastphys += len;
                return len;
        }
        if (li->esize) {
@@ -672,8 +672,8 @@ static int add_extent(void *data, u32 addr, u64 phys, int len)
        li->esize = len;
        li->data = p;
        li->size -= 12;
-       li->lastaddr = addr;
-       li->lastphys = phys;
+       li->lastaddr = addr + len;
+       li->lastphys = phys + len;
        return len;
 }