X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=ldiskfs%2Fkernel_patches%2Fpatches%2Fext3-fiemap-2.6-rhel5.patch;h=49e8f8f2af2b334d1246836264d5b3fc6ef68ff2;hp=5770464cacd63eb7d54da9ee9842c413e5108083;hb=5a017da9c108fe00f882672e454ba9eabddf2d71;hpb=64a4664442e8060f95fde4f30b1fa7d65282be97 diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch index 5770464..49e8f8f 100644 --- a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch +++ b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch @@ -1,11 +1,11 @@ A large part of this code is from the generic VFS code in fs/ioctl.c in the upstream kernel. -Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c +Index: linux-2.6.18-128.1.6/fs/ext3/ioctl.c =================================================================== ---- linux-2.6.18-53.1.14.orig/fs/ext3/ioctl.c -+++ linux-2.6.18-53.1.14/fs/ext3/ioctl.c -@@ -15,7 +15,159 @@ +--- linux-2.6.18-128.1.6.orig/fs/ext3/ioctl.c ++++ linux-2.6.18-128.1.6/fs/ext3/ioctl.c +@@ -15,7 +15,161 @@ #include #include #include @@ -19,9 +19,9 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c + * @fieinfo: Fiemap context passed into ->fiemap + * @logical: Extent logical start offset, in bytes + * @phys: Extent physical start offset, in bytes -+ * @len: Extent length, in bytes ++ * @len: Extent length, in bytes + * @flags: FIEMAP_EXTENT flags that describe this extent -+ * @lun: LUN on which this extent resides ++ * @lun: LUN on which this extent resides + * + * Called from file system ->fiemap callback. Will populate extent + * info as passed in via arguments and copy to user memory. On @@ -31,9 +31,9 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c + * extent that will fit in user array. + */ +#define SET_UNKNOWN_FLAGS (FIEMAP_EXTENT_DELALLOC) -+#define SET_NO_DIRECT_FLAGS (FIEMAP_EXTENT_DATA_COMPRESSED \ -+ |FIEMAP_EXTENT_DATA_ENCRYPTED \ ++#define SET_NO_DIRECT_FLAGS (FIEMAP_EXTENT_DATA_ENCRYPTED \ + |FIEMAP_EXTENT_NET) ++#define SET_NO_UNMOUNTED_IO_FLAGS (FIEMAP_EXTENT_DATA_ENCRYPTED) +#define SET_NOT_ALIGNED_FLAGS (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE) +int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical, + u64 phys, u64 len, u32 flags, dev_t dev) @@ -43,19 +43,21 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c + + /* only count the extents */ + if (fieinfo->fi_extents_max == 0) { -+ fieinfo->fi_extents_mapped++; -+ return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; ++ fieinfo->fi_extents_mapped++; ++ return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; + } + + if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max) -+ return 1; ++ return 1; + + if (flags & SET_UNKNOWN_FLAGS) -+ flags |= FIEMAP_EXTENT_UNKNOWN; ++ flags |= FIEMAP_EXTENT_UNKNOWN; + if (flags & SET_NO_DIRECT_FLAGS) -+ flags |= FIEMAP_EXTENT_NO_DIRECT; ++ flags |= FIEMAP_EXTENT_NO_DIRECT; + if (flags & SET_NOT_ALIGNED_FLAGS) -+ flags |= FIEMAP_EXTENT_NOT_ALIGNED; ++ flags |= FIEMAP_EXTENT_NOT_ALIGNED; ++ if (flags & SET_NO_UNMOUNTED_IO_FLAGS) ++ flags |= FIEMAP_EXTENT_ENCODED; + + extent.fe_logical = logical; + extent.fe_physical = phys; @@ -65,11 +67,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c + + dest += fieinfo->fi_extents_mapped; + if (copy_to_user(dest, &extent, sizeof(extent))) -+ return -EFAULT; ++ return -EFAULT; + + fieinfo->fi_extents_mapped++; + if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max) -+ return 1; ++ return 1; + + return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; +} @@ -131,11 +133,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c + int error = 0; + + if (copy_from_user(&fiemap, (struct fiemap __user *) arg, -+ sizeof(struct fiemap))) ++ sizeof(struct fiemap))) + return -EFAULT; + + if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS) -+ return -EINVAL; ++ return -EINVAL; + + error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length, + &len); @@ -149,7 +151,7 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c + if (fiemap.fm_extent_count != 0 && + !access_ok(VERIFY_WRITE, (void *)arg, + offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count]))) -+ return -EFAULT; ++ return -EFAULT; + + if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC) + filemap_write_and_wait(inode->i_mapping); @@ -165,7 +167,7 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, unsigned long arg) -@@ -272,7 +424,9 @@ flags_err: +@@ -276,7 +430,9 @@ flags_err: return err; } @@ -176,11 +178,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c default: return -ENOTTY; -Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h +Index: linux-2.6.18-128.1.6/include/linux/ext3_fs.h =================================================================== ---- linux-2.6.18-53.1.14.orig/include/linux/ext3_fs.h -+++ linux-2.6.18-53.1.14/include/linux/ext3_fs.h -@@ -257,15 +257,19 @@ struct ext3_new_group_data { +--- linux-2.6.18-128.1.6.orig/include/linux/ext3_fs.h ++++ linux-2.6.18-128.1.6/include/linux/ext3_fs.h +@@ -258,15 +258,19 @@ struct ext3_new_group_data { #define EXT3_IOC_SETFLAGS _IOW('f', 2, long) #define EXT3_IOC_GETVERSION _IOR('f', 3, long) #define EXT3_IOC_SETVERSION _IOW('f', 4, long) @@ -188,7 +190,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h +#define EXT3_IOC_SETRSVSZ _IOW('f', 6, long) #define EXT3_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long) #define EXT3_IOC_GROUP_ADD _IOW('f', 8,struct ext3_new_group_input) -+#define EXT3_IOC_FIEMAP _IOWR('f', 10, struct fiemap) ++#define EXT3_IOC_FIEMAP _IOWR('f', 11, struct fiemap) #define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long) #define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long) #ifdef CONFIG_JBD_DEBUG @@ -202,7 +204,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h /* * Mount options -@@ -1040,6 +1044,9 @@ extern int ext3_block_truncate_page(hand +@@ -1041,6 +1045,9 @@ extern int ext3_block_truncate_page(hand /* ioctl.c */ extern int ext3_ioctl (struct inode *, struct file *, unsigned int, unsigned long); @@ -212,7 +214,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h /* namei.c */ extern int ext3_orphan_add(handle_t *, struct inode *); -@@ -1117,7 +1124,6 @@ ext3_get_blocks_wrap(handle_t *handle, s +@@ -1118,7 +1125,6 @@ ext3_get_blocks_wrap(handle_t *handle, s return ret; } @@ -220,10 +222,10 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h #endif /* __KERNEL__ */ /* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */ -Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h +Index: linux-2.6.18-128.1.6/include/linux/ext3_extents.h =================================================================== ---- linux-2.6.18-53.1.14.orig/include/linux/ext3_extents.h -+++ linux-2.6.18-53.1.14/include/linux/ext3_extents.h +--- linux-2.6.18-128.1.6.orig/include/linux/ext3_extents.h ++++ linux-2.6.18-128.1.6/include/linux/ext3_extents.h @@ -142,8 +142,10 @@ struct ext3_ext_path { * callback must return valid extent (passed or newly created) */ @@ -237,9 +239,9 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h #define EXT_CONTINUE 0 #define EXT_BREAK 1 -@@ -152,6 +154,26 @@ typedef int (*ext_prepare_callback)(stru - +@@ -153,6 +155,26 @@ typedef int (*ext_prepare_callback)(stru #define EXT_MAX_BLOCK 0xffffffff + #define EXT_UNSET_BLOCK 1 +/* + * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an @@ -264,7 +266,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h #define EXT_FLAGS_CLR_UNKNOWN 0x7 /* Flags cleared on modification */ #define EXT_HDR_GEN_BITS 24 #define EXT_HDR_GEN_MASK ((1 << EXT_HDR_GEN_BITS) - 1) -@@ -219,6 +241,12 @@ ext3_ext_invalidate_cache(struct inode * +@@ -220,6 +242,12 @@ ext3_ext_invalidate_cache(struct inode * EXT3_I(inode)->i_cached_extent.ec_type = EXT3_EXT_CACHE_NO; } @@ -277,10 +279,10 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h extern int ext3_ext_search_left(struct inode *, struct ext3_ext_path *, unsigned long *, unsigned long *); extern int ext3_ext_search_right(struct inode *, struct ext3_ext_path *, unsigned long *, unsigned long *); extern int ext3_extent_tree_init(handle_t *, struct inode *); -Index: linux-2.6.18-53.1.14/fs/ext3/extents.c +Index: linux-2.6.18-128.1.6/fs/ext3/extents.c =================================================================== ---- linux-2.6.18-53.1.14.orig/fs/ext3/extents.c -+++ linux-2.6.18-53.1.14/fs/ext3/extents.c +--- linux-2.6.18-128.1.6.orig/fs/ext3/extents.c ++++ linux-2.6.18-128.1.6/fs/ext3/extents.c @@ -41,6 +41,7 @@ #include #include @@ -310,7 +312,7 @@ Index: linux-2.6.18-53.1.14/fs/ext3/extents.c + void *data) +{ + struct fiemap_extent_info *fieinfo = data; -+ unsigned long blksize_bits = inode->i_sb->s_blocksize_bits; ++ unsigned char blksize_bits = inode->i_sb->s_blocksize_bits; + __u64 logical; + __u64 physical; + __u64 length; @@ -357,8 +359,8 @@ Index: linux-2.6.18-53.1.14/fs/ext3/extents.c + * + * XXX this might miss a single-block extent at EXT_MAX_BLOCK + */ -+ if (logical + length - 1 == EXT_MAX_BLOCK || -+ ext3_ext_next_allocated_block(path) == EXT_MAX_BLOCK) ++ if (ext3_ext_next_allocated_block(path) == EXT_MAX_BLOCK || ++ newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK) + flags |= FIEMAP_EXTENT_LAST; + + error = fiemap_fill_next_extent(fieinfo, logical, physical, @@ -385,7 +387,7 @@ Index: linux-2.6.18-53.1.14/fs/ext3/extents.c + return -EBADR; + + start_blk = start >> inode->i_sb->s_blocksize_bits; -+ len_blks = (len + inode->i_sb->s_blocksize) >> inode->i_sb->s_blocksize_bits; ++ len_blks = (len + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; + + /* + * Walk the extent tree gathering extent information. @@ -402,15 +404,15 @@ Index: linux-2.6.18-53.1.14/fs/ext3/extents.c EXPORT_SYMBOL(ext3_mark_inode_dirty); EXPORT_SYMBOL(ext3_ext_invalidate_cache); EXPORT_SYMBOL(ext3_ext_insert_extent); -Index: linux-2.6.18-53.1.14/fs/ext3/fiemap.h +Index: linux-2.6.18-128.1.6/fs/ext3/fiemap.h =================================================================== --- /dev/null -+++ linux-2.6.18-53.1.14/fs/ext3/fiemap.h -@@ -0,0 +1,84 @@ ++++ linux-2.6.18-128.1.6/fs/ext3/fiemap.h +@@ -0,0 +1,85 @@ +/* + * FIEMAP ioctl infrastructure. + * -+ * Copyright (C) 2007 Cluster File Systems, Inc ++ * Copyright 2008 Sun Microsystems, Inc. + * + * Author: Kalpak Shah + * Andreas Dilger @@ -425,8 +427,10 @@ Index: linux-2.6.18-53.1.14/fs/ext3/fiemap.h + __u64 fe_physical; /* physical offset in bytes for the start + * of the extent from the beginning of the disk */ + __u64 fe_length; /* length in bytes for this extent */ ++ __u64 fe_reserved64[2]; + __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ + __u32 fe_device; /* device number for this extent */ ++ __u32 fe_reserved[2]; +}; + +struct fiemap { @@ -463,32 +467,30 @@ Index: linux-2.6.18-53.1.14/fs/ext3/fiemap.h +/* ldiskfs only supports FLAG_SYNC flag currently */ +#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) + -+ +#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */ +#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ +#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending. -+ * Sets EXTENT_UNKNOWN. */ -+#define FIEMAP_EXTENT_NO_DIRECT 0x00000008 /* Data mapping undefined */ -+#define FIEMAP_EXTENT_SECONDARY 0x00000010 /* Data copied offline. May -+ * set EXTENT_NO_DIRECT. */ -+#define FIEMAP_EXTENT_NET 0x00000020 /* Data stored remotely. -+ * Sets EXTENT_NO_DIRECT. */ -+#define FIEMAP_EXTENT_DATA_COMPRESSED 0x00000040 /* Data is compressed by fs. -+ * Sets EXTENT_NO_DIRECT. */ ++ * Sets EXTENT_UNKNOWN. */ ++#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read ++ * while fs is unmounted */ +#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs. -+ * Sets EXTENT_NO_DIRECT. */ ++ * Sets EXTENT_NO_DIRECT. */ +#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be -+ * block aligned. */ ++ * block aligned. */ +#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata. -+ * Sets EXTENT_NOT_ALIGNED.*/ ++ * Sets EXTENT_NOT_ALIGNED.*/ +#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block. -+ * Sets EXTENT_NOT_ALIGNED.*/ ++ * Sets EXTENT_NOT_ALIGNED.*/ +#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but -+ * no data (i.e. zero). */ ++ * no data (i.e. zero). */ +#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively -+ * support extents. Result -+ * merged for efficiency. */ ++ * support extents. Result ++ * merged for efficiency. */ ++ ++/* Lustre specific flags - use a high bit, don't conflict with upstream flag */ ++#define FIEMAP_EXTENT_NO_DIRECT 0x40000000 /* Data mapping undefined */ ++#define FIEMAP_EXTENT_NET 0x80000000 /* Data stored remotely. ++ * Sets NO_DIRECT flag */ + +#endif /* _LINUX_EXT3_FIEMAP_H */ + -