Whamcloud - gitweb
b=22769 improve error message for dx_probe
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-wantedi-2.6-sles11.patch
1 Index: linux-stage/fs/ext4/ialloc.c
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ialloc.c
4 +++ linux-stage/fs/ext4/ialloc.c
5 @@ -675,7 +675,8 @@ err_ret:
6   * For other inodes, search forward from the parent directory's block
7   * group to find a free inode.
8   */
9 -struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
10 +struct inode *ext4_new_inode_goal(handle_t *handle, struct inode *dir,
11 +                                 int mode, unsigned goal)
12  {
13         struct super_block *sb;
14         struct buffer_head *inode_bitmap_bh = NULL;
15 @@ -706,6 +707,14 @@ struct inode *ext4_new_inode(handle_t *h
16         sbi = EXT4_SB(sb);
17         es = sbi->s_es;
18  
19 +       if (goal && goal <= le32_to_cpu(es->s_inodes_count)) {
20 +               group = (goal - 1) / EXT4_INODES_PER_GROUP(sb);
21 +               ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb);
22 +
23 +               ret2 = 0;
24 +               goto got_group;
25 +       }
26 +
27         if (sbi->s_log_groups_per_flex) {
28                 ret2 = find_group_flex(sb, dir, &group);
29                 goto got_group;
30 @@ -724,7 +733,7 @@ got_group:
31         if (ret2 == -1)
32                 goto out;
33  
34 -       for (i = 0; i < sbi->s_groups_count; i++) {
35 +       for (i = 0; i < sbi->s_groups_count; i++, ino = 0) {
36                 err = -EIO;
37  
38                 gdp = ext4_get_group_desc(sb, group, &group_desc_bh);
39 @@ -736,8 +745,6 @@ got_group:
40                 if (!inode_bitmap_bh)
41                         goto fail;
42  
43 -               ino = 0;
44 -
45  repeat_in_this_group:
46                 ino = ext4_find_next_zero_bit((unsigned long *)
47                                         inode_bitmap_bh->b_data,
48 Index: linux-stage/fs/ext4/namei.c
49 ===================================================================
50 --- linux-stage.orig/fs/ext4/namei.c
51 +++ linux-stage/fs/ext4/namei.c
52 @@ -149,6 +149,17 @@ struct dx_map_entry
53         u16 size;
54  };
55  
56 +/*
57 + * dentry_param used by ext4_new_inode_wantedi()
58 + */
59 +#define LVFS_DENTRY_PARAM_MAGIC                20070216UL
60 +struct lvfs_dentry_params
61 +{
62 +       unsigned long   ldp_inum;
63 +       unsigned long   ldp_flags;
64 +       u32             ldp_magic;
65 +};
66 +
67  static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
68  static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
69  static inline unsigned dx_get_hash(struct dx_entry *entry);
70 @@ -1716,6 +1727,19 @@ static int ext4_add_nondir(handle_t *han
71         return err;
72  }
73  
74 +static unsigned ext4_dentry_goal(struct super_block *sb, struct dentry *dentry)
75 +{
76 +       unsigned inum = EXT4_SB(sb)->s_inode_goal;
77 +
78 +       if (dentry->d_fsdata != NULL) {
79 +               struct lvfs_dentry_params *param = dentry->d_fsdata;
80 +
81 +               if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC)
82 +                       inum = param->ldp_inum;
83 +       }
84 +       return inum;
85 +}
86 +
87  /*
88   * By the time this is called, we already have created
89   * the directory cache entry for the new file, but it
90 @@ -1741,7 +1766,8 @@ retry:
91         if (IS_DIRSYNC(dir))
92                 handle->h_sync = 1;
93  
94 -       inode = ext4_new_inode (handle, dir, mode);
95 +       inode = ext4_new_inode_goal(handle, dir, mode,
96 +                                   ext4_dentry_goal(dir->i_sb, dentry));
97         err = PTR_ERR(inode);
98         if (!IS_ERR(inode)) {
99                 inode->i_op = &ext4_file_inode_operations;
100 @@ -1775,7 +1800,8 @@ retry:
101         if (IS_DIRSYNC(dir))
102                 handle->h_sync = 1;
103  
104 -       inode = ext4_new_inode(handle, dir, mode);
105 +       inode = ext4_new_inode_goal(handle, dir, mode,
106 +                                   ext4_dentry_goal(dir->i_sb, dentry));
107         err = PTR_ERR(inode);
108         if (!IS_ERR(inode)) {
109                 init_special_inode(inode, inode->i_mode, rdev);
110 @@ -1811,7 +1836,8 @@ retry:
111         if (IS_DIRSYNC(dir))
112                 handle->h_sync = 1;
113  
114 -       inode = ext4_new_inode(handle, dir, S_IFDIR | mode);
115 +       inode = ext4_new_inode_goal(handle, dir, S_IFDIR | mode,
116 +                                   ext4_dentry_goal(dir->i_sb, dentry));
117         err = PTR_ERR(inode);
118         if (IS_ERR(inode))
119                 goto out_stop;
120 @@ -2211,7 +2236,8 @@ retry:
121         if (IS_DIRSYNC(dir))
122                 handle->h_sync = 1;
123  
124 -       inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO);
125 +       inode = ext4_new_inode_goal(handle, dir, S_IFLNK|S_IRWXUGO,
126 +                                   ext4_dentry_goal(dir->i_sb, dentry));
127         err = PTR_ERR(inode);
128         if (IS_ERR(inode))
129                 goto out_stop;
130 Index: linux-stage/fs/ext4/ext4.h
131 ===================================================================
132 --- linux-stage.orig/fs/ext4/ext4.h
133 +++ linux-stage/fs/ext4/ext4.h
134 @@ -1032,7 +1032,14 @@ extern int ext4fs_dirhash(const char *na
135                           dx_hash_info *hinfo);
136  
137  /* ialloc.c */
138 -extern struct inode * ext4_new_inode(handle_t *, struct inode *, int);
139 +extern struct inode *ext4_new_inode_goal(handle_t *handle, struct inode *dir,
140 +                                        int mode, unsigned goal);
141 +static inline struct inode *ext4_new_inode(handle_t *handle, struct inode *dir,
142 +                                          int mode)
143 +{
144 +       return ext4_new_inode_goal(handle, dir, mode,
145 +                                  EXT4_SB(dir->i_sb)->s_inode_goal);
146 +}
147  extern void ext4_free_inode(handle_t *, struct inode *);
148  extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
149  extern unsigned long ext4_count_free_inodes(struct super_block *);
150 Index: linux-stage/fs/ext4/super.c
151 ===================================================================
152 --- linux-stage.orig/fs/ext4/super.c
153 +++ linux-stage/fs/ext4/super.c
154 @@ -560,6 +560,7 @@ static void ext4_put_super(struct super_
155         }
156         if (sbi->s_proc) {
157                 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
158 +               remove_proc_entry("inode_goal", sbi->s_proc);
159                 remove_proc_entry(sb->s_id, ext4_proc_root);
160         }
161  
162 @@ -2274,10 +2275,14 @@ static int ext4_fill_super(struct super_
163         if (ext4_proc_root)
164                 sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root);
165  
166 -       if (sbi->s_proc)
167 +       if (sbi->s_proc) {
168                 proc_create_data("inode_readahead_blks", 0644, sbi->s_proc,
169                                  &ext4_ui_proc_fops,
170                                  &sbi->s_inode_readahead_blks);
171 +               proc_create_data("inode_goal", 0644, sbi->s_proc,
172 +                                &ext4_ui_proc_fops,
173 +                                &sbi->s_inode_goal);
174 +       }
175  #endif
176  
177         bgl_lock_init(&sbi->s_blockgroup_lock);
178 @@ -2553,6 +2558,7 @@ failed_mount2:
179  failed_mount:
180         if (sbi->s_proc) {
181                 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
182 +               remove_proc_entry("inode_goal", sbi->s_proc);
183                 remove_proc_entry(sb->s_id, ext4_proc_root);
184         }
185  #ifdef CONFIG_QUOTA
186 Index: linux-stage/fs/ext4/ext4_sb.h
187 ===================================================================
188 --- linux-stage.orig/fs/ext4/ext4_sb.h
189 +++ linux-stage/fs/ext4/ext4_sb.h
190 @@ -53,6 +53,7 @@ struct ext4_sb_info {
191         int s_inode_size;
192         int s_first_ino;
193         unsigned int s_inode_readahead_blks;
194 +       unsigned int s_inode_goal;
195         spinlock_t s_next_gen_lock;
196         u32 s_next_generation;
197         u32 s_hash_seed[4];
198