super.c 44 KB

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