Whamcloud - gitweb
file xnu_types.h was initially added on branch b_port_step.
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-record-extents-ea.patch
1 Index: linux-2.4.20-8/fs/ext3/super.c
2 ===================================================================
3 --- linux-2.4.20-8.orig/fs/ext3/super.c 2004-01-27 19:34:11.000000000 +0800
4 +++ linux-2.4.20-8/fs/ext3/super.c      2004-01-28 05:57:51.000000000 +0800
5 @@ -801,6 +801,8 @@
6                         set_opt (*mount_options, EXTENTS);
7                 else if (!strcmp (this_char, "extdebug"))
8                         set_opt (*mount_options, EXTDEBUG);
9 +               else if (!strcmp (this_char, "extents-ea"))
10 +                       set_opt (*mount_options, EXTENTS_EA); 
11                 else if (!strcmp (this_char, "grpid") ||
12                          !strcmp (this_char, "bsdgroups"))
13                         set_opt (*mount_options, GRPID);
14 Index: linux-2.4.20-8/fs/ext3/ialloc.c
15 ===================================================================
16 --- linux-2.4.20-8.orig/fs/ext3/ialloc.c        2004-01-28 01:02:17.000000000 +0800
17 +++ linux-2.4.20-8/fs/ext3/ialloc.c     2004-01-28 07:56:56.000000000 +0800
18 @@ -18,6 +18,7 @@
19  #include <linux/ext3_fs.h>
20  #include <linux/ext3_jbd.h>
21  #include <linux/ext3_xattr.h>
22 +#include <linux/ext3_extents.h>
23  #include <linux/stat.h>
24  #include <linux/string.h>
25  #include <linux/locks.h>
26 @@ -597,7 +598,7 @@
27                 EXT3_I(inode)->i_flags |= EXT3_EXTENTS_FL;
28                 ext3_extents_initialize_blockmap(handle, inode);
29         }
30
31 +
32         err = ext3_mark_iloc_dirty(handle, inode, &iloc);
33         if (err) goto fail;
34   
35 @@ -610,6 +611,12 @@
36                 return ERR_PTR(-EDQUOT);
37         }
38         ext3_debug ("allocating inode %lu\n", inode->i_ino);
39 +        
40 +       if (test_opt(sb, EXTENTS_EA)) {
41 +               EXT3_I(inode)->i_flags |= EXT3_EXTENTS_EA_FL;
42 +               ext3_init_extents_tree_in_ea(handle, inode);
43 +       }
44 +
45         return inode;
46  
47  fail:
48 Index: linux-2.4.20-8/fs/ext3/extents-in-ea.c
49 ===================================================================
50 --- linux-2.4.20-8.orig/fs/ext3/extents-in-ea.c 2004-01-27 20:21:43.000000000 +0800
51 +++ linux-2.4.20-8/fs/ext3/extents-in-ea.c      2004-01-28 06:05:26.000000000 +0800
52 @@ -30,6 +30,8 @@
53  #include <linux/slab.h>
54  #include <asm/uaccess.h>
55  
56 +#define EXTENTS_EA "sparse_extents"
57 +#define EXTENTS_EA_SIZE 64
58  static int ext3_get_ea_write_access(handle_t *handle, void *buffer)
59  {
60         struct buffer_head *bh = (struct buffer_head *) buffer;
61 @@ -81,6 +83,7 @@
62         brelse(bh);
63  }
64  
65 +
66  int ext3_init_tree_in_ea(struct inode *inode, int name_index,
67                                 const char *eaname, int size)
68  {
69 @@ -242,7 +245,23 @@
70                 buf->leaf_num++;
71         return EXT_CONTINUE;
72  }
73 -
74 +int ext3_init_extents_tree_in_ea(handle_t *handle, struct inode *inode)
75 +{
76 +       return ext3_init_tree_in_ea(inode, EXT3_XATTR_INDEX_EXTENTS,
77 +                                   EXTENTS_EA,  EXTENTS_EA_SIZE);      
78 +}  
79 +int ext3_insert_extents_in_ea(handle_t *handle, struct inode *inode,
80 +                              unsigned long from, unsigned long num)
81 +{
82 +       return ext3_ext_in_ea_alloc_space(inode, EXT3_XATTR_INDEX_EXTENTS,
83 +                                         EXTENTS_EA, from, num);       
84 +}
85 +int ext3_remove_extents_in_ea(handle_t *handle, struct inode *inode,
86 +                              unsigned long from, unsigned long num)
87 +{
88 +       return ext3_ext_in_ea_remove_space(inode, EXT3_XATTR_INDEX_EXTENTS,
89 +                                          EXTENTS_EA, from, num);      
90 +}
91  struct ea_tree_desc {
92         int name_index;
93         char eaname[256];
94 Index: linux-2.4.20-8/fs/ext3/inode.c
95 ===================================================================
96 --- linux-2.4.20-8.orig/fs/ext3/inode.c 2004-01-27 19:34:11.000000000 +0800
97 +++ linux-2.4.20-8/fs/ext3/inode.c      2004-01-28 06:03:46.000000000 +0800
98 @@ -32,7 +32,7 @@
99  #include <linux/quotaops.h>
100  #include <linux/module.h>
101  #include "iopen.h"
102 -
103 +#include <linux/ext3_extents.h>
104  /*
105   * SEARCH_FROM_ZERO forces each block allocation to search from the start
106   * of the filesystem.  This is to force rapid reallocation of recently-freed
107 @@ -852,9 +852,18 @@
108  ext3_get_block_wrap(handle_t *handle, struct inode *inode, long block,
109                 struct buffer_head *bh, int create)
110  {
111 +       int rc1 = 0, rc2 = 0;
112 +
113         if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
114 -               return ext3_ext_get_block(handle, inode, block, bh, create);
115 -       return ext3_get_block_handle(handle, inode, block, bh, create);
116 +               rc1 =  ext3_ext_get_block(handle, inode, block, bh, create);
117 +       rc1 = ext3_get_block_handle(handle, inode, block, bh, create);
118 +       if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_EA_FL) {
119 +               if (create)
120 +                       rc2 = ext3_insert_extents_in_ea(handle, inode, block, 1);       
121 +       }
122 +       if (!rc1)
123 +               return rc2;
124 +       return rc1; 
125  }
126  
127  /*
128 @@ -1897,6 +1906,11 @@
129  
130         ext3_discard_prealloc(inode);
131  
132 +       if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_EA_FL) {
133 +               last_block = (inode->i_size + inode->i_sb->s_blocksize - 1)
134 +                               >> EXT3_BLOCK_SIZE_BITS(inode->i_sb);
135 +               ext3_remove_extents_in_ea(NULL, inode, last_block, 0xffffffff);         
136 +       }
137         if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
138                 return ext3_ext_truncate(inode);
139  
140 Index: linux-2.4.20-8/include/linux/ext3_fs.h
141 ===================================================================
142 --- linux-2.4.20-8.orig/include/linux/ext3_fs.h 2004-01-27 20:21:43.000000000 +0800
143 +++ linux-2.4.20-8/include/linux/ext3_fs.h      2004-01-28 05:57:51.000000000 +0800
144 @@ -185,6 +185,7 @@
145  #define EXT3_JOURNAL_DATA_FL           0x00004000 /* file data should be journaled */
146  #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
147  #define EXT3_EXTENTS_FL                        0x00080000 /* Inode uses extents */
148 +#define EXT3_EXTENTS_EA_FL             0x00100000 /* Inode uses extents */
149  
150  #define EXT3_FL_USER_VISIBLE           0x00005FFF /* User visible flags */
151  #define EXT3_FL_USER_MODIFIABLE                0x000000FF /* User modifiable flags */
152 @@ -341,6 +342,7 @@
153  #define EXT3_MOUNT_ASYNCDEL            0x20000 /* Delayed deletion */
154  #define EXT3_MOUNT_EXTENTS             0x100000/* Extents support */
155  #define EXT3_MOUNT_EXTDEBUG            0x200000/* Extents debug */
156 +#define EXT3_MOUNT_EXTENTS_EA          0x400000/* record sparse Extents */
157  
158  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
159  #ifndef _LINUX_EXT2_FS_H
160 Index: linux-2.4.20-8/include/linux/ext3_xattr.h
161 ===================================================================
162 --- linux-2.4.20-8.orig/include/linux/ext3_xattr.h      2004-01-27 20:21:42.000000000 +0800
163 +++ linux-2.4.20-8/include/linux/ext3_xattr.h   2004-01-28 05:57:51.000000000 +0800
164 @@ -24,6 +24,7 @@
165  #define EXT3_XATTR_INDEX_TRUSTED               4
166  #define EXT3_XATTR_INDEX_LUSTRE                        5
167  #define EXT3_XATTR_INDEX_SECURITY              6
168 +#define EXT3_XATTR_INDEX_EXTENTS               7       
169  
170  struct ext3_xattr_header {
171         __u32   h_magic;        /* magic number for identification */
172 Index: linux-2.4.20-8/include/linux/ext3_extents.h
173 ===================================================================
174 --- linux-2.4.20-8.orig/include/linux/ext3_extents.h    2004-01-28 05:56:02.000000000 +0800
175 +++ linux-2.4.20-8/include/linux/ext3_extents.h 2004-01-28 06:46:15.000000000 +0800
176 @@ -209,5 +209,7 @@
177  extern struct ext3_ext_path * ext3_ext_find_extent(struct ext3_extents_tree *, int, struct ext3_ext_path *);
178  
179  extern int ext3_insert_extents_in_ea(handle_t *handle, struct inode *inode, unsigned long from, unsigned long num);
180 +extern int ext3_remove_extents_in_ea(handle_t *handle, struct inode *inode, unsigned long from, unsigned long num);
181 +extern int ext3_init_extents_tree_in_ea(handle_t *handle, struct inode *inode);
182  #endif /* _LINUX_EXT3_EXTENTS */
183