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