]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - fs/ext2/super.c
ext2: Call dquot_writeback_dquots() with s_umount held
[mirror_ubuntu-artful-kernel.git] / fs / ext2 / super.c
CommitLineData
1da177e4
LT
1/*
2 * linux/fs/ext2/super.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/fs/minix/inode.c
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 *
15 * Big-endian to little-endian byte-swapping/bitmaps by
16 * David S. Miller (davem@caip.rutgers.edu), 1995
17 */
18
1da177e4
LT
19#include <linux/module.h>
20#include <linux/string.h>
8fc2751b 21#include <linux/fs.h>
1da177e4
LT
22#include <linux/slab.h>
23#include <linux/init.h>
24#include <linux/blkdev.h>
25#include <linux/parser.h>
26#include <linux/random.h>
27#include <linux/buffer_head.h>
a5694255 28#include <linux/exportfs.h>
1da177e4 29#include <linux/vfs.h>
8fc2751b
MB
30#include <linux/seq_file.h>
31#include <linux/mount.h>
d8ea6cf8 32#include <linux/log2.h>
74abb989 33#include <linux/quotaops.h>
7c0f6ba6 34#include <linux/uaccess.h>
1da177e4
LT
35#include "ext2.h"
36#include "xattr.h"
37#include "acl.h"
38
65547661 39static void ext2_write_super(struct super_block *sb);
1da177e4 40static int ext2_remount (struct super_block * sb, int * flags, char * data);
726c3342 41static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf);
40f31dd4 42static int ext2_sync_fs(struct super_block *sb, int wait);
1e8b212f
JK
43static int ext2_freeze(struct super_block *sb);
44static int ext2_unfreeze(struct super_block *sb);
1da177e4 45
23a2ad6d
JP
46void ext2_error(struct super_block *sb, const char *function,
47 const char *fmt, ...)
1da177e4 48{
23a2ad6d 49 struct va_format vaf;
1da177e4
LT
50 va_list args;
51 struct ext2_sb_info *sbi = EXT2_SB(sb);
52 struct ext2_super_block *es = sbi->s_es;
53
54 if (!(sb->s_flags & MS_RDONLY)) {
c15271f4 55 spin_lock(&sbi->s_lock);
1da177e4 56 sbi->s_mount_state |= EXT2_ERROR_FS;
31f68e13 57 es->s_state |= cpu_to_le16(EXT2_ERROR_FS);
c15271f4 58 spin_unlock(&sbi->s_lock);
ee6921eb 59 ext2_sync_super(sb, es, 1);
1da177e4
LT
60 }
61
62 va_start(args, fmt);
23a2ad6d
JP
63
64 vaf.fmt = fmt;
65 vaf.va = &args;
66
67 printk(KERN_CRIT "EXT2-fs (%s): error: %s: %pV\n",
68 sb->s_id, function, &vaf);
69
1da177e4
LT
70 va_end(args);
71
72 if (test_opt(sb, ERRORS_PANIC))
2314b07c 73 panic("EXT2-fs: panic from previous error\n");
1da177e4 74 if (test_opt(sb, ERRORS_RO)) {
2314b07c
AF
75 ext2_msg(sb, KERN_CRIT,
76 "error: remounting filesystem read-only");
1da177e4
LT
77 sb->s_flags |= MS_RDONLY;
78 }
79}
80
2314b07c
AF
81void ext2_msg(struct super_block *sb, const char *prefix,
82 const char *fmt, ...)
1da177e4 83{
23a2ad6d 84 struct va_format vaf;
1da177e4
LT
85 va_list args;
86
87 va_start(args, fmt);
23a2ad6d
JP
88
89 vaf.fmt = fmt;
90 vaf.va = &args;
91
92 printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
93
1da177e4
LT
94 va_end(args);
95}
96
c15271f4
JB
97/*
98 * This must be called with sbi->s_lock held.
99 */
1da177e4
LT
100void ext2_update_dynamic_rev(struct super_block *sb)
101{
102 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
103
104 if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
105 return;
106
2314b07c
AF
107 ext2_msg(sb, KERN_WARNING,
108 "warning: updating to rev %d because of "
109 "new feature flag, running e2fsck is recommended",
1da177e4
LT
110 EXT2_DYNAMIC_REV);
111
112 es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
113 es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
114 es->s_rev_level = cpu_to_le32(EXT2_DYNAMIC_REV);
115 /* leave es->s_feature_*compat flags alone */
116 /* es->s_uuid will be set by e2fsck if empty */
117
118 /*
119 * The rest of the superblock fields should be zero, and if not it
120 * means they are likely already in use, so leave them alone. We
121 * can leave it up to e2fsck to clean up any inconsistencies there.
122 */
123}
124
125static void ext2_put_super (struct super_block * sb)
126{
127 int db_count;
128 int i;
129 struct ext2_sb_info *sbi = EXT2_SB(sb);
130
e0ccfd95
CH
131 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
132
be0726d3
JK
133 if (sbi->s_mb_cache) {
134 ext2_xattr_destroy_cache(sbi->s_mb_cache);
135 sbi->s_mb_cache = NULL;
136 }
1da177e4
LT
137 if (!(sb->s_flags & MS_RDONLY)) {
138 struct ext2_super_block *es = sbi->s_es;
139
c15271f4 140 spin_lock(&sbi->s_lock);
1da177e4 141 es->s_state = cpu_to_le16(sbi->s_mount_state);
c15271f4 142 spin_unlock(&sbi->s_lock);
ee6921eb 143 ext2_sync_super(sb, es, 1);
1da177e4
LT
144 }
145 db_count = sbi->s_gdb_count;
146 for (i = 0; i < db_count; i++)
147 if (sbi->s_group_desc[i])
148 brelse (sbi->s_group_desc[i]);
149 kfree(sbi->s_group_desc);
150 kfree(sbi->s_debts);
151 percpu_counter_destroy(&sbi->s_freeblocks_counter);
152 percpu_counter_destroy(&sbi->s_freeinodes_counter);
153 percpu_counter_destroy(&sbi->s_dirs_counter);
154 brelse (sbi->s_sbh);
155 sb->s_fs_info = NULL;
18a82eb9 156 kfree(sbi->s_blockgroup_lock);
1da177e4 157 kfree(sbi);
1da177e4
LT
158}
159
e18b890b 160static struct kmem_cache * ext2_inode_cachep;
1da177e4
LT
161
162static struct inode *ext2_alloc_inode(struct super_block *sb)
163{
164 struct ext2_inode_info *ei;
e625b310 165 ei = kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
1da177e4
LT
166 if (!ei)
167 return NULL;
a686cd89 168 ei->i_block_alloc_info = NULL;
1da177e4 169 ei->vfs_inode.i_version = 1;
64241118
JK
170#ifdef CONFIG_QUOTA
171 memset(&ei->i_dquot, 0, sizeof(ei->i_dquot));
172#endif
173
1da177e4
LT
174 return &ei->vfs_inode;
175}
176
fa0d7e3d 177static void ext2_i_callback(struct rcu_head *head)
1da177e4 178{
fa0d7e3d 179 struct inode *inode = container_of(head, struct inode, i_rcu);
1da177e4
LT
180 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
181}
182
fa0d7e3d
NP
183static void ext2_destroy_inode(struct inode *inode)
184{
185 call_rcu(&inode->i_rcu, ext2_i_callback);
186}
187
51cc5068 188static void init_once(void *foo)
1da177e4
LT
189{
190 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
191
a35afb83 192 rwlock_init(&ei->i_meta_lock);
1da177e4 193#ifdef CONFIG_EXT2_FS_XATTR
a35afb83 194 init_rwsem(&ei->xattr_sem);
1da177e4 195#endif
a686cd89 196 mutex_init(&ei->truncate_mutex);
5726b27b
RZ
197#ifdef CONFIG_FS_DAX
198 init_rwsem(&ei->dax_sem);
199#endif
a35afb83 200 inode_init_once(&ei->vfs_inode);
1da177e4 201}
20c2df83 202
0903353a 203static int __init init_inodecache(void)
1da177e4
LT
204{
205 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
206 sizeof(struct ext2_inode_info),
fffb60f9 207 0, (SLAB_RECLAIM_ACCOUNT|
5d097056 208 SLAB_MEM_SPREAD|SLAB_ACCOUNT),
20c2df83 209 init_once);
1da177e4
LT
210 if (ext2_inode_cachep == NULL)
211 return -ENOMEM;
212 return 0;
213}
214
215static void destroy_inodecache(void)
216{
8c0a8537
KS
217 /*
218 * Make sure all delayed rcu free inodes are flushed before we
219 * destroy cache.
220 */
221 rcu_barrier();
1a1d92c1 222 kmem_cache_destroy(ext2_inode_cachep);
1da177e4
LT
223}
224
34c80b1d 225static int ext2_show_options(struct seq_file *seq, struct dentry *root)
8fc2751b 226{
34c80b1d 227 struct super_block *sb = root->d_sb;
93d44cb2
MS
228 struct ext2_sb_info *sbi = EXT2_SB(sb);
229 struct ext2_super_block *es = sbi->s_es;
230 unsigned long def_mount_opts;
8fc2751b 231
c15271f4 232 spin_lock(&sbi->s_lock);
93d44cb2
MS
233 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
234
235 if (sbi->s_sb_block != 1)
236 seq_printf(seq, ",sb=%lu", sbi->s_sb_block);
237 if (test_opt(sb, MINIX_DF))
238 seq_puts(seq, ",minixdf");
239 if (test_opt(sb, GRPID))
8fc2751b 240 seq_puts(seq, ",grpid");
93d44cb2
MS
241 if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS))
242 seq_puts(seq, ",nogrpid");
b8a9f9e1 243 if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) ||
93d44cb2 244 le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) {
b8a9f9e1
EB
245 seq_printf(seq, ",resuid=%u",
246 from_kuid_munged(&init_user_ns, sbi->s_resuid));
93d44cb2 247 }
b8a9f9e1 248 if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) ||
93d44cb2 249 le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) {
b8a9f9e1
EB
250 seq_printf(seq, ",resgid=%u",
251 from_kgid_munged(&init_user_ns, sbi->s_resgid));
93d44cb2 252 }
14e11e10 253 if (test_opt(sb, ERRORS_RO)) {
93d44cb2
MS
254 int def_errors = le16_to_cpu(es->s_errors);
255
256 if (def_errors == EXT2_ERRORS_PANIC ||
14e11e10
AK
257 def_errors == EXT2_ERRORS_CONTINUE) {
258 seq_puts(seq, ",errors=remount-ro");
93d44cb2
MS
259 }
260 }
14e11e10
AK
261 if (test_opt(sb, ERRORS_CONT))
262 seq_puts(seq, ",errors=continue");
93d44cb2
MS
263 if (test_opt(sb, ERRORS_PANIC))
264 seq_puts(seq, ",errors=panic");
265 if (test_opt(sb, NO_UID32))
266 seq_puts(seq, ",nouid32");
267 if (test_opt(sb, DEBUG))
268 seq_puts(seq, ",debug");
269 if (test_opt(sb, OLDALLOC))
270 seq_puts(seq, ",oldalloc");
271
272#ifdef CONFIG_EXT2_FS_XATTR
273 if (test_opt(sb, XATTR_USER))
274 seq_puts(seq, ",user_xattr");
275 if (!test_opt(sb, XATTR_USER) &&
276 (def_mount_opts & EXT2_DEFM_XATTR_USER)) {
277 seq_puts(seq, ",nouser_xattr");
278 }
279#endif
280
281#ifdef CONFIG_EXT2_FS_POSIX_ACL
282 if (test_opt(sb, POSIX_ACL))
283 seq_puts(seq, ",acl");
284 if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL))
285 seq_puts(seq, ",noacl");
286#endif
287
288 if (test_opt(sb, NOBH))
289 seq_puts(seq, ",nobh");
8fc2751b
MB
290
291#if defined(CONFIG_QUOTA)
292 if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA)
293 seq_puts(seq, ",usrquota");
294
295 if (sbi->s_mount_opt & EXT2_MOUNT_GRPQUOTA)
296 seq_puts(seq, ",grpquota");
297#endif
298
6cd176a5 299#ifdef CONFIG_FS_DAX
83541796
CO
300 if (sbi->s_mount_opt & EXT2_MOUNT_XIP)
301 seq_puts(seq, ",xip");
9c3ce9ec
MW
302 if (sbi->s_mount_opt & EXT2_MOUNT_DAX)
303 seq_puts(seq, ",dax");
83541796
CO
304#endif
305
35c879dc
MS
306 if (!test_opt(sb, RESERVATION))
307 seq_puts(seq, ",noreservation");
308
c15271f4 309 spin_unlock(&sbi->s_lock);
8fc2751b
MB
310 return 0;
311}
312
1da177e4
LT
313#ifdef CONFIG_QUOTA
314static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off);
315static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off);
64241118
JK
316static struct dquot **ext2_get_dquots(struct inode *inode)
317{
318 return EXT2_I(inode)->i_dquot;
319}
1da177e4
LT
320#endif
321
ee9b6d61 322static const struct super_operations ext2_sops = {
1da177e4
LT
323 .alloc_inode = ext2_alloc_inode,
324 .destroy_inode = ext2_destroy_inode,
1da177e4 325 .write_inode = ext2_write_inode,
72edc4d0 326 .evict_inode = ext2_evict_inode,
1da177e4 327 .put_super = ext2_put_super,
40f31dd4 328 .sync_fs = ext2_sync_fs,
1e8b212f
JK
329 .freeze_fs = ext2_freeze,
330 .unfreeze_fs = ext2_unfreeze,
1da177e4
LT
331 .statfs = ext2_statfs,
332 .remount_fs = ext2_remount,
8fc2751b 333 .show_options = ext2_show_options,
1da177e4
LT
334#ifdef CONFIG_QUOTA
335 .quota_read = ext2_quota_read,
336 .quota_write = ext2_quota_write,
64241118 337 .get_dquots = ext2_get_dquots,
1da177e4
LT
338#endif
339};
340
2e4c68e3
CH
341static struct inode *ext2_nfs_get_inode(struct super_block *sb,
342 u64 ino, u32 generation)
ecaff756 343{
ecaff756 344 struct inode *inode;
ecaff756
N
345
346 if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO)
347 return ERR_PTR(-ESTALE);
348 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
349 return ERR_PTR(-ESTALE);
350
f32948dd
LH
351 /*
352 * ext2_iget isn't quite right if the inode is currently unallocated!
353 * However ext2_iget currently does appropriate checks to handle stale
354 * inodes so everything is OK.
ecaff756 355 */
52fcf703
DH
356 inode = ext2_iget(sb, ino);
357 if (IS_ERR(inode))
358 return ERR_CAST(inode);
359 if (generation && inode->i_generation != generation) {
ecaff756
N
360 /* we didn't find the right inode.. */
361 iput(inode);
362 return ERR_PTR(-ESTALE);
363 }
2e4c68e3
CH
364 return inode;
365}
366
367static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
368 int fh_len, int fh_type)
369{
370 return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
371 ext2_nfs_get_inode);
372}
373
374static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
375 int fh_len, int fh_type)
376{
377 return generic_fh_to_parent(sb, fid, fh_len, fh_type,
378 ext2_nfs_get_inode);
ecaff756
N
379}
380
39655164 381static const struct export_operations ext2_export_ops = {
2e4c68e3
CH
382 .fh_to_dentry = ext2_fh_to_dentry,
383 .fh_to_parent = ext2_fh_to_parent,
1da177e4
LT
384 .get_parent = ext2_get_parent,
385};
386
387static unsigned long get_sb_block(void **data)
388{
389 unsigned long sb_block;
390 char *options = (char *) *data;
391
392 if (!options || strncmp(options, "sb=", 3) != 0)
393 return 1; /* Default location */
394 options += 3;
395 sb_block = simple_strtoul(options, &options, 0);
396 if (*options && *options != ',') {
397 printk("EXT2-fs: Invalid sb specification: %s\n",
398 (char *) *data);
399 return 1;
400 }
401 if (*options == ',')
402 options++;
403 *data = (void *) options;
404 return sb_block;
405}
406
407enum {
408 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
8fc2751b 409 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic,
2860b733 410 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
8fc2751b 411 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
9c3ce9ec 412 Opt_acl, Opt_noacl, Opt_xip, Opt_dax, Opt_ignore, Opt_err, Opt_quota,
a686cd89 413 Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
1da177e4
LT
414};
415
a447c093 416static const match_table_t tokens = {
1da177e4
LT
417 {Opt_bsd_df, "bsddf"},
418 {Opt_minix_df, "minixdf"},
419 {Opt_grpid, "grpid"},
420 {Opt_grpid, "bsdgroups"},
421 {Opt_nogrpid, "nogrpid"},
422 {Opt_nogrpid, "sysvgroups"},
423 {Opt_resgid, "resgid=%u"},
424 {Opt_resuid, "resuid=%u"},
425 {Opt_sb, "sb=%u"},
426 {Opt_err_cont, "errors=continue"},
427 {Opt_err_panic, "errors=panic"},
428 {Opt_err_ro, "errors=remount-ro"},
429 {Opt_nouid32, "nouid32"},
430 {Opt_nocheck, "check=none"},
431 {Opt_nocheck, "nocheck"},
1da177e4
LT
432 {Opt_debug, "debug"},
433 {Opt_oldalloc, "oldalloc"},
434 {Opt_orlov, "orlov"},
435 {Opt_nobh, "nobh"},
436 {Opt_user_xattr, "user_xattr"},
437 {Opt_nouser_xattr, "nouser_xattr"},
438 {Opt_acl, "acl"},
439 {Opt_noacl, "noacl"},
6d79125b 440 {Opt_xip, "xip"},
9c3ce9ec 441 {Opt_dax, "dax"},
8fc2751b 442 {Opt_grpquota, "grpquota"},
1da177e4 443 {Opt_ignore, "noquota"},
8fc2751b
MB
444 {Opt_quota, "quota"},
445 {Opt_usrquota, "usrquota"},
a686cd89
MB
446 {Opt_reservation, "reservation"},
447 {Opt_noreservation, "noreservation"},
1da177e4
LT
448 {Opt_err, NULL}
449};
450
2314b07c 451static int parse_options(char *options, struct super_block *sb)
1da177e4 452{
2314b07c
AF
453 char *p;
454 struct ext2_sb_info *sbi = EXT2_SB(sb);
1da177e4 455 substring_t args[MAX_OPT_ARGS];
1da177e4 456 int option;
b8a9f9e1
EB
457 kuid_t uid;
458 kgid_t gid;
1da177e4
LT
459
460 if (!options)
461 return 1;
462
463 while ((p = strsep (&options, ",")) != NULL) {
464 int token;
465 if (!*p)
466 continue;
467
468 token = match_token(p, tokens, args);
469 switch (token) {
470 case Opt_bsd_df:
471 clear_opt (sbi->s_mount_opt, MINIX_DF);
472 break;
473 case Opt_minix_df:
474 set_opt (sbi->s_mount_opt, MINIX_DF);
475 break;
476 case Opt_grpid:
477 set_opt (sbi->s_mount_opt, GRPID);
478 break;
479 case Opt_nogrpid:
480 clear_opt (sbi->s_mount_opt, GRPID);
481 break;
482 case Opt_resuid:
483 if (match_int(&args[0], &option))
484 return 0;
b8a9f9e1
EB
485 uid = make_kuid(current_user_ns(), option);
486 if (!uid_valid(uid)) {
487 ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
ae2cf428 488 return 0;
b8a9f9e1
EB
489
490 }
491 sbi->s_resuid = uid;
1da177e4
LT
492 break;
493 case Opt_resgid:
494 if (match_int(&args[0], &option))
495 return 0;
b8a9f9e1
EB
496 gid = make_kgid(current_user_ns(), option);
497 if (!gid_valid(gid)) {
498 ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
ae2cf428 499 return 0;
b8a9f9e1
EB
500 }
501 sbi->s_resgid = gid;
1da177e4
LT
502 break;
503 case Opt_sb:
504 /* handled by get_sb_block() instead of here */
505 /* *sb_block = match_int(&args[0]); */
506 break;
507 case Opt_err_panic:
5a2b4062
VA
508 clear_opt (sbi->s_mount_opt, ERRORS_CONT);
509 clear_opt (sbi->s_mount_opt, ERRORS_RO);
510 set_opt (sbi->s_mount_opt, ERRORS_PANIC);
1da177e4
LT
511 break;
512 case Opt_err_ro:
5a2b4062
VA
513 clear_opt (sbi->s_mount_opt, ERRORS_CONT);
514 clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
515 set_opt (sbi->s_mount_opt, ERRORS_RO);
1da177e4
LT
516 break;
517 case Opt_err_cont:
5a2b4062
VA
518 clear_opt (sbi->s_mount_opt, ERRORS_RO);
519 clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
520 set_opt (sbi->s_mount_opt, ERRORS_CONT);
1da177e4
LT
521 break;
522 case Opt_nouid32:
523 set_opt (sbi->s_mount_opt, NO_UID32);
524 break;
1da177e4
LT
525 case Opt_nocheck:
526 clear_opt (sbi->s_mount_opt, CHECK);
527 break;
528 case Opt_debug:
529 set_opt (sbi->s_mount_opt, DEBUG);
530 break;
531 case Opt_oldalloc:
532 set_opt (sbi->s_mount_opt, OLDALLOC);
533 break;
534 case Opt_orlov:
535 clear_opt (sbi->s_mount_opt, OLDALLOC);
536 break;
537 case Opt_nobh:
538 set_opt (sbi->s_mount_opt, NOBH);
539 break;
540#ifdef CONFIG_EXT2_FS_XATTR
541 case Opt_user_xattr:
542 set_opt (sbi->s_mount_opt, XATTR_USER);
543 break;
544 case Opt_nouser_xattr:
545 clear_opt (sbi->s_mount_opt, XATTR_USER);
546 break;
547#else
548 case Opt_user_xattr:
549 case Opt_nouser_xattr:
2314b07c
AF
550 ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
551 "not supported");
1da177e4
LT
552 break;
553#endif
554#ifdef CONFIG_EXT2_FS_POSIX_ACL
555 case Opt_acl:
556 set_opt(sbi->s_mount_opt, POSIX_ACL);
557 break;
558 case Opt_noacl:
559 clear_opt(sbi->s_mount_opt, POSIX_ACL);
560 break;
561#else
562 case Opt_acl:
563 case Opt_noacl:
2314b07c
AF
564 ext2_msg(sb, KERN_INFO,
565 "(no)acl options not supported");
1da177e4
LT
566 break;
567#endif
6d79125b 568 case Opt_xip:
9c3ce9ec
MW
569 ext2_msg(sb, KERN_INFO, "use dax instead of xip");
570 set_opt(sbi->s_mount_opt, XIP);
571 /* Fall through */
572 case Opt_dax:
6cd176a5 573#ifdef CONFIG_FS_DAX
ef83b6e8
DW
574 ext2_msg(sb, KERN_WARNING,
575 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
9c3ce9ec 576 set_opt(sbi->s_mount_opt, DAX);
6d79125b 577#else
9c3ce9ec 578 ext2_msg(sb, KERN_INFO, "dax option not supported");
6d79125b
CO
579#endif
580 break;
8fc2751b
MB
581
582#if defined(CONFIG_QUOTA)
583 case Opt_quota:
584 case Opt_usrquota:
585 set_opt(sbi->s_mount_opt, USRQUOTA);
586 break;
587
588 case Opt_grpquota:
589 set_opt(sbi->s_mount_opt, GRPQUOTA);
590 break;
591#else
592 case Opt_quota:
593 case Opt_usrquota:
594 case Opt_grpquota:
2314b07c
AF
595 ext2_msg(sb, KERN_INFO,
596 "quota operations not supported");
8fc2751b
MB
597 break;
598#endif
599
a686cd89
MB
600 case Opt_reservation:
601 set_opt(sbi->s_mount_opt, RESERVATION);
2314b07c 602 ext2_msg(sb, KERN_INFO, "reservations ON");
a686cd89
MB
603 break;
604 case Opt_noreservation:
605 clear_opt(sbi->s_mount_opt, RESERVATION);
2314b07c 606 ext2_msg(sb, KERN_INFO, "reservations OFF");
a686cd89 607 break;
1da177e4
LT
608 case Opt_ignore:
609 break;
610 default:
611 return 0;
612 }
613 }
1da177e4
LT
614 return 1;
615}
616
617static int ext2_setup_super (struct super_block * sb,
618 struct ext2_super_block * es,
619 int read_only)
620{
621 int res = 0;
622 struct ext2_sb_info *sbi = EXT2_SB(sb);
623
624 if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
2314b07c
AF
625 ext2_msg(sb, KERN_ERR,
626 "error: revision level too high, "
627 "forcing read-only mode");
1da177e4
LT
628 res = MS_RDONLY;
629 }
630 if (read_only)
631 return res;
632 if (!(sbi->s_mount_state & EXT2_VALID_FS))
2314b07c
AF
633 ext2_msg(sb, KERN_WARNING,
634 "warning: mounting unchecked fs, "
635 "running e2fsck is recommended");
1da177e4 636 else if ((sbi->s_mount_state & EXT2_ERROR_FS))
2314b07c
AF
637 ext2_msg(sb, KERN_WARNING,
638 "warning: mounting fs with errors, "
639 "running e2fsck is recommended");
1da177e4
LT
640 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
641 le16_to_cpu(es->s_mnt_count) >=
642 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
2314b07c
AF
643 ext2_msg(sb, KERN_WARNING,
644 "warning: maximal mount count reached, "
645 "running e2fsck is recommended");
1da177e4 646 else if (le32_to_cpu(es->s_checkinterval) &&
2314b07c
AF
647 (le32_to_cpu(es->s_lastcheck) +
648 le32_to_cpu(es->s_checkinterval) <= get_seconds()))
649 ext2_msg(sb, KERN_WARNING,
650 "warning: checktime reached, "
651 "running e2fsck is recommended");
1da177e4
LT
652 if (!le16_to_cpu(es->s_max_mnt_count))
653 es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
fba4d399 654 le16_add_cpu(&es->s_mnt_count, 1);
1da177e4 655 if (test_opt (sb, DEBUG))
2314b07c
AF
656 ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
657 "bpg=%lu, ipg=%lu, mo=%04lx]",
1da177e4
LT
658 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
659 sbi->s_frag_size,
660 sbi->s_groups_count,
661 EXT2_BLOCKS_PER_GROUP(sb),
662 EXT2_INODES_PER_GROUP(sb),
663 sbi->s_mount_opt);
1da177e4
LT
664 return res;
665}
666
197cd65a 667static int ext2_check_descriptors(struct super_block *sb)
1da177e4
LT
668{
669 int i;
1da177e4 670 struct ext2_sb_info *sbi = EXT2_SB(sb);
1da177e4
LT
671
672 ext2_debug ("Checking group descriptors");
673
197cd65a
AM
674 for (i = 0; i < sbi->s_groups_count; i++) {
675 struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);
24097d12
AM
676 ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i);
677 ext2_fsblk_t last_block;
197cd65a 678
41f04d85
ES
679 if (i == sbi->s_groups_count - 1)
680 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
681 else
682 last_block = first_block +
683 (EXT2_BLOCKS_PER_GROUP(sb) - 1);
684
41f04d85
ES
685 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
686 le32_to_cpu(gdp->bg_block_bitmap) > last_block)
1da177e4
LT
687 {
688 ext2_error (sb, "ext2_check_descriptors",
689 "Block bitmap for group %d"
690 " not in group (block %lu)!",
691 i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
692 return 0;
693 }
41f04d85
ES
694 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
695 le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
1da177e4
LT
696 {
697 ext2_error (sb, "ext2_check_descriptors",
698 "Inode bitmap for group %d"
699 " not in group (block %lu)!",
700 i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
701 return 0;
702 }
41f04d85 703 if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
780dcdb2 704 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
41f04d85 705 last_block)
1da177e4
LT
706 {
707 ext2_error (sb, "ext2_check_descriptors",
708 "Inode table for group %d"
709 " not in group (block %lu)!",
710 i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
711 return 0;
712 }
1da177e4
LT
713 }
714 return 1;
715}
716
1da177e4
LT
717/*
718 * Maximal file size. There is a direct, and {,double-,triple-}indirect
719 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
720 * We need to be 1 filesystem block less than the 2^32 sector limit.
721 */
722static loff_t ext2_max_size(int bits)
723{
724 loff_t res = EXT2_NDIR_BLOCKS;
902be4c5
AK
725 int meta_blocks;
726 loff_t upper_limit;
727
728 /* This is calculated to be the largest file size for a
729 * dense, file such that the total number of
1da177e4 730 * sectors in the file, including data and all indirect blocks,
902be4c5
AK
731 * does not exceed 2^32 -1
732 * __u32 i_blocks representing the total number of
733 * 512 bytes blocks of the file
734 */
735 upper_limit = (1LL << 32) - 1;
736
737 /* total blocks in file system block size */
738 upper_limit >>= (bits - 9);
739
740
741 /* indirect blocks */
742 meta_blocks = 1;
743 /* double indirect blocks */
744 meta_blocks += 1 + (1LL << (bits-2));
745 /* tripple indirect blocks */
746 meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2)));
747
748 upper_limit -= meta_blocks;
749 upper_limit <<= bits;
1da177e4
LT
750
751 res += 1LL << (bits-2);
752 res += 1LL << (2*(bits-2));
753 res += 1LL << (3*(bits-2));
754 res <<= bits;
755 if (res > upper_limit)
756 res = upper_limit;
902be4c5
AK
757
758 if (res > MAX_LFS_FILESIZE)
759 res = MAX_LFS_FILESIZE;
760
1da177e4
LT
761 return res;
762}
763
764static unsigned long descriptor_loc(struct super_block *sb,
765 unsigned long logic_sb_block,
766 int nr)
767{
768 struct ext2_sb_info *sbi = EXT2_SB(sb);
24097d12 769 unsigned long bg, first_meta_bg;
1da177e4
LT
770 int has_super = 0;
771
1da177e4
LT
772 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
773
774 if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) ||
775 nr < first_meta_bg)
776 return (logic_sb_block + nr + 1);
777 bg = sbi->s_desc_per_block * nr;
778 if (ext2_bg_has_super(sb, bg))
779 has_super = 1;
24097d12
AM
780
781 return ext2_group_first_block_no(sb, bg) + has_super;
1da177e4
LT
782}
783
784static int ext2_fill_super(struct super_block *sb, void *data, int silent)
785{
786 struct buffer_head * bh;
787 struct ext2_sb_info * sbi;
788 struct ext2_super_block * es;
789 struct inode *root;
790 unsigned long block;
791 unsigned long sb_block = get_sb_block(&data);
792 unsigned long logic_sb_block;
793 unsigned long offset = 0;
794 unsigned long def_mount_opts;
52fcf703 795 long ret = -EINVAL;
1da177e4
LT
796 int blocksize = BLOCK_SIZE;
797 int db_count;
798 int i, j;
799 __le32 features;
833f4077 800 int err;
1da177e4 801
db719222 802 err = -ENOMEM;
f8314dc6 803 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
1da177e4 804 if (!sbi)
e124a320 805 goto failed;
18a82eb9
PE
806
807 sbi->s_blockgroup_lock =
808 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
809 if (!sbi->s_blockgroup_lock) {
810 kfree(sbi);
e124a320 811 goto failed;
18a82eb9 812 }
1da177e4 813 sb->s_fs_info = sbi;
93d44cb2 814 sbi->s_sb_block = sb_block;
1da177e4 815
c15271f4
JB
816 spin_lock_init(&sbi->s_lock);
817
1da177e4
LT
818 /*
819 * See what the current blocksize for the device is, and
820 * use that as the blocksize. Otherwise (or if the blocksize
821 * is smaller than the default) use the default.
822 * This is important for devices that have a hardware
823 * sectorsize that is larger than the default.
824 */
825 blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
826 if (!blocksize) {
2314b07c 827 ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
1da177e4
LT
828 goto failed_sbi;
829 }
830
831 /*
832 * If the superblock doesn't start on a hardware sector boundary,
833 * calculate the offset.
834 */
835 if (blocksize != BLOCK_SIZE) {
836 logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
837 offset = (sb_block*BLOCK_SIZE) % blocksize;
838 } else {
839 logic_sb_block = sb_block;
840 }
841
842 if (!(bh = sb_bread(sb, logic_sb_block))) {
2314b07c 843 ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
1da177e4
LT
844 goto failed_sbi;
845 }
846 /*
847 * Note: s_es must be initialized as soon as possible because
848 * some ext2 macro-instructions depend on its value
849 */
850 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
851 sbi->s_es = es;
852 sb->s_magic = le16_to_cpu(es->s_magic);
853
854 if (sb->s_magic != EXT2_SUPER_MAGIC)
855 goto cantfind_ext2;
856
857 /* Set defaults before we parse the mount options */
858 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
859 if (def_mount_opts & EXT2_DEFM_DEBUG)
860 set_opt(sbi->s_mount_opt, DEBUG);
861 if (def_mount_opts & EXT2_DEFM_BSDGROUPS)
862 set_opt(sbi->s_mount_opt, GRPID);
863 if (def_mount_opts & EXT2_DEFM_UID16)
864 set_opt(sbi->s_mount_opt, NO_UID32);
2e7842b8 865#ifdef CONFIG_EXT2_FS_XATTR
1da177e4
LT
866 if (def_mount_opts & EXT2_DEFM_XATTR_USER)
867 set_opt(sbi->s_mount_opt, XATTR_USER);
2e7842b8
HD
868#endif
869#ifdef CONFIG_EXT2_FS_POSIX_ACL
1da177e4
LT
870 if (def_mount_opts & EXT2_DEFM_ACL)
871 set_opt(sbi->s_mount_opt, POSIX_ACL);
2e7842b8 872#endif
1da177e4
LT
873
874 if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
875 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
14e11e10 876 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE)
5a2b4062 877 set_opt(sbi->s_mount_opt, ERRORS_CONT);
14e11e10
AK
878 else
879 set_opt(sbi->s_mount_opt, ERRORS_RO);
1da177e4 880
b8a9f9e1
EB
881 sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
882 sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
1da177e4 883
a686cd89
MB
884 set_opt(sbi->s_mount_opt, RESERVATION);
885
2314b07c 886 if (!parse_options((char *) data, sb))
1da177e4
LT
887 goto failed_mount;
888
889 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
890 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
891 MS_POSIXACL : 0);
46b15caa 892 sb->s_iflags |= SB_I_CGROUPWB;
1da177e4
LT
893
894 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
895 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
896 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
897 EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
2314b07c
AF
898 ext2_msg(sb, KERN_WARNING,
899 "warning: feature flags set on rev 0 fs, "
900 "running e2fsck is recommended");
1da177e4
LT
901 /*
902 * Check feature flags regardless of the revision level, since we
903 * previously didn't change the revision level when setting the flags,
904 * so there is a chance incompat flags are set on a rev 0 filesystem.
905 */
906 features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
907 if (features) {
2314b07c
AF
908 ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
909 "unsupported optional features (%x)",
910 le32_to_cpu(features));
1da177e4
LT
911 goto failed_mount;
912 }
913 if (!(sb->s_flags & MS_RDONLY) &&
914 (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
2314b07c
AF
915 ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
916 "unsupported optional features (%x)",
917 le32_to_cpu(features));
1da177e4
LT
918 goto failed_mount;
919 }
920
921 blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
922
9c3ce9ec 923 if (sbi->s_mount_opt & EXT2_MOUNT_DAX) {
284854be
TK
924 err = bdev_dax_supported(sb, blocksize);
925 if (err)
0de4830f 926 goto failed_mount;
6d79125b
CO
927 }
928
1da177e4
LT
929 /* If the blocksize doesn't match, re-read the thing.. */
930 if (sb->s_blocksize != blocksize) {
931 brelse(bh);
932
933 if (!sb_set_blocksize(sb, blocksize)) {
4e299c1d
RD
934 ext2_msg(sb, KERN_ERR,
935 "error: bad blocksize %d", blocksize);
1da177e4
LT
936 goto failed_sbi;
937 }
938
939 logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
940 offset = (sb_block*BLOCK_SIZE) % blocksize;
941 bh = sb_bread(sb, logic_sb_block);
942 if(!bh) {
2314b07c
AF
943 ext2_msg(sb, KERN_ERR, "error: couldn't read"
944 "superblock on 2nd try");
1da177e4
LT
945 goto failed_sbi;
946 }
947 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
948 sbi->s_es = es;
949 if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
2314b07c 950 ext2_msg(sb, KERN_ERR, "error: magic mismatch");
1da177e4
LT
951 goto failed_mount;
952 }
953 }
954
955 sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits);
8de52778 956 sb->s_max_links = EXT2_LINK_MAX;
1da177e4
LT
957
958 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
959 sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
960 sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
961 } else {
962 sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
963 sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
964 if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
d8ea6cf8 965 !is_power_of_2(sbi->s_inode_size) ||
1da177e4 966 (sbi->s_inode_size > blocksize)) {
2314b07c
AF
967 ext2_msg(sb, KERN_ERR,
968 "error: unsupported inode size: %d",
1da177e4
LT
969 sbi->s_inode_size);
970 goto failed_mount;
971 }
972 }
973
974 sbi->s_frag_size = EXT2_MIN_FRAG_SIZE <<
975 le32_to_cpu(es->s_log_frag_size);
976 if (sbi->s_frag_size == 0)
977 goto cantfind_ext2;
978 sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size;
979
980 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
981 sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
982 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
983
984 if (EXT2_INODE_SIZE(sb) == 0)
985 goto cantfind_ext2;
986 sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
607eb266 987 if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
1da177e4
LT
988 goto cantfind_ext2;
989 sbi->s_itb_per_group = sbi->s_inodes_per_group /
990 sbi->s_inodes_per_block;
991 sbi->s_desc_per_block = sb->s_blocksize /
992 sizeof (struct ext2_group_desc);
993 sbi->s_sbh = bh;
994 sbi->s_mount_state = le16_to_cpu(es->s_state);
995 sbi->s_addr_per_block_bits =
f0d1b0b3 996 ilog2 (EXT2_ADDR_PER_BLOCK(sb));
1da177e4 997 sbi->s_desc_per_block_bits =
f0d1b0b3 998 ilog2 (EXT2_DESC_PER_BLOCK(sb));
1da177e4
LT
999
1000 if (sb->s_magic != EXT2_SUPER_MAGIC)
1001 goto cantfind_ext2;
1002
1003 if (sb->s_blocksize != bh->b_size) {
1004 if (!silent)
2314b07c 1005 ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
1da177e4
LT
1006 goto failed_mount;
1007 }
1008
1009 if (sb->s_blocksize != sbi->s_frag_size) {
2314b07c
AF
1010 ext2_msg(sb, KERN_ERR,
1011 "error: fragsize %lu != blocksize %lu"
1012 "(not supported yet)",
1da177e4
LT
1013 sbi->s_frag_size, sb->s_blocksize);
1014 goto failed_mount;
1015 }
1016
1017 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
2314b07c
AF
1018 ext2_msg(sb, KERN_ERR,
1019 "error: #blocks per group too big: %lu",
1da177e4
LT
1020 sbi->s_blocks_per_group);
1021 goto failed_mount;
1022 }
1023 if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
2314b07c
AF
1024 ext2_msg(sb, KERN_ERR,
1025 "error: #fragments per group too big: %lu",
1da177e4
LT
1026 sbi->s_frags_per_group);
1027 goto failed_mount;
1028 }
1029 if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
2314b07c
AF
1030 ext2_msg(sb, KERN_ERR,
1031 "error: #inodes per group too big: %lu",
1da177e4
LT
1032 sbi->s_inodes_per_group);
1033 goto failed_mount;
1034 }
1035
1036 if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
1037 goto cantfind_ext2;
41f04d85
ES
1038 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
1039 le32_to_cpu(es->s_first_data_block) - 1)
1040 / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
1da177e4
LT
1041 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
1042 EXT2_DESC_PER_BLOCK(sb);
1043 sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
1044 if (sbi->s_group_desc == NULL) {
2314b07c 1045 ext2_msg(sb, KERN_ERR, "error: not enough memory");
1da177e4
LT
1046 goto failed_mount;
1047 }
18a82eb9 1048 bgl_lock_init(sbi->s_blockgroup_lock);
dd00cc48 1049 sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
1da177e4 1050 if (!sbi->s_debts) {
2314b07c 1051 ext2_msg(sb, KERN_ERR, "error: not enough memory");
1da177e4
LT
1052 goto failed_mount_group_desc;
1053 }
1da177e4
LT
1054 for (i = 0; i < db_count; i++) {
1055 block = descriptor_loc(sb, logic_sb_block, i);
1056 sbi->s_group_desc[i] = sb_bread(sb, block);
1057 if (!sbi->s_group_desc[i]) {
1058 for (j = 0; j < i; j++)
1059 brelse (sbi->s_group_desc[j]);
2314b07c
AF
1060 ext2_msg(sb, KERN_ERR,
1061 "error: unable to read group descriptors");
1da177e4
LT
1062 goto failed_mount_group_desc;
1063 }
1064 }
1065 if (!ext2_check_descriptors (sb)) {
2314b07c 1066 ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
1da177e4
LT
1067 goto failed_mount2;
1068 }
1069 sbi->s_gdb_count = db_count;
1070 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1071 spin_lock_init(&sbi->s_next_gen_lock);
0216bfcf 1072
a686cd89
MB
1073 /* per fileystem reservation list head & lock */
1074 spin_lock_init(&sbi->s_rsv_window_lock);
1075 sbi->s_rsv_window_root = RB_ROOT;
1076 /*
1077 * Add a single, static dummy reservation to the start of the
1078 * reservation window list --- it gives us a placeholder for
1079 * append-at-start-of-list which makes the allocation logic
1080 * _much_ simpler.
1081 */
1082 sbi->s_rsv_window_head.rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
1083 sbi->s_rsv_window_head.rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
1084 sbi->s_rsv_window_head.rsv_alloc_hit = 0;
1085 sbi->s_rsv_window_head.rsv_goal_size = 0;
1086 ext2_rsv_window_add(sb, &sbi->s_rsv_window_head);
1087
833f4077 1088 err = percpu_counter_init(&sbi->s_freeblocks_counter,
908c7f19 1089 ext2_count_free_blocks(sb), GFP_KERNEL);
833f4077
PZ
1090 if (!err) {
1091 err = percpu_counter_init(&sbi->s_freeinodes_counter,
908c7f19 1092 ext2_count_free_inodes(sb), GFP_KERNEL);
833f4077
PZ
1093 }
1094 if (!err) {
1095 err = percpu_counter_init(&sbi->s_dirs_counter,
908c7f19 1096 ext2_count_dirs(sb), GFP_KERNEL);
833f4077
PZ
1097 }
1098 if (err) {
2314b07c 1099 ext2_msg(sb, KERN_ERR, "error: insufficient memory");
833f4077
PZ
1100 goto failed_mount3;
1101 }
be0726d3
JK
1102
1103#ifdef CONFIG_EXT2_FS_XATTR
1104 sbi->s_mb_cache = ext2_xattr_create_cache();
1105 if (!sbi->s_mb_cache) {
1106 ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache");
1107 goto failed_mount3;
1108 }
1109#endif
1da177e4
LT
1110 /*
1111 * set up enough so that it can read an inode
1112 */
1113 sb->s_op = &ext2_sops;
1114 sb->s_export_op = &ext2_export_ops;
1115 sb->s_xattr = ext2_xattr_handlers;
123e9caf
CH
1116
1117#ifdef CONFIG_QUOTA
1118 sb->dq_op = &dquot_operations;
287a8095 1119 sb->s_qcop = &dquot_quotactl_ops;
64241118 1120 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
123e9caf
CH
1121#endif
1122
52fcf703
DH
1123 root = ext2_iget(sb, EXT2_ROOT_INO);
1124 if (IS_ERR(root)) {
1125 ret = PTR_ERR(root);
0216bfcf 1126 goto failed_mount3;
1da177e4
LT
1127 }
1128 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
52fcf703 1129 iput(root);
2314b07c 1130 ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
0216bfcf 1131 goto failed_mount3;
1da177e4 1132 }
52fcf703 1133
48fde701 1134 sb->s_root = d_make_root(root);
52fcf703 1135 if (!sb->s_root) {
2314b07c 1136 ext2_msg(sb, KERN_ERR, "error: get root inode failed");
52fcf703
DH
1137 ret = -ENOMEM;
1138 goto failed_mount3;
1139 }
1da177e4 1140 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
2314b07c
AF
1141 ext2_msg(sb, KERN_WARNING,
1142 "warning: mounting ext3 filesystem as ext2");
4c96a68b
JB
1143 if (ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY))
1144 sb->s_flags |= MS_RDONLY;
1145 ext2_write_super(sb);
1da177e4
LT
1146 return 0;
1147
1148cantfind_ext2:
1149 if (!silent)
2314b07c
AF
1150 ext2_msg(sb, KERN_ERR,
1151 "error: can't find an ext2 filesystem on dev %s.",
1152 sb->s_id);
1da177e4 1153 goto failed_mount;
0216bfcf 1154failed_mount3:
be0726d3
JK
1155 if (sbi->s_mb_cache)
1156 ext2_xattr_destroy_cache(sbi->s_mb_cache);
0216bfcf
MC
1157 percpu_counter_destroy(&sbi->s_freeblocks_counter);
1158 percpu_counter_destroy(&sbi->s_freeinodes_counter);
1159 percpu_counter_destroy(&sbi->s_dirs_counter);
1da177e4
LT
1160failed_mount2:
1161 for (i = 0; i < db_count; i++)
1162 brelse(sbi->s_group_desc[i]);
1163failed_mount_group_desc:
1164 kfree(sbi->s_group_desc);
1165 kfree(sbi->s_debts);
1166failed_mount:
1167 brelse(bh);
1168failed_sbi:
1169 sb->s_fs_info = NULL;
0f7ee7c1 1170 kfree(sbi->s_blockgroup_lock);
1da177e4 1171 kfree(sbi);
e124a320 1172failed:
52fcf703 1173 return ret;
1da177e4
LT
1174}
1175
7bf0dc9b
TT
1176static void ext2_clear_super_error(struct super_block *sb)
1177{
1178 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
1179
1180 if (buffer_write_io_error(sbh)) {
1181 /*
1182 * Oh, dear. A previous attempt to write the
1183 * superblock failed. This could happen because the
1184 * USB device was yanked out. Or it could happen to
1185 * be a transient write error and maybe the block will
1186 * be remapped. Nothing we can do but to retry the
1187 * write and hope for the best.
1188 */
2b8120ef
JB
1189 ext2_msg(sb, KERN_ERR,
1190 "previous I/O error to superblock detected\n");
7bf0dc9b
TT
1191 clear_buffer_write_io_error(sbh);
1192 set_buffer_uptodate(sbh);
1193 }
1194}
1195
65547661
JK
1196void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
1197 int wait)
1da177e4 1198{
7bf0dc9b 1199 ext2_clear_super_error(sb);
c15271f4 1200 spin_lock(&EXT2_SB(sb)->s_lock);
1da177e4
LT
1201 es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
1202 es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
1203 es->s_wtime = cpu_to_le32(get_seconds());
c15271f4
JB
1204 /* unlock before we do IO */
1205 spin_unlock(&EXT2_SB(sb)->s_lock);
1da177e4 1206 mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
ee6921eb
JB
1207 if (wait)
1208 sync_dirty_buffer(EXT2_SB(sb)->s_sbh);
1da177e4
LT
1209}
1210
1211/*
1212 * In the second extended file system, it is not necessary to
1213 * write the super block since we use a mapping of the
1214 * disk super block in a buffer.
1215 *
1216 * However, this function is still used to set the fs valid
1217 * flags to 0. We need to set this flag to 0 since the fs
1218 * may have been checked while mounted and e2fsck may have
1219 * set s_state to EXT2_VALID_FS after some corrections.
1220 */
40f31dd4 1221static int ext2_sync_fs(struct super_block *sb, int wait)
1da177e4 1222{
c15271f4 1223 struct ext2_sb_info *sbi = EXT2_SB(sb);
40f31dd4
CH
1224 struct ext2_super_block *es = EXT2_SB(sb)->s_es;
1225
a1177825
JK
1226 /*
1227 * Write quota structures to quota file, sync_blockdev() will write
1228 * them to disk later
1229 */
1230 dquot_writeback_dquots(sb, -1);
1231
c15271f4 1232 spin_lock(&sbi->s_lock);
40f31dd4
CH
1233 if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) {
1234 ext2_debug("setting valid to 0\n");
1235 es->s_state &= cpu_to_le16(~EXT2_VALID_FS);
1da177e4 1236 }
c15271f4 1237 spin_unlock(&sbi->s_lock);
ee6921eb 1238 ext2_sync_super(sb, es, wait);
40f31dd4
CH
1239 return 0;
1240}
1241
1e8b212f
JK
1242static int ext2_freeze(struct super_block *sb)
1243{
1244 struct ext2_sb_info *sbi = EXT2_SB(sb);
1245
1246 /*
1247 * Open but unlinked files present? Keep EXT2_VALID_FS flag cleared
1248 * because we have unattached inodes and thus filesystem is not fully
1249 * consistent.
1250 */
1251 if (atomic_long_read(&sb->s_remove_count)) {
1252 ext2_sync_fs(sb, 1);
1253 return 0;
1254 }
1255 /* Set EXT2_FS_VALID flag */
1256 spin_lock(&sbi->s_lock);
1257 sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state);
1258 spin_unlock(&sbi->s_lock);
1259 ext2_sync_super(sb, sbi->s_es, 1);
1260
1261 return 0;
1262}
1263
1264static int ext2_unfreeze(struct super_block *sb)
1265{
1266 /* Just write sb to clear EXT2_VALID_FS flag */
1267 ext2_write_super(sb);
1268
1269 return 0;
1270}
40f31dd4 1271
65547661 1272static void ext2_write_super(struct super_block *sb)
40f31dd4
CH
1273{
1274 if (!(sb->s_flags & MS_RDONLY))
1275 ext2_sync_fs(sb, 1);
1da177e4
LT
1276}
1277
1278static int ext2_remount (struct super_block * sb, int * flags, char * data)
1279{
1280 struct ext2_sb_info * sbi = EXT2_SB(sb);
1281 struct ext2_super_block * es;
50a52234
JK
1282 struct ext2_mount_options old_opts;
1283 unsigned long old_sb_flags;
1284 int err;
1285
02b9984d 1286 sync_filesystem(sb);
c15271f4 1287 spin_lock(&sbi->s_lock);
337eb00a 1288
50a52234
JK
1289 /* Store the old options */
1290 old_sb_flags = sb->s_flags;
1291 old_opts.s_mount_opt = sbi->s_mount_opt;
1292 old_opts.s_resuid = sbi->s_resuid;
1293 old_opts.s_resgid = sbi->s_resgid;
1da177e4
LT
1294
1295 /*
1296 * Allow the "check" option to be passed as a remount option.
1297 */
2314b07c 1298 if (!parse_options(data, sb)) {
50a52234
JK
1299 err = -EINVAL;
1300 goto restore_opts;
1301 }
1da177e4
LT
1302
1303 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
1304 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
1305
1306 es = sbi->s_es;
9c3ce9ec 1307 if ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT2_MOUNT_DAX) {
2314b07c 1308 ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
9c3ce9ec
MW
1309 "dax flag with busy inodes while remounting");
1310 sbi->s_mount_opt ^= EXT2_MOUNT_DAX;
0e4a9b59 1311 }
337eb00a 1312 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
c15271f4 1313 spin_unlock(&sbi->s_lock);
1da177e4 1314 return 0;
337eb00a 1315 }
1da177e4
LT
1316 if (*flags & MS_RDONLY) {
1317 if (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||
337eb00a 1318 !(sbi->s_mount_state & EXT2_VALID_FS)) {
c15271f4 1319 spin_unlock(&sbi->s_lock);
1da177e4 1320 return 0;
337eb00a 1321 }
c79d967d 1322
1da177e4
LT
1323 /*
1324 * OK, we are remounting a valid rw partition rdonly, so set
1325 * the rdonly flag and then mark the partition as valid again.
1326 */
1327 es->s_state = cpu_to_le16(sbi->s_mount_state);
1328 es->s_mtime = cpu_to_le32(get_seconds());
c15271f4 1329 spin_unlock(&sbi->s_lock);
c79d967d 1330
0f0dd62f
CH
1331 err = dquot_suspend(sb, -1);
1332 if (err < 0) {
c79d967d
CH
1333 spin_lock(&sbi->s_lock);
1334 goto restore_opts;
1335 }
1336
4c96a68b 1337 ext2_sync_super(sb, es, 1);
1da177e4
LT
1338 } else {
1339 __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
1340 ~EXT2_FEATURE_RO_COMPAT_SUPP);
1341 if (ret) {
2314b07c
AF
1342 ext2_msg(sb, KERN_WARNING,
1343 "warning: couldn't remount RDWR because of "
1344 "unsupported optional features (%x).",
1345 le32_to_cpu(ret));
50a52234
JK
1346 err = -EROFS;
1347 goto restore_opts;
1da177e4
LT
1348 }
1349 /*
1350 * Mounting a RDONLY partition read-write, so reread and
1351 * store the current valid flag. (It may have been changed
1352 * by e2fsck since we originally mounted the partition.)
1353 */
1354 sbi->s_mount_state = le16_to_cpu(es->s_state);
1355 if (!ext2_setup_super (sb, es, 0))
1356 sb->s_flags &= ~MS_RDONLY;
c15271f4 1357 spin_unlock(&sbi->s_lock);
c79d967d 1358
4c96a68b 1359 ext2_write_super(sb);
c79d967d 1360
0f0dd62f 1361 dquot_resume(sb, -1);
1da177e4 1362 }
c79d967d 1363
1da177e4 1364 return 0;
50a52234
JK
1365restore_opts:
1366 sbi->s_mount_opt = old_opts.s_mount_opt;
1367 sbi->s_resuid = old_opts.s_resuid;
1368 sbi->s_resgid = old_opts.s_resgid;
1369 sb->s_flags = old_sb_flags;
c15271f4 1370 spin_unlock(&sbi->s_lock);
50a52234 1371 return err;
1da177e4
LT
1372}
1373
726c3342 1374static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1da177e4 1375{
726c3342 1376 struct super_block *sb = dentry->d_sb;
1da177e4 1377 struct ext2_sb_info *sbi = EXT2_SB(sb);
e4fca01e 1378 struct ext2_super_block *es = sbi->s_es;
e4fca01e 1379 u64 fsid;
1da177e4 1380
c15271f4
JB
1381 spin_lock(&sbi->s_lock);
1382
1da177e4 1383 if (test_opt (sb, MINIX_DF))
2235219b
BP
1384 sbi->s_overhead_last = 0;
1385 else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) {
1386 unsigned long i, overhead = 0;
1387 smp_rmb();
1388
1da177e4 1389 /*
2235219b
BP
1390 * Compute the overhead (FS structures). This is constant
1391 * for a given filesystem unless the number of block groups
1392 * changes so we cache the previous value until it does.
1da177e4
LT
1393 */
1394
1395 /*
1396 * All of the blocks before first_data_block are
1397 * overhead
1398 */
e4fca01e 1399 overhead = le32_to_cpu(es->s_first_data_block);
1da177e4
LT
1400
1401 /*
1402 * Add the overhead attributed to the superblock and
1403 * block group descriptors. If the sparse superblocks
1404 * feature is turned on, then not all groups have this.
1405 */
1406 for (i = 0; i < sbi->s_groups_count; i++)
1407 overhead += ext2_bg_has_super(sb, i) +
1408 ext2_bg_num_gdb(sb, i);
1409
1410 /*
1411 * Every block group has an inode bitmap, a block
1412 * bitmap, and an inode table.
1413 */
1414 overhead += (sbi->s_groups_count *
1415 (2 + sbi->s_itb_per_group));
2235219b
BP
1416 sbi->s_overhead_last = overhead;
1417 smp_wmb();
1418 sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count);
1da177e4
LT
1419 }
1420
1421 buf->f_type = EXT2_SUPER_MAGIC;
1422 buf->f_bsize = sb->s_blocksize;
2235219b 1423 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
1da177e4 1424 buf->f_bfree = ext2_count_free_blocks(sb);
2235219b 1425 es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
e4fca01e
PE
1426 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
1427 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
1da177e4 1428 buf->f_bavail = 0;
e4fca01e
PE
1429 buf->f_files = le32_to_cpu(es->s_inodes_count);
1430 buf->f_ffree = ext2_count_free_inodes(sb);
2235219b 1431 es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
1da177e4 1432 buf->f_namelen = EXT2_NAME_LEN;
e4fca01e
PE
1433 fsid = le64_to_cpup((void *)es->s_uuid) ^
1434 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
1435 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
1436 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
c15271f4 1437 spin_unlock(&sbi->s_lock);
1da177e4
LT
1438 return 0;
1439}
1440
152a0836
AV
1441static struct dentry *ext2_mount(struct file_system_type *fs_type,
1442 int flags, const char *dev_name, void *data)
1da177e4 1443{
152a0836 1444 return mount_bdev(fs_type, flags, dev_name, data, ext2_fill_super);
1da177e4
LT
1445}
1446
1447#ifdef CONFIG_QUOTA
1448
1449/* Read data from quotafile - avoid pagecache and such because we cannot afford
1450 * acquiring the locks... As quota files are never truncated and quota code
25985edc 1451 * itself serializes the operations (and no one else should touch the files)
1da177e4
LT
1452 * we don't have to be afraid of races */
1453static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
1454 size_t len, loff_t off)
1455{
1456 struct inode *inode = sb_dqopt(sb)->files[type];
1457 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
1458 int err = 0;
1459 int offset = off & (sb->s_blocksize - 1);
1460 int tocopy;
1461 size_t toread;
1462 struct buffer_head tmp_bh;
1463 struct buffer_head *bh;
1464 loff_t i_size = i_size_read(inode);
1465
1466 if (off > i_size)
1467 return 0;
1468 if (off+len > i_size)
1469 len = i_size-off;
1470 toread = len;
1471 while (toread > 0) {
1472 tocopy = sb->s_blocksize - offset < toread ?
1473 sb->s_blocksize - offset : toread;
1474
1475 tmp_bh.b_state = 0;
c16831b4 1476 tmp_bh.b_size = sb->s_blocksize;
1da177e4 1477 err = ext2_get_block(inode, blk, &tmp_bh, 0);
a686cd89 1478 if (err < 0)
1da177e4
LT
1479 return err;
1480 if (!buffer_mapped(&tmp_bh)) /* A hole? */
1481 memset(data, 0, tocopy);
1482 else {
1483 bh = sb_bread(sb, tmp_bh.b_blocknr);
1484 if (!bh)
1485 return -EIO;
1486 memcpy(data, bh->b_data+offset, tocopy);
1487 brelse(bh);
1488 }
1489 offset = 0;
1490 toread -= tocopy;
1491 data += tocopy;
1492 blk++;
1493 }
1494 return len;
1495}
1496
1497/* Write to quotafile */
1498static ssize_t ext2_quota_write(struct super_block *sb, int type,
1499 const char *data, size_t len, loff_t off)
1500{
1501 struct inode *inode = sb_dqopt(sb)->files[type];
1502 sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
1503 int err = 0;
1504 int offset = off & (sb->s_blocksize - 1);
1505 int tocopy;
1506 size_t towrite = len;
1507 struct buffer_head tmp_bh;
1508 struct buffer_head *bh;
1509
1da177e4
LT
1510 while (towrite > 0) {
1511 tocopy = sb->s_blocksize - offset < towrite ?
1512 sb->s_blocksize - offset : towrite;
1513
1514 tmp_bh.b_state = 0;
df4e7ac0 1515 tmp_bh.b_size = sb->s_blocksize;
1da177e4 1516 err = ext2_get_block(inode, blk, &tmp_bh, 1);
a686cd89 1517 if (err < 0)
1da177e4
LT
1518 goto out;
1519 if (offset || tocopy != EXT2_BLOCK_SIZE(sb))
1520 bh = sb_bread(sb, tmp_bh.b_blocknr);
1521 else
1522 bh = sb_getblk(sb, tmp_bh.b_blocknr);
2b0542a4 1523 if (unlikely(!bh)) {
1da177e4
LT
1524 err = -EIO;
1525 goto out;
1526 }
1527 lock_buffer(bh);
1528 memcpy(bh->b_data+offset, data, tocopy);
1529 flush_dcache_page(bh->b_page);
1530 set_buffer_uptodate(bh);
1531 mark_buffer_dirty(bh);
1532 unlock_buffer(bh);
1533 brelse(bh);
1534 offset = 0;
1535 towrite -= tocopy;
1536 data += tocopy;
1537 blk++;
1538 }
1539out:
e2a3fde7 1540 if (len == towrite)
1da177e4
LT
1541 return err;
1542 if (inode->i_size < off+len-towrite)
1543 i_size_write(inode, off+len-towrite);
1544 inode->i_version++;
078cd827 1545 inode->i_mtime = inode->i_ctime = current_time(inode);
1da177e4 1546 mark_inode_dirty(inode);
1da177e4
LT
1547 return len - towrite;
1548}
1549
1550#endif
1551
1552static struct file_system_type ext2_fs_type = {
1553 .owner = THIS_MODULE,
1554 .name = "ext2",
152a0836 1555 .mount = ext2_mount,
1da177e4 1556 .kill_sb = kill_block_super,
46b15caa 1557 .fs_flags = FS_REQUIRES_DEV,
1da177e4 1558};
7f78e035 1559MODULE_ALIAS_FS("ext2");
1da177e4
LT
1560
1561static int __init init_ext2_fs(void)
1562{
be0726d3
JK
1563 int err;
1564
1da177e4
LT
1565 err = init_inodecache();
1566 if (err)
be0726d3 1567 return err;
1da177e4
LT
1568 err = register_filesystem(&ext2_fs_type);
1569 if (err)
1570 goto out;
1571 return 0;
1572out:
1573 destroy_inodecache();
1da177e4
LT
1574 return err;
1575}
1576
1577static void __exit exit_ext2_fs(void)
1578{
1579 unregister_filesystem(&ext2_fs_type);
1580 destroy_inodecache();
1da177e4
LT
1581}
1582
302bf2f3
PG
1583MODULE_AUTHOR("Remy Card and others");
1584MODULE_DESCRIPTION("Second Extended Filesystem");
1585MODULE_LICENSE("GPL");
1da177e4
LT
1586module_init(init_ext2_fs)
1587module_exit(exit_ext2_fs)