-Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
+Index: linux-2.6.16.54-0.2.5/fs/ext3/extents.c
===================================================================
--- /dev/null
-+++ linux-2.6.16.27-0.9/fs/ext3/extents.c
-@@ -0,0 +1,2359 @@
++++ linux-2.6.16.54-0.2.5/fs/ext3/extents.c
+@@ -0,0 +1,2264 @@
+/*
-+ * Copyright(c) 2003, 2004, 2005, Cluster File Systems, Inc, info@clusterfs.com
++ * Copyright 2008 Sun Microsystems, Inc.
+ * Written by Alex Tomas <alex@clusterfs.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ return ext3_ext_calc_metadata_amount(&tree, blocks);
+}
+
-+static int
-+ext3_ext_store_extent_cb(struct ext3_extents_tree *tree,
-+ struct ext3_ext_path *path,
-+ struct ext3_ext_cache *newex)
-+{
-+ struct ext3_extent_buf *buf = (struct ext3_extent_buf *) tree->private;
-+
-+ if (newex->ec_type != EXT3_EXT_CACHE_EXTENT)
-+ return EXT_CONTINUE;
-+
-+ if (buf->err < 0)
-+ return EXT_BREAK;
-+ if (buf->cur - buf->buffer + sizeof(*newex) > buf->buflen)
-+ return EXT_BREAK;
-+
-+ if (!copy_to_user(buf->cur, newex, sizeof(*newex))) {
-+ buf->err++;
-+ buf->cur += sizeof(*newex);
-+ } else {
-+ buf->err = -EFAULT;
-+ return EXT_BREAK;
-+ }
-+ return EXT_CONTINUE;
-+}
-+
-+static int
-+ext3_ext_collect_stats_cb(struct ext3_extents_tree *tree,
-+ struct ext3_ext_path *path,
-+ struct ext3_ext_cache *ex)
-+{
-+ struct ext3_extent_tree_stats *buf =
-+ (struct ext3_extent_tree_stats *) tree->private;
-+ int depth;
-+
-+ if (ex->ec_type != EXT3_EXT_CACHE_EXTENT)
-+ return EXT_CONTINUE;
-+
-+ depth = EXT_DEPTH(tree);
-+ buf->extents_num++;
-+ if (path[depth].p_ext == EXT_FIRST_EXTENT(path[depth].p_hdr))
-+ buf->leaf_num++;
-+ return EXT_CONTINUE;
-+}
-+
-+int ext3_ext_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
-+ unsigned long arg)
-+{
-+ int err = 0;
-+
-+ if (!(EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL))
-+ return -EINVAL;
-+
-+ if (cmd == EXT3_IOC_GET_EXTENTS) {
-+ struct ext3_extent_buf buf;
-+ struct ext3_extents_tree tree;
-+
-+ if (copy_from_user(&buf, (void *) arg, sizeof(buf)))
-+ return -EFAULT;
-+
-+ ext3_init_tree_desc(&tree, inode);
-+ buf.cur = buf.buffer;
-+ buf.err = 0;
-+ tree.private = &buf;
-+ down(&EXT3_I(inode)->truncate_sem);
-+ err = ext3_ext_walk_space(&tree, buf.start, EXT_MAX_BLOCK,
-+ ext3_ext_store_extent_cb);
-+ up(&EXT3_I(inode)->truncate_sem);
-+ if (err == 0)
-+ err = buf.err;
-+ } else if (cmd == EXT3_IOC_GET_TREE_STATS) {
-+ struct ext3_extent_tree_stats buf;
-+ struct ext3_extents_tree tree;
-+
-+ ext3_init_tree_desc(&tree, inode);
-+ down(&EXT3_I(inode)->truncate_sem);
-+ buf.depth = EXT_DEPTH(&tree);
-+ buf.extents_num = 0;
-+ buf.leaf_num = 0;
-+ tree.private = &buf;
-+ err = ext3_ext_walk_space(&tree, 0, EXT_MAX_BLOCK,
-+ ext3_ext_collect_stats_cb);
-+ up(&EXT3_I(inode)->truncate_sem);
-+ if (!err)
-+ err = copy_to_user((void *) arg, &buf, sizeof(buf));
-+ } else if (cmd == EXT3_IOC_GET_TREE_DEPTH) {
-+ struct ext3_extents_tree tree;
-+ ext3_init_tree_desc(&tree, inode);
-+ down(&EXT3_I(inode)->truncate_sem);
-+ err = EXT_DEPTH(&tree);
-+ up(&EXT3_I(inode)->truncate_sem);
-+ }
-+
-+ return err;
-+}
-+
+EXPORT_SYMBOL(ext3_init_tree_desc);
+EXPORT_SYMBOL(ext3_mark_inode_dirty);
+EXPORT_SYMBOL(ext3_ext_invalidate_cache);
+EXPORT_SYMBOL(ext3_ext_walk_space);
+EXPORT_SYMBOL(ext3_ext_find_goal);
+EXPORT_SYMBOL(ext3_ext_calc_credits_for_insert);
-Index: linux-2.6.16.27-0.9/fs/ext3/ialloc.c
+Index: linux-2.6.16.54-0.2.5/fs/ext3/ialloc.c
===================================================================
---- linux-2.6.16.27-0.9.orig/fs/ext3/ialloc.c
-+++ linux-2.6.16.27-0.9/fs/ext3/ialloc.c
+--- linux-2.6.16.54-0.2.5.orig/fs/ext3/ialloc.c
++++ linux-2.6.16.54-0.2.5/fs/ext3/ialloc.c
@@ -601,7 +601,7 @@ got:
ei->i_dir_start_lookup = 0;
ei->i_disksize = 0;
err = ext3_mark_inode_dirty(handle, inode);
if (err) {
ext3_std_error(sb, err);
-Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
+Index: linux-2.6.16.54-0.2.5/fs/ext3/inode.c
===================================================================
---- linux-2.6.16.27-0.9.orig/fs/ext3/inode.c
-+++ linux-2.6.16.27-0.9/fs/ext3/inode.c
+--- linux-2.6.16.54-0.2.5.orig/fs/ext3/inode.c
++++ linux-2.6.16.54-0.2.5/fs/ext3/inode.c
@@ -40,7 +40,7 @@
#include "iopen.h"
#include "acl.h"
/*
* Test whether an inode is a fast symlink.
-@@ -788,6 +788,17 @@ out:
+@@ -789,6 +789,17 @@ out:
return err;
}
static int ext3_get_block(struct inode *inode, sector_t iblock,
struct buffer_head *bh_result, int create)
{
-@@ -798,8 +809,8 @@ static int ext3_get_block(struct inode *
+@@ -799,8 +810,8 @@ static int ext3_get_block(struct inode *
handle = ext3_journal_current_handle();
J_ASSERT(handle != 0);
}
return ret;
}
-@@ -843,7 +854,7 @@ ext3_direct_io_get_blocks(struct inode *
+@@ -844,7 +855,7 @@ ext3_direct_io_get_blocks(struct inode *
get_block:
if (ret == 0)
bh_result, create, 0);
bh_result->b_size = (1 << inode->i_blkbits);
return ret;
-@@ -863,7 +874,7 @@ struct buffer_head *ext3_getblk(handle_t
+@@ -864,7 +875,7 @@ struct buffer_head *ext3_getblk(handle_t
dummy.b_state = 0;
dummy.b_blocknr = -1000;
buffer_trace_init(&dummy.b_history);
if (!*errp && buffer_mapped(&dummy)) {
struct buffer_head *bh;
bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
-@@ -1606,7 +1617,7 @@ void ext3_set_aops(struct inode *inode)
+@@ -1607,7 +1618,7 @@ void ext3_set_aops(struct inode *inode)
* This required during truncate. We need to physically zero the tail end
* of that block so it doesn't yield old data if the file is later grown.
*/
struct address_space *mapping, loff_t from)
{
unsigned long index = from >> PAGE_CACHE_SHIFT;
-@@ -2116,6 +2127,9 @@ void ext3_truncate(struct inode * inode)
+@@ -2117,6 +2128,9 @@ void ext3_truncate(struct inode * inode)
return;
}
if (ext3_should_journal_data(inode))
ret = 3 * (bpp + indirects) + 2;
else
-Index: linux-2.6.16.27-0.9/fs/ext3/Makefile
+Index: linux-2.6.16.54-0.2.5/fs/ext3/Makefile
===================================================================
---- linux-2.6.16.27-0.9.orig/fs/ext3/Makefile
-+++ linux-2.6.16.27-0.9/fs/ext3/Makefile
+--- linux-2.6.16.54-0.2.5.orig/fs/ext3/Makefile
++++ linux-2.6.16.54-0.2.5/fs/ext3/Makefile
@@ -5,7 +5,8 @@
obj-$(CONFIG_EXT3_FS) += ext3.o
ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
-Index: linux-2.6.16.27-0.9/fs/ext3/super.c
+Index: linux-2.6.16.54-0.2.5/fs/ext3/super.c
===================================================================
---- linux-2.6.16.27-0.9.orig/fs/ext3/super.c
-+++ linux-2.6.16.27-0.9/fs/ext3/super.c
+--- linux-2.6.16.54-0.2.5.orig/fs/ext3/super.c
++++ linux-2.6.16.54-0.2.5/fs/ext3/super.c
@@ -392,6 +392,7 @@ static void ext3_put_super (struct super
struct ext3_super_block *es = sbi->s_es;
int i;
return &ei->vfs_inode;
}
-@@ -681,6 +684,7 @@ enum {
+@@ -678,6 +681,7 @@ enum {
Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
Opt_grpquota
};
-@@ -732,6 +736,9 @@ static match_table_t tokens = {
+@@ -729,6 +733,9 @@ static match_table_t tokens = {
{Opt_iopen, "iopen"},
{Opt_noiopen, "noiopen"},
{Opt_iopen_nopriv, "iopen_nopriv"},
{Opt_barrier, "barrier=%u"},
{Opt_err, NULL},
{Opt_resize, "resize"},
-@@ -1073,6 +1080,15 @@ clear_qf_name:
+@@ -1070,6 +1077,15 @@ clear_qf_name:
case Opt_nobh:
set_opt(sbi->s_mount_opt, NOBH);
break;
default:
printk (KERN_ERR
"EXT3-fs: Unrecognized mount option \"%s\" "
-@@ -1799,6 +1815,7 @@ static int ext3_fill_super (struct super
+@@ -1800,6 +1816,7 @@ static int ext3_fill_super (struct super
percpu_counter_mod(&sbi->s_dirs_counter,
ext3_count_dirs(sb));
lock_kernel();
return 0;
-Index: linux-2.6.16.27-0.9/fs/ext3/ioctl.c
-===================================================================
---- linux-2.6.16.27-0.9.orig/fs/ext3/ioctl.c
-+++ linux-2.6.16.27-0.9/fs/ext3/ioctl.c
-@@ -125,6 +125,10 @@ flags_err:
- err = ext3_change_inode_journal_flag(inode, jflag);
- return err;
- }
-+ case EXT3_IOC_GET_EXTENTS:
-+ case EXT3_IOC_GET_TREE_STATS:
-+ case EXT3_IOC_GET_TREE_DEPTH:
-+ return ext3_ext_ioctl(inode, filp, cmd, arg);
- case EXT3_IOC_GETVERSION:
- case EXT3_IOC_GETVERSION_OLD:
- return put_user(inode->i_generation, (int __user *) arg);
-Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
+Index: linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
===================================================================
---- linux-2.6.16.27-0.9.orig/include/linux/ext3_fs.h
-+++ linux-2.6.16.27-0.9/include/linux/ext3_fs.h
+--- linux-2.6.16.54-0.2.5.orig/include/linux/ext3_fs.h
++++ linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
@@ -185,9 +185,10 @@ struct ext3_group_desc
#define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
#define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
/*
-@@ -237,6 +238,9 @@ struct ext3_new_group_data {
- #endif
- #define EXT3_IOC_GETRSVSZ _IOR('f', 5, long)
- #define EXT3_IOC_SETRSVSZ _IOW('f', 6, long)
-+#define EXT3_IOC_GET_EXTENTS _IOR('f', 7, long)
-+#define EXT3_IOC_GET_TREE_DEPTH _IOR('f', 8, long)
-+#define EXT3_IOC_GET_TREE_STATS _IOR('f', 9, long)
-
- /*
- * Mount options
-@@ -377,6 +381,8 @@ struct ext3_inode {
+@@ -377,6 +378,8 @@ struct ext3_inode {
#define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
#define EXT3_MOUNT_IOPEN 0x400000 /* Allow access via iopen */
#define EXT3_MOUNT_IOPEN_NOPRIV 0x800000/* Make iopen world-readable */
/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
#ifndef clear_opt
-@@ -565,11 +571,13 @@ static inline struct ext3_inode_info *EX
+@@ -574,11 +577,13 @@ static inline int ext3_valid_inum(struct
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
#define EXT3_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
-@@ -776,6 +784,7 @@ extern unsigned long ext3_count_free (st
+@@ -785,6 +790,7 @@ extern unsigned long ext3_count_free (st
/* inode.c */
int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
-@@ -795,6 +804,7 @@ extern int ext3_get_inode_loc(struct ino
+@@ -804,6 +810,7 @@ extern int ext3_get_inode_loc(struct ino
extern void ext3_truncate (struct inode *);
extern void ext3_set_inode_flags(struct inode *);
extern void ext3_set_aops(struct inode *inode);
/* ioctl.c */
extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
-@@ -848,6 +858,16 @@ extern struct inode_operations ext3_spec
+@@ -857,6 +864,14 @@ extern struct inode_operations ext3_spec
extern struct inode_operations ext3_symlink_inode_operations;
extern struct inode_operations ext3_fast_symlink_inode_operations;
+extern void ext3_ext_init(struct super_block *);
+extern void ext3_ext_release(struct super_block *);
+extern void ext3_extents_initialize_blockmap(handle_t *, struct inode *);
-+extern int ext3_ext_ioctl(struct inode *inode, struct file *filp,
-+ unsigned int cmd, unsigned long arg);
#endif /* __KERNEL__ */
-Index: linux-2.6.16.27-0.9/include/linux/ext3_extents.h
+Index: linux-2.6.16.54-0.2.5/include/linux/ext3_extents.h
===================================================================
--- /dev/null
-+++ linux-2.6.16.27-0.9/include/linux/ext3_extents.h
++++ linux-2.6.16.54-0.2.5/include/linux/ext3_extents.h
@@ -0,0 +1,262 @@
+/*
-+ * Copyright (c) 2003, Cluster File Systems, Inc, info@clusterfs.com
++ * Copyright 2008 Sun Microsystems, Inc.
+ * Written by Alex Tomas <alex@clusterfs.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+
+
+#endif /* _LINUX_EXT3_EXTENTS */
-Index: linux-2.6.16.27-0.9/include/linux/ext3_fs_i.h
+Index: linux-2.6.16.54-0.2.5/include/linux/ext3_fs_i.h
===================================================================
---- linux-2.6.16.27-0.9.orig/include/linux/ext3_fs_i.h
-+++ linux-2.6.16.27-0.9/include/linux/ext3_fs_i.h
+--- linux-2.6.16.54-0.2.5.orig/include/linux/ext3_fs_i.h
++++ linux-2.6.16.54-0.2.5/include/linux/ext3_fs_i.h
@@ -133,6 +133,8 @@ struct ext3_inode_info {
*/
struct semaphore truncate_sem;