#endif
struct inode *inode = ext3_ext_base2inode(base);
struct ext3_extent nex;
+#if defined(HAVE_EXT4_LDISKFS) && defined(WALK_SPACE_HAS_DATA_SEM)
+ struct ext4_ext_path *tmppath = NULL;
+ struct ext4_extent *tmpex;
+#endif
unsigned long pblock;
unsigned long tgen;
- int err, i;
+ int err, i, depth;
unsigned long count;
handle_t *handle;
- i = EXT_DEPTH(base);
+ i = depth = EXT_DEPTH(base);
EXT_ASSERT(i == path->p_depth);
EXT_ASSERT(path[i].p_hdr);
return EXT_REPEAT;
}
+#if defined(HAVE_EXT4_LDISKFS) && defined(WALK_SPACE_HAS_DATA_SEM)
+ /* In 2.6.32 kernel, ext4_ext_walk_space()'s callback func is not
+ * protected by i_data_sem, we need revalidate extent to be created */
+ down_write((&EXT4_I(inode)->i_data_sem));
+
+ /* validate extent, make sure the extent tree does not changed */
+ tmppath = ext4_ext_find_extent(inode, cex->ec_block, NULL);
+ if (IS_ERR(tmppath)) {
+ up_write(&EXT4_I(inode)->i_data_sem);
+ ext3_journal_stop(handle);
+ return PTR_ERR(tmppath);
+ }
+ tmpex = tmppath[depth].p_ext;
+ if (tmpex != ex) {
+ /* cex is invalid, try again */
+ ext4_ext_drop_refs(tmppath);
+ kfree(tmppath);
+ up_write(&EXT4_I(inode)->i_data_sem);
+ ext3_journal_stop(handle);
+ return EXT_REPEAT;
+ }
+#endif
+
count = cex->ec_len;
pblock = new_blocks(handle, base, path, cex->ec_block, &count, &err);
if (!pblock)
BUG_ON(le32_to_cpu(nex.ee_block) != cex->ec_block);
out:
+#if defined(HAVE_EXT4_LDISKFS) && defined(WALK_SPACE_HAS_DATA_SEM)
+ ext4_ext_drop_refs(tmppath);
+ kfree(tmppath);
+ up_write((&EXT4_I(inode)->i_data_sem));
+#endif
ext3_journal_stop(handle);
map:
if (err >= 0) {