super.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * super.c
  5. *
  6. * load/unload driver, mount/dismount volumes
  7. *
  8. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2 of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public
  21. * License along with this program; if not, write to the
  22. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. * Boston, MA 021110-1307, USA.
  24. */
  25. #include <linux/module.h>
  26. #include <linux/fs.h>
  27. #include <linux/types.h>
  28. #include <linux/slab.h>
  29. #include <linux/highmem.h>
  30. #include <linux/utsname.h>
  31. #include <linux/init.h>
  32. #include <linux/random.h>
  33. #include <linux/statfs.h>
  34. #include <linux/moduleparam.h>
  35. #include <linux/blkdev.h>
  36. #include <linux/socket.h>
  37. #include <linux/inet.h>
  38. #include <linux/parser.h>
  39. #include <linux/crc32.h>
  40. #include <linux/debugfs.h>
  41. #include <linux/mount.h>
  42. #include <linux/seq_file.h>
  43. #define MLOG_MASK_PREFIX ML_SUPER
  44. #include <cluster/masklog.h>
  45. #include "ocfs2.h"
  46. /* this should be the only file to include a version 1 header */
  47. #include "ocfs1_fs_compat.h"
  48. #include "alloc.h"
  49. #include "dlmglue.h"
  50. #include "export.h"
  51. #include "extent_map.h"
  52. #include "heartbeat.h"
  53. #include "inode.h"
  54. #include "journal.h"
  55. #include "localalloc.h"
  56. #include "namei.h"
  57. #include "slot_map.h"
  58. #include "super.h"
  59. #include "sysfile.h"
  60. #include "uptodate.h"
  61. #include "ver.h"
  62. #include "buffer_head_io.h"
  63. static struct kmem_cache *ocfs2_inode_cachep = NULL;
  64. /* OCFS2 needs to schedule several differnt types of work which
  65. * require cluster locking, disk I/O, recovery waits, etc. Since these
  66. * types of work tend to be heavy we avoid using the kernel events
  67. * workqueue and schedule on our own. */
  68. struct workqueue_struct *ocfs2_wq = NULL;
  69. static struct dentry *ocfs2_debugfs_root = NULL;
  70. MODULE_AUTHOR("Oracle");
  71. MODULE_LICENSE("GPL");
  72. struct mount_options
  73. {
  74. unsigned long commit_interval;
  75. unsigned long mount_opt;
  76. unsigned int atime_quantum;
  77. signed short slot;
  78. unsigned int localalloc_opt;
  79. char cluster_stack[OCFS2_STACK_LABEL_LEN + 1];
  80. };
  81. static int ocfs2_parse_options(struct super_block *sb, char *options,
  82. struct mount_options *mopt,
  83. int is_remount);
  84. static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt);
  85. static void ocfs2_put_super(struct super_block *sb);
  86. static int ocfs2_mount_volume(struct super_block *sb);
  87. static int ocfs2_remount(struct super_block *sb, int *flags, char *data);
  88. static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err);
  89. static int ocfs2_initialize_mem_caches(void);
  90. static void ocfs2_free_mem_caches(void);
  91. static void ocfs2_delete_osb(struct ocfs2_super *osb);
  92. static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf);
  93. static int ocfs2_sync_fs(struct super_block *sb, int wait);
  94. static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb);
  95. static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb);
  96. static void ocfs2_release_system_inodes(struct ocfs2_super *osb);
  97. static int ocfs2_check_volume(struct ocfs2_super *osb);
  98. static int ocfs2_verify_volume(struct ocfs2_dinode *di,
  99. struct buffer_head *bh,
  100. u32 sectsize);
  101. static int ocfs2_initialize_super(struct super_block *sb,
  102. struct buffer_head *bh,
  103. int sector_size);
  104. static int ocfs2_get_sector(struct super_block *sb,
  105. struct buffer_head **bh,
  106. int block,
  107. int sect_size);
  108. static void ocfs2_write_super(struct super_block *sb);
  109. static struct inode *ocfs2_alloc_inode(struct super_block *sb);
  110. static void ocfs2_destroy_inode(struct inode *inode);
  111. static const struct super_operations ocfs2_sops = {
  112. .statfs = ocfs2_statfs,
  113. .alloc_inode = ocfs2_alloc_inode,
  114. .destroy_inode = ocfs2_destroy_inode,
  115. .drop_inode = ocfs2_drop_inode,
  116. .clear_inode = ocfs2_clear_inode,
  117. .delete_inode = ocfs2_delete_inode,
  118. .sync_fs = ocfs2_sync_fs,
  119. .write_super = ocfs2_write_super,
  120. .put_super = ocfs2_put_super,
  121. .remount_fs = ocfs2_remount,
  122. .show_options = ocfs2_show_options,
  123. };
  124. enum {
  125. Opt_barrier,
  126. Opt_err_panic,
  127. Opt_err_ro,
  128. Opt_intr,
  129. Opt_nointr,
  130. Opt_hb_none,
  131. Opt_hb_local,
  132. Opt_data_ordered,
  133. Opt_data_writeback,
  134. Opt_atime_quantum,
  135. Opt_slot,
  136. Opt_commit,
  137. Opt_localalloc,
  138. Opt_localflocks,
  139. Opt_stack,
  140. Opt_err,
  141. };
  142. static match_table_t tokens = {
  143. {Opt_barrier, "barrier=%u"},
  144. {Opt_err_panic, "errors=panic"},
  145. {Opt_err_ro, "errors=remount-ro"},
  146. {Opt_intr, "intr"},
  147. {Opt_nointr, "nointr"},
  148. {Opt_hb_none, OCFS2_HB_NONE},
  149. {Opt_hb_local, OCFS2_HB_LOCAL},
  150. {Opt_data_ordered, "data=ordered"},
  151. {Opt_data_writeback, "data=writeback"},
  152. {Opt_atime_quantum, "atime_quantum=%u"},
  153. {Opt_slot, "preferred_slot=%u"},
  154. {Opt_commit, "commit=%u"},
  155. {Opt_localalloc, "localalloc=%d"},
  156. {Opt_localflocks, "localflocks"},
  157. {Opt_stack, "cluster_stack=%s"},
  158. {Opt_err, NULL}
  159. };
  160. /*
  161. * write_super and sync_fs ripped right out of ext3.
  162. */
  163. static void ocfs2_write_super(struct super_block *sb)
  164. {
  165. if (mutex_trylock(&sb->s_lock) != 0)
  166. BUG();
  167. sb->s_dirt = 0;
  168. }
  169. static int ocfs2_sync_fs(struct super_block *sb, int wait)
  170. {
  171. int status;
  172. tid_t target;
  173. struct ocfs2_super *osb = OCFS2_SB(sb);
  174. sb->s_dirt = 0;
  175. if (ocfs2_is_hard_readonly(osb))
  176. return -EROFS;
  177. if (wait) {
  178. status = ocfs2_flush_truncate_log(osb);
  179. if (status < 0)
  180. mlog_errno(status);
  181. } else {
  182. ocfs2_schedule_truncate_log_flush(osb, 0);
  183. }
  184. if (journal_start_commit(OCFS2_SB(sb)->journal->j_journal, &target)) {
  185. if (wait)
  186. log_wait_commit(OCFS2_SB(sb)->journal->j_journal,
  187. target);
  188. }
  189. return 0;
  190. }
  191. static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb)
  192. {
  193. struct inode *new = NULL;
  194. int status = 0;
  195. int i;
  196. mlog_entry_void();
  197. new = ocfs2_iget(osb, osb->root_blkno, OCFS2_FI_FLAG_SYSFILE, 0);
  198. if (IS_ERR(new)) {
  199. status = PTR_ERR(new);
  200. mlog_errno(status);
  201. goto bail;
  202. }
  203. osb->root_inode = new;
  204. new = ocfs2_iget(osb, osb->system_dir_blkno, OCFS2_FI_FLAG_SYSFILE, 0);
  205. if (IS_ERR(new)) {
  206. status = PTR_ERR(new);
  207. mlog_errno(status);
  208. goto bail;
  209. }
  210. osb->sys_root_inode = new;
  211. for (i = OCFS2_FIRST_ONLINE_SYSTEM_INODE;
  212. i <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; i++) {
  213. new = ocfs2_get_system_file_inode(osb, i, osb->slot_num);
  214. if (!new) {
  215. ocfs2_release_system_inodes(osb);
  216. status = -EINVAL;
  217. mlog_errno(status);
  218. /* FIXME: Should ERROR_RO_FS */
  219. mlog(ML_ERROR, "Unable to load system inode %d, "
  220. "possibly corrupt fs?", i);
  221. goto bail;
  222. }
  223. // the array now has one ref, so drop this one
  224. iput(new);
  225. }
  226. bail:
  227. mlog_exit(status);
  228. return status;
  229. }
  230. static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb)
  231. {
  232. struct inode *new = NULL;
  233. int status = 0;
  234. int i;
  235. mlog_entry_void();
  236. for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1;
  237. i < NUM_SYSTEM_INODES;
  238. i++) {
  239. new = ocfs2_get_system_file_inode(osb, i, osb->slot_num);
  240. if (!new) {
  241. ocfs2_release_system_inodes(osb);
  242. status = -EINVAL;
  243. mlog(ML_ERROR, "status=%d, sysfile=%d, slot=%d\n",
  244. status, i, osb->slot_num);
  245. goto bail;
  246. }
  247. /* the array now has one ref, so drop this one */
  248. iput(new);
  249. }
  250. bail:
  251. mlog_exit(status);
  252. return status;
  253. }
  254. static void ocfs2_release_system_inodes(struct ocfs2_super *osb)
  255. {
  256. int i;
  257. struct inode *inode;
  258. mlog_entry_void();
  259. for (i = 0; i < NUM_SYSTEM_INODES; i++) {
  260. inode = osb->system_inodes[i];
  261. if (inode) {
  262. iput(inode);
  263. osb->system_inodes[i] = NULL;
  264. }
  265. }
  266. inode = osb->sys_root_inode;
  267. if (inode) {
  268. iput(inode);
  269. osb->sys_root_inode = NULL;
  270. }
  271. inode = osb->root_inode;
  272. if (inode) {
  273. iput(inode);
  274. osb->root_inode = NULL;
  275. }
  276. mlog_exit(0);
  277. }
  278. /* We're allocating fs objects, use GFP_NOFS */
  279. static struct inode *ocfs2_alloc_inode(struct super_block *sb)
  280. {
  281. struct ocfs2_inode_info *oi;
  282. oi = kmem_cache_alloc(ocfs2_inode_cachep, GFP_NOFS);
  283. if (!oi)
  284. return NULL;
  285. return &oi->vfs_inode;
  286. }
  287. static void ocfs2_destroy_inode(struct inode *inode)
  288. {
  289. kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode));
  290. }
  291. static unsigned long long ocfs2_max_file_offset(unsigned int bbits,
  292. unsigned int cbits)
  293. {
  294. unsigned int bytes = 1 << cbits;
  295. unsigned int trim = bytes;
  296. unsigned int bitshift = 32;
  297. /*
  298. * i_size and all block offsets in ocfs2 are always 64 bits
  299. * wide. i_clusters is 32 bits, in cluster-sized units. So on
  300. * 64 bit platforms, cluster size will be the limiting factor.
  301. */
  302. #if BITS_PER_LONG == 32
  303. # if defined(CONFIG_LBD)
  304. BUILD_BUG_ON(sizeof(sector_t) != 8);
  305. /*
  306. * We might be limited by page cache size.
  307. */
  308. if (bytes > PAGE_CACHE_SIZE) {
  309. bytes = PAGE_CACHE_SIZE;
  310. trim = 1;
  311. /*
  312. * Shift by 31 here so that we don't get larger than
  313. * MAX_LFS_FILESIZE
  314. */
  315. bitshift = 31;
  316. }
  317. # else
  318. /*
  319. * We are limited by the size of sector_t. Use block size, as
  320. * that's what we expose to the VFS.
  321. */
  322. bytes = 1 << bbits;
  323. trim = 1;
  324. bitshift = 31;
  325. # endif
  326. #endif
  327. /*
  328. * Trim by a whole cluster when we can actually approach the
  329. * on-disk limits. Otherwise we can overflow i_clusters when
  330. * an extent start is at the max offset.
  331. */
  332. return (((unsigned long long)bytes) << bitshift) - trim;
  333. }
  334. static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
  335. {
  336. int incompat_features;
  337. int ret = 0;
  338. struct mount_options parsed_options;
  339. struct ocfs2_super *osb = OCFS2_SB(sb);
  340. if (!ocfs2_parse_options(sb, data, &parsed_options, 1)) {
  341. ret = -EINVAL;
  342. goto out;
  343. }
  344. if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
  345. (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
  346. ret = -EINVAL;
  347. mlog(ML_ERROR, "Cannot change heartbeat mode on remount\n");
  348. goto out;
  349. }
  350. if ((osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) !=
  351. (parsed_options.mount_opt & OCFS2_MOUNT_DATA_WRITEBACK)) {
  352. ret = -EINVAL;
  353. mlog(ML_ERROR, "Cannot change data mode on remount\n");
  354. goto out;
  355. }
  356. /* We're going to/from readonly mode. */
  357. if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
  358. /* Lock here so the check of HARD_RO and the potential
  359. * setting of SOFT_RO is atomic. */
  360. spin_lock(&osb->osb_lock);
  361. if (osb->osb_flags & OCFS2_OSB_HARD_RO) {
  362. mlog(ML_ERROR, "Remount on readonly device is forbidden.\n");
  363. ret = -EROFS;
  364. goto unlock_osb;
  365. }
  366. if (*flags & MS_RDONLY) {
  367. mlog(0, "Going to ro mode.\n");
  368. sb->s_flags |= MS_RDONLY;
  369. osb->osb_flags |= OCFS2_OSB_SOFT_RO;
  370. } else {
  371. mlog(0, "Making ro filesystem writeable.\n");
  372. if (osb->osb_flags & OCFS2_OSB_ERROR_FS) {
  373. mlog(ML_ERROR, "Cannot remount RDWR "
  374. "filesystem due to previous errors.\n");
  375. ret = -EROFS;
  376. goto unlock_osb;
  377. }
  378. incompat_features = OCFS2_HAS_RO_COMPAT_FEATURE(sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP);
  379. if (incompat_features) {
  380. mlog(ML_ERROR, "Cannot remount RDWR because "
  381. "of unsupported optional features "
  382. "(%x).\n", incompat_features);
  383. ret = -EINVAL;
  384. goto unlock_osb;
  385. }
  386. sb->s_flags &= ~MS_RDONLY;
  387. osb->osb_flags &= ~OCFS2_OSB_SOFT_RO;
  388. }
  389. unlock_osb:
  390. spin_unlock(&osb->osb_lock);
  391. }
  392. if (!ret) {
  393. /* Only save off the new mount options in case of a successful
  394. * remount. */
  395. osb->s_mount_opt = parsed_options.mount_opt;
  396. osb->s_atime_quantum = parsed_options.atime_quantum;
  397. osb->preferred_slot = parsed_options.slot;
  398. if (parsed_options.commit_interval)
  399. osb->osb_commit_interval = parsed_options.commit_interval;
  400. if (!ocfs2_is_hard_readonly(osb))
  401. ocfs2_set_journal_params(osb);
  402. }
  403. out:
  404. return ret;
  405. }
  406. static int ocfs2_sb_probe(struct super_block *sb,
  407. struct buffer_head **bh,
  408. int *sector_size)
  409. {
  410. int status, tmpstat;
  411. struct ocfs1_vol_disk_hdr *hdr;
  412. struct ocfs2_dinode *di;
  413. int blksize;
  414. *bh = NULL;
  415. /* may be > 512 */
  416. *sector_size = bdev_hardsect_size(sb->s_bdev);
  417. if (*sector_size > OCFS2_MAX_BLOCKSIZE) {
  418. mlog(ML_ERROR, "Hardware sector size too large: %d (max=%d)\n",
  419. *sector_size, OCFS2_MAX_BLOCKSIZE);
  420. status = -EINVAL;
  421. goto bail;
  422. }
  423. /* Can this really happen? */
  424. if (*sector_size < OCFS2_MIN_BLOCKSIZE)
  425. *sector_size = OCFS2_MIN_BLOCKSIZE;
  426. /* check block zero for old format */
  427. status = ocfs2_get_sector(sb, bh, 0, *sector_size);
  428. if (status < 0) {
  429. mlog_errno(status);
  430. goto bail;
  431. }
  432. hdr = (struct ocfs1_vol_disk_hdr *) (*bh)->b_data;
  433. if (hdr->major_version == OCFS1_MAJOR_VERSION) {
  434. mlog(ML_ERROR, "incompatible version: %u.%u\n",
  435. hdr->major_version, hdr->minor_version);
  436. status = -EINVAL;
  437. }
  438. if (memcmp(hdr->signature, OCFS1_VOLUME_SIGNATURE,
  439. strlen(OCFS1_VOLUME_SIGNATURE)) == 0) {
  440. mlog(ML_ERROR, "incompatible volume signature: %8s\n",
  441. hdr->signature);
  442. status = -EINVAL;
  443. }
  444. brelse(*bh);
  445. *bh = NULL;
  446. if (status < 0) {
  447. mlog(ML_ERROR, "This is an ocfs v1 filesystem which must be "
  448. "upgraded before mounting with ocfs v2\n");
  449. goto bail;
  450. }
  451. /*
  452. * Now check at magic offset for 512, 1024, 2048, 4096
  453. * blocksizes. 4096 is the maximum blocksize because it is
  454. * the minimum clustersize.
  455. */
  456. status = -EINVAL;
  457. for (blksize = *sector_size;
  458. blksize <= OCFS2_MAX_BLOCKSIZE;
  459. blksize <<= 1) {
  460. tmpstat = ocfs2_get_sector(sb, bh,
  461. OCFS2_SUPER_BLOCK_BLKNO,
  462. blksize);
  463. if (tmpstat < 0) {
  464. status = tmpstat;
  465. mlog_errno(status);
  466. goto bail;
  467. }
  468. di = (struct ocfs2_dinode *) (*bh)->b_data;
  469. status = ocfs2_verify_volume(di, *bh, blksize);
  470. if (status >= 0)
  471. goto bail;
  472. brelse(*bh);
  473. *bh = NULL;
  474. if (status != -EAGAIN)
  475. break;
  476. }
  477. bail:
  478. return status;
  479. }
  480. static int ocfs2_verify_heartbeat(struct ocfs2_super *osb)
  481. {
  482. if (ocfs2_mount_local(osb)) {
  483. if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) {
  484. mlog(ML_ERROR, "Cannot heartbeat on a locally "
  485. "mounted device.\n");
  486. return -EINVAL;
  487. }
  488. }
  489. if (ocfs2_userspace_stack(osb)) {
  490. if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) {
  491. mlog(ML_ERROR, "Userspace stack expected, but "
  492. "o2cb heartbeat arguments passed to mount\n");
  493. return -EINVAL;
  494. }
  495. }
  496. if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
  497. if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb) &&
  498. !ocfs2_userspace_stack(osb)) {
  499. mlog(ML_ERROR, "Heartbeat has to be started to mount "
  500. "a read-write clustered device.\n");
  501. return -EINVAL;
  502. }
  503. }
  504. return 0;
  505. }
  506. /*
  507. * If we're using a userspace stack, mount should have passed
  508. * a name that matches the disk. If not, mount should not
  509. * have passed a stack.
  510. */
  511. static int ocfs2_verify_userspace_stack(struct ocfs2_super *osb,
  512. struct mount_options *mopt)
  513. {
  514. if (!ocfs2_userspace_stack(osb) && mopt->cluster_stack[0]) {
  515. mlog(ML_ERROR,
  516. "cluster stack passed to mount, but this filesystem "
  517. "does not support it\n");
  518. return -EINVAL;
  519. }
  520. if (ocfs2_userspace_stack(osb) &&
  521. strncmp(osb->osb_cluster_stack, mopt->cluster_stack,
  522. OCFS2_STACK_LABEL_LEN)) {
  523. mlog(ML_ERROR,
  524. "cluster stack passed to mount (\"%s\") does not "
  525. "match the filesystem (\"%s\")\n",
  526. mopt->cluster_stack,
  527. osb->osb_cluster_stack);
  528. return -EINVAL;
  529. }
  530. return 0;
  531. }
  532. static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
  533. {
  534. struct dentry *root;
  535. int status, sector_size;
  536. struct mount_options parsed_options;
  537. struct inode *inode = NULL;
  538. struct ocfs2_super *osb = NULL;
  539. struct buffer_head *bh = NULL;
  540. char nodestr[8];
  541. mlog_entry("%p, %p, %i", sb, data, silent);
  542. if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) {
  543. status = -EINVAL;
  544. goto read_super_error;
  545. }
  546. /* probe for superblock */
  547. status = ocfs2_sb_probe(sb, &bh, &sector_size);
  548. if (status < 0) {
  549. mlog(ML_ERROR, "superblock probe failed!\n");
  550. goto read_super_error;
  551. }
  552. status = ocfs2_initialize_super(sb, bh, sector_size);
  553. osb = OCFS2_SB(sb);
  554. if (status < 0) {
  555. mlog_errno(status);
  556. goto read_super_error;
  557. }
  558. brelse(bh);
  559. bh = NULL;
  560. osb->s_mount_opt = parsed_options.mount_opt;
  561. osb->s_atime_quantum = parsed_options.atime_quantum;
  562. osb->preferred_slot = parsed_options.slot;
  563. osb->osb_commit_interval = parsed_options.commit_interval;
  564. osb->local_alloc_size = parsed_options.localalloc_opt;
  565. status = ocfs2_verify_userspace_stack(osb, &parsed_options);
  566. if (status)
  567. goto read_super_error;
  568. sb->s_magic = OCFS2_SUPER_MAGIC;
  569. /* Hard readonly mode only if: bdev_read_only, MS_RDONLY,
  570. * heartbeat=none */
  571. if (bdev_read_only(sb->s_bdev)) {
  572. if (!(sb->s_flags & MS_RDONLY)) {
  573. status = -EACCES;
  574. mlog(ML_ERROR, "Readonly device detected but readonly "
  575. "mount was not specified.\n");
  576. goto read_super_error;
  577. }
  578. /* You should not be able to start a local heartbeat
  579. * on a readonly device. */
  580. if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) {
  581. status = -EROFS;
  582. mlog(ML_ERROR, "Local heartbeat specified on readonly "
  583. "device.\n");
  584. goto read_super_error;
  585. }
  586. status = ocfs2_check_journals_nolocks(osb);
  587. if (status < 0) {
  588. if (status == -EROFS)
  589. mlog(ML_ERROR, "Recovery required on readonly "
  590. "file system, but write access is "
  591. "unavailable.\n");
  592. else
  593. mlog_errno(status);
  594. goto read_super_error;
  595. }
  596. ocfs2_set_ro_flag(osb, 1);
  597. printk(KERN_NOTICE "Readonly device detected. No cluster "
  598. "services will be utilized for this mount. Recovery "
  599. "will be skipped.\n");
  600. }
  601. if (!ocfs2_is_hard_readonly(osb)) {
  602. if (sb->s_flags & MS_RDONLY)
  603. ocfs2_set_ro_flag(osb, 0);
  604. }
  605. status = ocfs2_verify_heartbeat(osb);
  606. if (status < 0) {
  607. mlog_errno(status);
  608. goto read_super_error;
  609. }
  610. osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
  611. ocfs2_debugfs_root);
  612. if (!osb->osb_debug_root) {
  613. status = -EINVAL;
  614. mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n");
  615. goto read_super_error;
  616. }
  617. status = ocfs2_mount_volume(sb);
  618. if (osb->root_inode)
  619. inode = igrab(osb->root_inode);
  620. if (status < 0)
  621. goto read_super_error;
  622. if (!inode) {
  623. status = -EIO;
  624. mlog_errno(status);
  625. goto read_super_error;
  626. }
  627. root = d_alloc_root(inode);
  628. if (!root) {
  629. status = -ENOMEM;
  630. mlog_errno(status);
  631. goto read_super_error;
  632. }
  633. sb->s_root = root;
  634. ocfs2_complete_mount_recovery(osb);
  635. if (ocfs2_mount_local(osb))
  636. snprintf(nodestr, sizeof(nodestr), "local");
  637. else
  638. snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num);
  639. printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) "
  640. "with %s data mode.\n",
  641. osb->dev_str, nodestr, osb->slot_num,
  642. osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" :
  643. "ordered");
  644. atomic_set(&osb->vol_state, VOLUME_MOUNTED);
  645. wake_up(&osb->osb_mount_event);
  646. mlog_exit(status);
  647. return status;
  648. read_super_error:
  649. if (bh != NULL)
  650. brelse(bh);
  651. if (inode)
  652. iput(inode);
  653. if (osb) {
  654. atomic_set(&osb->vol_state, VOLUME_DISABLED);
  655. wake_up(&osb->osb_mount_event);
  656. ocfs2_dismount_volume(sb, 1);
  657. }
  658. mlog_exit(status);
  659. return status;
  660. }
  661. static int ocfs2_get_sb(struct file_system_type *fs_type,
  662. int flags,
  663. const char *dev_name,
  664. void *data,
  665. struct vfsmount *mnt)
  666. {
  667. return get_sb_bdev(fs_type, flags, dev_name, data, ocfs2_fill_super,
  668. mnt);
  669. }
  670. static struct file_system_type ocfs2_fs_type = {
  671. .owner = THIS_MODULE,
  672. .name = "ocfs2",
  673. .get_sb = ocfs2_get_sb, /* is this called when we mount
  674. * the fs? */
  675. .kill_sb = kill_block_super, /* set to the generic one
  676. * right now, but do we
  677. * need to change that? */
  678. .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE,
  679. .next = NULL
  680. };
  681. static int ocfs2_parse_options(struct super_block *sb,
  682. char *options,
  683. struct mount_options *mopt,
  684. int is_remount)
  685. {
  686. int status;
  687. char *p;
  688. mlog_entry("remount: %d, options: \"%s\"\n", is_remount,
  689. options ? options : "(none)");
  690. mopt->commit_interval = 0;
  691. mopt->mount_opt = 0;
  692. mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
  693. mopt->slot = OCFS2_INVALID_SLOT;
  694. mopt->localalloc_opt = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE;
  695. mopt->cluster_stack[0] = '\0';
  696. if (!options) {
  697. status = 1;
  698. goto bail;
  699. }
  700. while ((p = strsep(&options, ",")) != NULL) {
  701. int token, option;
  702. substring_t args[MAX_OPT_ARGS];
  703. if (!*p)
  704. continue;
  705. token = match_token(p, tokens, args);
  706. switch (token) {
  707. case Opt_hb_local:
  708. mopt->mount_opt |= OCFS2_MOUNT_HB_LOCAL;
  709. break;
  710. case Opt_hb_none:
  711. mopt->mount_opt &= ~OCFS2_MOUNT_HB_LOCAL;
  712. break;
  713. case Opt_barrier:
  714. if (match_int(&args[0], &option)) {
  715. status = 0;
  716. goto bail;
  717. }
  718. if (option)
  719. mopt->mount_opt |= OCFS2_MOUNT_BARRIER;
  720. else
  721. mopt->mount_opt &= ~OCFS2_MOUNT_BARRIER;
  722. break;
  723. case Opt_intr:
  724. mopt->mount_opt &= ~OCFS2_MOUNT_NOINTR;
  725. break;
  726. case Opt_nointr:
  727. mopt->mount_opt |= OCFS2_MOUNT_NOINTR;
  728. break;
  729. case Opt_err_panic:
  730. mopt->mount_opt |= OCFS2_MOUNT_ERRORS_PANIC;
  731. break;
  732. case Opt_err_ro:
  733. mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_PANIC;
  734. break;
  735. case Opt_data_ordered:
  736. mopt->mount_opt &= ~OCFS2_MOUNT_DATA_WRITEBACK;
  737. break;
  738. case Opt_data_writeback:
  739. mopt->mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK;
  740. break;
  741. case Opt_atime_quantum:
  742. if (match_int(&args[0], &option)) {
  743. status = 0;
  744. goto bail;
  745. }
  746. if (option >= 0)
  747. mopt->atime_quantum = option;
  748. break;
  749. case Opt_slot:
  750. option = 0;
  751. if (match_int(&args[0], &option)) {
  752. status = 0;
  753. goto bail;
  754. }
  755. if (option)
  756. mopt->slot = (s16)option;
  757. break;
  758. case Opt_commit:
  759. option = 0;
  760. if (match_int(&args[0], &option)) {
  761. status = 0;
  762. goto bail;
  763. }
  764. if (option < 0)
  765. return 0;
  766. if (option == 0)
  767. option = JBD_DEFAULT_MAX_COMMIT_AGE;
  768. mopt->commit_interval = HZ * option;
  769. break;
  770. case Opt_localalloc:
  771. option = 0;
  772. if (match_int(&args[0], &option)) {
  773. status = 0;
  774. goto bail;
  775. }
  776. if (option >= 0 && (option <= ocfs2_local_alloc_size(sb) * 8))
  777. mopt->localalloc_opt = option;
  778. break;
  779. case Opt_localflocks:
  780. /*
  781. * Changing this during remount could race
  782. * flock() requests, or "unbalance" existing
  783. * ones (e.g., a lock is taken in one mode but
  784. * dropped in the other). If users care enough
  785. * to flip locking modes during remount, we
  786. * could add a "local" flag to individual
  787. * flock structures for proper tracking of
  788. * state.
  789. */
  790. if (!is_remount)
  791. mopt->mount_opt |= OCFS2_MOUNT_LOCALFLOCKS;
  792. break;
  793. case Opt_stack:
  794. /* Check both that the option we were passed
  795. * is of the right length and that it is a proper
  796. * string of the right length.
  797. */
  798. if (((args[0].to - args[0].from) !=
  799. OCFS2_STACK_LABEL_LEN) ||
  800. (strnlen(args[0].from,
  801. OCFS2_STACK_LABEL_LEN) !=
  802. OCFS2_STACK_LABEL_LEN)) {
  803. mlog(ML_ERROR,
  804. "Invalid cluster_stack option\n");
  805. status = 0;
  806. goto bail;
  807. }
  808. memcpy(mopt->cluster_stack, args[0].from,
  809. OCFS2_STACK_LABEL_LEN);
  810. mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
  811. break;
  812. default:
  813. mlog(ML_ERROR,
  814. "Unrecognized mount option \"%s\" "
  815. "or missing value\n", p);
  816. status = 0;
  817. goto bail;
  818. }
  819. }
  820. status = 1;
  821. bail:
  822. mlog_exit(status);
  823. return status;
  824. }
  825. static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
  826. {
  827. struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb);
  828. unsigned long opts = osb->s_mount_opt;
  829. if (opts & OCFS2_MOUNT_HB_LOCAL)
  830. seq_printf(s, ",_netdev,heartbeat=local");
  831. else
  832. seq_printf(s, ",heartbeat=none");
  833. if (opts & OCFS2_MOUNT_NOINTR)
  834. seq_printf(s, ",nointr");
  835. if (opts & OCFS2_MOUNT_DATA_WRITEBACK)
  836. seq_printf(s, ",data=writeback");
  837. else
  838. seq_printf(s, ",data=ordered");
  839. if (opts & OCFS2_MOUNT_BARRIER)
  840. seq_printf(s, ",barrier=1");
  841. if (opts & OCFS2_MOUNT_ERRORS_PANIC)
  842. seq_printf(s, ",errors=panic");
  843. else
  844. seq_printf(s, ",errors=remount-ro");
  845. if (osb->preferred_slot != OCFS2_INVALID_SLOT)
  846. seq_printf(s, ",preferred_slot=%d", osb->preferred_slot);
  847. if (osb->s_atime_quantum != OCFS2_DEFAULT_ATIME_QUANTUM)
  848. seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum);
  849. if (osb->osb_commit_interval)
  850. seq_printf(s, ",commit=%u",
  851. (unsigned) (osb->osb_commit_interval / HZ));
  852. if (osb->local_alloc_size != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE)
  853. seq_printf(s, ",localalloc=%d", osb->local_alloc_size);
  854. if (opts & OCFS2_MOUNT_LOCALFLOCKS)
  855. seq_printf(s, ",localflocks,");
  856. if (osb->osb_cluster_stack[0])
  857. seq_printf(s, ",cluster_stack=%.*s", OCFS2_STACK_LABEL_LEN,
  858. osb->osb_cluster_stack);
  859. return 0;
  860. }
  861. static int __init ocfs2_init(void)
  862. {
  863. int status;
  864. mlog_entry_void();
  865. ocfs2_print_version();
  866. status = init_ocfs2_uptodate_cache();
  867. if (status < 0) {
  868. mlog_errno(status);
  869. goto leave;
  870. }
  871. status = ocfs2_initialize_mem_caches();
  872. if (status < 0) {
  873. mlog_errno(status);
  874. goto leave;
  875. }
  876. ocfs2_wq = create_singlethread_workqueue("ocfs2_wq");
  877. if (!ocfs2_wq) {
  878. status = -ENOMEM;
  879. goto leave;
  880. }
  881. ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
  882. if (!ocfs2_debugfs_root) {
  883. status = -EFAULT;
  884. mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
  885. }
  886. ocfs2_set_locking_protocol();
  887. leave:
  888. if (status < 0) {
  889. ocfs2_free_mem_caches();
  890. exit_ocfs2_uptodate_cache();
  891. }
  892. mlog_exit(status);
  893. if (status >= 0) {
  894. return register_filesystem(&ocfs2_fs_type);
  895. } else
  896. return -1;
  897. }
  898. static void __exit ocfs2_exit(void)
  899. {
  900. mlog_entry_void();
  901. if (ocfs2_wq) {
  902. flush_workqueue(ocfs2_wq);
  903. destroy_workqueue(ocfs2_wq);
  904. }
  905. debugfs_remove(ocfs2_debugfs_root);
  906. ocfs2_free_mem_caches();
  907. unregister_filesystem(&ocfs2_fs_type);
  908. exit_ocfs2_uptodate_cache();
  909. mlog_exit_void();
  910. }
  911. static void ocfs2_put_super(struct super_block *sb)
  912. {
  913. mlog_entry("(0x%p)\n", sb);
  914. ocfs2_sync_blockdev(sb);
  915. ocfs2_dismount_volume(sb, 0);
  916. mlog_exit_void();
  917. }
  918. static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
  919. {
  920. struct ocfs2_super *osb;
  921. u32 numbits, freebits;
  922. int status;
  923. struct ocfs2_dinode *bm_lock;
  924. struct buffer_head *bh = NULL;
  925. struct inode *inode = NULL;
  926. mlog_entry("(%p, %p)\n", dentry->d_sb, buf);
  927. osb = OCFS2_SB(dentry->d_sb);
  928. inode = ocfs2_get_system_file_inode(osb,
  929. GLOBAL_BITMAP_SYSTEM_INODE,
  930. OCFS2_INVALID_SLOT);
  931. if (!inode) {
  932. mlog(ML_ERROR, "failed to get bitmap inode\n");
  933. status = -EIO;
  934. goto bail;
  935. }
  936. status = ocfs2_inode_lock(inode, &bh, 0);
  937. if (status < 0) {
  938. mlog_errno(status);
  939. goto bail;
  940. }
  941. bm_lock = (struct ocfs2_dinode *) bh->b_data;
  942. numbits = le32_to_cpu(bm_lock->id1.bitmap1.i_total);
  943. freebits = numbits - le32_to_cpu(bm_lock->id1.bitmap1.i_used);
  944. buf->f_type = OCFS2_SUPER_MAGIC;
  945. buf->f_bsize = dentry->d_sb->s_blocksize;
  946. buf->f_namelen = OCFS2_MAX_FILENAME_LEN;
  947. buf->f_blocks = ((sector_t) numbits) *
  948. (osb->s_clustersize >> osb->sb->s_blocksize_bits);
  949. buf->f_bfree = ((sector_t) freebits) *
  950. (osb->s_clustersize >> osb->sb->s_blocksize_bits);
  951. buf->f_bavail = buf->f_bfree;
  952. buf->f_files = numbits;
  953. buf->f_ffree = freebits;
  954. brelse(bh);
  955. ocfs2_inode_unlock(inode, 0);
  956. status = 0;
  957. bail:
  958. if (inode)
  959. iput(inode);
  960. mlog_exit(status);
  961. return status;
  962. }
  963. static void ocfs2_inode_init_once(struct kmem_cache *cachep, void *data)
  964. {
  965. struct ocfs2_inode_info *oi = data;
  966. oi->ip_flags = 0;
  967. oi->ip_open_count = 0;
  968. spin_lock_init(&oi->ip_lock);
  969. ocfs2_extent_map_init(&oi->vfs_inode);
  970. INIT_LIST_HEAD(&oi->ip_io_markers);
  971. oi->ip_created_trans = 0;
  972. oi->ip_last_trans = 0;
  973. oi->ip_dir_start_lookup = 0;
  974. init_rwsem(&oi->ip_alloc_sem);
  975. mutex_init(&oi->ip_io_mutex);
  976. oi->ip_blkno = 0ULL;
  977. oi->ip_clusters = 0;
  978. ocfs2_lock_res_init_once(&oi->ip_rw_lockres);
  979. ocfs2_lock_res_init_once(&oi->ip_inode_lockres);
  980. ocfs2_lock_res_init_once(&oi->ip_open_lockres);
  981. ocfs2_metadata_cache_init(&oi->vfs_inode);
  982. inode_init_once(&oi->vfs_inode);
  983. }
  984. static int ocfs2_initialize_mem_caches(void)
  985. {
  986. ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache",
  987. sizeof(struct ocfs2_inode_info),
  988. 0,
  989. (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
  990. SLAB_MEM_SPREAD),
  991. ocfs2_inode_init_once);
  992. if (!ocfs2_inode_cachep)
  993. return -ENOMEM;
  994. return 0;
  995. }
  996. static void ocfs2_free_mem_caches(void)
  997. {
  998. if (ocfs2_inode_cachep)
  999. kmem_cache_destroy(ocfs2_inode_cachep);
  1000. ocfs2_inode_cachep = NULL;
  1001. }
  1002. static int ocfs2_get_sector(struct super_block *sb,
  1003. struct buffer_head **bh,
  1004. int block,
  1005. int sect_size)
  1006. {
  1007. if (!sb_set_blocksize(sb, sect_size)) {
  1008. mlog(ML_ERROR, "unable to set blocksize\n");
  1009. return -EIO;
  1010. }
  1011. *bh = sb_getblk(sb, block);
  1012. if (!*bh) {
  1013. mlog_errno(-EIO);
  1014. return -EIO;
  1015. }
  1016. lock_buffer(*bh);
  1017. if (!buffer_dirty(*bh))
  1018. clear_buffer_uptodate(*bh);
  1019. unlock_buffer(*bh);
  1020. ll_rw_block(READ, 1, bh);
  1021. wait_on_buffer(*bh);
  1022. return 0;
  1023. }
  1024. static int ocfs2_mount_volume(struct super_block *sb)
  1025. {
  1026. int status = 0;
  1027. int unlock_super = 0;
  1028. struct ocfs2_super *osb = OCFS2_SB(sb);
  1029. mlog_entry_void();
  1030. if (ocfs2_is_hard_readonly(osb))
  1031. goto leave;
  1032. status = ocfs2_dlm_init(osb);
  1033. if (status < 0) {
  1034. mlog_errno(status);
  1035. goto leave;
  1036. }
  1037. status = ocfs2_super_lock(osb, 1);
  1038. if (status < 0) {
  1039. mlog_errno(status);
  1040. goto leave;
  1041. }
  1042. unlock_super = 1;
  1043. /* This will load up the node map and add ourselves to it. */
  1044. status = ocfs2_find_slot(osb);
  1045. if (status < 0) {
  1046. mlog_errno(status);
  1047. goto leave;
  1048. }
  1049. /* load all node-local system inodes */
  1050. status = ocfs2_init_local_system_inodes(osb);
  1051. if (status < 0) {
  1052. mlog_errno(status);
  1053. goto leave;
  1054. }
  1055. status = ocfs2_check_volume(osb);
  1056. if (status < 0) {
  1057. mlog_errno(status);
  1058. goto leave;
  1059. }
  1060. status = ocfs2_truncate_log_init(osb);
  1061. if (status < 0) {
  1062. mlog_errno(status);
  1063. goto leave;
  1064. }
  1065. if (ocfs2_mount_local(osb))
  1066. goto leave;
  1067. leave:
  1068. if (unlock_super)
  1069. ocfs2_super_unlock(osb, 1);
  1070. mlog_exit(status);
  1071. return status;
  1072. }
  1073. static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
  1074. {
  1075. int tmp, hangup_needed = 0;
  1076. struct ocfs2_super *osb = NULL;
  1077. char nodestr[8];
  1078. mlog_entry("(0x%p)\n", sb);
  1079. BUG_ON(!sb);
  1080. osb = OCFS2_SB(sb);
  1081. BUG_ON(!osb);
  1082. ocfs2_shutdown_local_alloc(osb);
  1083. ocfs2_truncate_log_shutdown(osb);
  1084. /* This will disable recovery and flush any recovery work. */
  1085. ocfs2_recovery_exit(osb);
  1086. ocfs2_journal_shutdown(osb);
  1087. ocfs2_sync_blockdev(sb);
  1088. /* No cluster connection means we've failed during mount, so skip
  1089. * all the steps which depended on that to complete. */
  1090. if (osb->cconn) {
  1091. tmp = ocfs2_super_lock(osb, 1);
  1092. if (tmp < 0) {
  1093. mlog_errno(tmp);
  1094. return;
  1095. }
  1096. }
  1097. if (osb->slot_num != OCFS2_INVALID_SLOT)
  1098. ocfs2_put_slot(osb);
  1099. if (osb->cconn)
  1100. ocfs2_super_unlock(osb, 1);
  1101. ocfs2_release_system_inodes(osb);
  1102. /*
  1103. * If we're dismounting due to mount error, mount.ocfs2 will clean
  1104. * up heartbeat. If we're a local mount, there is no heartbeat.
  1105. * If we failed before we got a uuid_str yet, we can't stop
  1106. * heartbeat. Otherwise, do it.
  1107. */
  1108. if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str)
  1109. hangup_needed = 1;
  1110. if (osb->cconn)
  1111. ocfs2_dlm_shutdown(osb, hangup_needed);
  1112. debugfs_remove(osb->osb_debug_root);
  1113. if (hangup_needed)
  1114. ocfs2_cluster_hangup(osb->uuid_str, strlen(osb->uuid_str));
  1115. atomic_set(&osb->vol_state, VOLUME_DISMOUNTED);
  1116. if (ocfs2_mount_local(osb))
  1117. snprintf(nodestr, sizeof(nodestr), "local");
  1118. else
  1119. snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num);
  1120. printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n",
  1121. osb->dev_str, nodestr);
  1122. ocfs2_delete_osb(osb);
  1123. kfree(osb);
  1124. sb->s_dev = 0;
  1125. sb->s_fs_info = NULL;
  1126. }
  1127. static int ocfs2_setup_osb_uuid(struct ocfs2_super *osb, const unsigned char *uuid,
  1128. unsigned uuid_bytes)
  1129. {
  1130. int i, ret;
  1131. char *ptr;
  1132. BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN);
  1133. osb->uuid_str = kzalloc(OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL);
  1134. if (osb->uuid_str == NULL)
  1135. return -ENOMEM;
  1136. for (i = 0, ptr = osb->uuid_str; i < OCFS2_VOL_UUID_LEN; i++) {
  1137. /* print with null */
  1138. ret = snprintf(ptr, 3, "%02X", uuid[i]);
  1139. if (ret != 2) /* drop super cleans up */
  1140. return -EINVAL;
  1141. /* then only advance past the last char */
  1142. ptr += 2;
  1143. }
  1144. return 0;
  1145. }
  1146. static int ocfs2_initialize_super(struct super_block *sb,
  1147. struct buffer_head *bh,
  1148. int sector_size)
  1149. {
  1150. int status;
  1151. int i, cbits, bbits;
  1152. struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
  1153. struct inode *inode = NULL;
  1154. struct ocfs2_journal *journal;
  1155. __le32 uuid_net_key;
  1156. struct ocfs2_super *osb;
  1157. mlog_entry_void();
  1158. osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL);
  1159. if (!osb) {
  1160. status = -ENOMEM;
  1161. mlog_errno(status);
  1162. goto bail;
  1163. }
  1164. sb->s_fs_info = osb;
  1165. sb->s_op = &ocfs2_sops;
  1166. sb->s_export_op = &ocfs2_export_ops;
  1167. sb->s_time_gran = 1;
  1168. sb->s_flags |= MS_NOATIME;
  1169. /* this is needed to support O_LARGEFILE */
  1170. cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
  1171. bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
  1172. sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
  1173. osb->sb = sb;
  1174. /* Save off for ocfs2_rw_direct */
  1175. osb->s_sectsize_bits = blksize_bits(sector_size);
  1176. BUG_ON(!osb->s_sectsize_bits);
  1177. spin_lock_init(&osb->dc_task_lock);
  1178. init_waitqueue_head(&osb->dc_event);
  1179. osb->dc_work_sequence = 0;
  1180. osb->dc_wake_sequence = 0;
  1181. INIT_LIST_HEAD(&osb->blocked_lock_list);
  1182. osb->blocked_lock_count = 0;
  1183. spin_lock_init(&osb->osb_lock);
  1184. ocfs2_init_inode_steal_slot(osb);
  1185. atomic_set(&osb->alloc_stats.moves, 0);
  1186. atomic_set(&osb->alloc_stats.local_data, 0);
  1187. atomic_set(&osb->alloc_stats.bitmap_data, 0);
  1188. atomic_set(&osb->alloc_stats.bg_allocs, 0);
  1189. atomic_set(&osb->alloc_stats.bg_extends, 0);
  1190. ocfs2_init_node_maps(osb);
  1191. snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
  1192. MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
  1193. status = ocfs2_recovery_init(osb);
  1194. if (status) {
  1195. mlog(ML_ERROR, "Unable to initialize recovery state\n");
  1196. mlog_errno(status);
  1197. goto bail;
  1198. }
  1199. init_waitqueue_head(&osb->checkpoint_event);
  1200. atomic_set(&osb->needs_checkpoint, 0);
  1201. osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
  1202. osb->slot_num = OCFS2_INVALID_SLOT;
  1203. osb->local_alloc_state = OCFS2_LA_UNUSED;
  1204. osb->local_alloc_bh = NULL;
  1205. init_waitqueue_head(&osb->osb_mount_event);
  1206. osb->vol_label = kmalloc(OCFS2_MAX_VOL_LABEL_LEN, GFP_KERNEL);
  1207. if (!osb->vol_label) {
  1208. mlog(ML_ERROR, "unable to alloc vol label\n");
  1209. status = -ENOMEM;
  1210. goto bail;
  1211. }
  1212. osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots);
  1213. if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) {
  1214. mlog(ML_ERROR, "Invalid number of node slots (%u)\n",
  1215. osb->max_slots);
  1216. status = -EINVAL;
  1217. goto bail;
  1218. }
  1219. mlog(0, "max_slots for this device: %u\n", osb->max_slots);
  1220. init_waitqueue_head(&osb->osb_wipe_event);
  1221. osb->osb_orphan_wipes = kcalloc(osb->max_slots,
  1222. sizeof(*osb->osb_orphan_wipes),
  1223. GFP_KERNEL);
  1224. if (!osb->osb_orphan_wipes) {
  1225. status = -ENOMEM;
  1226. mlog_errno(status);
  1227. goto bail;
  1228. }
  1229. osb->s_feature_compat =
  1230. le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_compat);
  1231. osb->s_feature_ro_compat =
  1232. le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_ro_compat);
  1233. osb->s_feature_incompat =
  1234. le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_incompat);
  1235. if ((i = OCFS2_HAS_INCOMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_INCOMPAT_SUPP))) {
  1236. mlog(ML_ERROR, "couldn't mount because of unsupported "
  1237. "optional features (%x).\n", i);
  1238. status = -EINVAL;
  1239. goto bail;
  1240. }
  1241. if (!(osb->sb->s_flags & MS_RDONLY) &&
  1242. (i = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP))) {
  1243. mlog(ML_ERROR, "couldn't mount RDWR because of "
  1244. "unsupported optional features (%x).\n", i);
  1245. status = -EINVAL;
  1246. goto bail;
  1247. }
  1248. if (ocfs2_userspace_stack(osb)) {
  1249. memcpy(osb->osb_cluster_stack,
  1250. OCFS2_RAW_SB(di)->s_cluster_info.ci_stack,
  1251. OCFS2_STACK_LABEL_LEN);
  1252. osb->osb_cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
  1253. if (strlen(osb->osb_cluster_stack) != OCFS2_STACK_LABEL_LEN) {
  1254. mlog(ML_ERROR,
  1255. "couldn't mount because of an invalid "
  1256. "cluster stack label (%s) \n",
  1257. osb->osb_cluster_stack);
  1258. status = -EINVAL;
  1259. goto bail;
  1260. }
  1261. } else {
  1262. /* The empty string is identical with classic tools that
  1263. * don't know about s_cluster_info. */
  1264. osb->osb_cluster_stack[0] = '\0';
  1265. }
  1266. get_random_bytes(&osb->s_next_generation, sizeof(u32));
  1267. /* FIXME
  1268. * This should be done in ocfs2_journal_init(), but unknown
  1269. * ordering issues will cause the filesystem to crash.
  1270. * If anyone wants to figure out what part of the code
  1271. * refers to osb->journal before ocfs2_journal_init() is run,
  1272. * be my guest.
  1273. */
  1274. /* initialize our journal structure */
  1275. journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL);
  1276. if (!journal) {
  1277. mlog(ML_ERROR, "unable to alloc journal\n");
  1278. status = -ENOMEM;
  1279. goto bail;
  1280. }
  1281. osb->journal = journal;
  1282. journal->j_osb = osb;
  1283. atomic_set(&journal->j_num_trans, 0);
  1284. init_rwsem(&journal->j_trans_barrier);
  1285. init_waitqueue_head(&journal->j_checkpointed);
  1286. spin_lock_init(&journal->j_lock);
  1287. journal->j_trans_id = (unsigned long) 1;
  1288. INIT_LIST_HEAD(&journal->j_la_cleanups);
  1289. INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery);
  1290. journal->j_state = OCFS2_JOURNAL_FREE;
  1291. /* get some pseudo constants for clustersize bits */
  1292. osb->s_clustersize_bits =
  1293. le32_to_cpu(di->id2.i_super.s_clustersize_bits);
  1294. osb->s_clustersize = 1 << osb->s_clustersize_bits;
  1295. mlog(0, "clusterbits=%d\n", osb->s_clustersize_bits);
  1296. if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE ||
  1297. osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) {
  1298. mlog(ML_ERROR, "Volume has invalid cluster size (%d)\n",
  1299. osb->s_clustersize);
  1300. status = -EINVAL;
  1301. goto bail;
  1302. }
  1303. if (ocfs2_clusters_to_blocks(osb->sb, le32_to_cpu(di->i_clusters) - 1)
  1304. > (u32)~0UL) {
  1305. mlog(ML_ERROR, "Volume might try to write to blocks beyond "
  1306. "what jbd can address in 32 bits.\n");
  1307. status = -EINVAL;
  1308. goto bail;
  1309. }
  1310. if (ocfs2_setup_osb_uuid(osb, di->id2.i_super.s_uuid,
  1311. sizeof(di->id2.i_super.s_uuid))) {
  1312. mlog(ML_ERROR, "Out of memory trying to setup our uuid.\n");
  1313. status = -ENOMEM;
  1314. goto bail;
  1315. }
  1316. memcpy(&uuid_net_key, di->id2.i_super.s_uuid, sizeof(uuid_net_key));
  1317. strncpy(osb->vol_label, di->id2.i_super.s_label, 63);
  1318. osb->vol_label[63] = '\0';
  1319. osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno);
  1320. osb->system_dir_blkno = le64_to_cpu(di->id2.i_super.s_system_dir_blkno);
  1321. osb->first_cluster_group_blkno =
  1322. le64_to_cpu(di->id2.i_super.s_first_cluster_group);
  1323. osb->fs_generation = le32_to_cpu(di->i_fs_generation);
  1324. mlog(0, "vol_label: %s\n", osb->vol_label);
  1325. mlog(0, "uuid: %s\n", osb->uuid_str);
  1326. mlog(0, "root_blkno=%llu, system_dir_blkno=%llu\n",
  1327. (unsigned long long)osb->root_blkno,
  1328. (unsigned long long)osb->system_dir_blkno);
  1329. osb->osb_dlm_debug = ocfs2_new_dlm_debug();
  1330. if (!osb->osb_dlm_debug) {
  1331. status = -ENOMEM;
  1332. mlog_errno(status);
  1333. goto bail;
  1334. }
  1335. atomic_set(&osb->vol_state, VOLUME_INIT);
  1336. /* load root, system_dir, and all global system inodes */
  1337. status = ocfs2_init_global_system_inodes(osb);
  1338. if (status < 0) {
  1339. mlog_errno(status);
  1340. goto bail;
  1341. }
  1342. /*
  1343. * global bitmap
  1344. */
  1345. inode = ocfs2_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE,
  1346. OCFS2_INVALID_SLOT);
  1347. if (!inode) {
  1348. status = -EINVAL;
  1349. mlog_errno(status);
  1350. goto bail;
  1351. }
  1352. osb->bitmap_blkno = OCFS2_I(inode)->ip_blkno;
  1353. iput(inode);
  1354. osb->bitmap_cpg = ocfs2_group_bitmap_size(sb) * 8;
  1355. status = ocfs2_init_slot_info(osb);
  1356. if (status < 0) {
  1357. mlog_errno(status);
  1358. goto bail;
  1359. }
  1360. bail:
  1361. mlog_exit(status);
  1362. return status;
  1363. }
  1364. /*
  1365. * will return: -EAGAIN if it is ok to keep searching for superblocks
  1366. * -EINVAL if there is a bad superblock
  1367. * 0 on success
  1368. */
  1369. static int ocfs2_verify_volume(struct ocfs2_dinode *di,
  1370. struct buffer_head *bh,
  1371. u32 blksz)
  1372. {
  1373. int status = -EAGAIN;
  1374. mlog_entry_void();
  1375. if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
  1376. strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) {
  1377. status = -EINVAL;
  1378. if ((1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits)) != blksz) {
  1379. mlog(ML_ERROR, "found superblock with incorrect block "
  1380. "size: found %u, should be %u\n",
  1381. 1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits),
  1382. blksz);
  1383. } else if (le16_to_cpu(di->id2.i_super.s_major_rev_level) !=
  1384. OCFS2_MAJOR_REV_LEVEL ||
  1385. le16_to_cpu(di->id2.i_super.s_minor_rev_level) !=
  1386. OCFS2_MINOR_REV_LEVEL) {
  1387. mlog(ML_ERROR, "found superblock with bad version: "
  1388. "found %u.%u, should be %u.%u\n",
  1389. le16_to_cpu(di->id2.i_super.s_major_rev_level),
  1390. le16_to_cpu(di->id2.i_super.s_minor_rev_level),
  1391. OCFS2_MAJOR_REV_LEVEL,
  1392. OCFS2_MINOR_REV_LEVEL);
  1393. } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) {
  1394. mlog(ML_ERROR, "bad block number on superblock: "
  1395. "found %llu, should be %llu\n",
  1396. (unsigned long long)le64_to_cpu(di->i_blkno),
  1397. (unsigned long long)bh->b_blocknr);
  1398. } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 ||
  1399. le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) {
  1400. mlog(ML_ERROR, "bad cluster size found: %u\n",
  1401. 1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits));
  1402. } else if (!le64_to_cpu(di->id2.i_super.s_root_blkno)) {
  1403. mlog(ML_ERROR, "bad root_blkno: 0\n");
  1404. } else if (!le64_to_cpu(di->id2.i_super.s_system_dir_blkno)) {
  1405. mlog(ML_ERROR, "bad system_dir_blkno: 0\n");
  1406. } else if (le16_to_cpu(di->id2.i_super.s_max_slots) > OCFS2_MAX_SLOTS) {
  1407. mlog(ML_ERROR,
  1408. "Superblock slots found greater than file system "
  1409. "maximum: found %u, max %u\n",
  1410. le16_to_cpu(di->id2.i_super.s_max_slots),
  1411. OCFS2_MAX_SLOTS);
  1412. } else {
  1413. /* found it! */
  1414. status = 0;
  1415. }
  1416. }
  1417. mlog_exit(status);
  1418. return status;
  1419. }
  1420. static int ocfs2_check_volume(struct ocfs2_super *osb)
  1421. {
  1422. int status;
  1423. int dirty;
  1424. int local;
  1425. struct ocfs2_dinode *local_alloc = NULL; /* only used if we
  1426. * recover
  1427. * ourselves. */
  1428. mlog_entry_void();
  1429. /* Init our journal object. */
  1430. status = ocfs2_journal_init(osb->journal, &dirty);
  1431. if (status < 0) {
  1432. mlog(ML_ERROR, "Could not initialize journal!\n");
  1433. goto finally;
  1434. }
  1435. /* If the journal was unmounted cleanly then we don't want to
  1436. * recover anything. Otherwise, journal_load will do that
  1437. * dirty work for us :) */
  1438. if (!dirty) {
  1439. status = ocfs2_journal_wipe(osb->journal, 0);
  1440. if (status < 0) {
  1441. mlog_errno(status);
  1442. goto finally;
  1443. }
  1444. } else {
  1445. mlog(ML_NOTICE, "File system was not unmounted cleanly, "
  1446. "recovering volume.\n");
  1447. }
  1448. local = ocfs2_mount_local(osb);
  1449. /* will play back anything left in the journal. */
  1450. ocfs2_journal_load(osb->journal, local);
  1451. if (dirty) {
  1452. /* recover my local alloc if we didn't unmount cleanly. */
  1453. status = ocfs2_begin_local_alloc_recovery(osb,
  1454. osb->slot_num,
  1455. &local_alloc);
  1456. if (status < 0) {
  1457. mlog_errno(status);
  1458. goto finally;
  1459. }
  1460. /* we complete the recovery process after we've marked
  1461. * ourselves as mounted. */
  1462. }
  1463. mlog(0, "Journal loaded.\n");
  1464. status = ocfs2_load_local_alloc(osb);
  1465. if (status < 0) {
  1466. mlog_errno(status);
  1467. goto finally;
  1468. }
  1469. if (dirty) {
  1470. /* Recovery will be completed after we've mounted the
  1471. * rest of the volume. */
  1472. osb->dirty = 1;
  1473. osb->local_alloc_copy = local_alloc;
  1474. local_alloc = NULL;
  1475. }
  1476. /* go through each journal, trylock it and if you get the
  1477. * lock, and it's marked as dirty, set the bit in the recover
  1478. * map and launch a recovery thread for it. */
  1479. status = ocfs2_mark_dead_nodes(osb);
  1480. if (status < 0)
  1481. mlog_errno(status);
  1482. finally:
  1483. if (local_alloc)
  1484. kfree(local_alloc);
  1485. mlog_exit(status);
  1486. return status;
  1487. }
  1488. /*
  1489. * The routine gets called from dismount or close whenever a dismount on
  1490. * volume is requested and the osb open count becomes 1.
  1491. * It will remove the osb from the global list and also free up all the
  1492. * initialized resources and fileobject.
  1493. */
  1494. static void ocfs2_delete_osb(struct ocfs2_super *osb)
  1495. {
  1496. mlog_entry_void();
  1497. /* This function assumes that the caller has the main osb resource */
  1498. ocfs2_free_slot_info(osb);
  1499. kfree(osb->osb_orphan_wipes);
  1500. /* FIXME
  1501. * This belongs in journal shutdown, but because we have to
  1502. * allocate osb->journal at the start of ocfs2_initalize_osb(),
  1503. * we free it here.
  1504. */
  1505. kfree(osb->journal);
  1506. if (osb->local_alloc_copy)
  1507. kfree(osb->local_alloc_copy);
  1508. kfree(osb->uuid_str);
  1509. ocfs2_put_dlm_debug(osb->osb_dlm_debug);
  1510. memset(osb, 0, sizeof(struct ocfs2_super));
  1511. mlog_exit_void();
  1512. }
  1513. /* Put OCFS2 into a readonly state, or (if the user specifies it),
  1514. * panic(). We do not support continue-on-error operation. */
  1515. static void ocfs2_handle_error(struct super_block *sb)
  1516. {
  1517. struct ocfs2_super *osb = OCFS2_SB(sb);
  1518. if (osb->s_mount_opt & OCFS2_MOUNT_ERRORS_PANIC)
  1519. panic("OCFS2: (device %s): panic forced after error\n",
  1520. sb->s_id);
  1521. ocfs2_set_osb_flag(osb, OCFS2_OSB_ERROR_FS);
  1522. if (sb->s_flags & MS_RDONLY &&
  1523. (ocfs2_is_soft_readonly(osb) ||
  1524. ocfs2_is_hard_readonly(osb)))
  1525. return;
  1526. printk(KERN_CRIT "File system is now read-only due to the potential "
  1527. "of on-disk corruption. Please run fsck.ocfs2 once the file "
  1528. "system is unmounted.\n");
  1529. sb->s_flags |= MS_RDONLY;
  1530. ocfs2_set_ro_flag(osb, 0);
  1531. }
  1532. static char error_buf[1024];
  1533. void __ocfs2_error(struct super_block *sb,
  1534. const char *function,
  1535. const char *fmt, ...)
  1536. {
  1537. va_list args;
  1538. va_start(args, fmt);
  1539. vsnprintf(error_buf, sizeof(error_buf), fmt, args);
  1540. va_end(args);
  1541. /* Not using mlog here because we want to show the actual
  1542. * function the error came from. */
  1543. printk(KERN_CRIT "OCFS2: ERROR (device %s): %s: %s\n",
  1544. sb->s_id, function, error_buf);
  1545. ocfs2_handle_error(sb);
  1546. }
  1547. /* Handle critical errors. This is intentionally more drastic than
  1548. * ocfs2_handle_error, so we only use for things like journal errors,
  1549. * etc. */
  1550. void __ocfs2_abort(struct super_block* sb,
  1551. const char *function,
  1552. const char *fmt, ...)
  1553. {
  1554. va_list args;
  1555. va_start(args, fmt);
  1556. vsnprintf(error_buf, sizeof(error_buf), fmt, args);
  1557. va_end(args);
  1558. printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n",
  1559. sb->s_id, function, error_buf);
  1560. /* We don't have the cluster support yet to go straight to
  1561. * hard readonly in here. Until then, we want to keep
  1562. * ocfs2_abort() so that we can at least mark critical
  1563. * errors.
  1564. *
  1565. * TODO: This should abort the journal and alert other nodes
  1566. * that our slot needs recovery. */
  1567. /* Force a panic(). This stinks, but it's better than letting
  1568. * things continue without having a proper hard readonly
  1569. * here. */
  1570. OCFS2_SB(sb)->s_mount_opt |= OCFS2_MOUNT_ERRORS_PANIC;
  1571. ocfs2_handle_error(sb);
  1572. }
  1573. module_init(ocfs2_init);
  1574. module_exit(ocfs2_exit);