1/ Skip offset for InoIdx
2/ when moving address down, clear the space at the end
3/ stop when we find the last address.
Signed-off-by: NeilBrown <neilb@suse.de>
u64 phys;
u32 a;
int found = 0;
+ int type;
- p = buf+2;
+ p = buf;
+ if (test_bit(B_InoIdx, &ib->b.flags)) {
+ int offset = LAFSI(ib->b.inode)->metadata_size;
+ len -= offset;
+ p += offset;
+ }
+ type = decode16(p);
len -= 2;
+ LAFS_BUG(type != IBLK_INDEX, &ib->b);
while (len > 10) {
phys = decode48(p);
a = decode32(p);
len -= 10;
+ if (phys == 0)
+ break;
if (found) {
p -= 20;
encode48(p, phys);
encode32(p, a);
- p += 10;
+ encode48(p, 0ULL);
+ encode32(p, 0UL);
if (rv == 0)
rv = a;
} else if (a == addr)
found = 1;
else
- BUG_ON(a > addr);
+ LAFS_BUG(a > addr, &ib->b);
}
+ LAFS_BUG(!found, &ib->b);
unmap_iblock(ib, buf);
lafs_dirty_iblock(ib);
return rv;