From dd6496697f9cb8e518d4409859e22936f17de0fc Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 22 Jun 2010 12:05:12 +1000 Subject: [PATCH] Revert a21596e51b872635c7cb0683a21fff981f5d3716 As index block don't change addresses after all, this isn't needed. Signed-off-by: NeilBrown --- index.c | 16 +++------------- modify.c | 24 ++++-------------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/index.c b/index.c index efeeb06..84e51ff 100644 --- a/index.c +++ b/index.c @@ -1263,11 +1263,6 @@ u32 lafs_leaf_next(struct indexblock *ib, u32 start) static u64 index_lookup(void *bf, int len, u32 target, u32 *addrp, u32 *nextp) { - /* We treat the first address in the buffer as *addrp, no - * matter what is really there. *addrp is the address of - * *this* index block. So if we find a hit on the first - * entry, we leave *addrp unchanged. - */ unsigned char *buf = bf; int lo, hi; u32 addr; @@ -1290,10 +1285,7 @@ index_lookup(void *bf, int len, u32 target, u32 *addrp, u32 *nextp) cp = buf; cp += mid*10; p = decode48(cp); - if (mid == 0) - addr = *addrp; - else - addr = decode32(cp); + addr = decode32(cp); dprintk("...addr=%lu target=%lu lo=%d mid=%d hi=%d\n", (unsigned long)addr, (unsigned long)target, lo, mid, hi); @@ -1307,8 +1299,7 @@ index_lookup(void *bf, int len, u32 target, u32 *addrp, u32 *nextp) cp += lo*10; p = decode48(cp); addr = decode32(cp); - if (lo > 0) - *addrp = addr; + *addrp = addr; if (cp+10 <= (unsigned char *) buf + len && nextp) { /* FIXME what about non-dense blocks? */ @@ -1325,7 +1316,7 @@ int lafs_index_empty(struct indexblock *ib) char *buf = map_iblock(ib); int blocksize = ib->b.inode->i_sb->s_blocksize; struct lafs_inode *li = LAFSI(ib->b.inode); - u32 addr = ib->b.fileaddr; + u32 addr; u64 phys; if (test_bit(B_InoIdx, &ib->b.flags)) @@ -1387,7 +1378,6 @@ lafs_leaf_find(struct inode *inode, u32 addr, int adopt, u32 *next, * So we don't use lafs_leaf_find during truncation. */ buf = map_iblock(ib); - iaddr = ib->b.fileaddr; iphys = index_lookup(buf + offset, blocksize - offset, addr, &iaddr, next); unmap_iblock(ib, buf); diff --git a/modify.c b/modify.c index 67a2561..8652030 100644 --- a/modify.c +++ b/modify.c @@ -189,8 +189,7 @@ static int incorporate_extent(struct uninc *ui, char *buf, int size) return credits; } -static int incorporate_index(struct block *uninc, char *buf, int size, - u32 first_addr) +static int incorporate_index(struct block *uninc, char *buf, int size) { /* see if we can merge the addresses of uninc blocks * with those in buf, by counting the total number, @@ -232,8 +231,6 @@ static int incorporate_index(struct block *uninc, char *buf, int size, if (i < icnt) { b = buf + i*10 + 6; iaddr = decode32(b); - if (i == 0) - iaddr = first_addr; } else iaddr = 0xffffffff; @@ -314,9 +311,7 @@ static int incorporate_index(struct block *uninc, char *buf, int size, uaddr = uninc->fileaddr; else uaddr = 0; - if (i == 1) - iaddr = first_addr; - else if (i > 1) { + if (i) { b = buf + (i-1)*10 + 6; iaddr = decode32(b); } else @@ -720,7 +715,6 @@ static int check_leaf(void *data, u32 addr, u64 phys, int len) } static u32 walk_index(u32 addr, char **bufp, int len, struct block *uninc, - u32 first_addr, int (*handle)(void*, u32, u64), void *data) { @@ -744,8 +738,6 @@ static u32 walk_index(u32 addr, char **bufp, int len, struct block *uninc, phys = decode48(buf); addr = decode32(buf); len -= 10; - if (buf == *bufp + 10) - addr = first_addr; } while (uninc && @@ -1444,7 +1436,6 @@ static int do_incorporate_internal(struct fs *fs, struct indexblock *ib, ok = walk_index(ib->b.fileaddr, &buf, len-2, uninc, - ib->b.fileaddr, add_index, &layout); @@ -1553,7 +1544,7 @@ static int do_incorporate_internal(struct fs *fs, struct indexblock *ib, new->uninc = b->chain; b->chain = NULL; nbuf = map_iblock(new); - cr = incorporate_index(b, nbuf, len, next); + cr = incorporate_index(b, nbuf, len); unmap_iblock(new, nbuf); LAFS_BUG(cr < 0, &ib->b); *credits += cr; @@ -1580,7 +1571,6 @@ static u32 update_index(struct indexblock *ib, u32 addr, u64 newphys) u32 a; int found = 0; int type; - int first = 1; p = buf; if (test_bit(B_InoIdx, &ib->b.flags)) { @@ -1594,11 +1584,6 @@ static u32 update_index(struct indexblock *ib, u32 addr, u64 newphys) while (len > 10) { phys = decode48(p); a = decode32(p); - if (first) { - /* Ignore first address in index blocks */ - a = ib->b.fileaddr; - first = 0; - } len -= 10; if (found) { p -= 20; @@ -1789,8 +1774,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib) /* internal index block. Might be able to merge in-place */ if (*(u16 *)(buf) == cpu_to_le16(IBLK_INDEX) && (cred = incorporate_index(uninc, buf+2, - blocksize-(offset+2), - ib->b.fileaddr)) >= 0) { + blocksize-(offset+2))) >= 0) { unmap_iblock(ib, buf-offset); uit.credits = cred; goto out; -- 2.39.5