i=adilger
i=johann
fix test for last block
A large part of this code is from the generic VFS code in fs/ioctl.c in the
upstream kernel.
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-92.1.22/fs/ext3/ioctl.c
+Index: linux-2.6.18-128.1.6/fs/ext3/ioctl.c
===================================================================
===================================================================
---- linux-2.6.18-92.1.22.orig/fs/ext3/ioctl.c
-+++ linux-2.6.18-92.1.22/fs/ext3/ioctl.c
+--- 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 <linux/time.h>
#include <asm/uaccess.h>
@@ -15,7 +15,161 @@
#include <linux/time.h>
#include <asm/uaccess.h>
int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
-@@ -272,7 +426,9 @@ flags_err:
+@@ -276,7 +430,9 @@ flags_err:
-Index: linux-2.6.18-92.1.22/include/linux/ext3_fs.h
+Index: linux-2.6.18-128.1.6/include/linux/ext3_fs.h
===================================================================
===================================================================
---- linux-2.6.18-92.1.22.orig/include/linux/ext3_fs.h
-+++ linux-2.6.18-92.1.22/include/linux/ext3_fs.h
+--- 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)
@@ -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)
#endif /* __KERNEL__ */
/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
#endif /* __KERNEL__ */
/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
-Index: linux-2.6.18-92.1.22/include/linux/ext3_extents.h
+Index: linux-2.6.18-128.1.6/include/linux/ext3_extents.h
===================================================================
===================================================================
---- linux-2.6.18-92.1.22.orig/include/linux/ext3_extents.h
-+++ linux-2.6.18-92.1.22/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)
*/
@@ -142,8 +142,10 @@ struct ext3_ext_path {
* callback must return valid extent (passed or newly created)
*/
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 *);
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-92.1.22/fs/ext3/extents.c
+Index: linux-2.6.18-128.1.6/fs/ext3/extents.c
===================================================================
===================================================================
---- linux-2.6.18-92.1.22.orig/fs/ext3/extents.c
-+++ linux-2.6.18-92.1.22/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 <linux/string.h>
#include <linux/slab.h>
@@ -41,6 +41,7 @@
#include <linux/string.h>
#include <linux/slab.h>
+ void *data)
+{
+ struct fiemap_extent_info *fieinfo = data;
+ 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;
+ __u64 logical;
+ __u64 physical;
+ __u64 length;
+ *
+ * XXX this might miss a single-block extent at EXT_MAX_BLOCK
+ */
+ *
+ * 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,
+ flags |= FIEMAP_EXTENT_LAST;
+
+ error = fiemap_fill_next_extent(fieinfo, logical, physical,
EXPORT_SYMBOL(ext3_mark_inode_dirty);
EXPORT_SYMBOL(ext3_ext_invalidate_cache);
EXPORT_SYMBOL(ext3_ext_insert_extent);
EXPORT_SYMBOL(ext3_mark_inode_dirty);
EXPORT_SYMBOL(ext3_ext_invalidate_cache);
EXPORT_SYMBOL(ext3_ext_insert_extent);
-Index: linux-2.6.18-92.1.22/fs/ext3/fiemap.h
+Index: linux-2.6.18-128.1.6/fs/ext3/fiemap.h
===================================================================
--- /dev/null
===================================================================
--- /dev/null
-+++ linux-2.6.18-92.1.22/fs/ext3/fiemap.h
++++ linux-2.6.18-128.1.6/fs/ext3/fiemap.h
@@ -0,0 +1,85 @@
+/*
+ * FIEMAP ioctl infrastructure.
@@ -0,0 +1,85 @@
+/*
+ * FIEMAP ioctl infrastructure.
A large part of this code is from the generic VFS code in fs/ioctl.c in the
upstream kernel.
A large part of this code is from the generic VFS code in fs/ioctl.c in the
upstream kernel.
-Index: linux-2.6.9-67.0.22/fs/ext3/ioctl.c
+Index: linux-2.6.16.60-0.37/fs/ext3/ioctl.c
===================================================================
===================================================================
---- linux-2.6.9-67.0.22.orig/fs/ext3/ioctl.c
-+++ linux-2.6.9-67.0.22/fs/ext3/ioctl.c
-@@ -14,7 +14,161 @@
+--- linux-2.6.16.60-0.37.orig/fs/ext3/ioctl.c
++++ linux-2.6.16.60-0.37/fs/ext3/ioctl.c
+@@ -15,7 +15,161 @@
#include <linux/time.h>
#include <asm/uaccess.h>
#include <linux/namei.h>
#include <linux/time.h>
#include <asm/uaccess.h>
#include <linux/namei.h>
int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
-@@ -244,7 +398,9 @@ flags_err:
+@@ -262,7 +416,9 @@ flags_err:
-Index: linux-2.6.9-67.0.22/include/linux/ext3_fs.h
+Index: linux-2.6.16.60-0.37/include/linux/ext3_fs.h
===================================================================
===================================================================
---- linux-2.6.9-67.0.22.orig/include/linux/ext3_fs.h
-+++ linux-2.6.9-67.0.22/include/linux/ext3_fs.h
-@@ -260,15 +260,19 @@ struct ext3_new_group_data {
+--- linux-2.6.16.60-0.37.orig/include/linux/ext3_fs.h
++++ linux-2.6.16.60-0.37/include/linux/ext3_fs.h
+@@ -261,15 +261,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)
#define EXT3_IOC_SETFLAGS _IOW('f', 2, long)
#define EXT3_IOC_GETVERSION _IOR('f', 3, long)
#define EXT3_IOC_SETVERSION _IOW('f', 4, long)
+#define EXT3_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
/*
+#define EXT3_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
/*
- * Structure of an inode on the disk
-@@ -963,6 +967,9 @@ extern void ext3_set_aops(struct inode *
+ * Mount options
+@@ -997,6 +1001,9 @@ extern int ext3_writepage_trans_blocks(s
/* ioctl.c */
extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
/* ioctl.c */
extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
/* namei.c */
extern int ext3_orphan_add(handle_t *, struct inode *);
/* namei.c */
extern int ext3_orphan_add(handle_t *, struct inode *);
-Index: linux-2.6.9-67.0.22/include/linux/ext3_extents.h
+Index: linux-2.6.16.60-0.37/include/linux/ext3_extents.h
===================================================================
===================================================================
---- linux-2.6.9-67.0.22.orig/include/linux/ext3_extents.h
-+++ linux-2.6.9-67.0.22/include/linux/ext3_extents.h
+--- linux-2.6.16.60-0.37.orig/include/linux/ext3_extents.h
++++ linux-2.6.16.60-0.37/include/linux/ext3_extents.h
@@ -170,7 +170,10 @@ struct ext3_extents_helpers {
*/
typedef int (*ext_prepare_callback)(struct ext3_extents_tree *,
@@ -170,7 +170,10 @@ struct ext3_extents_helpers {
*/
typedef int (*ext_prepare_callback)(struct ext3_extents_tree *,
#define EXT_CONTINUE 0
#define EXT_BREAK 1
#define EXT_CONTINUE 0
#define EXT_BREAK 1
-@@ -179,6 +182,25 @@ typedef int (*ext_prepare_callback)(stru
-
+@@ -180,6 +183,25 @@ typedef int (*ext_prepare_callback)(stru
#define EXT_MAX_BLOCK 0xffffffff
#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
+/*
+ * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
#define EXT_FIRST_EXTENT(__hdr__) \
((struct ext3_extent *) (((char *) (__hdr__)) + \
#define EXT_FIRST_EXTENT(__hdr__) \
((struct ext3_extent *) (((char *) (__hdr__)) + \
-@@ -244,6 +266,12 @@ struct ext3_extent_tree_stats {
+@@ -243,6 +265,12 @@ struct ext3_extent_tree_stats {
extern int ext3_ext_search_left(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
extern int ext3_ext_search_right(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
extern void ext3_init_tree_desc(struct ext3_extents_tree *, struct inode *);
extern int ext3_ext_search_left(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
extern int ext3_ext_search_right(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
extern void ext3_init_tree_desc(struct ext3_extents_tree *, struct inode *);
-Index: linux-2.6.9-67.0.22/fs/ext3/extents.c
+Index: linux-2.6.16.60-0.37/fs/ext3/extents.c
===================================================================
===================================================================
---- linux-2.6.9-67.0.22.orig/fs/ext3/extents.c
-+++ linux-2.6.9-67.0.22/fs/ext3/extents.c
+--- linux-2.6.16.60-0.37.orig/fs/ext3/extents.c
++++ linux-2.6.16.60-0.37/fs/ext3/extents.c
@@ -41,6 +41,7 @@
#include <linux/string.h>
#include <linux/slab.h>
@@ -41,6 +41,7 @@
#include <linux/string.h>
#include <linux/slab.h>
-@@ -1489,7 +1490,7 @@ int ext3_ext_walk_space(struct ext3_exte
+@@ -1488,7 +1489,7 @@ int ext3_ext_walk_space(struct ext3_exte
EXT_ASSERT(cbex.ec_len > 0);
EXT_ASSERT(path[depth].p_hdr);
EXT_ASSERT(cbex.ec_len > 0);
EXT_ASSERT(path[depth].p_hdr);
ext3_ext_drop_refs(path);
if (err < 0)
ext3_ext_drop_refs(path);
if (err < 0)
-@@ -2503,7 +2504,109 @@ int ext3_ext_calc_blockmap_metadata(stru
+@@ -2502,7 +2503,109 @@ int ext3_ext_calc_blockmap_metadata(stru
ext3_init_tree_desc(&tree, inode);
return ext3_ext_calc_metadata_amount(&tree, blocks);
}
ext3_init_tree_desc(&tree, inode);
return ext3_ext_calc_metadata_amount(&tree, blocks);
}
+{
+ struct fiemap_extent_info *fieinfo = (struct fiemap_extent_info *)tree->private;
+ struct inode *inode = tree->inode;
+{
+ struct fiemap_extent_info *fieinfo = (struct fiemap_extent_info *)tree->private;
+ struct inode *inode = tree->inode;
-+ 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;
+ __u64 logical;
+ __u64 physical;
+ __u64 length;
+ *
+ * XXX this might miss a single-block extent at EXT_MAX_BLOCK
+ */
+ *
+ * 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,
+ flags |= FIEMAP_EXTENT_LAST;
+
+ error = fiemap_fill_next_extent(fieinfo, logical, physical,
EXPORT_SYMBOL(ext3_init_tree_desc);
EXPORT_SYMBOL(ext3_mark_inode_dirty);
EXPORT_SYMBOL(ext3_ext_invalidate_cache);
EXPORT_SYMBOL(ext3_init_tree_desc);
EXPORT_SYMBOL(ext3_mark_inode_dirty);
EXPORT_SYMBOL(ext3_ext_invalidate_cache);
-Index: linux-2.6.9-67.0.22/fs/ext3/fiemap.h
+Index: linux-2.6.16.60-0.37/fs/ext3/fiemap.h
===================================================================
--- /dev/null
===================================================================
--- /dev/null
-+++ linux-2.6.9-67.0.22/fs/ext3/fiemap.h
++++ linux-2.6.16.60-0.37/fs/ext3/fiemap.h
@@ -0,0 +1,85 @@
+/*
+ * FIEMAP ioctl infrastructure.
@@ -0,0 +1,85 @@
+/*
+ * FIEMAP ioctl infrastructure.
A large part of this code is from the generic VFS code in fs/ioctl.c in the
upstream kernel.
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.i386/fs/ext4/ioctl.c
+Index: linux-2.6.18-128.1.6/fs/ext4/ioctl.c
===================================================================
===================================================================
---- linux-2.6.18.i386.orig/fs/ext4/ioctl.c
-+++ linux-2.6.18.i386/fs/ext4/ioctl.c
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ioctl.c
++++ linux-2.6.18-128.1.6/fs/ext4/ioctl.c
@@ -17,6 +17,162 @@
#include "ext4_jbd2.h"
#include "ext4.h"
@@ -17,6 +17,162 @@
#include "ext4_jbd2.h"
#include "ext4.h"
default:
return -ENOTTY;
}
default:
return -ENOTTY;
}
-Index: linux-2.6.18.i386/fs/ext4/ext4.h
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4.h
===================================================================
===================================================================
---- linux-2.6.18.i386.orig/fs/ext4/ext4.h
-+++ linux-2.6.18.i386/fs/ext4/ext4.h
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4.h
@@ -300,6 +300,7 @@ struct ext4_new_group_data {
#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
@@ -300,6 +300,7 @@ struct ext4_new_group_data {
#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
-@@ -1115,6 +1118,9 @@ extern int ext4_page_mkwrite(struct vm_a
+@@ -1117,6 +1120,9 @@ extern int ext4_page_mkwrite(struct vm_a
/* ioctl.c */
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
/* ioctl.c */
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
/* migrate.c */
extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
/* migrate.c */
extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
-Index: linux-2.6.18.i386/fs/ext4/ext4_extents.h
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4_extents.h
===================================================================
===================================================================
---- linux-2.6.18.i386.orig/fs/ext4/ext4_extents.h
-+++ linux-2.6.18.i386/fs/ext4/ext4_extents.h
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4_extents.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4_extents.h
@@ -128,6 +128,22 @@ struct ext4_ext_path {
#define EXT_MAX_BLOCK 0xffffffff
@@ -128,6 +128,22 @@ struct ext4_ext_path {
#define EXT_MAX_BLOCK 0xffffffff
extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
struct ext4_ext_path *);
extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
struct ext4_ext_path *);
extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
-Index: linux-2.6.18.i386/fs/ext4/extents.c
+Index: linux-2.6.18-128.1.6/fs/ext4/extents.c
===================================================================
===================================================================
---- linux-2.6.18.i386.orig/fs/ext4/extents.c
-+++ linux-2.6.18.i386/fs/ext4/extents.c
+--- linux-2.6.18-128.1.6.orig/fs/ext4/extents.c
++++ linux-2.6.18-128.1.6/fs/ext4/extents.c
@@ -44,7 +44,7 @@
#include <asm/uaccess.h>
#include "ext4_jbd2.h"
@@ -44,7 +44,7 @@
#include <asm/uaccess.h>
#include "ext4_jbd2.h"
+ void *data)
+{
+ struct fiemap_extent_info *fieinfo = data;
+ 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;
+ __u64 logical;
+ __u64 physical;
+ __u64 length;
+ *
+ * XXX this might miss a single-block extent at EXT_MAX_BLOCK
+ */
+ *
+ * XXX this might miss a single-block extent at EXT_MAX_BLOCK
+ */
-+ if (logical + length - 1 == EXT_MAX_BLOCK ||
-+ ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
++ if (ext4_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,
+ flags |= FIEMAP_EXTENT_LAST;
+
+ error = fiemap_fill_next_extent(fieinfo, logical, physical,
-Index: linux-2.6.18.i386/fs/ext4/fiemap.h
+Index: linux-2.6.18-128.1.6/fs/ext4/fiemap.h
===================================================================
--- /dev/null
===================================================================
--- /dev/null
-+++ linux-2.6.18.i386/fs/ext4/fiemap.h
++++ linux-2.6.18-128.1.6/fs/ext4/fiemap.h
@@ -0,0 +1,85 @@
+/*
+ * FIEMAP ioctl infrastructure.
@@ -0,0 +1,85 @@
+/*
+ * FIEMAP ioctl infrastructure.
-@@ -1130,6 +1133,9 @@ extern int ext4_page_mkwrite(struct vm_a
+@@ -1132,6 +1135,9 @@ extern int ext4_page_mkwrite(struct vm_a
/* ioctl.c */
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
/* ioctl.c */
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
+ void *data)
+{
+ struct fiemap_extent_info *fieinfo = data;
+ 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;
+ __u64 logical;
+ __u64 physical;
+ __u64 length;
+ *
+ * XXX this might miss a single-block extent at EXT_MAX_BLOCK
+ */
+ *
+ * XXX this might miss a single-block extent at EXT_MAX_BLOCK
+ */
-+ if (logical + length - 1 == EXT_MAX_BLOCK ||
-+ ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
++ if (ext4_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,
+ flags |= FIEMAP_EXTENT_LAST;
+
+ error = fiemap_fill_next_extent(fieinfo, logical, physical,