add 2.6.32 patches to use ext4 for ext2/3
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-2.6.32 / 040-use_ext4_for_ext23.patch
1 From 24b584240a0006ea7436cd35f5e8983eb76f1e6f Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Mon, 7 Dec 2009 14:08:51 -0500
4 Subject: [PATCH] ext4: Use ext4 file system driver for ext2/ext3 file system mounts
5
6 Add a new config option, CONFIG_EXT4_USE_FOR_EXT23 which if enabled,
7 will cause ext4 to be used for either ext2 or ext3 file system mounts
8 when ext2 or ext3 is not enabled in the configuration.
9
10 This allows minimalist kernel fanatics to drop to file system drivers
11 from their compiled kernel with out losing functionality.
12
13 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
14 ---
15 fs/ext4/Kconfig | 10 +++++++++
16 fs/ext4/super.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 2 files changed, 68 insertions(+), 0 deletions(-)
18
19 --- a/fs/ext4/Kconfig
20 +++ b/fs/ext4/Kconfig
21 @@ -26,6 +26,16 @@ config EXT4_FS
22
23 If unsure, say N.
24
25 +config EXT4_USE_FOR_EXT23
26 + bool "Use ext4 for ext2/ext3 file systems"
27 + depends on !EXT3_FS || !EXT2_FS
28 + default y
29 + help
30 + Allow the ext4 file system driver code to be used for ext2 or
31 + ext3 file system mounts. This allows users to reduce their
32 + compiled kernel size by using one file system driver for
33 + ext2, ext3, and ext4 file systems.
34 +
35 config EXT4_FS_XATTR
36 bool "Ext4 extended attributes"
37 depends on EXT4_FS
38 --- a/fs/ext4/super.c
39 +++ b/fs/ext4/super.c
40 @@ -3989,6 +3989,58 @@ static int ext4_get_sb(struct file_syste
41 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
42 }
43
44 +#if !defined(CONTIG_EXT2_FS) && defined(CONFIG_EXT4_USE_FOR_EXT23)
45 +static struct file_system_type ext2_fs_type = {
46 + .owner = THIS_MODULE,
47 + .name = "ext2",
48 + .get_sb = ext4_get_sb,
49 + .kill_sb = kill_block_super,
50 + .fs_flags = FS_REQUIRES_DEV,
51 +};
52 +
53 +static inline void register_as_ext2(void)
54 +{
55 + int err = register_filesystem(&ext2_fs_type);
56 + if (err)
57 + printk(KERN_WARNING
58 + "EXT4-fs: Unable to register as ext2 (%d)\n", err);
59 +}
60 +
61 +static inline void unregister_as_ext2(void)
62 +{
63 + unregister_filesystem(&ext2_fs_type);
64 +}
65 +#else
66 +static inline void register_as_ext2(void) { }
67 +static inline void unregister_as_ext2(void) { }
68 +#endif
69 +
70 +#if !defined(CONTIG_EXT3_FS) && defined(CONFIG_EXT4_USE_FOR_EXT23)
71 +static struct file_system_type ext3_fs_type = {
72 + .owner = THIS_MODULE,
73 + .name = "ext3",
74 + .get_sb = ext4_get_sb,
75 + .kill_sb = kill_block_super,
76 + .fs_flags = FS_REQUIRES_DEV,
77 +};
78 +
79 +static inline void register_as_ext3(void)
80 +{
81 + int err = register_filesystem(&ext3_fs_type);
82 + if (err)
83 + printk(KERN_WARNING
84 + "EXT4-fs: Unable to register as ext3 (%d)\n", err);
85 +}
86 +
87 +static inline void unregister_as_ext3(void)
88 +{
89 + unregister_filesystem(&ext3_fs_type);
90 +}
91 +#else
92 +static inline void register_as_ext3(void) { }
93 +static inline void unregister_as_ext3(void) { }
94 +#endif
95 +
96 static struct file_system_type ext4_fs_type = {
97 .owner = THIS_MODULE,
98 .name = "ext4",
99 @@ -4018,11 +4070,15 @@ static int __init init_ext4_fs(void)
100 err = init_inodecache();
101 if (err)
102 goto out1;
103 + register_as_ext2();
104 + register_as_ext3();
105 err = register_filesystem(&ext4_fs_type);
106 if (err)
107 goto out;
108 return 0;
109 out:
110 + unregister_as_ext2();
111 + unregister_as_ext3();
112 destroy_inodecache();
113 out1:
114 exit_ext4_xattr();
115 @@ -4038,6 +4094,8 @@ out4:
116
117 static void __exit exit_ext4_fs(void)
118 {
119 + unregister_as_ext2();
120 + unregister_as_ext3();
121 unregister_filesystem(&ext4_fs_type);
122 destroy_inodecache();
123 exit_ext4_xattr();