/*
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011 Whamcloud, Inc.
+ *
*/
/*
* This file is part of Lustre, http://www.lustre.org/
static __u64 get_i_version(struct inode *inode)
{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) && defined(HAVE_EXT4_LDISKFS)
- return inode->i_version;
-#else
return EXT3_I(inode)->i_fs_version;
-#endif
}
static void set_i_version(struct inode *inode, __u64 new_version)
{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) && defined(HAVE_EXT4_LDISKFS)
- inode->i_version = new_version;
-#else
(EXT3_I(inode))->i_fs_version = new_version;
-#endif
}
/*
cpu_to_le32(EXT3_EXTENTS_FL | EXT3_INDEX_FL))) {
CWARN("extent-mapped directory found with "
"ext3-based ldiskfs - contact "
- "http://bugzilla.lustre.org/\n");
+ "http://bugs.whamcloud.com/\n");
warned = 1;
}
}
#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) {