Whamcloud - gitweb
LU-1146 build: batch update copyright messages
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-max-dir-size-sles11.patch
1 Index: linux-2.6.27.21-0.1/fs/ext4/ialloc.c
2 ===================================================================
3 --- linux-2.6.27.21-0.1.orig/fs/ext4/ialloc.c   2009-07-07 14:35:55.000000000 +0530
4 +++ linux-2.6.27.21-0.1/fs/ext4/ialloc.c        2009-07-07 14:38:17.000000000 +0530
5 @@ -700,12 +700,15 @@
6                 return ERR_PTR(-EPERM);
7  
8         sb = dir->i_sb;
9 +       sbi = EXT4_SB(sb);
10 +       if (sbi->s_max_dir_size > 0 && i_size_read(dir) >= sbi->s_max_dir_size)
11 +               return ERR_PTR(-EFBIG);
12 +
13         inode = new_inode(sb);
14         if (!inode)
15                 return ERR_PTR(-ENOMEM);
16         ei = EXT4_I(inode);
17  
18 -       sbi = EXT4_SB(sb);
19         es = sbi->s_es;
20  
21         if (goal && goal < le32_to_cpu(es->s_inodes_count)) {
22 Index: linux-2.6.27.21-0.1/fs/ext4/super.c
23 ===================================================================
24 --- linux-2.6.27.21-0.1.orig/fs/ext4/super.c    2009-07-07 14:38:06.000000000 +0530
25 +++ linux-2.6.27.21-0.1/fs/ext4/super.c 2009-07-07 14:38:41.000000000 +0530
26 @@ -41,6 +41,7 @@
27  #include <asm/uaccess.h>
28  #include <linux/kthread.h>
29  #include <linux/utsname.h>
30 +#include <linux/proc_fs.h>
31  
32  #include "ext4.h"
33  #include "ext4_jbd2.h"
34 @@ -71,6 +72,8 @@
35  static void ext4_write_super_lockfs(struct super_block *sb);
36  
37  
38 +struct proc_dir_entry *proc_root_ext4;
39 +
40  ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
41                                struct ext4_group_desc *bg)
42  {
43 @@ -603,6 +606,7 @@
44         }
45         if (sbi->s_mmp_tsk)
46                 kthread_stop(sbi->s_mmp_tsk);
47 +
48         sb->s_fs_info = NULL;
49         kfree(sbi);
50         return;
51 @@ -2283,6 +2287,46 @@
52         return 0;
53  }
54  
55 +static int ext4_max_dir_size_read(char *page, char **start, off_t off,
56 +                                  int count, int *eof, void *data)
57 +{
58 +       struct ext4_sb_info *sbi = data;
59 +       int len;
60 +
61 +       *eof = 1;
62 +       if (off != 0)
63 +               return 0;
64 +
65 +       len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
66 +       *start = page;
67 +       return len;
68 +}
69 +
70 +static int ext4_max_dir_size_write(struct file *file, const char *buffer,
71 +                                   unsigned long count, void *data)
72 +{
73 +       struct ext4_sb_info *sbi = data;
74 +       char str[32];
75 +       unsigned long value;
76 +       char *end;
77 +
78 +       if (count >= sizeof(str)) {
79 +               printk(KERN_ERR "EXT4-fs: %s string too long, max %u bytes\n",
80 +                      EXT4_MAX_DIR_SIZE_NAME, (int)sizeof(str));
81 +               return -EOVERFLOW;
82 +       }
83 +
84 +       if (copy_from_user(str, buffer, count))
85 +               return -EFAULT;
86 +
87 +       value = simple_strtol(str, &end, 0);
88 +       if (value < 0)
89 +               return -ERANGE;
90 +
91 +       sbi->s_max_dir_size = value;
92 +       return count;
93 +}
94 +
95  static int ext4_fill_super(struct super_block *sb, void *data, int silent)
96                                 __releases(kernel_lock)
97                                 __acquires(kernel_lock)
98 @@ -2307,6 +2351,7 @@
99         int needs_recovery, has_huge_files;
100         int features;
101         __u64 blocks_count;
102 +       struct proc_dir_entry *proc;
103         int err;
104  
105         sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
106 @@ -2880,6 +2925,22 @@
107                test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
108                "writeback");
109  
110 +       sbi->s_max_dir_size = EXT4_DEFAULT_MAX_DIR_SIZE;
111 +       proc = create_proc_entry(EXT4_MAX_DIR_SIZE_NAME,
112 +                                S_IFREG | S_IRUGO | S_IWUSR, sbi->s_proc);
113 +       if (proc == NULL) {
114 +               printk(KERN_ERR "EXT4-fs: unable to create %s\n",
115 +                      EXT4_MAX_DIR_SIZE_NAME);
116 +               remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
117 +               remove_proc_entry(sbi->s_proc->name, proc_root_ext4);
118 +               sbi->s_proc = NULL;
119 +               ret = -ENOMEM;
120 +               goto failed_mount4;
121 +       }
122 +       proc->data = sbi;
123 +       proc->read_proc = ext4_max_dir_size_read;
124 +       proc->write_proc = ext4_max_dir_size_write;
125 +
126         lock_kernel();
127         return 0;
128  
129 @@ -2906,6 +2967,7 @@
130  failed_mount:
131         if (sbi->s_proc) {
132                 remove_proc_entry("inode_readahead_blks", sbi->s_proc);
133 +               remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
134                 remove_proc_entry("inode_goal", sbi->s_proc);
135                 remove_proc_entry(sb->s_id, ext4_proc_root);
136         }
137 @@ -3254,7 +3316,6 @@
138         }
139  }
140  
141 -
142  /*
143   * Have we just finished recovery?  If so, and if we are mounting (or
144   * remounting) the filesystem readonly, then we will end up with a
145 Index: linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h
146 ===================================================================
147 --- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_sb.h  2009-07-07 14:36:58.000000000 +0530
148 +++ linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h       2009-07-07 14:38:17.000000000 +0530
149 @@ -119,6 +119,7 @@
150         /* where last allocation was done - for stream allocation */
151         unsigned long s_mb_last_group;
152         unsigned long s_mb_last_start;
153 +       unsigned long s_max_dir_size;
154  
155         /* history to debug policy */
156         struct ext4_mb_history *s_mb_history;
157 Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h
158 ===================================================================
159 --- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h     2009-07-07 14:38:12.000000000 +0530
160 +++ linux-2.6.27.21-0.1/fs/ext4/ext4.h  2009-07-07 14:38:17.000000000 +0530
161 @@ -1017,6 +1017,14 @@
162   */
163  #define EXT4_MMP_MIN_CHECK_INTERVAL    5
164  
165 +extern struct proc_dir_entry *proc_root_ext4;
166 +
167 +/*
168 + * max directory size tunable
169 + */
170 +#define EXT4_DEFAULT_MAX_DIR_SIZE      0
171 +#define EXT4_MAX_DIR_SIZE_NAME         "max_dir_size"
172 +
173  /*
174   * Function prototypes
175   */
176 Index: linux-2.6.27.21-0.1/fs/ext4/mballoc.c
177 ===================================================================
178 --- linux-2.6.27.21-0.1.orig/fs/ext4/mballoc.c  2009-07-07 14:08:21.000000000 +0530
179 +++ linux-2.6.27.21-0.1/fs/ext4/mballoc.c       2009-07-07 14:38:17.000000000 +0530
180 @@ -2943,6 +2943,7 @@
181         remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc);
182         remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc);
183         remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc);
184 +       remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
185         return -ENOMEM;
186  #else
187         return 0;
188 @@ -2963,6 +2964,7 @@
189         remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc);
190         remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc);
191         remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc);
192 +       remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
193  #endif
194         return 0;
195  }