Whamcloud - gitweb
LU-2473 ldiskfs: Reorganize ldiskfs kernel patches
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.3 / ext4-max-dir-size.patch
1 Index: linux-2.6.32-el6-beta/fs/ext4/ialloc.c
2 ===================================================================
3 --- linux-2.6.32-el6-beta.orig/fs/ext4/ialloc.c
4 +++ linux-2.6.32-el6-beta/fs/ext4/ialloc.c
5 @@ -825,11 +825,15 @@ struct inode *ext4_new_inode(handle_t *h
6         sb = dir->i_sb;
7         ngroups = ext4_get_groups_count(sb);
8         trace_ext4_request_inode(dir, mode);
9 +
10 +       sbi = EXT4_SB(sb);
11 +       if (sbi->s_max_dir_size > 0 && i_size_read(dir) >= sbi->s_max_dir_size)
12 +               return ERR_PTR(-EFBIG);
13 +
14         inode = new_inode(sb);
15         if (!inode)
16                 return ERR_PTR(-ENOMEM);
17         ei = EXT4_I(inode);
18 -       sbi = EXT4_SB(sb);
19  
20         if (!goal)
21                 goal = sbi->s_inode_goal;
22 Index: linux-2.6.32-el6-beta/fs/ext4/super.c
23 ===================================================================
24 --- linux-2.6.32-el6-beta.orig/fs/ext4/super.c
25 +++ linux-2.6.32-el6-beta/fs/ext4/super.c
26 @@ -2601,6 +2601,7 @@ EXT4_RO_ATTR(lifetime_write_kbytes);
27  EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show,
28                  inode_readahead_blks_store, s_inode_readahead_blks);
29  EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
30 +EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size);
31  EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
32  EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
33  EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
34 @@ -2615,6 +2616,7 @@ static struct attribute *ext4_attrs[] = 
35         ATTR_LIST(lifetime_write_kbytes),
36         ATTR_LIST(inode_readahead_blks),
37         ATTR_LIST(inode_goal),
38 +       ATTR_LIST(max_dir_size),
39         ATTR_LIST(mb_stats),
40         ATTR_LIST(mb_max_to_scan),
41         ATTR_LIST(mb_min_to_scan),
42 Index: linux-2.6.32-el6-beta/fs/ext4/ext4.h
43 ===================================================================
44 --- linux-2.6.32-el6-beta.orig/fs/ext4/ext4.h
45 +++ linux-2.6.32-el6-beta/fs/ext4/ext4.h
46 @@ -1029,6 +1029,8 @@ struct ext4_sb_info {
47
48         unsigned int s_log_groups_per_flex;
49         struct flex_groups *s_flex_groups;
50 +
51 +       unsigned long s_max_dir_size;
52
53         /* workqueue for dio unwritten */
54         struct workqueue_struct *dio_unwritten_wq;
55 @@ -1353,6 +1355,12 @@ struct mmp_struct {
56  #define EXT4_MMP_MIN_CHECK_INTERVAL    5
57  
58  /*
59 + * max directory size tunable
60 + */
61 +#define EXT4_DEFAULT_MAX_DIR_SIZE      0
62 +#define EXT4_MAX_DIR_SIZE_NAME         "max_dir_size"
63 +
64 +/*
65   * Function prototypes
66   */
67