#include <linux/lustre_compat25.h>
#include <linux/lprocfs_status.h>
-#ifdef EXT3_MULTIBLOCK_ALLOCATOR
#ifdef HAVE_EXT4_LDISKFS
#include <ext4/ext4_extents.h>
#else
#include <linux/ext3_extents.h>
#endif
-#endif
#include "lustre_quota_fmt.h"
#define FSFILT_SINGLEDATA_TRANS_BLOCKS(sb) EXT3_SINGLEDATA_TRANS_BLOCKS
#endif
+#ifdef EXT_INSERT_EXTENT_WITH_5ARGS
+#define fsfilt_ext3_ext_insert_extent(handle, inode, path, newext, flag) \
+ ext3_ext_insert_extent(handle, inode, path, newext, flag)
+#else
+#define fsfilt_ext3_ext_insert_extent(handle, inode, path, newext, flag) \
+ ext3_ext_insert_extent(handle, inode, path, newext)
+#endif
+
+
static cfs_mem_cache_t *fcb_cache;
struct fsfilt_cb_data {
ENTRY;
/* FIXME: Can't do this because of nested transaction deadlock */
- if (cmd == EXT3_IOC_SETFLAGS && (*(int *)arg) & EXT3_JOURNAL_DATA_FL) {
- CERROR("can't set data journal flag on file\n");
- RETURN(-EPERM);
+ if (cmd == EXT3_IOC_SETFLAGS) {
+ /* We can't enable data journaling on OST objects, because
+ * this forces the transaction to be closed in order to
+ * flush the journal, but the caller will already have a
+ * compound transaction open to update the last_rcvd file,
+ * and this thread would deadlock trying to set the flag. */
+ if ((*(int *)arg) & EXT3_JOURNAL_DATA_FL) {
+ CERROR("can't set data journal flag on file\n");
+ RETURN(-EPERM);
+ }
+ /* Because the MDS does not see the EXTENTS_FL set on the
+ * OST objects, mask this flag into all set flags. It is
+ * not legal to clear this flag in any case, so we are not
+ * changing the functionality by doing this. b=22911 */
+ *(int *)arg |= EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL;
}
#ifdef HAVE_EXT4_LDISKFS
return ext3_force_commit(sb);
}
-#if defined(EXT3_MULTIBLOCK_ALLOCATOR) && (!defined(EXT3_EXT_CACHE_NO) || defined(EXT_CACHE_MARK))
-#warning "kernel code has old extents/mballoc patch, disabling"
-#undef EXT3_MULTIBLOCK_ALLOCATOR
-#endif
#ifndef EXT3_EXTENTS_FL
#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
#endif
-#ifdef EXT3_MULTIBLOCK_ALLOCATOR
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
-#define fsfilt_up_truncate_sem(inode) up(&EXT3_I(inode)->truncate_sem);
-#define fsfilt_down_truncate_sem(inode) down(&EXT3_I(inode)->truncate_sem);
-#else
-#ifdef HAVE_EXT4_LDISKFS
-#define fsfilt_up_truncate_sem(inode) up_write((&EXT4_I(inode)->i_data_sem));
-#define fsfilt_down_truncate_sem(inode) down_write((&EXT4_I(inode)->i_data_sem));
+# define fsfilt_up_truncate_sem(inode) up(&LDISKFS_I(inode)->truncate_sem);
+# define fsfilt_down_truncate_sem(inode) down(&LDISKFS_I(inode)->truncate_sem);
#else
-#define fsfilt_up_truncate_sem(inode) mutex_unlock(&EXT3_I(inode)->truncate_mutex);
-#define fsfilt_down_truncate_sem(inode) mutex_lock(&EXT3_I(inode)->truncate_mutex);
-#endif
+# ifdef HAVE_EXT4_LDISKFS
+# ifdef WALK_SPACE_HAS_DATA_SEM /* We only use it in fsfilt_map_nblocks() for now */
+# define fsfilt_up_truncate_sem(inode) do{ }while(0)
+# define fsfilt_down_truncate_sem(inode) do{ }while(0)
+# else
+# define fsfilt_up_truncate_sem(inode) up_write((&EXT4_I(inode)->i_data_sem))
+# define fsfilt_down_truncate_sem(inode) down_write((&EXT4_I(inode)->i_data_sem))
+# endif
+# else
+# define fsfilt_up_truncate_sem(inode) mutex_unlock(&EXT3_I(inode)->truncate_mutex)
+# define fsfilt_down_truncate_sem(inode) mutex_lock(&EXT3_I(inode)->truncate_mutex)
+# endif
#endif
#ifndef EXT_ASSERT
nex.ee_block = cpu_to_le32(cex->ec_block);
ext3_ext_store_pblock(&nex, pblock);
nex.ee_len = cpu_to_le16(count);
- err = ext3_ext_insert_extent(handle, base, path, &nex);
+ err = fsfilt_ext3_ext_insert_extent(handle, base, path, &nex, 0);
if (err) {
/* free data blocks we just allocated */
/* not a good idea to call discard here directly,
cleanup:
return rc;
}
-#endif /* EXT3_MULTIBLOCK_ALLOCATOR */
extern int ext3_map_inode_page(struct inode *inode, struct page *page,
unsigned long *blocks, int *created, int create);
cfs_semaphore_t *optional_sem)
{
int rc;
-#ifdef EXT3_MULTIBLOCK_ALLOCATOR
+
if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL) {
rc = fsfilt_ext3_map_ext_inode_pages(inode, page, pages,
blocks, created, create);
return rc;
}
-#endif
if (optional_sem != NULL)
cfs_down(optional_sem);
rc = fsfilt_ext3_map_bm_inode_pages(inode, page, pages, blocks,