super.c 44 KB

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