Whamcloud - gitweb
b=20298 (Merge head ldiskfs and b1_8 ldiskfs)
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-extents-2.6.16-sles10.patch
index fd17dab..5b363ea 100644 (file)
@@ -1,10 +1,10 @@
-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
@@ -970,7 +970,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +}
 +
 +/*
-+ * returns first allocated block from next leaf or EXT_MAX_BLOCK
++ * returns first allocated block from next leaf or EXT_UNSET_BLOCK
 + */
 +static unsigned ext3_ext_next_leaf_block(struct ext3_extents_tree *tree,
 +                                       struct ext3_ext_path *path)
@@ -982,7 +982,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +
 +      /* zero-tree has no leaf blocks at all */
 +      if (depth == 0)
-+              return EXT_MAX_BLOCK;
++              return EXT_UNSET_BLOCK;
 +
 +      /* go to index block */
 +      depth--;
@@ -994,7 +994,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +              depth--;        
 +      }
 +
-+      return EXT_MAX_BLOCK;
++      return EXT_UNSET_BLOCK;
 +}
 +
 +/*
@@ -1112,7 +1112,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +      /* probably next leaf has space for us? */
 +      fex = EXT_LAST_EXTENT(eh);
 +      next = ext3_ext_next_leaf_block(tree, path);
-+      if (newext->ee_block > fex->ee_block && next != EXT_MAX_BLOCK) {
++      if (newext->ee_block > fex->ee_block && next != EXT_UNSET_BLOCK) {
 +              ext_debug(tree, "next leaf block - %d\n", next);
 +              EXT_ASSERT(!npath);
 +              npath = ext3_ext_find_extent(tree, next, NULL);
@@ -1577,8 +1577,8 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +              path[depth].p_ext = ex;
 +      
 +              a = ex->ee_block > start ? ex->ee_block : start;
-+              b = ex->ee_block + ex->ee_len - 1 < end ?
-+                      ex->ee_block + ex->ee_len - 1 : end;
++              b = (unsigned long long)ex->ee_block + ex->ee_len - 1 <
++                      end ? ex->ee_block + ex->ee_len - 1 : end;
 +              
 +              ext_debug(tree, "  border %u:%u\n", a, b);
 +
@@ -2260,101 +2260,6 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +      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);
@@ -2362,10 +2267,10 @@ Index: linux-2.6.16.27-0.9/fs/ext3/extents.c
 +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;
@@ -2394,10 +2299,10 @@ Index: linux-2.6.16.27-0.9/fs/ext3/ialloc.c
        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"
@@ -2407,7 +2312,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
  
  /*
   * Test whether an inode is a fast symlink.
-@@ -788,6 +788,17 @@ out:
+@@ -789,6 +789,17 @@ out:
        return err;
  }
  
@@ -2425,7 +2330,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
  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);
        }
@@ -2436,7 +2341,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
        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)
@@ -2445,7 +2350,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
                                        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);
@@ -2454,7 +2359,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
        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.
   */
@@ -2463,7 +2368,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
                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;
        }
  
@@ -2490,24 +2395,23 @@ Index: linux-2.6.16.27-0.9/fs/ext3/inode.c
        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.18.8/fs/ext3/Makefile
 ===================================================================
---- linux-2.6.16.27-0.9.orig/fs/ext3/Makefile
-+++ linux-2.6.16.27-0.9/fs/ext3/Makefile
-@@ -5,7 +5,8 @@
+--- linux-2.6.18.8.orig/fs/ext3/Makefile       2007-07-17 09:18:11.000000000 +0200
++++ linux-2.6.18.8/fs/ext3/Makefile    2007-07-17 11:08:11.000000000 +0200
+@@ -5,7 +5,7 @@
  obj-$(CONFIG_EXT3_FS) += ext3.o
  
  ext3-y        := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
 -         ioctl.o namei.o super.o symlink.o hash.o resize.o
-+         ioctl.o namei.o super.o symlink.o hash.o resize.o \
-+         extents.o
++         ioctl.o namei.o super.o symlink.o hash.o resize.o extents.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;
@@ -2525,7 +2429,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/super.c
        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,
@@ -2533,7 +2437,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/super.c
        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"},
@@ -2543,7 +2447,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/super.c
        {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;
@@ -2559,7 +2463,7 @@ Index: linux-2.6.16.27-0.9/fs/ext3/super.c
                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));
  
@@ -2567,25 +2471,10 @@ Index: linux-2.6.16.27-0.9/fs/ext3/super.c
        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) */
@@ -2598,17 +2487,7 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
  #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 */
@@ -2617,7 +2496,7 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
  
  /* 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
@@ -2632,7 +2511,7 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
  #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 */
@@ -2640,7 +2519,7 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
  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);
@@ -2648,7 +2527,7 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
  
  /* 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;
  
@@ -2660,18 +2539,16 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_fs.h
 +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
-@@ -0,0 +1,262 @@
++++ linux-2.6.16.54-0.2.5/include/linux/ext3_extents.h
+@@ -0,0 +1,263 @@
 +/*
-+ * 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
@@ -2850,6 +2727,7 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_extents.h
 +
 +
 +#define EXT_MAX_BLOCK 0xffffffff
++#define EXT_UNSET_BLOCK 1
 +
 +
 +#define EXT_FIRST_EXTENT(__hdr__) \
@@ -2932,10 +2810,10 @@ Index: linux-2.6.16.27-0.9/include/linux/ext3_extents.h
 +
 +
 +#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;