return p;
}
+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;
+ u64 phys;
+
+ if (test_bit(B_InoIdx, &ib->b.flags))
+ phys = index_lookup(buf + li->metadata_size,
+ blocksize - li->metadata_size,
+ ib->b.fileaddr, &addr, NULL);
+ else
+ phys = index_lookup(buf, blocksize,
+ ib->b.fileaddr, &addr, NULL);
+ unmap_iblock(ib, buf);
+
+ return phys == 0;
+}
+
struct indexblock *
lafs_leaf_find(struct inode *inode, u32 addr, int adopt, u32 *next,
int async, REFARG)
struct indexblock *lafs_leaf_find(struct inode *inode, u32 addr,
int adopt, u32 *next, int async, REFARG);
u32 lafs_leaf_next(struct indexblock *ib, u32 start);
+int lafs_index_empty(struct indexblock *ib);
#ifdef DEBUG_IOLOCK
#define set_iolock_info(b) ( (b)->iolock_file = __FILE__, (b)->iolock_line = __LINE__)
#else
* B_Valid so that it doesn't get written out,
* but rather gets allocated as '0'.
*/
- if (test_bit(B_Valid, &ib->b.flags) &&
- lafs_leaf_next(ib, ib->b.fileaddr) == 0xFFFFFFFF)
- clear_bit(B_Valid, &ib->b.flags);
+ if (test_bit(B_Valid, &ib->b.flags)) {
+ if (ib->depth == 1 &&
+ lafs_leaf_next(ib, ib->b.fileaddr) == 0xFFFFFFFF)
+ clear_bit(B_Valid, &ib->b.flags);
+ if (ib->depth > 1 &&
+ lafs_index_empty(ib))
+ clear_bit(B_Valid, &ib->b.flags);
+ }
}
/***************************************************************