]>
Commit | Line | Data |
---|---|---|
ccd979bd MF |
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 | ||
26 | #include <linux/module.h> | |
27 | #include <linux/fs.h> | |
28 | #include <linux/types.h> | |
29 | #include <linux/slab.h> | |
30 | #include <linux/highmem.h> | |
31 | #include <linux/utsname.h> | |
32 | #include <linux/init.h> | |
33 | #include <linux/random.h> | |
34 | #include <linux/statfs.h> | |
35 | #include <linux/moduleparam.h> | |
36 | #include <linux/blkdev.h> | |
37 | #include <linux/socket.h> | |
38 | #include <linux/inet.h> | |
39 | #include <linux/parser.h> | |
40 | #include <linux/crc32.h> | |
41 | #include <linux/debugfs.h> | |
d550071c | 42 | #include <linux/mount.h> |
6953b4c0 | 43 | #include <linux/seq_file.h> |
19ece546 | 44 | #include <linux/quotaops.h> |
337eb00a | 45 | #include <linux/smp_lock.h> |
ccd979bd MF |
46 | |
47 | #define MLOG_MASK_PREFIX ML_SUPER | |
48 | #include <cluster/masklog.h> | |
49 | ||
50 | #include "ocfs2.h" | |
51 | ||
52 | /* this should be the only file to include a version 1 header */ | |
53 | #include "ocfs1_fs_compat.h" | |
54 | ||
55 | #include "alloc.h" | |
d030cc97 | 56 | #include "blockcheck.h" |
ccd979bd MF |
57 | #include "dlmglue.h" |
58 | #include "export.h" | |
59 | #include "extent_map.h" | |
60 | #include "heartbeat.h" | |
61 | #include "inode.h" | |
62 | #include "journal.h" | |
63 | #include "localalloc.h" | |
64 | #include "namei.h" | |
65 | #include "slot_map.h" | |
66 | #include "super.h" | |
67 | #include "sysfile.h" | |
68 | #include "uptodate.h" | |
69 | #include "ver.h" | |
cf1d6c76 | 70 | #include "xattr.h" |
9e33d69f | 71 | #include "quota.h" |
ccd979bd MF |
72 | |
73 | #include "buffer_head_io.h" | |
74 | ||
e18b890b | 75 | static struct kmem_cache *ocfs2_inode_cachep = NULL; |
9e33d69f JK |
76 | struct kmem_cache *ocfs2_dquot_cachep; |
77 | struct kmem_cache *ocfs2_qf_chunk_cachep; | |
ccd979bd | 78 | |
ccd979bd MF |
79 | /* OCFS2 needs to schedule several differnt types of work which |
80 | * require cluster locking, disk I/O, recovery waits, etc. Since these | |
81 | * types of work tend to be heavy we avoid using the kernel events | |
82 | * workqueue and schedule on our own. */ | |
83 | struct workqueue_struct *ocfs2_wq = NULL; | |
84 | ||
85 | static struct dentry *ocfs2_debugfs_root = NULL; | |
86 | ||
87 | MODULE_AUTHOR("Oracle"); | |
88 | MODULE_LICENSE("GPL"); | |
89 | ||
c0123ade TY |
90 | struct mount_options |
91 | { | |
d147b3d6 | 92 | unsigned long commit_interval; |
c0123ade TY |
93 | unsigned long mount_opt; |
94 | unsigned int atime_quantum; | |
95 | signed short slot; | |
2fbe8d1e | 96 | unsigned int localalloc_opt; |
b61817e1 | 97 | char cluster_stack[OCFS2_STACK_LABEL_LEN + 1]; |
c0123ade TY |
98 | }; |
99 | ||
ccd979bd | 100 | static int ocfs2_parse_options(struct super_block *sb, char *options, |
c0123ade | 101 | struct mount_options *mopt, |
baf4661a | 102 | int is_remount); |
d550071c | 103 | static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt); |
ccd979bd MF |
104 | static void ocfs2_put_super(struct super_block *sb); |
105 | static int ocfs2_mount_volume(struct super_block *sb); | |
106 | static int ocfs2_remount(struct super_block *sb, int *flags, char *data); | |
107 | static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err); | |
108 | static int ocfs2_initialize_mem_caches(void); | |
109 | static void ocfs2_free_mem_caches(void); | |
110 | static void ocfs2_delete_osb(struct ocfs2_super *osb); | |
111 | ||
726c3342 | 112 | static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf); |
ccd979bd MF |
113 | |
114 | static int ocfs2_sync_fs(struct super_block *sb, int wait); | |
115 | ||
116 | static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb); | |
117 | static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb); | |
bddb8eb3 | 118 | static void ocfs2_release_system_inodes(struct ocfs2_super *osb); |
ccd979bd MF |
119 | static int ocfs2_check_volume(struct ocfs2_super *osb); |
120 | static int ocfs2_verify_volume(struct ocfs2_dinode *di, | |
121 | struct buffer_head *bh, | |
73be192b JB |
122 | u32 sectsize, |
123 | struct ocfs2_blockcheck_stats *stats); | |
ccd979bd MF |
124 | static int ocfs2_initialize_super(struct super_block *sb, |
125 | struct buffer_head *bh, | |
73be192b JB |
126 | int sector_size, |
127 | struct ocfs2_blockcheck_stats *stats); | |
ccd979bd MF |
128 | static int ocfs2_get_sector(struct super_block *sb, |
129 | struct buffer_head **bh, | |
130 | int block, | |
131 | int sect_size); | |
ccd979bd MF |
132 | static struct inode *ocfs2_alloc_inode(struct super_block *sb); |
133 | static void ocfs2_destroy_inode(struct inode *inode); | |
19ece546 JK |
134 | static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend); |
135 | static int ocfs2_enable_quotas(struct ocfs2_super *osb); | |
136 | static void ocfs2_disable_quotas(struct ocfs2_super *osb); | |
ccd979bd | 137 | |
ee9b6d61 | 138 | static const struct super_operations ocfs2_sops = { |
ccd979bd MF |
139 | .statfs = ocfs2_statfs, |
140 | .alloc_inode = ocfs2_alloc_inode, | |
141 | .destroy_inode = ocfs2_destroy_inode, | |
142 | .drop_inode = ocfs2_drop_inode, | |
143 | .clear_inode = ocfs2_clear_inode, | |
144 | .delete_inode = ocfs2_delete_inode, | |
145 | .sync_fs = ocfs2_sync_fs, | |
ccd979bd MF |
146 | .put_super = ocfs2_put_super, |
147 | .remount_fs = ocfs2_remount, | |
d550071c | 148 | .show_options = ocfs2_show_options, |
9e33d69f JK |
149 | .quota_read = ocfs2_quota_read, |
150 | .quota_write = ocfs2_quota_write, | |
ccd979bd MF |
151 | }; |
152 | ||
153 | enum { | |
154 | Opt_barrier, | |
155 | Opt_err_panic, | |
156 | Opt_err_ro, | |
157 | Opt_intr, | |
158 | Opt_nointr, | |
159 | Opt_hb_none, | |
160 | Opt_hb_local, | |
161 | Opt_data_ordered, | |
162 | Opt_data_writeback, | |
7f1a37e3 | 163 | Opt_atime_quantum, |
baf4661a | 164 | Opt_slot, |
d147b3d6 | 165 | Opt_commit, |
2fbe8d1e | 166 | Opt_localalloc, |
53fc622b | 167 | Opt_localflocks, |
b61817e1 | 168 | Opt_stack, |
cf1d6c76 TY |
169 | Opt_user_xattr, |
170 | Opt_nouser_xattr, | |
12462f1d | 171 | Opt_inode64, |
a68979b8 TY |
172 | Opt_acl, |
173 | Opt_noacl, | |
19ece546 JK |
174 | Opt_usrquota, |
175 | Opt_grpquota, | |
ccd979bd MF |
176 | Opt_err, |
177 | }; | |
178 | ||
a447c093 | 179 | static const match_table_t tokens = { |
ccd979bd MF |
180 | {Opt_barrier, "barrier=%u"}, |
181 | {Opt_err_panic, "errors=panic"}, | |
182 | {Opt_err_ro, "errors=remount-ro"}, | |
183 | {Opt_intr, "intr"}, | |
184 | {Opt_nointr, "nointr"}, | |
185 | {Opt_hb_none, OCFS2_HB_NONE}, | |
186 | {Opt_hb_local, OCFS2_HB_LOCAL}, | |
187 | {Opt_data_ordered, "data=ordered"}, | |
188 | {Opt_data_writeback, "data=writeback"}, | |
7f1a37e3 | 189 | {Opt_atime_quantum, "atime_quantum=%u"}, |
baf4661a | 190 | {Opt_slot, "preferred_slot=%u"}, |
d147b3d6 | 191 | {Opt_commit, "commit=%u"}, |
2fbe8d1e | 192 | {Opt_localalloc, "localalloc=%d"}, |
53fc622b | 193 | {Opt_localflocks, "localflocks"}, |
b61817e1 | 194 | {Opt_stack, "cluster_stack=%s"}, |
cf1d6c76 TY |
195 | {Opt_user_xattr, "user_xattr"}, |
196 | {Opt_nouser_xattr, "nouser_xattr"}, | |
12462f1d | 197 | {Opt_inode64, "inode64"}, |
a68979b8 TY |
198 | {Opt_acl, "acl"}, |
199 | {Opt_noacl, "noacl"}, | |
19ece546 JK |
200 | {Opt_usrquota, "usrquota"}, |
201 | {Opt_grpquota, "grpquota"}, | |
ccd979bd MF |
202 | {Opt_err, NULL} |
203 | }; | |
204 | ||
50397507 SM |
205 | #ifdef CONFIG_DEBUG_FS |
206 | static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) | |
207 | { | |
208 | int out = 0; | |
209 | int i; | |
210 | struct ocfs2_cluster_connection *cconn = osb->cconn; | |
211 | struct ocfs2_recovery_map *rm = osb->recovery_map; | |
15633a22 | 212 | struct ocfs2_orphan_scan *os; |
50397507 SM |
213 | |
214 | out += snprintf(buf + out, len - out, | |
215 | "%10s => Id: %-s Uuid: %-s Gen: 0x%X Label: %-s\n", | |
216 | "Device", osb->dev_str, osb->uuid_str, | |
217 | osb->fs_generation, osb->vol_label); | |
218 | ||
219 | out += snprintf(buf + out, len - out, | |
220 | "%10s => State: %d Flags: 0x%lX\n", "Volume", | |
221 | atomic_read(&osb->vol_state), osb->osb_flags); | |
222 | ||
223 | out += snprintf(buf + out, len - out, | |
224 | "%10s => Block: %lu Cluster: %d\n", "Sizes", | |
225 | osb->sb->s_blocksize, osb->s_clustersize); | |
226 | ||
227 | out += snprintf(buf + out, len - out, | |
228 | "%10s => Compat: 0x%X Incompat: 0x%X " | |
229 | "ROcompat: 0x%X\n", | |
230 | "Features", osb->s_feature_compat, | |
231 | osb->s_feature_incompat, osb->s_feature_ro_compat); | |
232 | ||
233 | out += snprintf(buf + out, len - out, | |
234 | "%10s => Opts: 0x%lX AtimeQuanta: %u\n", "Mount", | |
235 | osb->s_mount_opt, osb->s_atime_quantum); | |
236 | ||
c3d38840 SM |
237 | if (cconn) { |
238 | out += snprintf(buf + out, len - out, | |
239 | "%10s => Stack: %s Name: %*s " | |
240 | "Version: %d.%d\n", "Cluster", | |
241 | (*osb->osb_cluster_stack == '\0' ? | |
242 | "o2cb" : osb->osb_cluster_stack), | |
243 | cconn->cc_namelen, cconn->cc_name, | |
244 | cconn->cc_version.pv_major, | |
245 | cconn->cc_version.pv_minor); | |
246 | } | |
50397507 SM |
247 | |
248 | spin_lock(&osb->dc_task_lock); | |
249 | out += snprintf(buf + out, len - out, | |
250 | "%10s => Pid: %d Count: %lu WakeSeq: %lu " | |
251 | "WorkSeq: %lu\n", "DownCnvt", | |
c3d38840 SM |
252 | (osb->dc_task ? task_pid_nr(osb->dc_task) : -1), |
253 | osb->blocked_lock_count, osb->dc_wake_sequence, | |
254 | osb->dc_work_sequence); | |
50397507 SM |
255 | spin_unlock(&osb->dc_task_lock); |
256 | ||
257 | spin_lock(&osb->osb_lock); | |
258 | out += snprintf(buf + out, len - out, "%10s => Pid: %d Nodes:", | |
259 | "Recovery", | |
260 | (osb->recovery_thread_task ? | |
261 | task_pid_nr(osb->recovery_thread_task) : -1)); | |
262 | if (rm->rm_used == 0) | |
263 | out += snprintf(buf + out, len - out, " None\n"); | |
264 | else { | |
265 | for (i = 0; i < rm->rm_used; i++) | |
266 | out += snprintf(buf + out, len - out, " %d", | |
267 | rm->rm_entries[i]); | |
268 | out += snprintf(buf + out, len - out, "\n"); | |
269 | } | |
270 | spin_unlock(&osb->osb_lock); | |
271 | ||
272 | out += snprintf(buf + out, len - out, | |
273 | "%10s => Pid: %d Interval: %lu Needs: %d\n", "Commit", | |
c3d38840 SM |
274 | (osb->commit_task ? task_pid_nr(osb->commit_task) : -1), |
275 | osb->osb_commit_interval, | |
50397507 SM |
276 | atomic_read(&osb->needs_checkpoint)); |
277 | ||
278 | out += snprintf(buf + out, len - out, | |
c3d38840 | 279 | "%10s => State: %d TxnId: %lu NumTxns: %d\n", |
50397507 | 280 | "Journal", osb->journal->j_state, |
c3d38840 SM |
281 | osb->journal->j_trans_id, |
282 | atomic_read(&osb->journal->j_num_trans)); | |
50397507 SM |
283 | |
284 | out += snprintf(buf + out, len - out, | |
285 | "%10s => GlobalAllocs: %d LocalAllocs: %d " | |
286 | "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n", | |
287 | "Stats", | |
288 | atomic_read(&osb->alloc_stats.bitmap_data), | |
289 | atomic_read(&osb->alloc_stats.local_data), | |
290 | atomic_read(&osb->alloc_stats.bg_allocs), | |
291 | atomic_read(&osb->alloc_stats.moves), | |
292 | atomic_read(&osb->alloc_stats.bg_extends)); | |
293 | ||
294 | out += snprintf(buf + out, len - out, | |
295 | "%10s => State: %u Descriptor: %llu Size: %u bits " | |
296 | "Default: %u bits\n", | |
297 | "LocalAlloc", osb->local_alloc_state, | |
298 | (unsigned long long)osb->la_last_gd, | |
299 | osb->local_alloc_bits, osb->local_alloc_default_bits); | |
300 | ||
301 | spin_lock(&osb->osb_lock); | |
302 | out += snprintf(buf + out, len - out, | |
303 | "%10s => Slot: %d NumStolen: %d\n", "Steal", | |
304 | osb->s_inode_steal_slot, | |
305 | atomic_read(&osb->s_num_inodes_stolen)); | |
306 | spin_unlock(&osb->osb_lock); | |
307 | ||
308 | out += snprintf(buf + out, len - out, "%10s => %3s %10s\n", | |
309 | "Slots", "Num", "RecoGen"); | |
50397507 SM |
310 | for (i = 0; i < osb->max_slots; ++i) { |
311 | out += snprintf(buf + out, len - out, | |
312 | "%10s %c %3d %10d\n", | |
313 | " ", | |
314 | (i == osb->slot_num ? '*' : ' '), | |
315 | i, osb->slot_recovery_generations[i]); | |
316 | } | |
317 | ||
15633a22 SE |
318 | os = &osb->osb_orphan_scan; |
319 | out += snprintf(buf + out, len - out, "Orphan Scan=> "); | |
320 | out += snprintf(buf + out, len - out, "Local: %u Global: %u ", | |
321 | os->os_count, os->os_seqno); | |
322 | out += snprintf(buf + out, len - out, " Last Scan: %lu seconds ago\n", | |
323 | (get_seconds() - os->os_scantime.tv_sec)); | |
324 | ||
50397507 SM |
325 | return out; |
326 | } | |
327 | ||
328 | static int ocfs2_osb_debug_open(struct inode *inode, struct file *file) | |
329 | { | |
330 | struct ocfs2_super *osb = inode->i_private; | |
331 | char *buf = NULL; | |
332 | ||
333 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | |
334 | if (!buf) | |
335 | goto bail; | |
336 | ||
337 | i_size_write(inode, ocfs2_osb_dump(osb, buf, PAGE_SIZE)); | |
338 | ||
339 | file->private_data = buf; | |
340 | ||
341 | return 0; | |
342 | bail: | |
343 | return -ENOMEM; | |
344 | } | |
345 | ||
346 | static int ocfs2_debug_release(struct inode *inode, struct file *file) | |
347 | { | |
348 | kfree(file->private_data); | |
349 | return 0; | |
350 | } | |
351 | ||
352 | static ssize_t ocfs2_debug_read(struct file *file, char __user *buf, | |
353 | size_t nbytes, loff_t *ppos) | |
354 | { | |
355 | return simple_read_from_buffer(buf, nbytes, ppos, file->private_data, | |
356 | i_size_read(file->f_mapping->host)); | |
357 | } | |
358 | #else | |
359 | static int ocfs2_osb_debug_open(struct inode *inode, struct file *file) | |
360 | { | |
361 | return 0; | |
362 | } | |
363 | static int ocfs2_debug_release(struct inode *inode, struct file *file) | |
364 | { | |
365 | return 0; | |
366 | } | |
367 | static ssize_t ocfs2_debug_read(struct file *file, char __user *buf, | |
368 | size_t nbytes, loff_t *ppos) | |
369 | { | |
370 | return 0; | |
371 | } | |
372 | #endif /* CONFIG_DEBUG_FS */ | |
373 | ||
374 | static struct file_operations ocfs2_osb_debug_fops = { | |
375 | .open = ocfs2_osb_debug_open, | |
376 | .release = ocfs2_debug_release, | |
377 | .read = ocfs2_debug_read, | |
378 | .llseek = generic_file_llseek, | |
379 | }; | |
380 | ||
ccd979bd MF |
381 | static int ocfs2_sync_fs(struct super_block *sb, int wait) |
382 | { | |
bddb8eb3 | 383 | int status; |
ccd979bd MF |
384 | tid_t target; |
385 | struct ocfs2_super *osb = OCFS2_SB(sb); | |
386 | ||
ccd979bd MF |
387 | if (ocfs2_is_hard_readonly(osb)) |
388 | return -EROFS; | |
389 | ||
390 | if (wait) { | |
391 | status = ocfs2_flush_truncate_log(osb); | |
392 | if (status < 0) | |
393 | mlog_errno(status); | |
394 | } else { | |
395 | ocfs2_schedule_truncate_log_flush(osb, 0); | |
396 | } | |
397 | ||
2b4e30fb JB |
398 | if (jbd2_journal_start_commit(OCFS2_SB(sb)->journal->j_journal, |
399 | &target)) { | |
ccd979bd | 400 | if (wait) |
2b4e30fb JB |
401 | jbd2_log_wait_commit(OCFS2_SB(sb)->journal->j_journal, |
402 | target); | |
ccd979bd MF |
403 | } |
404 | return 0; | |
405 | } | |
406 | ||
1a224ad1 JK |
407 | static int ocfs2_need_system_inode(struct ocfs2_super *osb, int ino) |
408 | { | |
409 | if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA) | |
410 | && (ino == USER_QUOTA_SYSTEM_INODE | |
411 | || ino == LOCAL_USER_QUOTA_SYSTEM_INODE)) | |
412 | return 0; | |
413 | if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) | |
414 | && (ino == GROUP_QUOTA_SYSTEM_INODE | |
415 | || ino == LOCAL_GROUP_QUOTA_SYSTEM_INODE)) | |
416 | return 0; | |
417 | return 1; | |
418 | } | |
419 | ||
ccd979bd MF |
420 | static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) |
421 | { | |
422 | struct inode *new = NULL; | |
423 | int status = 0; | |
424 | int i; | |
425 | ||
426 | mlog_entry_void(); | |
427 | ||
5fa0613e | 428 | new = ocfs2_iget(osb, osb->root_blkno, OCFS2_FI_FLAG_SYSFILE, 0); |
ccd979bd MF |
429 | if (IS_ERR(new)) { |
430 | status = PTR_ERR(new); | |
431 | mlog_errno(status); | |
432 | goto bail; | |
433 | } | |
434 | osb->root_inode = new; | |
435 | ||
5fa0613e | 436 | new = ocfs2_iget(osb, osb->system_dir_blkno, OCFS2_FI_FLAG_SYSFILE, 0); |
ccd979bd MF |
437 | if (IS_ERR(new)) { |
438 | status = PTR_ERR(new); | |
439 | mlog_errno(status); | |
440 | goto bail; | |
441 | } | |
442 | osb->sys_root_inode = new; | |
443 | ||
444 | for (i = OCFS2_FIRST_ONLINE_SYSTEM_INODE; | |
445 | i <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; i++) { | |
1a224ad1 JK |
446 | if (!ocfs2_need_system_inode(osb, i)) |
447 | continue; | |
ccd979bd MF |
448 | new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); |
449 | if (!new) { | |
450 | ocfs2_release_system_inodes(osb); | |
451 | status = -EINVAL; | |
452 | mlog_errno(status); | |
453 | /* FIXME: Should ERROR_RO_FS */ | |
454 | mlog(ML_ERROR, "Unable to load system inode %d, " | |
455 | "possibly corrupt fs?", i); | |
456 | goto bail; | |
457 | } | |
458 | // the array now has one ref, so drop this one | |
459 | iput(new); | |
460 | } | |
461 | ||
462 | bail: | |
463 | mlog_exit(status); | |
464 | return status; | |
465 | } | |
466 | ||
467 | static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) | |
468 | { | |
469 | struct inode *new = NULL; | |
470 | int status = 0; | |
471 | int i; | |
472 | ||
473 | mlog_entry_void(); | |
474 | ||
475 | for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; | |
476 | i < NUM_SYSTEM_INODES; | |
477 | i++) { | |
1a224ad1 JK |
478 | if (!ocfs2_need_system_inode(osb, i)) |
479 | continue; | |
ccd979bd MF |
480 | new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); |
481 | if (!new) { | |
482 | ocfs2_release_system_inodes(osb); | |
483 | status = -EINVAL; | |
484 | mlog(ML_ERROR, "status=%d, sysfile=%d, slot=%d\n", | |
485 | status, i, osb->slot_num); | |
486 | goto bail; | |
487 | } | |
488 | /* the array now has one ref, so drop this one */ | |
489 | iput(new); | |
490 | } | |
491 | ||
492 | bail: | |
493 | mlog_exit(status); | |
494 | return status; | |
495 | } | |
496 | ||
bddb8eb3 | 497 | static void ocfs2_release_system_inodes(struct ocfs2_super *osb) |
ccd979bd | 498 | { |
bddb8eb3 | 499 | int i; |
ccd979bd MF |
500 | struct inode *inode; |
501 | ||
502 | mlog_entry_void(); | |
503 | ||
504 | for (i = 0; i < NUM_SYSTEM_INODES; i++) { | |
505 | inode = osb->system_inodes[i]; | |
506 | if (inode) { | |
507 | iput(inode); | |
508 | osb->system_inodes[i] = NULL; | |
509 | } | |
510 | } | |
511 | ||
512 | inode = osb->sys_root_inode; | |
513 | if (inode) { | |
514 | iput(inode); | |
515 | osb->sys_root_inode = NULL; | |
516 | } | |
517 | ||
518 | inode = osb->root_inode; | |
519 | if (inode) { | |
520 | iput(inode); | |
521 | osb->root_inode = NULL; | |
522 | } | |
523 | ||
bddb8eb3 | 524 | mlog_exit(0); |
ccd979bd MF |
525 | } |
526 | ||
527 | /* We're allocating fs objects, use GFP_NOFS */ | |
528 | static struct inode *ocfs2_alloc_inode(struct super_block *sb) | |
529 | { | |
530 | struct ocfs2_inode_info *oi; | |
531 | ||
e6b4f8da | 532 | oi = kmem_cache_alloc(ocfs2_inode_cachep, GFP_NOFS); |
ccd979bd MF |
533 | if (!oi) |
534 | return NULL; | |
535 | ||
2b4e30fb | 536 | jbd2_journal_init_jbd_inode(&oi->ip_jinode, &oi->vfs_inode); |
ccd979bd MF |
537 | return &oi->vfs_inode; |
538 | } | |
539 | ||
540 | static void ocfs2_destroy_inode(struct inode *inode) | |
541 | { | |
542 | kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); | |
543 | } | |
544 | ||
5a254031 MF |
545 | static unsigned long long ocfs2_max_file_offset(unsigned int bbits, |
546 | unsigned int cbits) | |
ccd979bd | 547 | { |
5a254031 MF |
548 | unsigned int bytes = 1 << cbits; |
549 | unsigned int trim = bytes; | |
550 | unsigned int bitshift = 32; | |
551 | ||
552 | /* | |
553 | * i_size and all block offsets in ocfs2 are always 64 bits | |
554 | * wide. i_clusters is 32 bits, in cluster-sized units. So on | |
555 | * 64 bit platforms, cluster size will be the limiting factor. | |
ccd979bd MF |
556 | */ |
557 | ||
558 | #if BITS_PER_LONG == 32 | |
559 | # if defined(CONFIG_LBD) | |
2ecd05ae | 560 | BUILD_BUG_ON(sizeof(sector_t) != 8); |
5a254031 MF |
561 | /* |
562 | * We might be limited by page cache size. | |
563 | */ | |
564 | if (bytes > PAGE_CACHE_SIZE) { | |
565 | bytes = PAGE_CACHE_SIZE; | |
566 | trim = 1; | |
567 | /* | |
568 | * Shift by 31 here so that we don't get larger than | |
569 | * MAX_LFS_FILESIZE | |
570 | */ | |
571 | bitshift = 31; | |
572 | } | |
ccd979bd | 573 | # else |
5a254031 MF |
574 | /* |
575 | * We are limited by the size of sector_t. Use block size, as | |
576 | * that's what we expose to the VFS. | |
577 | */ | |
578 | bytes = 1 << bbits; | |
579 | trim = 1; | |
580 | bitshift = 31; | |
ccd979bd MF |
581 | # endif |
582 | #endif | |
583 | ||
5a254031 MF |
584 | /* |
585 | * Trim by a whole cluster when we can actually approach the | |
586 | * on-disk limits. Otherwise we can overflow i_clusters when | |
587 | * an extent start is at the max offset. | |
588 | */ | |
589 | return (((unsigned long long)bytes) << bitshift) - trim; | |
ccd979bd MF |
590 | } |
591 | ||
592 | static int ocfs2_remount(struct super_block *sb, int *flags, char *data) | |
593 | { | |
594 | int incompat_features; | |
595 | int ret = 0; | |
c0123ade | 596 | struct mount_options parsed_options; |
ccd979bd MF |
597 | struct ocfs2_super *osb = OCFS2_SB(sb); |
598 | ||
337eb00a AIB |
599 | lock_kernel(); |
600 | ||
c0123ade | 601 | if (!ocfs2_parse_options(sb, data, &parsed_options, 1)) { |
ccd979bd MF |
602 | ret = -EINVAL; |
603 | goto out; | |
604 | } | |
605 | ||
606 | if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) != | |
c0123ade | 607 | (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) { |
ccd979bd MF |
608 | ret = -EINVAL; |
609 | mlog(ML_ERROR, "Cannot change heartbeat mode on remount\n"); | |
610 | goto out; | |
611 | } | |
612 | ||
613 | if ((osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) != | |
c0123ade | 614 | (parsed_options.mount_opt & OCFS2_MOUNT_DATA_WRITEBACK)) { |
ccd979bd MF |
615 | ret = -EINVAL; |
616 | mlog(ML_ERROR, "Cannot change data mode on remount\n"); | |
617 | goto out; | |
618 | } | |
619 | ||
12462f1d JB |
620 | /* Probably don't want this on remount; it might |
621 | * mess with other nodes */ | |
622 | if (!(osb->s_mount_opt & OCFS2_MOUNT_INODE64) && | |
623 | (parsed_options.mount_opt & OCFS2_MOUNT_INODE64)) { | |
624 | ret = -EINVAL; | |
625 | mlog(ML_ERROR, "Cannot enable inode64 on remount\n"); | |
626 | goto out; | |
627 | } | |
628 | ||
ccd979bd MF |
629 | /* We're going to/from readonly mode. */ |
630 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { | |
19ece546 JK |
631 | /* Disable quota accounting before remounting RO */ |
632 | if (*flags & MS_RDONLY) { | |
633 | ret = ocfs2_susp_quotas(osb, 0); | |
634 | if (ret < 0) | |
635 | goto out; | |
636 | } | |
ccd979bd MF |
637 | /* Lock here so the check of HARD_RO and the potential |
638 | * setting of SOFT_RO is atomic. */ | |
639 | spin_lock(&osb->osb_lock); | |
640 | if (osb->osb_flags & OCFS2_OSB_HARD_RO) { | |
641 | mlog(ML_ERROR, "Remount on readonly device is forbidden.\n"); | |
642 | ret = -EROFS; | |
643 | goto unlock_osb; | |
644 | } | |
645 | ||
646 | if (*flags & MS_RDONLY) { | |
647 | mlog(0, "Going to ro mode.\n"); | |
648 | sb->s_flags |= MS_RDONLY; | |
649 | osb->osb_flags |= OCFS2_OSB_SOFT_RO; | |
650 | } else { | |
651 | mlog(0, "Making ro filesystem writeable.\n"); | |
652 | ||
653 | if (osb->osb_flags & OCFS2_OSB_ERROR_FS) { | |
654 | mlog(ML_ERROR, "Cannot remount RDWR " | |
655 | "filesystem due to previous errors.\n"); | |
656 | ret = -EROFS; | |
657 | goto unlock_osb; | |
658 | } | |
659 | incompat_features = OCFS2_HAS_RO_COMPAT_FEATURE(sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP); | |
660 | if (incompat_features) { | |
661 | mlog(ML_ERROR, "Cannot remount RDWR because " | |
662 | "of unsupported optional features " | |
663 | "(%x).\n", incompat_features); | |
664 | ret = -EINVAL; | |
665 | goto unlock_osb; | |
666 | } | |
667 | sb->s_flags &= ~MS_RDONLY; | |
668 | osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; | |
669 | } | |
670 | unlock_osb: | |
671 | spin_unlock(&osb->osb_lock); | |
19ece546 JK |
672 | /* Enable quota accounting after remounting RW */ |
673 | if (!ret && !(*flags & MS_RDONLY)) { | |
674 | if (sb_any_quota_suspended(sb)) | |
675 | ret = ocfs2_susp_quotas(osb, 1); | |
676 | else | |
677 | ret = ocfs2_enable_quotas(osb); | |
678 | if (ret < 0) { | |
679 | /* Return back changes... */ | |
680 | spin_lock(&osb->osb_lock); | |
681 | sb->s_flags |= MS_RDONLY; | |
682 | osb->osb_flags |= OCFS2_OSB_SOFT_RO; | |
683 | spin_unlock(&osb->osb_lock); | |
684 | goto out; | |
685 | } | |
686 | } | |
ccd979bd MF |
687 | } |
688 | ||
689 | if (!ret) { | |
ccd979bd MF |
690 | /* Only save off the new mount options in case of a successful |
691 | * remount. */ | |
a68979b8 TY |
692 | if (!(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR)) |
693 | parsed_options.mount_opt &= ~OCFS2_MOUNT_POSIX_ACL; | |
c0123ade TY |
694 | osb->s_mount_opt = parsed_options.mount_opt; |
695 | osb->s_atime_quantum = parsed_options.atime_quantum; | |
696 | osb->preferred_slot = parsed_options.slot; | |
d147b3d6 MF |
697 | if (parsed_options.commit_interval) |
698 | osb->osb_commit_interval = parsed_options.commit_interval; | |
e001e796 MF |
699 | |
700 | if (!ocfs2_is_hard_readonly(osb)) | |
701 | ocfs2_set_journal_params(osb); | |
ccd979bd MF |
702 | } |
703 | out: | |
337eb00a | 704 | unlock_kernel(); |
ccd979bd MF |
705 | return ret; |
706 | } | |
707 | ||
708 | static int ocfs2_sb_probe(struct super_block *sb, | |
709 | struct buffer_head **bh, | |
73be192b JB |
710 | int *sector_size, |
711 | struct ocfs2_blockcheck_stats *stats) | |
ccd979bd | 712 | { |
bddb8eb3 | 713 | int status, tmpstat; |
ccd979bd MF |
714 | struct ocfs1_vol_disk_hdr *hdr; |
715 | struct ocfs2_dinode *di; | |
716 | int blksize; | |
717 | ||
718 | *bh = NULL; | |
719 | ||
720 | /* may be > 512 */ | |
e1defc4f | 721 | *sector_size = bdev_logical_block_size(sb->s_bdev); |
ccd979bd MF |
722 | if (*sector_size > OCFS2_MAX_BLOCKSIZE) { |
723 | mlog(ML_ERROR, "Hardware sector size too large: %d (max=%d)\n", | |
724 | *sector_size, OCFS2_MAX_BLOCKSIZE); | |
725 | status = -EINVAL; | |
726 | goto bail; | |
727 | } | |
728 | ||
729 | /* Can this really happen? */ | |
730 | if (*sector_size < OCFS2_MIN_BLOCKSIZE) | |
731 | *sector_size = OCFS2_MIN_BLOCKSIZE; | |
732 | ||
733 | /* check block zero for old format */ | |
734 | status = ocfs2_get_sector(sb, bh, 0, *sector_size); | |
735 | if (status < 0) { | |
736 | mlog_errno(status); | |
737 | goto bail; | |
738 | } | |
739 | hdr = (struct ocfs1_vol_disk_hdr *) (*bh)->b_data; | |
740 | if (hdr->major_version == OCFS1_MAJOR_VERSION) { | |
741 | mlog(ML_ERROR, "incompatible version: %u.%u\n", | |
742 | hdr->major_version, hdr->minor_version); | |
743 | status = -EINVAL; | |
744 | } | |
745 | if (memcmp(hdr->signature, OCFS1_VOLUME_SIGNATURE, | |
746 | strlen(OCFS1_VOLUME_SIGNATURE)) == 0) { | |
747 | mlog(ML_ERROR, "incompatible volume signature: %8s\n", | |
748 | hdr->signature); | |
749 | status = -EINVAL; | |
750 | } | |
751 | brelse(*bh); | |
752 | *bh = NULL; | |
753 | if (status < 0) { | |
754 | mlog(ML_ERROR, "This is an ocfs v1 filesystem which must be " | |
755 | "upgraded before mounting with ocfs v2\n"); | |
756 | goto bail; | |
757 | } | |
758 | ||
759 | /* | |
760 | * Now check at magic offset for 512, 1024, 2048, 4096 | |
761 | * blocksizes. 4096 is the maximum blocksize because it is | |
762 | * the minimum clustersize. | |
763 | */ | |
764 | status = -EINVAL; | |
765 | for (blksize = *sector_size; | |
766 | blksize <= OCFS2_MAX_BLOCKSIZE; | |
767 | blksize <<= 1) { | |
768 | tmpstat = ocfs2_get_sector(sb, bh, | |
769 | OCFS2_SUPER_BLOCK_BLKNO, | |
770 | blksize); | |
771 | if (tmpstat < 0) { | |
772 | status = tmpstat; | |
773 | mlog_errno(status); | |
774 | goto bail; | |
775 | } | |
776 | di = (struct ocfs2_dinode *) (*bh)->b_data; | |
73be192b JB |
777 | memset(stats, 0, sizeof(struct ocfs2_blockcheck_stats)); |
778 | status = ocfs2_verify_volume(di, *bh, blksize, stats); | |
ccd979bd MF |
779 | if (status >= 0) |
780 | goto bail; | |
781 | brelse(*bh); | |
782 | *bh = NULL; | |
783 | if (status != -EAGAIN) | |
784 | break; | |
785 | } | |
786 | ||
787 | bail: | |
788 | return status; | |
789 | } | |
790 | ||
c271c5c2 SM |
791 | static int ocfs2_verify_heartbeat(struct ocfs2_super *osb) |
792 | { | |
793 | if (ocfs2_mount_local(osb)) { | |
794 | if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { | |
795 | mlog(ML_ERROR, "Cannot heartbeat on a locally " | |
796 | "mounted device.\n"); | |
797 | return -EINVAL; | |
798 | } | |
799 | } | |
800 | ||
b61817e1 JB |
801 | if (ocfs2_userspace_stack(osb)) { |
802 | if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { | |
803 | mlog(ML_ERROR, "Userspace stack expected, but " | |
804 | "o2cb heartbeat arguments passed to mount\n"); | |
805 | return -EINVAL; | |
806 | } | |
807 | } | |
808 | ||
c271c5c2 | 809 | if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { |
b61817e1 JB |
810 | if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb) && |
811 | !ocfs2_userspace_stack(osb)) { | |
c271c5c2 SM |
812 | mlog(ML_ERROR, "Heartbeat has to be started to mount " |
813 | "a read-write clustered device.\n"); | |
814 | return -EINVAL; | |
815 | } | |
816 | } | |
817 | ||
818 | return 0; | |
819 | } | |
820 | ||
b61817e1 JB |
821 | /* |
822 | * If we're using a userspace stack, mount should have passed | |
823 | * a name that matches the disk. If not, mount should not | |
824 | * have passed a stack. | |
825 | */ | |
826 | static int ocfs2_verify_userspace_stack(struct ocfs2_super *osb, | |
827 | struct mount_options *mopt) | |
828 | { | |
829 | if (!ocfs2_userspace_stack(osb) && mopt->cluster_stack[0]) { | |
830 | mlog(ML_ERROR, | |
831 | "cluster stack passed to mount, but this filesystem " | |
832 | "does not support it\n"); | |
833 | return -EINVAL; | |
834 | } | |
835 | ||
836 | if (ocfs2_userspace_stack(osb) && | |
837 | strncmp(osb->osb_cluster_stack, mopt->cluster_stack, | |
838 | OCFS2_STACK_LABEL_LEN)) { | |
839 | mlog(ML_ERROR, | |
840 | "cluster stack passed to mount (\"%s\") does not " | |
841 | "match the filesystem (\"%s\")\n", | |
842 | mopt->cluster_stack, | |
843 | osb->osb_cluster_stack); | |
844 | return -EINVAL; | |
845 | } | |
846 | ||
847 | return 0; | |
848 | } | |
849 | ||
19ece546 JK |
850 | static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend) |
851 | { | |
852 | int type; | |
853 | struct super_block *sb = osb->sb; | |
854 | unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, | |
855 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; | |
856 | int status = 0; | |
857 | ||
858 | for (type = 0; type < MAXQUOTAS; type++) { | |
859 | if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) | |
860 | continue; | |
861 | if (unsuspend) | |
862 | status = vfs_quota_enable( | |
863 | sb_dqopt(sb)->files[type], | |
864 | type, QFMT_OCFS2, | |
865 | DQUOT_SUSPENDED); | |
866 | else | |
867 | status = vfs_quota_disable(sb, type, | |
868 | DQUOT_SUSPENDED); | |
869 | if (status < 0) | |
870 | break; | |
871 | } | |
872 | if (status < 0) | |
873 | mlog(ML_ERROR, "Failed to suspend/unsuspend quotas on " | |
874 | "remount (error = %d).\n", status); | |
875 | return status; | |
876 | } | |
877 | ||
878 | static int ocfs2_enable_quotas(struct ocfs2_super *osb) | |
879 | { | |
880 | struct inode *inode[MAXQUOTAS] = { NULL, NULL }; | |
881 | struct super_block *sb = osb->sb; | |
882 | unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, | |
883 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; | |
884 | unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE, | |
885 | LOCAL_GROUP_QUOTA_SYSTEM_INODE }; | |
886 | int status; | |
887 | int type; | |
888 | ||
889 | sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NEGATIVE_USAGE; | |
890 | for (type = 0; type < MAXQUOTAS; type++) { | |
891 | if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) | |
892 | continue; | |
893 | inode[type] = ocfs2_get_system_file_inode(osb, ino[type], | |
894 | osb->slot_num); | |
895 | if (!inode[type]) { | |
896 | status = -ENOENT; | |
897 | goto out_quota_off; | |
898 | } | |
899 | status = vfs_quota_enable(inode[type], type, QFMT_OCFS2, | |
900 | DQUOT_USAGE_ENABLED); | |
901 | if (status < 0) | |
902 | goto out_quota_off; | |
903 | } | |
904 | ||
905 | for (type = 0; type < MAXQUOTAS; type++) | |
906 | iput(inode[type]); | |
907 | return 0; | |
908 | out_quota_off: | |
909 | ocfs2_disable_quotas(osb); | |
910 | for (type = 0; type < MAXQUOTAS; type++) | |
911 | iput(inode[type]); | |
912 | mlog_errno(status); | |
913 | return status; | |
914 | } | |
915 | ||
916 | static void ocfs2_disable_quotas(struct ocfs2_super *osb) | |
917 | { | |
918 | int type; | |
919 | struct inode *inode; | |
920 | struct super_block *sb = osb->sb; | |
921 | ||
922 | /* We mostly ignore errors in this function because there's not much | |
923 | * we can do when we see them */ | |
924 | for (type = 0; type < MAXQUOTAS; type++) { | |
925 | if (!sb_has_quota_loaded(sb, type)) | |
926 | continue; | |
927 | inode = igrab(sb->s_dquot.files[type]); | |
928 | /* Turn off quotas. This will remove all dquot structures from | |
929 | * memory and so they will be automatically synced to global | |
930 | * quota files */ | |
931 | vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED | | |
932 | DQUOT_LIMITS_ENABLED); | |
933 | if (!inode) | |
934 | continue; | |
935 | iput(inode); | |
936 | } | |
937 | } | |
938 | ||
939 | /* Handle quota on quotactl */ | |
940 | static int ocfs2_quota_on(struct super_block *sb, int type, int format_id, | |
941 | char *path, int remount) | |
942 | { | |
943 | unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, | |
944 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; | |
945 | ||
946 | if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) | |
947 | return -EINVAL; | |
948 | ||
949 | if (remount) | |
950 | return 0; /* Just ignore it has been handled in | |
951 | * ocfs2_remount() */ | |
952 | return vfs_quota_enable(sb_dqopt(sb)->files[type], type, | |
953 | format_id, DQUOT_LIMITS_ENABLED); | |
954 | } | |
955 | ||
956 | /* Handle quota off quotactl */ | |
957 | static int ocfs2_quota_off(struct super_block *sb, int type, int remount) | |
958 | { | |
959 | if (remount) | |
960 | return 0; /* Ignore now and handle later in | |
961 | * ocfs2_remount() */ | |
962 | return vfs_quota_disable(sb, type, DQUOT_LIMITS_ENABLED); | |
963 | } | |
964 | ||
965 | static struct quotactl_ops ocfs2_quotactl_ops = { | |
966 | .quota_on = ocfs2_quota_on, | |
967 | .quota_off = ocfs2_quota_off, | |
968 | .quota_sync = vfs_quota_sync, | |
969 | .get_info = vfs_get_dqinfo, | |
970 | .set_info = vfs_set_dqinfo, | |
971 | .get_dqblk = vfs_get_dqblk, | |
972 | .set_dqblk = vfs_set_dqblk, | |
973 | }; | |
974 | ||
ccd979bd MF |
975 | static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) |
976 | { | |
977 | struct dentry *root; | |
978 | int status, sector_size; | |
c0123ade | 979 | struct mount_options parsed_options; |
ccd979bd MF |
980 | struct inode *inode = NULL; |
981 | struct ocfs2_super *osb = NULL; | |
982 | struct buffer_head *bh = NULL; | |
c271c5c2 | 983 | char nodestr[8]; |
73be192b | 984 | struct ocfs2_blockcheck_stats stats; |
ccd979bd MF |
985 | |
986 | mlog_entry("%p, %p, %i", sb, data, silent); | |
987 | ||
c0123ade | 988 | if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) { |
ccd979bd MF |
989 | status = -EINVAL; |
990 | goto read_super_error; | |
991 | } | |
992 | ||
993 | /* probe for superblock */ | |
73be192b | 994 | status = ocfs2_sb_probe(sb, &bh, §or_size, &stats); |
ccd979bd MF |
995 | if (status < 0) { |
996 | mlog(ML_ERROR, "superblock probe failed!\n"); | |
997 | goto read_super_error; | |
998 | } | |
999 | ||
73be192b | 1000 | status = ocfs2_initialize_super(sb, bh, sector_size, &stats); |
ccd979bd MF |
1001 | osb = OCFS2_SB(sb); |
1002 | if (status < 0) { | |
1003 | mlog_errno(status); | |
1004 | goto read_super_error; | |
1005 | } | |
1006 | brelse(bh); | |
1007 | bh = NULL; | |
a68979b8 TY |
1008 | |
1009 | if (!(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR)) | |
1010 | parsed_options.mount_opt &= ~OCFS2_MOUNT_POSIX_ACL; | |
1011 | ||
c0123ade TY |
1012 | osb->s_mount_opt = parsed_options.mount_opt; |
1013 | osb->s_atime_quantum = parsed_options.atime_quantum; | |
1014 | osb->preferred_slot = parsed_options.slot; | |
d147b3d6 | 1015 | osb->osb_commit_interval = parsed_options.commit_interval; |
9c7af40b MF |
1016 | osb->local_alloc_default_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt); |
1017 | osb->local_alloc_bits = osb->local_alloc_default_bits; | |
19ece546 JK |
1018 | if (osb->s_mount_opt & OCFS2_MOUNT_USRQUOTA && |
1019 | !OCFS2_HAS_RO_COMPAT_FEATURE(sb, | |
1020 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) { | |
1021 | status = -EINVAL; | |
1022 | mlog(ML_ERROR, "User quotas were requested, but this " | |
1023 | "filesystem does not have the feature enabled.\n"); | |
1024 | goto read_super_error; | |
1025 | } | |
1026 | if (osb->s_mount_opt & OCFS2_MOUNT_GRPQUOTA && | |
1027 | !OCFS2_HAS_RO_COMPAT_FEATURE(sb, | |
1028 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) { | |
1029 | status = -EINVAL; | |
1030 | mlog(ML_ERROR, "Group quotas were requested, but this " | |
1031 | "filesystem does not have the feature enabled.\n"); | |
1032 | goto read_super_error; | |
1033 | } | |
ccd979bd | 1034 | |
b61817e1 JB |
1035 | status = ocfs2_verify_userspace_stack(osb, &parsed_options); |
1036 | if (status) | |
1037 | goto read_super_error; | |
1038 | ||
ccd979bd MF |
1039 | sb->s_magic = OCFS2_SUPER_MAGIC; |
1040 | ||
a68979b8 TY |
1041 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
1042 | ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | |
1043 | ||
ccd979bd MF |
1044 | /* Hard readonly mode only if: bdev_read_only, MS_RDONLY, |
1045 | * heartbeat=none */ | |
1046 | if (bdev_read_only(sb->s_bdev)) { | |
1047 | if (!(sb->s_flags & MS_RDONLY)) { | |
1048 | status = -EACCES; | |
1049 | mlog(ML_ERROR, "Readonly device detected but readonly " | |
1050 | "mount was not specified.\n"); | |
1051 | goto read_super_error; | |
1052 | } | |
1053 | ||
1054 | /* You should not be able to start a local heartbeat | |
1055 | * on a readonly device. */ | |
1056 | if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { | |
1057 | status = -EROFS; | |
1058 | mlog(ML_ERROR, "Local heartbeat specified on readonly " | |
1059 | "device.\n"); | |
1060 | goto read_super_error; | |
1061 | } | |
1062 | ||
1063 | status = ocfs2_check_journals_nolocks(osb); | |
1064 | if (status < 0) { | |
1065 | if (status == -EROFS) | |
1066 | mlog(ML_ERROR, "Recovery required on readonly " | |
1067 | "file system, but write access is " | |
1068 | "unavailable.\n"); | |
1069 | else | |
1070 | mlog_errno(status); | |
1071 | goto read_super_error; | |
1072 | } | |
1073 | ||
1074 | ocfs2_set_ro_flag(osb, 1); | |
1075 | ||
1076 | printk(KERN_NOTICE "Readonly device detected. No cluster " | |
1077 | "services will be utilized for this mount. Recovery " | |
1078 | "will be skipped.\n"); | |
1079 | } | |
1080 | ||
1081 | if (!ocfs2_is_hard_readonly(osb)) { | |
ccd979bd MF |
1082 | if (sb->s_flags & MS_RDONLY) |
1083 | ocfs2_set_ro_flag(osb, 0); | |
1084 | } | |
1085 | ||
c271c5c2 SM |
1086 | status = ocfs2_verify_heartbeat(osb); |
1087 | if (status < 0) { | |
1088 | mlog_errno(status); | |
1089 | goto read_super_error; | |
1090 | } | |
1091 | ||
ccd979bd MF |
1092 | osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, |
1093 | ocfs2_debugfs_root); | |
1094 | if (!osb->osb_debug_root) { | |
1095 | status = -EINVAL; | |
1096 | mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n"); | |
1097 | goto read_super_error; | |
1098 | } | |
1099 | ||
50397507 SM |
1100 | osb->osb_ctxt = debugfs_create_file("fs_state", S_IFREG|S_IRUSR, |
1101 | osb->osb_debug_root, | |
1102 | osb, | |
1103 | &ocfs2_osb_debug_fops); | |
1104 | if (!osb->osb_ctxt) { | |
1105 | status = -EINVAL; | |
1106 | mlog_errno(status); | |
1107 | goto read_super_error; | |
1108 | } | |
1109 | ||
73be192b JB |
1110 | if (ocfs2_meta_ecc(osb)) { |
1111 | status = ocfs2_blockcheck_stats_debugfs_install( | |
1112 | &osb->osb_ecc_stats, | |
1113 | osb->osb_debug_root); | |
1114 | if (status) { | |
1115 | mlog(ML_ERROR, | |
1116 | "Unable to create blockcheck statistics " | |
1117 | "files\n"); | |
1118 | goto read_super_error; | |
1119 | } | |
1120 | } | |
1121 | ||
ccd979bd MF |
1122 | status = ocfs2_mount_volume(sb); |
1123 | if (osb->root_inode) | |
1124 | inode = igrab(osb->root_inode); | |
1125 | ||
1126 | if (status < 0) | |
1127 | goto read_super_error; | |
1128 | ||
1129 | if (!inode) { | |
1130 | status = -EIO; | |
1131 | mlog_errno(status); | |
1132 | goto read_super_error; | |
1133 | } | |
1134 | ||
1135 | root = d_alloc_root(inode); | |
1136 | if (!root) { | |
1137 | status = -ENOMEM; | |
1138 | mlog_errno(status); | |
1139 | goto read_super_error; | |
1140 | } | |
1141 | ||
1142 | sb->s_root = root; | |
1143 | ||
1144 | ocfs2_complete_mount_recovery(osb); | |
1145 | ||
c271c5c2 SM |
1146 | if (ocfs2_mount_local(osb)) |
1147 | snprintf(nodestr, sizeof(nodestr), "local"); | |
1148 | else | |
19fdb624 | 1149 | snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num); |
c271c5c2 SM |
1150 | |
1151 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) " | |
781ee3e2 | 1152 | "with %s data mode.\n", |
c271c5c2 | 1153 | osb->dev_str, nodestr, osb->slot_num, |
ccd979bd MF |
1154 | osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : |
1155 | "ordered"); | |
1156 | ||
1157 | atomic_set(&osb->vol_state, VOLUME_MOUNTED); | |
1158 | wake_up(&osb->osb_mount_event); | |
1159 | ||
19ece546 JK |
1160 | /* Now we can initialize quotas because we can afford to wait |
1161 | * for cluster locks recovery now. That also means that truncation | |
1162 | * log recovery can happen but that waits for proper quota setup */ | |
1163 | if (!(sb->s_flags & MS_RDONLY)) { | |
1164 | status = ocfs2_enable_quotas(osb); | |
1165 | if (status < 0) { | |
1166 | /* We have to err-out specially here because | |
1167 | * s_root is already set */ | |
1168 | mlog_errno(status); | |
1169 | atomic_set(&osb->vol_state, VOLUME_DISABLED); | |
1170 | wake_up(&osb->osb_mount_event); | |
1171 | mlog_exit(status); | |
1172 | return status; | |
1173 | } | |
1174 | } | |
1175 | ||
1176 | ocfs2_complete_quota_recovery(osb); | |
1177 | ||
1178 | /* Now we wake up again for processes waiting for quotas */ | |
1179 | atomic_set(&osb->vol_state, VOLUME_MOUNTED_QUOTAS); | |
1180 | wake_up(&osb->osb_mount_event); | |
1181 | ||
ccd979bd MF |
1182 | mlog_exit(status); |
1183 | return status; | |
1184 | ||
1185 | read_super_error: | |
a81cb88b | 1186 | brelse(bh); |
ccd979bd MF |
1187 | |
1188 | if (inode) | |
1189 | iput(inode); | |
1190 | ||
1191 | if (osb) { | |
1192 | atomic_set(&osb->vol_state, VOLUME_DISABLED); | |
1193 | wake_up(&osb->osb_mount_event); | |
1194 | ocfs2_dismount_volume(sb, 1); | |
1195 | } | |
1196 | ||
1197 | mlog_exit(status); | |
1198 | return status; | |
1199 | } | |
1200 | ||
454e2398 DH |
1201 | static int ocfs2_get_sb(struct file_system_type *fs_type, |
1202 | int flags, | |
1203 | const char *dev_name, | |
1204 | void *data, | |
1205 | struct vfsmount *mnt) | |
ccd979bd | 1206 | { |
454e2398 DH |
1207 | return get_sb_bdev(fs_type, flags, dev_name, data, ocfs2_fill_super, |
1208 | mnt); | |
ccd979bd MF |
1209 | } |
1210 | ||
1211 | static struct file_system_type ocfs2_fs_type = { | |
1212 | .owner = THIS_MODULE, | |
1213 | .name = "ocfs2", | |
1214 | .get_sb = ocfs2_get_sb, /* is this called when we mount | |
1215 | * the fs? */ | |
1216 | .kill_sb = kill_block_super, /* set to the generic one | |
1217 | * right now, but do we | |
1218 | * need to change that? */ | |
1ba9da2f | 1219 | .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE, |
ccd979bd MF |
1220 | .next = NULL |
1221 | }; | |
1222 | ||
1223 | static int ocfs2_parse_options(struct super_block *sb, | |
1224 | char *options, | |
c0123ade | 1225 | struct mount_options *mopt, |
ccd979bd MF |
1226 | int is_remount) |
1227 | { | |
1228 | int status; | |
1229 | char *p; | |
1230 | ||
1231 | mlog_entry("remount: %d, options: \"%s\"\n", is_remount, | |
1232 | options ? options : "(none)"); | |
1233 | ||
d147b3d6 | 1234 | mopt->commit_interval = 0; |
c0123ade TY |
1235 | mopt->mount_opt = 0; |
1236 | mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | |
1237 | mopt->slot = OCFS2_INVALID_SLOT; | |
2fbe8d1e | 1238 | mopt->localalloc_opt = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; |
b61817e1 | 1239 | mopt->cluster_stack[0] = '\0'; |
ccd979bd MF |
1240 | |
1241 | if (!options) { | |
1242 | status = 1; | |
1243 | goto bail; | |
1244 | } | |
1245 | ||
1246 | while ((p = strsep(&options, ",")) != NULL) { | |
1247 | int token, option; | |
1248 | substring_t args[MAX_OPT_ARGS]; | |
1249 | ||
1250 | if (!*p) | |
1251 | continue; | |
1252 | ||
1253 | token = match_token(p, tokens, args); | |
1254 | switch (token) { | |
1255 | case Opt_hb_local: | |
c0123ade | 1256 | mopt->mount_opt |= OCFS2_MOUNT_HB_LOCAL; |
ccd979bd MF |
1257 | break; |
1258 | case Opt_hb_none: | |
c0123ade | 1259 | mopt->mount_opt &= ~OCFS2_MOUNT_HB_LOCAL; |
ccd979bd MF |
1260 | break; |
1261 | case Opt_barrier: | |
1262 | if (match_int(&args[0], &option)) { | |
1263 | status = 0; | |
1264 | goto bail; | |
1265 | } | |
1266 | if (option) | |
c0123ade | 1267 | mopt->mount_opt |= OCFS2_MOUNT_BARRIER; |
ccd979bd | 1268 | else |
c0123ade | 1269 | mopt->mount_opt &= ~OCFS2_MOUNT_BARRIER; |
ccd979bd MF |
1270 | break; |
1271 | case Opt_intr: | |
c0123ade | 1272 | mopt->mount_opt &= ~OCFS2_MOUNT_NOINTR; |
ccd979bd MF |
1273 | break; |
1274 | case Opt_nointr: | |
c0123ade | 1275 | mopt->mount_opt |= OCFS2_MOUNT_NOINTR; |
ccd979bd MF |
1276 | break; |
1277 | case Opt_err_panic: | |
c0123ade | 1278 | mopt->mount_opt |= OCFS2_MOUNT_ERRORS_PANIC; |
ccd979bd MF |
1279 | break; |
1280 | case Opt_err_ro: | |
c0123ade | 1281 | mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_PANIC; |
ccd979bd MF |
1282 | break; |
1283 | case Opt_data_ordered: | |
c0123ade | 1284 | mopt->mount_opt &= ~OCFS2_MOUNT_DATA_WRITEBACK; |
ccd979bd MF |
1285 | break; |
1286 | case Opt_data_writeback: | |
c0123ade | 1287 | mopt->mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; |
ccd979bd | 1288 | break; |
cf1d6c76 TY |
1289 | case Opt_user_xattr: |
1290 | mopt->mount_opt &= ~OCFS2_MOUNT_NOUSERXATTR; | |
1291 | break; | |
1292 | case Opt_nouser_xattr: | |
1293 | mopt->mount_opt |= OCFS2_MOUNT_NOUSERXATTR; | |
1294 | break; | |
7f1a37e3 TY |
1295 | case Opt_atime_quantum: |
1296 | if (match_int(&args[0], &option)) { | |
1297 | status = 0; | |
1298 | goto bail; | |
1299 | } | |
1300 | if (option >= 0) | |
c0123ade | 1301 | mopt->atime_quantum = option; |
7f1a37e3 | 1302 | break; |
baf4661a SM |
1303 | case Opt_slot: |
1304 | option = 0; | |
1305 | if (match_int(&args[0], &option)) { | |
1306 | status = 0; | |
1307 | goto bail; | |
1308 | } | |
1309 | if (option) | |
c0123ade | 1310 | mopt->slot = (s16)option; |
baf4661a | 1311 | break; |
d147b3d6 MF |
1312 | case Opt_commit: |
1313 | option = 0; | |
1314 | if (match_int(&args[0], &option)) { | |
1315 | status = 0; | |
1316 | goto bail; | |
1317 | } | |
1318 | if (option < 0) | |
1319 | return 0; | |
1320 | if (option == 0) | |
2b4e30fb | 1321 | option = JBD2_DEFAULT_MAX_COMMIT_AGE; |
d147b3d6 MF |
1322 | mopt->commit_interval = HZ * option; |
1323 | break; | |
2fbe8d1e SM |
1324 | case Opt_localalloc: |
1325 | option = 0; | |
1326 | if (match_int(&args[0], &option)) { | |
1327 | status = 0; | |
1328 | goto bail; | |
1329 | } | |
1330 | if (option >= 0 && (option <= ocfs2_local_alloc_size(sb) * 8)) | |
1331 | mopt->localalloc_opt = option; | |
1332 | break; | |
53fc622b MF |
1333 | case Opt_localflocks: |
1334 | /* | |
1335 | * Changing this during remount could race | |
1336 | * flock() requests, or "unbalance" existing | |
1337 | * ones (e.g., a lock is taken in one mode but | |
1338 | * dropped in the other). If users care enough | |
1339 | * to flip locking modes during remount, we | |
1340 | * could add a "local" flag to individual | |
1341 | * flock structures for proper tracking of | |
1342 | * state. | |
1343 | */ | |
1344 | if (!is_remount) | |
1345 | mopt->mount_opt |= OCFS2_MOUNT_LOCALFLOCKS; | |
1346 | break; | |
b61817e1 JB |
1347 | case Opt_stack: |
1348 | /* Check both that the option we were passed | |
1349 | * is of the right length and that it is a proper | |
1350 | * string of the right length. | |
1351 | */ | |
1352 | if (((args[0].to - args[0].from) != | |
1353 | OCFS2_STACK_LABEL_LEN) || | |
1354 | (strnlen(args[0].from, | |
1355 | OCFS2_STACK_LABEL_LEN) != | |
1356 | OCFS2_STACK_LABEL_LEN)) { | |
1357 | mlog(ML_ERROR, | |
1358 | "Invalid cluster_stack option\n"); | |
1359 | status = 0; | |
1360 | goto bail; | |
1361 | } | |
1362 | memcpy(mopt->cluster_stack, args[0].from, | |
1363 | OCFS2_STACK_LABEL_LEN); | |
1364 | mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0'; | |
1365 | break; | |
12462f1d JB |
1366 | case Opt_inode64: |
1367 | mopt->mount_opt |= OCFS2_MOUNT_INODE64; | |
1368 | break; | |
19ece546 JK |
1369 | case Opt_usrquota: |
1370 | /* We check only on remount, otherwise features | |
1371 | * aren't yet initialized. */ | |
1372 | if (is_remount && !OCFS2_HAS_RO_COMPAT_FEATURE(sb, | |
1373 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) { | |
1374 | mlog(ML_ERROR, "User quota requested but " | |
1375 | "filesystem feature is not set\n"); | |
1376 | status = 0; | |
1377 | goto bail; | |
1378 | } | |
1379 | mopt->mount_opt |= OCFS2_MOUNT_USRQUOTA; | |
1380 | break; | |
1381 | case Opt_grpquota: | |
1382 | if (is_remount && !OCFS2_HAS_RO_COMPAT_FEATURE(sb, | |
1383 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) { | |
1384 | mlog(ML_ERROR, "Group quota requested but " | |
1385 | "filesystem feature is not set\n"); | |
1386 | status = 0; | |
1387 | goto bail; | |
1388 | } | |
1389 | mopt->mount_opt |= OCFS2_MOUNT_GRPQUOTA; | |
1390 | break; | |
a68979b8 TY |
1391 | #ifdef CONFIG_OCFS2_FS_POSIX_ACL |
1392 | case Opt_acl: | |
1393 | mopt->mount_opt |= OCFS2_MOUNT_POSIX_ACL; | |
1394 | break; | |
1395 | case Opt_noacl: | |
1396 | mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL; | |
1397 | break; | |
1398 | #else | |
1399 | case Opt_acl: | |
1400 | case Opt_noacl: | |
1401 | printk(KERN_INFO "ocfs2 (no)acl options not supported\n"); | |
1402 | break; | |
1403 | #endif | |
ccd979bd MF |
1404 | default: |
1405 | mlog(ML_ERROR, | |
1406 | "Unrecognized mount option \"%s\" " | |
1407 | "or missing value\n", p); | |
1408 | status = 0; | |
1409 | goto bail; | |
1410 | } | |
1411 | } | |
1412 | ||
1413 | status = 1; | |
1414 | ||
1415 | bail: | |
1416 | mlog_exit(status); | |
1417 | return status; | |
1418 | } | |
1419 | ||
d550071c SM |
1420 | static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) |
1421 | { | |
1422 | struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb); | |
1423 | unsigned long opts = osb->s_mount_opt; | |
ebcee4b5 | 1424 | unsigned int local_alloc_megs; |
d550071c SM |
1425 | |
1426 | if (opts & OCFS2_MOUNT_HB_LOCAL) | |
1427 | seq_printf(s, ",_netdev,heartbeat=local"); | |
1428 | else | |
1429 | seq_printf(s, ",heartbeat=none"); | |
1430 | ||
1431 | if (opts & OCFS2_MOUNT_NOINTR) | |
1432 | seq_printf(s, ",nointr"); | |
1433 | ||
1434 | if (opts & OCFS2_MOUNT_DATA_WRITEBACK) | |
1435 | seq_printf(s, ",data=writeback"); | |
1436 | else | |
1437 | seq_printf(s, ",data=ordered"); | |
1438 | ||
1439 | if (opts & OCFS2_MOUNT_BARRIER) | |
1440 | seq_printf(s, ",barrier=1"); | |
1441 | ||
1442 | if (opts & OCFS2_MOUNT_ERRORS_PANIC) | |
1443 | seq_printf(s, ",errors=panic"); | |
1444 | else | |
1445 | seq_printf(s, ",errors=remount-ro"); | |
1446 | ||
1447 | if (osb->preferred_slot != OCFS2_INVALID_SLOT) | |
1448 | seq_printf(s, ",preferred_slot=%d", osb->preferred_slot); | |
1449 | ||
1450 | if (osb->s_atime_quantum != OCFS2_DEFAULT_ATIME_QUANTUM) | |
1451 | seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum); | |
1452 | ||
d147b3d6 MF |
1453 | if (osb->osb_commit_interval) |
1454 | seq_printf(s, ",commit=%u", | |
1455 | (unsigned) (osb->osb_commit_interval / HZ)); | |
1456 | ||
ebcee4b5 MF |
1457 | local_alloc_megs = osb->local_alloc_bits >> (20 - osb->s_clustersize_bits); |
1458 | if (local_alloc_megs != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE) | |
1459 | seq_printf(s, ",localalloc=%d", local_alloc_megs); | |
2fbe8d1e | 1460 | |
53fc622b MF |
1461 | if (opts & OCFS2_MOUNT_LOCALFLOCKS) |
1462 | seq_printf(s, ",localflocks,"); | |
1463 | ||
b61817e1 JB |
1464 | if (osb->osb_cluster_stack[0]) |
1465 | seq_printf(s, ",cluster_stack=%.*s", OCFS2_STACK_LABEL_LEN, | |
1466 | osb->osb_cluster_stack); | |
19ece546 JK |
1467 | if (opts & OCFS2_MOUNT_USRQUOTA) |
1468 | seq_printf(s, ",usrquota"); | |
1469 | if (opts & OCFS2_MOUNT_GRPQUOTA) | |
1470 | seq_printf(s, ",grpquota"); | |
b61817e1 | 1471 | |
b0f73cfc SM |
1472 | if (opts & OCFS2_MOUNT_NOUSERXATTR) |
1473 | seq_printf(s, ",nouser_xattr"); | |
1474 | else | |
1475 | seq_printf(s, ",user_xattr"); | |
1476 | ||
12462f1d JB |
1477 | if (opts & OCFS2_MOUNT_INODE64) |
1478 | seq_printf(s, ",inode64"); | |
1479 | ||
a68979b8 TY |
1480 | #ifdef CONFIG_OCFS2_FS_POSIX_ACL |
1481 | if (opts & OCFS2_MOUNT_POSIX_ACL) | |
1482 | seq_printf(s, ",acl"); | |
1483 | else | |
1484 | seq_printf(s, ",noacl"); | |
1485 | #endif | |
1486 | ||
d550071c SM |
1487 | return 0; |
1488 | } | |
1489 | ||
ccd979bd MF |
1490 | static int __init ocfs2_init(void) |
1491 | { | |
1492 | int status; | |
1493 | ||
1494 | mlog_entry_void(); | |
1495 | ||
1496 | ocfs2_print_version(); | |
1497 | ||
ccd979bd MF |
1498 | status = init_ocfs2_uptodate_cache(); |
1499 | if (status < 0) { | |
1500 | mlog_errno(status); | |
1501 | goto leave; | |
1502 | } | |
1503 | ||
1504 | status = ocfs2_initialize_mem_caches(); | |
1505 | if (status < 0) { | |
1506 | mlog_errno(status); | |
1507 | goto leave; | |
1508 | } | |
1509 | ||
1510 | ocfs2_wq = create_singlethread_workqueue("ocfs2_wq"); | |
1511 | if (!ocfs2_wq) { | |
1512 | status = -ENOMEM; | |
1513 | goto leave; | |
1514 | } | |
1515 | ||
ccd979bd MF |
1516 | ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); |
1517 | if (!ocfs2_debugfs_root) { | |
1518 | status = -EFAULT; | |
1519 | mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); | |
1520 | } | |
1521 | ||
171bf93c MF |
1522 | status = ocfs2_quota_setup(); |
1523 | if (status) | |
1524 | goto leave; | |
1525 | ||
63e0c48a JB |
1526 | ocfs2_set_locking_protocol(); |
1527 | ||
9e33d69f | 1528 | status = register_quota_format(&ocfs2_quota_format); |
ccd979bd MF |
1529 | leave: |
1530 | if (status < 0) { | |
171bf93c | 1531 | ocfs2_quota_shutdown(); |
ccd979bd MF |
1532 | ocfs2_free_mem_caches(); |
1533 | exit_ocfs2_uptodate_cache(); | |
ccd979bd MF |
1534 | } |
1535 | ||
1536 | mlog_exit(status); | |
1537 | ||
1538 | if (status >= 0) { | |
1539 | return register_filesystem(&ocfs2_fs_type); | |
1540 | } else | |
1541 | return -1; | |
1542 | } | |
1543 | ||
1544 | static void __exit ocfs2_exit(void) | |
1545 | { | |
1546 | mlog_entry_void(); | |
1547 | ||
171bf93c MF |
1548 | ocfs2_quota_shutdown(); |
1549 | ||
ccd979bd MF |
1550 | if (ocfs2_wq) { |
1551 | flush_workqueue(ocfs2_wq); | |
1552 | destroy_workqueue(ocfs2_wq); | |
1553 | } | |
1554 | ||
9e33d69f JK |
1555 | unregister_quota_format(&ocfs2_quota_format); |
1556 | ||
ccd979bd MF |
1557 | debugfs_remove(ocfs2_debugfs_root); |
1558 | ||
1559 | ocfs2_free_mem_caches(); | |
1560 | ||
1561 | unregister_filesystem(&ocfs2_fs_type); | |
1562 | ||
ccd979bd MF |
1563 | exit_ocfs2_uptodate_cache(); |
1564 | ||
1565 | mlog_exit_void(); | |
1566 | } | |
1567 | ||
1568 | static void ocfs2_put_super(struct super_block *sb) | |
1569 | { | |
1570 | mlog_entry("(0x%p)\n", sb); | |
1571 | ||
6cfd0148 CH |
1572 | lock_kernel(); |
1573 | ||
ccd979bd MF |
1574 | ocfs2_sync_blockdev(sb); |
1575 | ocfs2_dismount_volume(sb, 0); | |
1576 | ||
6cfd0148 CH |
1577 | unlock_kernel(); |
1578 | ||
ccd979bd MF |
1579 | mlog_exit_void(); |
1580 | } | |
1581 | ||
726c3342 | 1582 | static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) |
ccd979bd MF |
1583 | { |
1584 | struct ocfs2_super *osb; | |
1585 | u32 numbits, freebits; | |
1586 | int status; | |
1587 | struct ocfs2_dinode *bm_lock; | |
1588 | struct buffer_head *bh = NULL; | |
1589 | struct inode *inode = NULL; | |
1590 | ||
726c3342 | 1591 | mlog_entry("(%p, %p)\n", dentry->d_sb, buf); |
ccd979bd | 1592 | |
726c3342 | 1593 | osb = OCFS2_SB(dentry->d_sb); |
ccd979bd MF |
1594 | |
1595 | inode = ocfs2_get_system_file_inode(osb, | |
1596 | GLOBAL_BITMAP_SYSTEM_INODE, | |
1597 | OCFS2_INVALID_SLOT); | |
1598 | if (!inode) { | |
1599 | mlog(ML_ERROR, "failed to get bitmap inode\n"); | |
1600 | status = -EIO; | |
1601 | goto bail; | |
1602 | } | |
1603 | ||
e63aecb6 | 1604 | status = ocfs2_inode_lock(inode, &bh, 0); |
ccd979bd MF |
1605 | if (status < 0) { |
1606 | mlog_errno(status); | |
1607 | goto bail; | |
1608 | } | |
1609 | ||
1610 | bm_lock = (struct ocfs2_dinode *) bh->b_data; | |
1611 | ||
1612 | numbits = le32_to_cpu(bm_lock->id1.bitmap1.i_total); | |
1613 | freebits = numbits - le32_to_cpu(bm_lock->id1.bitmap1.i_used); | |
1614 | ||
1615 | buf->f_type = OCFS2_SUPER_MAGIC; | |
726c3342 | 1616 | buf->f_bsize = dentry->d_sb->s_blocksize; |
ccd979bd MF |
1617 | buf->f_namelen = OCFS2_MAX_FILENAME_LEN; |
1618 | buf->f_blocks = ((sector_t) numbits) * | |
1619 | (osb->s_clustersize >> osb->sb->s_blocksize_bits); | |
1620 | buf->f_bfree = ((sector_t) freebits) * | |
1621 | (osb->s_clustersize >> osb->sb->s_blocksize_bits); | |
1622 | buf->f_bavail = buf->f_bfree; | |
1623 | buf->f_files = numbits; | |
1624 | buf->f_ffree = freebits; | |
1625 | ||
1626 | brelse(bh); | |
1627 | ||
e63aecb6 | 1628 | ocfs2_inode_unlock(inode, 0); |
ccd979bd MF |
1629 | status = 0; |
1630 | bail: | |
1631 | if (inode) | |
1632 | iput(inode); | |
1633 | ||
1634 | mlog_exit(status); | |
1635 | ||
1636 | return status; | |
1637 | } | |
1638 | ||
51cc5068 | 1639 | static void ocfs2_inode_init_once(void *data) |
ccd979bd MF |
1640 | { |
1641 | struct ocfs2_inode_info *oi = data; | |
1642 | ||
a35afb83 CL |
1643 | oi->ip_flags = 0; |
1644 | oi->ip_open_count = 0; | |
1645 | spin_lock_init(&oi->ip_lock); | |
1646 | ocfs2_extent_map_init(&oi->vfs_inode); | |
1647 | INIT_LIST_HEAD(&oi->ip_io_markers); | |
1648 | oi->ip_created_trans = 0; | |
1649 | oi->ip_last_trans = 0; | |
1650 | oi->ip_dir_start_lookup = 0; | |
ccd979bd | 1651 | |
a35afb83 | 1652 | init_rwsem(&oi->ip_alloc_sem); |
cf1d6c76 | 1653 | init_rwsem(&oi->ip_xattr_sem); |
a35afb83 | 1654 | mutex_init(&oi->ip_io_mutex); |
ccd979bd | 1655 | |
a35afb83 CL |
1656 | oi->ip_blkno = 0ULL; |
1657 | oi->ip_clusters = 0; | |
ccd979bd | 1658 | |
a35afb83 | 1659 | ocfs2_lock_res_init_once(&oi->ip_rw_lockres); |
e63aecb6 | 1660 | ocfs2_lock_res_init_once(&oi->ip_inode_lockres); |
a35afb83 | 1661 | ocfs2_lock_res_init_once(&oi->ip_open_lockres); |
ccd979bd | 1662 | |
a35afb83 | 1663 | ocfs2_metadata_cache_init(&oi->vfs_inode); |
ccd979bd | 1664 | |
a35afb83 | 1665 | inode_init_once(&oi->vfs_inode); |
ccd979bd MF |
1666 | } |
1667 | ||
1668 | static int ocfs2_initialize_mem_caches(void) | |
1669 | { | |
1670 | ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache", | |
fffb60f9 PJ |
1671 | sizeof(struct ocfs2_inode_info), |
1672 | 0, | |
1673 | (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| | |
1674 | SLAB_MEM_SPREAD), | |
20c2df83 | 1675 | ocfs2_inode_init_once); |
9e33d69f JK |
1676 | ocfs2_dquot_cachep = kmem_cache_create("ocfs2_dquot_cache", |
1677 | sizeof(struct ocfs2_dquot), | |
1678 | 0, | |
1679 | (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| | |
1680 | SLAB_MEM_SPREAD), | |
1681 | NULL); | |
1682 | ocfs2_qf_chunk_cachep = kmem_cache_create("ocfs2_qf_chunk_cache", | |
1683 | sizeof(struct ocfs2_quota_chunk), | |
1684 | 0, | |
1685 | (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD), | |
1686 | NULL); | |
1687 | if (!ocfs2_inode_cachep || !ocfs2_dquot_cachep || | |
1688 | !ocfs2_qf_chunk_cachep) { | |
1689 | if (ocfs2_inode_cachep) | |
1690 | kmem_cache_destroy(ocfs2_inode_cachep); | |
1691 | if (ocfs2_dquot_cachep) | |
1692 | kmem_cache_destroy(ocfs2_dquot_cachep); | |
1693 | if (ocfs2_qf_chunk_cachep) | |
1694 | kmem_cache_destroy(ocfs2_qf_chunk_cachep); | |
ccd979bd | 1695 | return -ENOMEM; |
9e33d69f | 1696 | } |
ccd979bd | 1697 | |
ccd979bd MF |
1698 | return 0; |
1699 | } | |
1700 | ||
1701 | static void ocfs2_free_mem_caches(void) | |
1702 | { | |
1703 | if (ocfs2_inode_cachep) | |
1704 | kmem_cache_destroy(ocfs2_inode_cachep); | |
ccd979bd | 1705 | ocfs2_inode_cachep = NULL; |
9e33d69f JK |
1706 | |
1707 | if (ocfs2_dquot_cachep) | |
1708 | kmem_cache_destroy(ocfs2_dquot_cachep); | |
1709 | ocfs2_dquot_cachep = NULL; | |
1710 | ||
1711 | if (ocfs2_qf_chunk_cachep) | |
1712 | kmem_cache_destroy(ocfs2_qf_chunk_cachep); | |
1713 | ocfs2_qf_chunk_cachep = NULL; | |
ccd979bd MF |
1714 | } |
1715 | ||
1716 | static int ocfs2_get_sector(struct super_block *sb, | |
1717 | struct buffer_head **bh, | |
1718 | int block, | |
1719 | int sect_size) | |
1720 | { | |
1721 | if (!sb_set_blocksize(sb, sect_size)) { | |
1722 | mlog(ML_ERROR, "unable to set blocksize\n"); | |
1723 | return -EIO; | |
1724 | } | |
1725 | ||
1726 | *bh = sb_getblk(sb, block); | |
1727 | if (!*bh) { | |
1728 | mlog_errno(-EIO); | |
1729 | return -EIO; | |
1730 | } | |
1731 | lock_buffer(*bh); | |
1732 | if (!buffer_dirty(*bh)) | |
1733 | clear_buffer_uptodate(*bh); | |
1734 | unlock_buffer(*bh); | |
1735 | ll_rw_block(READ, 1, bh); | |
1736 | wait_on_buffer(*bh); | |
28d57d43 | 1737 | if (!buffer_uptodate(*bh)) { |
1738 | mlog_errno(-EIO); | |
1739 | brelse(*bh); | |
1740 | *bh = NULL; | |
1741 | return -EIO; | |
1742 | } | |
1743 | ||
ccd979bd MF |
1744 | return 0; |
1745 | } | |
1746 | ||
ccd979bd MF |
1747 | static int ocfs2_mount_volume(struct super_block *sb) |
1748 | { | |
1749 | int status = 0; | |
1750 | int unlock_super = 0; | |
1751 | struct ocfs2_super *osb = OCFS2_SB(sb); | |
1752 | ||
1753 | mlog_entry_void(); | |
1754 | ||
1755 | if (ocfs2_is_hard_readonly(osb)) | |
1756 | goto leave; | |
1757 | ||
ccd979bd MF |
1758 | status = ocfs2_dlm_init(osb); |
1759 | if (status < 0) { | |
1760 | mlog_errno(status); | |
1761 | goto leave; | |
1762 | } | |
1763 | ||
ccd979bd MF |
1764 | status = ocfs2_super_lock(osb, 1); |
1765 | if (status < 0) { | |
1766 | mlog_errno(status); | |
1767 | goto leave; | |
1768 | } | |
1769 | unlock_super = 1; | |
1770 | ||
1771 | /* This will load up the node map and add ourselves to it. */ | |
1772 | status = ocfs2_find_slot(osb); | |
1773 | if (status < 0) { | |
1774 | mlog_errno(status); | |
1775 | goto leave; | |
1776 | } | |
1777 | ||
ccd979bd MF |
1778 | /* load all node-local system inodes */ |
1779 | status = ocfs2_init_local_system_inodes(osb); | |
1780 | if (status < 0) { | |
1781 | mlog_errno(status); | |
1782 | goto leave; | |
1783 | } | |
1784 | ||
1785 | status = ocfs2_check_volume(osb); | |
1786 | if (status < 0) { | |
1787 | mlog_errno(status); | |
1788 | goto leave; | |
1789 | } | |
1790 | ||
1791 | status = ocfs2_truncate_log_init(osb); | |
06c59bb8 | 1792 | if (status < 0) |
ccd979bd | 1793 | mlog_errno(status); |
c271c5c2 | 1794 | |
ccd979bd MF |
1795 | leave: |
1796 | if (unlock_super) | |
1797 | ocfs2_super_unlock(osb, 1); | |
1798 | ||
1799 | mlog_exit(status); | |
1800 | return status; | |
1801 | } | |
1802 | ||
ccd979bd MF |
1803 | static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) |
1804 | { | |
286eaa95 | 1805 | int tmp, hangup_needed = 0; |
ccd979bd | 1806 | struct ocfs2_super *osb = NULL; |
c271c5c2 | 1807 | char nodestr[8]; |
ccd979bd MF |
1808 | |
1809 | mlog_entry("(0x%p)\n", sb); | |
1810 | ||
1811 | BUG_ON(!sb); | |
1812 | osb = OCFS2_SB(sb); | |
1813 | BUG_ON(!osb); | |
1814 | ||
50397507 SM |
1815 | debugfs_remove(osb->osb_ctxt); |
1816 | ||
692684e1 SM |
1817 | /* Orphan scan should be stopped as early as possible */ |
1818 | ocfs2_orphan_scan_stop(osb); | |
1819 | ||
19ece546 JK |
1820 | ocfs2_disable_quotas(osb); |
1821 | ||
ccd979bd MF |
1822 | ocfs2_shutdown_local_alloc(osb); |
1823 | ||
1824 | ocfs2_truncate_log_shutdown(osb); | |
1825 | ||
553abd04 JB |
1826 | /* This will disable recovery and flush any recovery work. */ |
1827 | ocfs2_recovery_exit(osb); | |
ccd979bd MF |
1828 | |
1829 | ocfs2_journal_shutdown(osb); | |
1830 | ||
1831 | ocfs2_sync_blockdev(sb); | |
1832 | ||
4670c46d JB |
1833 | /* No cluster connection means we've failed during mount, so skip |
1834 | * all the steps which depended on that to complete. */ | |
1835 | if (osb->cconn) { | |
ccd979bd MF |
1836 | tmp = ocfs2_super_lock(osb, 1); |
1837 | if (tmp < 0) { | |
1838 | mlog_errno(tmp); | |
1839 | return; | |
1840 | } | |
19b613d4 | 1841 | } |
ccd979bd | 1842 | |
19b613d4 MF |
1843 | if (osb->slot_num != OCFS2_INVALID_SLOT) |
1844 | ocfs2_put_slot(osb); | |
ccd979bd | 1845 | |
4670c46d | 1846 | if (osb->cconn) |
ccd979bd | 1847 | ocfs2_super_unlock(osb, 1); |
ccd979bd MF |
1848 | |
1849 | ocfs2_release_system_inodes(osb); | |
1850 | ||
6953b4c0 | 1851 | /* |
6953b4c0 JB |
1852 | * If we're dismounting due to mount error, mount.ocfs2 will clean |
1853 | * up heartbeat. If we're a local mount, there is no heartbeat. | |
1854 | * If we failed before we got a uuid_str yet, we can't stop | |
1855 | * heartbeat. Otherwise, do it. | |
1856 | */ | |
1857 | if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str) | |
286eaa95 JB |
1858 | hangup_needed = 1; |
1859 | ||
1860 | if (osb->cconn) | |
1861 | ocfs2_dlm_shutdown(osb, hangup_needed); | |
1862 | ||
73be192b | 1863 | ocfs2_blockcheck_stats_debugfs_remove(&osb->osb_ecc_stats); |
286eaa95 JB |
1864 | debugfs_remove(osb->osb_debug_root); |
1865 | ||
1866 | if (hangup_needed) | |
6953b4c0 | 1867 | ocfs2_cluster_hangup(osb->uuid_str, strlen(osb->uuid_str)); |
ccd979bd MF |
1868 | |
1869 | atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); | |
1870 | ||
c271c5c2 SM |
1871 | if (ocfs2_mount_local(osb)) |
1872 | snprintf(nodestr, sizeof(nodestr), "local"); | |
1873 | else | |
19fdb624 | 1874 | snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num); |
c271c5c2 SM |
1875 | |
1876 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n", | |
1877 | osb->dev_str, nodestr); | |
ccd979bd MF |
1878 | |
1879 | ocfs2_delete_osb(osb); | |
1880 | kfree(osb); | |
1881 | sb->s_dev = 0; | |
1882 | sb->s_fs_info = NULL; | |
1883 | } | |
1884 | ||
1885 | static int ocfs2_setup_osb_uuid(struct ocfs2_super *osb, const unsigned char *uuid, | |
1886 | unsigned uuid_bytes) | |
1887 | { | |
1888 | int i, ret; | |
1889 | char *ptr; | |
1890 | ||
1891 | BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN); | |
1892 | ||
cd861280 | 1893 | osb->uuid_str = kzalloc(OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL); |
ccd979bd MF |
1894 | if (osb->uuid_str == NULL) |
1895 | return -ENOMEM; | |
1896 | ||
ccd979bd MF |
1897 | for (i = 0, ptr = osb->uuid_str; i < OCFS2_VOL_UUID_LEN; i++) { |
1898 | /* print with null */ | |
1899 | ret = snprintf(ptr, 3, "%02X", uuid[i]); | |
1900 | if (ret != 2) /* drop super cleans up */ | |
1901 | return -EINVAL; | |
1902 | /* then only advance past the last char */ | |
1903 | ptr += 2; | |
1904 | } | |
1905 | ||
1906 | return 0; | |
1907 | } | |
1908 | ||
1909 | static int ocfs2_initialize_super(struct super_block *sb, | |
1910 | struct buffer_head *bh, | |
73be192b JB |
1911 | int sector_size, |
1912 | struct ocfs2_blockcheck_stats *stats) | |
ccd979bd | 1913 | { |
bddb8eb3 | 1914 | int status; |
5a254031 MF |
1915 | int i, cbits, bbits; |
1916 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data; | |
ccd979bd | 1917 | struct inode *inode = NULL; |
ccd979bd MF |
1918 | struct ocfs2_journal *journal; |
1919 | __le32 uuid_net_key; | |
1920 | struct ocfs2_super *osb; | |
1921 | ||
1922 | mlog_entry_void(); | |
1923 | ||
cd861280 | 1924 | osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL); |
ccd979bd MF |
1925 | if (!osb) { |
1926 | status = -ENOMEM; | |
1927 | mlog_errno(status); | |
1928 | goto bail; | |
1929 | } | |
1930 | ||
1931 | sb->s_fs_info = osb; | |
1932 | sb->s_op = &ocfs2_sops; | |
1933 | sb->s_export_op = &ocfs2_export_ops; | |
19ece546 JK |
1934 | sb->s_qcop = &ocfs2_quotactl_ops; |
1935 | sb->dq_op = &ocfs2_quota_operations; | |
cf1d6c76 | 1936 | sb->s_xattr = ocfs2_xattr_handlers; |
e0dceaf0 | 1937 | sb->s_time_gran = 1; |
ccd979bd MF |
1938 | sb->s_flags |= MS_NOATIME; |
1939 | /* this is needed to support O_LARGEFILE */ | |
5a254031 MF |
1940 | cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits); |
1941 | bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits); | |
1942 | sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits); | |
ccd979bd | 1943 | |
9b7895ef MF |
1944 | osb->osb_dx_mask = (1 << (cbits - bbits)) - 1; |
1945 | ||
1946 | for (i = 0; i < 3; i++) | |
1947 | osb->osb_dx_seed[i] = le32_to_cpu(di->id2.i_super.s_dx_seed[i]); | |
1948 | osb->osb_dx_seed[3] = le32_to_cpu(di->id2.i_super.s_uuid_hash); | |
1949 | ||
ccd979bd MF |
1950 | osb->sb = sb; |
1951 | /* Save off for ocfs2_rw_direct */ | |
1952 | osb->s_sectsize_bits = blksize_bits(sector_size); | |
ebdec83b | 1953 | BUG_ON(!osb->s_sectsize_bits); |
ccd979bd | 1954 | |
34d024f8 MF |
1955 | spin_lock_init(&osb->dc_task_lock); |
1956 | init_waitqueue_head(&osb->dc_event); | |
1957 | osb->dc_work_sequence = 0; | |
1958 | osb->dc_wake_sequence = 0; | |
ccd979bd MF |
1959 | INIT_LIST_HEAD(&osb->blocked_lock_list); |
1960 | osb->blocked_lock_count = 0; | |
ccd979bd | 1961 | spin_lock_init(&osb->osb_lock); |
c8b9cf9a | 1962 | spin_lock_init(&osb->osb_xattr_lock); |
4d0ddb2c | 1963 | ocfs2_init_inode_steal_slot(osb); |
ccd979bd MF |
1964 | |
1965 | atomic_set(&osb->alloc_stats.moves, 0); | |
1966 | atomic_set(&osb->alloc_stats.local_data, 0); | |
1967 | atomic_set(&osb->alloc_stats.bitmap_data, 0); | |
1968 | atomic_set(&osb->alloc_stats.bg_allocs, 0); | |
1969 | atomic_set(&osb->alloc_stats.bg_extends, 0); | |
1970 | ||
73be192b JB |
1971 | /* Copy the blockcheck stats from the superblock probe */ |
1972 | osb->osb_ecc_stats = *stats; | |
1973 | ||
ccd979bd MF |
1974 | ocfs2_init_node_maps(osb); |
1975 | ||
1976 | snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", | |
1977 | MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); | |
1978 | ||
553abd04 JB |
1979 | status = ocfs2_recovery_init(osb); |
1980 | if (status) { | |
1981 | mlog(ML_ERROR, "Unable to initialize recovery state\n"); | |
1982 | mlog_errno(status); | |
1983 | goto bail; | |
1984 | } | |
ccd979bd | 1985 | |
83273932 SE |
1986 | status = ocfs2_orphan_scan_init(osb); |
1987 | if (status) { | |
1988 | mlog(ML_ERROR, "Unable to initialize delayed orphan scan\n"); | |
1989 | mlog_errno(status); | |
1990 | goto bail; | |
1991 | } | |
1992 | ||
ccd979bd MF |
1993 | init_waitqueue_head(&osb->checkpoint_event); |
1994 | atomic_set(&osb->needs_checkpoint, 0); | |
1995 | ||
7f1a37e3 TY |
1996 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; |
1997 | ||
ccd979bd MF |
1998 | osb->slot_num = OCFS2_INVALID_SLOT; |
1999 | ||
8154da3d TY |
2000 | osb->s_xattr_inline_size = le16_to_cpu( |
2001 | di->id2.i_super.s_xattr_inline_size); | |
fdd77704 | 2002 | |
ccd979bd MF |
2003 | osb->local_alloc_state = OCFS2_LA_UNUSED; |
2004 | osb->local_alloc_bh = NULL; | |
9c7af40b | 2005 | INIT_DELAYED_WORK(&osb->la_enable_wq, ocfs2_la_enable_worker); |
ccd979bd | 2006 | |
ccd979bd MF |
2007 | init_waitqueue_head(&osb->osb_mount_event); |
2008 | ||
2009 | osb->vol_label = kmalloc(OCFS2_MAX_VOL_LABEL_LEN, GFP_KERNEL); | |
2010 | if (!osb->vol_label) { | |
2011 | mlog(ML_ERROR, "unable to alloc vol label\n"); | |
2012 | status = -ENOMEM; | |
2013 | goto bail; | |
2014 | } | |
2015 | ||
ccd979bd MF |
2016 | osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots); |
2017 | if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) { | |
2018 | mlog(ML_ERROR, "Invalid number of node slots (%u)\n", | |
2019 | osb->max_slots); | |
2020 | status = -EINVAL; | |
2021 | goto bail; | |
2022 | } | |
781ee3e2 | 2023 | mlog(0, "max_slots for this device: %u\n", osb->max_slots); |
ccd979bd | 2024 | |
539d8264 SM |
2025 | osb->slot_recovery_generations = |
2026 | kcalloc(osb->max_slots, sizeof(*osb->slot_recovery_generations), | |
2027 | GFP_KERNEL); | |
2028 | if (!osb->slot_recovery_generations) { | |
2029 | status = -ENOMEM; | |
2030 | mlog_errno(status); | |
2031 | goto bail; | |
2032 | } | |
2033 | ||
b4df6ed8 MF |
2034 | init_waitqueue_head(&osb->osb_wipe_event); |
2035 | osb->osb_orphan_wipes = kcalloc(osb->max_slots, | |
2036 | sizeof(*osb->osb_orphan_wipes), | |
2037 | GFP_KERNEL); | |
2038 | if (!osb->osb_orphan_wipes) { | |
2039 | status = -ENOMEM; | |
2040 | mlog_errno(status); | |
2041 | goto bail; | |
2042 | } | |
2043 | ||
ccd979bd MF |
2044 | osb->s_feature_compat = |
2045 | le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_compat); | |
2046 | osb->s_feature_ro_compat = | |
2047 | le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_ro_compat); | |
2048 | osb->s_feature_incompat = | |
2049 | le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_incompat); | |
2050 | ||
2051 | if ((i = OCFS2_HAS_INCOMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_INCOMPAT_SUPP))) { | |
2052 | mlog(ML_ERROR, "couldn't mount because of unsupported " | |
2053 | "optional features (%x).\n", i); | |
2054 | status = -EINVAL; | |
2055 | goto bail; | |
2056 | } | |
2057 | if (!(osb->sb->s_flags & MS_RDONLY) && | |
2058 | (i = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP))) { | |
2059 | mlog(ML_ERROR, "couldn't mount RDWR because of " | |
2060 | "unsupported optional features (%x).\n", i); | |
2061 | status = -EINVAL; | |
2062 | goto bail; | |
2063 | } | |
2064 | ||
b61817e1 JB |
2065 | if (ocfs2_userspace_stack(osb)) { |
2066 | memcpy(osb->osb_cluster_stack, | |
2067 | OCFS2_RAW_SB(di)->s_cluster_info.ci_stack, | |
2068 | OCFS2_STACK_LABEL_LEN); | |
2069 | osb->osb_cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0'; | |
2070 | if (strlen(osb->osb_cluster_stack) != OCFS2_STACK_LABEL_LEN) { | |
2071 | mlog(ML_ERROR, | |
2072 | "couldn't mount because of an invalid " | |
2073 | "cluster stack label (%s) \n", | |
2074 | osb->osb_cluster_stack); | |
2075 | status = -EINVAL; | |
2076 | goto bail; | |
2077 | } | |
2078 | } else { | |
2079 | /* The empty string is identical with classic tools that | |
2080 | * don't know about s_cluster_info. */ | |
2081 | osb->osb_cluster_stack[0] = '\0'; | |
2082 | } | |
2083 | ||
ccd979bd MF |
2084 | get_random_bytes(&osb->s_next_generation, sizeof(u32)); |
2085 | ||
2086 | /* FIXME | |
2087 | * This should be done in ocfs2_journal_init(), but unknown | |
2088 | * ordering issues will cause the filesystem to crash. | |
2089 | * If anyone wants to figure out what part of the code | |
2090 | * refers to osb->journal before ocfs2_journal_init() is run, | |
2091 | * be my guest. | |
2092 | */ | |
2093 | /* initialize our journal structure */ | |
2094 | ||
cd861280 | 2095 | journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL); |
ccd979bd MF |
2096 | if (!journal) { |
2097 | mlog(ML_ERROR, "unable to alloc journal\n"); | |
2098 | status = -ENOMEM; | |
2099 | goto bail; | |
2100 | } | |
2101 | osb->journal = journal; | |
2102 | journal->j_osb = osb; | |
2103 | ||
2104 | atomic_set(&journal->j_num_trans, 0); | |
2105 | init_rwsem(&journal->j_trans_barrier); | |
2106 | init_waitqueue_head(&journal->j_checkpointed); | |
2107 | spin_lock_init(&journal->j_lock); | |
2108 | journal->j_trans_id = (unsigned long) 1; | |
2109 | INIT_LIST_HEAD(&journal->j_la_cleanups); | |
c4028958 | 2110 | INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery); |
ccd979bd MF |
2111 | journal->j_state = OCFS2_JOURNAL_FREE; |
2112 | ||
ea455f8a JK |
2113 | INIT_WORK(&osb->dentry_lock_work, ocfs2_drop_dl_inodes); |
2114 | osb->dentry_lock_list = NULL; | |
2115 | ||
ccd979bd MF |
2116 | /* get some pseudo constants for clustersize bits */ |
2117 | osb->s_clustersize_bits = | |
2118 | le32_to_cpu(di->id2.i_super.s_clustersize_bits); | |
2119 | osb->s_clustersize = 1 << osb->s_clustersize_bits; | |
2120 | mlog(0, "clusterbits=%d\n", osb->s_clustersize_bits); | |
2121 | ||
2122 | if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE || | |
2123 | osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) { | |
2124 | mlog(ML_ERROR, "Volume has invalid cluster size (%d)\n", | |
2125 | osb->s_clustersize); | |
2126 | status = -EINVAL; | |
2127 | goto bail; | |
2128 | } | |
2129 | ||
2130 | if (ocfs2_clusters_to_blocks(osb->sb, le32_to_cpu(di->i_clusters) - 1) | |
2131 | > (u32)~0UL) { | |
2132 | mlog(ML_ERROR, "Volume might try to write to blocks beyond " | |
2133 | "what jbd can address in 32 bits.\n"); | |
2134 | status = -EINVAL; | |
2135 | goto bail; | |
2136 | } | |
2137 | ||
2138 | if (ocfs2_setup_osb_uuid(osb, di->id2.i_super.s_uuid, | |
2139 | sizeof(di->id2.i_super.s_uuid))) { | |
2140 | mlog(ML_ERROR, "Out of memory trying to setup our uuid.\n"); | |
2141 | status = -ENOMEM; | |
2142 | goto bail; | |
2143 | } | |
2144 | ||
78427043 | 2145 | memcpy(&uuid_net_key, di->id2.i_super.s_uuid, sizeof(uuid_net_key)); |
ccd979bd MF |
2146 | |
2147 | strncpy(osb->vol_label, di->id2.i_super.s_label, 63); | |
2148 | osb->vol_label[63] = '\0'; | |
2149 | osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno); | |
2150 | osb->system_dir_blkno = le64_to_cpu(di->id2.i_super.s_system_dir_blkno); | |
2151 | osb->first_cluster_group_blkno = | |
2152 | le64_to_cpu(di->id2.i_super.s_first_cluster_group); | |
2153 | osb->fs_generation = le32_to_cpu(di->i_fs_generation); | |
cf1d6c76 | 2154 | osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash); |
ccd979bd MF |
2155 | mlog(0, "vol_label: %s\n", osb->vol_label); |
2156 | mlog(0, "uuid: %s\n", osb->uuid_str); | |
b0697053 MF |
2157 | mlog(0, "root_blkno=%llu, system_dir_blkno=%llu\n", |
2158 | (unsigned long long)osb->root_blkno, | |
2159 | (unsigned long long)osb->system_dir_blkno); | |
ccd979bd MF |
2160 | |
2161 | osb->osb_dlm_debug = ocfs2_new_dlm_debug(); | |
2162 | if (!osb->osb_dlm_debug) { | |
2163 | status = -ENOMEM; | |
2164 | mlog_errno(status); | |
2165 | goto bail; | |
2166 | } | |
2167 | ||
2168 | atomic_set(&osb->vol_state, VOLUME_INIT); | |
2169 | ||
2170 | /* load root, system_dir, and all global system inodes */ | |
2171 | status = ocfs2_init_global_system_inodes(osb); | |
2172 | if (status < 0) { | |
2173 | mlog_errno(status); | |
2174 | goto bail; | |
2175 | } | |
2176 | ||
2177 | /* | |
2178 | * global bitmap | |
2179 | */ | |
2180 | inode = ocfs2_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, | |
2181 | OCFS2_INVALID_SLOT); | |
2182 | if (!inode) { | |
2183 | status = -EINVAL; | |
2184 | mlog_errno(status); | |
2185 | goto bail; | |
2186 | } | |
2187 | ||
2188 | osb->bitmap_blkno = OCFS2_I(inode)->ip_blkno; | |
ccd979bd | 2189 | iput(inode); |
ccd979bd | 2190 | |
e9d578a8 | 2191 | osb->bitmap_cpg = ocfs2_group_bitmap_size(sb) * 8; |
ccd979bd MF |
2192 | |
2193 | status = ocfs2_init_slot_info(osb); | |
2194 | if (status < 0) { | |
2195 | mlog_errno(status); | |
2196 | goto bail; | |
2197 | } | |
2198 | ||
ccd979bd MF |
2199 | bail: |
2200 | mlog_exit(status); | |
2201 | return status; | |
2202 | } | |
2203 | ||
2204 | /* | |
2205 | * will return: -EAGAIN if it is ok to keep searching for superblocks | |
2206 | * -EINVAL if there is a bad superblock | |
2207 | * 0 on success | |
2208 | */ | |
2209 | static int ocfs2_verify_volume(struct ocfs2_dinode *di, | |
2210 | struct buffer_head *bh, | |
73be192b JB |
2211 | u32 blksz, |
2212 | struct ocfs2_blockcheck_stats *stats) | |
ccd979bd MF |
2213 | { |
2214 | int status = -EAGAIN; | |
2215 | ||
2216 | mlog_entry_void(); | |
2217 | ||
2218 | if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE, | |
2219 | strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) { | |
d030cc97 JB |
2220 | /* We have to do a raw check of the feature here */ |
2221 | if (le32_to_cpu(di->id2.i_super.s_feature_incompat) & | |
2222 | OCFS2_FEATURE_INCOMPAT_META_ECC) { | |
2223 | status = ocfs2_block_check_validate(bh->b_data, | |
2224 | bh->b_size, | |
73be192b JB |
2225 | &di->i_check, |
2226 | stats); | |
d030cc97 JB |
2227 | if (status) |
2228 | goto out; | |
2229 | } | |
ccd979bd MF |
2230 | status = -EINVAL; |
2231 | if ((1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits)) != blksz) { | |
2232 | mlog(ML_ERROR, "found superblock with incorrect block " | |
2233 | "size: found %u, should be %u\n", | |
2234 | 1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits), | |
2235 | blksz); | |
2236 | } else if (le16_to_cpu(di->id2.i_super.s_major_rev_level) != | |
2237 | OCFS2_MAJOR_REV_LEVEL || | |
2238 | le16_to_cpu(di->id2.i_super.s_minor_rev_level) != | |
2239 | OCFS2_MINOR_REV_LEVEL) { | |
2240 | mlog(ML_ERROR, "found superblock with bad version: " | |
2241 | "found %u.%u, should be %u.%u\n", | |
2242 | le16_to_cpu(di->id2.i_super.s_major_rev_level), | |
2243 | le16_to_cpu(di->id2.i_super.s_minor_rev_level), | |
2244 | OCFS2_MAJOR_REV_LEVEL, | |
2245 | OCFS2_MINOR_REV_LEVEL); | |
2246 | } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) { | |
2247 | mlog(ML_ERROR, "bad block number on superblock: " | |
b0697053 | 2248 | "found %llu, should be %llu\n", |
1ca1a111 | 2249 | (unsigned long long)le64_to_cpu(di->i_blkno), |
b0697053 | 2250 | (unsigned long long)bh->b_blocknr); |
ccd979bd MF |
2251 | } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 || |
2252 | le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) { | |
2253 | mlog(ML_ERROR, "bad cluster size found: %u\n", | |
2254 | 1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits)); | |
2255 | } else if (!le64_to_cpu(di->id2.i_super.s_root_blkno)) { | |
2256 | mlog(ML_ERROR, "bad root_blkno: 0\n"); | |
2257 | } else if (!le64_to_cpu(di->id2.i_super.s_system_dir_blkno)) { | |
2258 | mlog(ML_ERROR, "bad system_dir_blkno: 0\n"); | |
2259 | } else if (le16_to_cpu(di->id2.i_super.s_max_slots) > OCFS2_MAX_SLOTS) { | |
2260 | mlog(ML_ERROR, | |
2261 | "Superblock slots found greater than file system " | |
2262 | "maximum: found %u, max %u\n", | |
2263 | le16_to_cpu(di->id2.i_super.s_max_slots), | |
2264 | OCFS2_MAX_SLOTS); | |
2265 | } else { | |
2266 | /* found it! */ | |
2267 | status = 0; | |
2268 | } | |
2269 | } | |
2270 | ||
d030cc97 | 2271 | out: |
ccd979bd MF |
2272 | mlog_exit(status); |
2273 | return status; | |
2274 | } | |
2275 | ||
2276 | static int ocfs2_check_volume(struct ocfs2_super *osb) | |
2277 | { | |
bddb8eb3 | 2278 | int status; |
ccd979bd | 2279 | int dirty; |
c271c5c2 | 2280 | int local; |
ccd979bd MF |
2281 | struct ocfs2_dinode *local_alloc = NULL; /* only used if we |
2282 | * recover | |
2283 | * ourselves. */ | |
2284 | ||
2285 | mlog_entry_void(); | |
2286 | ||
2287 | /* Init our journal object. */ | |
2288 | status = ocfs2_journal_init(osb->journal, &dirty); | |
2289 | if (status < 0) { | |
2290 | mlog(ML_ERROR, "Could not initialize journal!\n"); | |
2291 | goto finally; | |
2292 | } | |
2293 | ||
2294 | /* If the journal was unmounted cleanly then we don't want to | |
2295 | * recover anything. Otherwise, journal_load will do that | |
2296 | * dirty work for us :) */ | |
2297 | if (!dirty) { | |
2298 | status = ocfs2_journal_wipe(osb->journal, 0); | |
2299 | if (status < 0) { | |
2300 | mlog_errno(status); | |
2301 | goto finally; | |
2302 | } | |
2303 | } else { | |
2304 | mlog(ML_NOTICE, "File system was not unmounted cleanly, " | |
2305 | "recovering volume.\n"); | |
2306 | } | |
2307 | ||
c271c5c2 SM |
2308 | local = ocfs2_mount_local(osb); |
2309 | ||
ccd979bd | 2310 | /* will play back anything left in the journal. */ |
539d8264 | 2311 | status = ocfs2_journal_load(osb->journal, local, dirty); |
01af4820 WW |
2312 | if (status < 0) { |
2313 | mlog(ML_ERROR, "ocfs2 journal load failed! %d\n", status); | |
2314 | goto finally; | |
2315 | } | |
ccd979bd MF |
2316 | |
2317 | if (dirty) { | |
2318 | /* recover my local alloc if we didn't unmount cleanly. */ | |
2319 | status = ocfs2_begin_local_alloc_recovery(osb, | |
2320 | osb->slot_num, | |
2321 | &local_alloc); | |
2322 | if (status < 0) { | |
2323 | mlog_errno(status); | |
2324 | goto finally; | |
2325 | } | |
2326 | /* we complete the recovery process after we've marked | |
2327 | * ourselves as mounted. */ | |
2328 | } | |
2329 | ||
2330 | mlog(0, "Journal loaded.\n"); | |
2331 | ||
2332 | status = ocfs2_load_local_alloc(osb); | |
2333 | if (status < 0) { | |
2334 | mlog_errno(status); | |
2335 | goto finally; | |
2336 | } | |
2337 | ||
2338 | if (dirty) { | |
2339 | /* Recovery will be completed after we've mounted the | |
2340 | * rest of the volume. */ | |
2341 | osb->dirty = 1; | |
2342 | osb->local_alloc_copy = local_alloc; | |
2343 | local_alloc = NULL; | |
2344 | } | |
2345 | ||
2346 | /* go through each journal, trylock it and if you get the | |
2347 | * lock, and it's marked as dirty, set the bit in the recover | |
2348 | * map and launch a recovery thread for it. */ | |
2349 | status = ocfs2_mark_dead_nodes(osb); | |
9140db04 SE |
2350 | if (status < 0) { |
2351 | mlog_errno(status); | |
2352 | goto finally; | |
2353 | } | |
2354 | ||
2355 | status = ocfs2_compute_replay_slots(osb); | |
ccd979bd MF |
2356 | if (status < 0) |
2357 | mlog_errno(status); | |
2358 | ||
2359 | finally: | |
2360 | if (local_alloc) | |
2361 | kfree(local_alloc); | |
2362 | ||
2363 | mlog_exit(status); | |
2364 | return status; | |
2365 | } | |
2366 | ||
2367 | /* | |
2368 | * The routine gets called from dismount or close whenever a dismount on | |
2369 | * volume is requested and the osb open count becomes 1. | |
2370 | * It will remove the osb from the global list and also free up all the | |
2371 | * initialized resources and fileobject. | |
2372 | */ | |
2373 | static void ocfs2_delete_osb(struct ocfs2_super *osb) | |
2374 | { | |
2375 | mlog_entry_void(); | |
2376 | ||
2377 | /* This function assumes that the caller has the main osb resource */ | |
2378 | ||
8e8a4603 | 2379 | ocfs2_free_slot_info(osb); |
ccd979bd | 2380 | |
b4df6ed8 | 2381 | kfree(osb->osb_orphan_wipes); |
539d8264 | 2382 | kfree(osb->slot_recovery_generations); |
ccd979bd MF |
2383 | /* FIXME |
2384 | * This belongs in journal shutdown, but because we have to | |
2385 | * allocate osb->journal at the start of ocfs2_initalize_osb(), | |
2386 | * we free it here. | |
2387 | */ | |
2388 | kfree(osb->journal); | |
2389 | if (osb->local_alloc_copy) | |
2390 | kfree(osb->local_alloc_copy); | |
2391 | kfree(osb->uuid_str); | |
2392 | ocfs2_put_dlm_debug(osb->osb_dlm_debug); | |
2393 | memset(osb, 0, sizeof(struct ocfs2_super)); | |
2394 | ||
2395 | mlog_exit_void(); | |
2396 | } | |
2397 | ||
2398 | /* Put OCFS2 into a readonly state, or (if the user specifies it), | |
2399 | * panic(). We do not support continue-on-error operation. */ | |
2400 | static void ocfs2_handle_error(struct super_block *sb) | |
2401 | { | |
2402 | struct ocfs2_super *osb = OCFS2_SB(sb); | |
2403 | ||
2404 | if (osb->s_mount_opt & OCFS2_MOUNT_ERRORS_PANIC) | |
2405 | panic("OCFS2: (device %s): panic forced after error\n", | |
2406 | sb->s_id); | |
2407 | ||
2408 | ocfs2_set_osb_flag(osb, OCFS2_OSB_ERROR_FS); | |
2409 | ||
2410 | if (sb->s_flags & MS_RDONLY && | |
2411 | (ocfs2_is_soft_readonly(osb) || | |
2412 | ocfs2_is_hard_readonly(osb))) | |
2413 | return; | |
2414 | ||
2415 | printk(KERN_CRIT "File system is now read-only due to the potential " | |
2416 | "of on-disk corruption. Please run fsck.ocfs2 once the file " | |
2417 | "system is unmounted.\n"); | |
2418 | sb->s_flags |= MS_RDONLY; | |
2419 | ocfs2_set_ro_flag(osb, 0); | |
2420 | } | |
2421 | ||
2422 | static char error_buf[1024]; | |
2423 | ||
2424 | void __ocfs2_error(struct super_block *sb, | |
2425 | const char *function, | |
2426 | const char *fmt, ...) | |
2427 | { | |
2428 | va_list args; | |
2429 | ||
2430 | va_start(args, fmt); | |
4a6e617a | 2431 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
ccd979bd MF |
2432 | va_end(args); |
2433 | ||
2434 | /* Not using mlog here because we want to show the actual | |
2435 | * function the error came from. */ | |
2436 | printk(KERN_CRIT "OCFS2: ERROR (device %s): %s: %s\n", | |
2437 | sb->s_id, function, error_buf); | |
2438 | ||
2439 | ocfs2_handle_error(sb); | |
2440 | } | |
2441 | ||
2442 | /* Handle critical errors. This is intentionally more drastic than | |
2443 | * ocfs2_handle_error, so we only use for things like journal errors, | |
2444 | * etc. */ | |
2445 | void __ocfs2_abort(struct super_block* sb, | |
2446 | const char *function, | |
2447 | const char *fmt, ...) | |
2448 | { | |
2449 | va_list args; | |
2450 | ||
2451 | va_start(args, fmt); | |
4a6e617a | 2452 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
ccd979bd MF |
2453 | va_end(args); |
2454 | ||
2455 | printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", | |
2456 | sb->s_id, function, error_buf); | |
2457 | ||
2458 | /* We don't have the cluster support yet to go straight to | |
2459 | * hard readonly in here. Until then, we want to keep | |
2460 | * ocfs2_abort() so that we can at least mark critical | |
2461 | * errors. | |
2462 | * | |
2463 | * TODO: This should abort the journal and alert other nodes | |
2464 | * that our slot needs recovery. */ | |
2465 | ||
2466 | /* Force a panic(). This stinks, but it's better than letting | |
2467 | * things continue without having a proper hard readonly | |
2468 | * here. */ | |
2469 | OCFS2_SB(sb)->s_mount_opt |= OCFS2_MOUNT_ERRORS_PANIC; | |
2470 | ocfs2_handle_error(sb); | |
2471 | } | |
2472 | ||
2473 | module_init(ocfs2_init); | |
2474 | module_exit(ocfs2_exit); |