Lines Matching refs:osb
101 static void ocfs2_delete_osb(struct ocfs2_super *osb);
107 static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb);
108 static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb);
109 static void ocfs2_release_system_inodes(struct ocfs2_super *osb);
110 static int ocfs2_check_volume(struct ocfs2_super *osb);
125 static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend);
126 static int ocfs2_enable_quotas(struct ocfs2_super *osb);
127 static void ocfs2_disable_quotas(struct ocfs2_super *osb);
216 static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) in ocfs2_osb_dump() argument
218 struct ocfs2_cluster_connection *cconn = osb->cconn; in ocfs2_osb_dump()
219 struct ocfs2_recovery_map *rm = osb->recovery_map; in ocfs2_osb_dump()
220 struct ocfs2_orphan_scan *os = &osb->osb_orphan_scan; in ocfs2_osb_dump()
226 "Device", osb->dev_str, osb->uuid_str, in ocfs2_osb_dump()
227 osb->fs_generation, osb->vol_label); in ocfs2_osb_dump()
231 atomic_read(&osb->vol_state), osb->osb_flags); in ocfs2_osb_dump()
235 osb->sb->s_blocksize, osb->s_clustersize); in ocfs2_osb_dump()
240 "Features", osb->s_feature_compat, in ocfs2_osb_dump()
241 osb->s_feature_incompat, osb->s_feature_ro_compat); in ocfs2_osb_dump()
245 osb->s_mount_opt, osb->s_atime_quantum); in ocfs2_osb_dump()
251 (*osb->osb_cluster_stack == '\0' ? in ocfs2_osb_dump()
252 "o2cb" : osb->osb_cluster_stack), in ocfs2_osb_dump()
258 spin_lock_irqsave(&osb->dc_task_lock, flags); in ocfs2_osb_dump()
262 (osb->dc_task ? task_pid_nr(osb->dc_task) : -1), in ocfs2_osb_dump()
263 osb->blocked_lock_count, osb->dc_wake_sequence, in ocfs2_osb_dump()
264 osb->dc_work_sequence); in ocfs2_osb_dump()
265 spin_unlock_irqrestore(&osb->dc_task_lock, flags); in ocfs2_osb_dump()
267 spin_lock(&osb->osb_lock); in ocfs2_osb_dump()
270 (osb->recovery_thread_task ? in ocfs2_osb_dump()
271 task_pid_nr(osb->recovery_thread_task) : -1)); in ocfs2_osb_dump()
280 spin_unlock(&osb->osb_lock); in ocfs2_osb_dump()
284 (osb->commit_task ? task_pid_nr(osb->commit_task) : -1), in ocfs2_osb_dump()
285 osb->osb_commit_interval); in ocfs2_osb_dump()
289 "Journal", osb->journal->j_state, in ocfs2_osb_dump()
290 osb->journal->j_trans_id, in ocfs2_osb_dump()
291 atomic_read(&osb->journal->j_num_trans)); in ocfs2_osb_dump()
297 atomic_read(&osb->alloc_stats.bitmap_data), in ocfs2_osb_dump()
298 atomic_read(&osb->alloc_stats.local_data), in ocfs2_osb_dump()
299 atomic_read(&osb->alloc_stats.bg_allocs), in ocfs2_osb_dump()
300 atomic_read(&osb->alloc_stats.moves), in ocfs2_osb_dump()
301 atomic_read(&osb->alloc_stats.bg_extends)); in ocfs2_osb_dump()
306 "LocalAlloc", osb->local_alloc_state, in ocfs2_osb_dump()
307 (unsigned long long)osb->la_last_gd, in ocfs2_osb_dump()
308 osb->local_alloc_bits, osb->local_alloc_default_bits); in ocfs2_osb_dump()
310 spin_lock(&osb->osb_lock); in ocfs2_osb_dump()
314 osb->s_inode_steal_slot, in ocfs2_osb_dump()
315 atomic_read(&osb->s_num_inodes_stolen), in ocfs2_osb_dump()
316 osb->s_meta_steal_slot, in ocfs2_osb_dump()
317 atomic_read(&osb->s_num_meta_stolen)); in ocfs2_osb_dump()
318 spin_unlock(&osb->osb_lock); in ocfs2_osb_dump()
332 for (i = 0; i < osb->max_slots; ++i) { in ocfs2_osb_dump()
336 (i == osb->slot_num ? '*' : ' '), in ocfs2_osb_dump()
337 i, osb->slot_recovery_generations[i]); in ocfs2_osb_dump()
345 struct ocfs2_super *osb = inode->i_private; in ocfs2_osb_debug_open() local
352 i_size_write(inode, ocfs2_osb_dump(osb, buf, PAGE_SIZE)); in ocfs2_osb_debug_open()
400 struct ocfs2_super *osb = OCFS2_SB(sb); in ocfs2_sync_fs() local
402 if (ocfs2_is_hard_readonly(osb)) in ocfs2_sync_fs()
406 status = ocfs2_flush_truncate_log(osb); in ocfs2_sync_fs()
410 ocfs2_schedule_truncate_log_flush(osb, 0); in ocfs2_sync_fs()
413 if (jbd2_journal_start_commit(osb->journal->j_journal, in ocfs2_sync_fs()
416 jbd2_log_wait_commit(osb->journal->j_journal, in ocfs2_sync_fs()
422 static int ocfs2_need_system_inode(struct ocfs2_super *osb, int ino) in ocfs2_need_system_inode() argument
424 if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA) in ocfs2_need_system_inode()
428 if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) in ocfs2_need_system_inode()
435 static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) in ocfs2_init_global_system_inodes() argument
441 new = ocfs2_iget(osb, osb->root_blkno, OCFS2_FI_FLAG_SYSFILE, 0); in ocfs2_init_global_system_inodes()
447 osb->root_inode = new; in ocfs2_init_global_system_inodes()
449 new = ocfs2_iget(osb, osb->system_dir_blkno, OCFS2_FI_FLAG_SYSFILE, 0); in ocfs2_init_global_system_inodes()
455 osb->sys_root_inode = new; in ocfs2_init_global_system_inodes()
459 if (!ocfs2_need_system_inode(osb, i)) in ocfs2_init_global_system_inodes()
461 new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); in ocfs2_init_global_system_inodes()
463 ocfs2_release_system_inodes(osb); in ocfs2_init_global_system_inodes()
464 status = ocfs2_is_soft_readonly(osb) ? -EROFS : -EINVAL; in ocfs2_init_global_system_inodes()
480 static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) in ocfs2_init_local_system_inodes() argument
489 if (!ocfs2_need_system_inode(osb, i)) in ocfs2_init_local_system_inodes()
491 new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); in ocfs2_init_local_system_inodes()
493 ocfs2_release_system_inodes(osb); in ocfs2_init_local_system_inodes()
494 status = ocfs2_is_soft_readonly(osb) ? -EROFS : -EINVAL; in ocfs2_init_local_system_inodes()
496 status, i, osb->slot_num); in ocfs2_init_local_system_inodes()
509 static void ocfs2_release_system_inodes(struct ocfs2_super *osb) in ocfs2_release_system_inodes() argument
515 inode = osb->global_system_inodes[i]; in ocfs2_release_system_inodes()
518 osb->global_system_inodes[i] = NULL; in ocfs2_release_system_inodes()
522 inode = osb->sys_root_inode; in ocfs2_release_system_inodes()
525 osb->sys_root_inode = NULL; in ocfs2_release_system_inodes()
528 inode = osb->root_inode; in ocfs2_release_system_inodes()
531 osb->root_inode = NULL; in ocfs2_release_system_inodes()
534 if (!osb->local_system_inodes) in ocfs2_release_system_inodes()
537 for (i = 0; i < NUM_LOCAL_SYSTEM_INODES * osb->max_slots; i++) { in ocfs2_release_system_inodes()
538 if (osb->local_system_inodes[i]) { in ocfs2_release_system_inodes()
539 iput(osb->local_system_inodes[i]); in ocfs2_release_system_inodes()
540 osb->local_system_inodes[i] = NULL; in ocfs2_release_system_inodes()
544 kfree(osb->local_system_inodes); in ocfs2_release_system_inodes()
545 osb->local_system_inodes = NULL; in ocfs2_release_system_inodes()
612 struct ocfs2_super *osb = OCFS2_SB(sb); in ocfs2_remount() local
625 if ((osb->s_mount_opt & tmp) != (parsed_options.mount_opt & tmp)) { in ocfs2_remount()
631 if ((osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) != in ocfs2_remount()
640 if (!(osb->s_mount_opt & OCFS2_MOUNT_INODE64) && in ocfs2_remount()
651 ret = ocfs2_susp_quotas(osb, 0); in ocfs2_remount()
657 spin_lock(&osb->osb_lock); in ocfs2_remount()
658 if (osb->osb_flags & OCFS2_OSB_HARD_RO) { in ocfs2_remount()
666 osb->osb_flags |= OCFS2_OSB_SOFT_RO; in ocfs2_remount()
668 if (osb->osb_flags & OCFS2_OSB_ERROR_FS) { in ocfs2_remount()
683 osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; in ocfs2_remount()
685 trace_ocfs2_remount(sb->s_flags, osb->osb_flags, *flags); in ocfs2_remount()
687 spin_unlock(&osb->osb_lock); in ocfs2_remount()
691 ret = ocfs2_susp_quotas(osb, 1); in ocfs2_remount()
693 ret = ocfs2_enable_quotas(osb); in ocfs2_remount()
696 spin_lock(&osb->osb_lock); in ocfs2_remount()
698 osb->osb_flags |= OCFS2_OSB_SOFT_RO; in ocfs2_remount()
699 spin_unlock(&osb->osb_lock); in ocfs2_remount()
708 osb->s_mount_opt = parsed_options.mount_opt; in ocfs2_remount()
709 osb->s_atime_quantum = parsed_options.atime_quantum; in ocfs2_remount()
710 osb->preferred_slot = parsed_options.slot; in ocfs2_remount()
712 osb->osb_commit_interval = parsed_options.commit_interval; in ocfs2_remount()
714 if (!ocfs2_is_hard_readonly(osb)) in ocfs2_remount()
715 ocfs2_set_journal_params(osb); in ocfs2_remount()
718 ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ? in ocfs2_remount()
811 static int ocfs2_verify_heartbeat(struct ocfs2_super *osb) in ocfs2_verify_heartbeat() argument
815 if (osb->s_mount_opt & hb_enabled) { in ocfs2_verify_heartbeat()
816 if (ocfs2_mount_local(osb)) { in ocfs2_verify_heartbeat()
821 if (ocfs2_userspace_stack(osb)) { in ocfs2_verify_heartbeat()
826 if (((osb->s_mount_opt & OCFS2_MOUNT_HB_GLOBAL) && in ocfs2_verify_heartbeat()
827 !ocfs2_cluster_o2cb_global_heartbeat(osb)) || in ocfs2_verify_heartbeat()
828 ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) && in ocfs2_verify_heartbeat()
829 ocfs2_cluster_o2cb_global_heartbeat(osb))) { in ocfs2_verify_heartbeat()
835 if (!(osb->s_mount_opt & hb_enabled)) { in ocfs2_verify_heartbeat()
836 if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb) && in ocfs2_verify_heartbeat()
837 !ocfs2_userspace_stack(osb)) { in ocfs2_verify_heartbeat()
852 static int ocfs2_verify_userspace_stack(struct ocfs2_super *osb, in ocfs2_verify_userspace_stack() argument
855 if (!ocfs2_userspace_stack(osb) && mopt->cluster_stack[0]) { in ocfs2_verify_userspace_stack()
862 if (ocfs2_userspace_stack(osb) && in ocfs2_verify_userspace_stack()
863 strncmp(osb->osb_cluster_stack, mopt->cluster_stack, in ocfs2_verify_userspace_stack()
869 osb->osb_cluster_stack); in ocfs2_verify_userspace_stack()
876 static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend) in ocfs2_susp_quotas() argument
879 struct super_block *sb = osb->sb; in ocfs2_susp_quotas()
907 static int ocfs2_enable_quotas(struct ocfs2_super *osb) in ocfs2_enable_quotas() argument
910 struct super_block *sb = osb->sb; in ocfs2_enable_quotas()
924 inode[type] = ocfs2_get_system_file_inode(osb, ino[type], in ocfs2_enable_quotas()
925 osb->slot_num); in ocfs2_enable_quotas()
940 ocfs2_disable_quotas(osb); in ocfs2_enable_quotas()
947 static void ocfs2_disable_quotas(struct ocfs2_super *osb) in ocfs2_disable_quotas() argument
951 struct super_block *sb = osb->sb; in ocfs2_disable_quotas()
979 struct ocfs2_super *osb = NULL; in ocfs2_fill_super() local
999 osb = OCFS2_SB(sb); in ocfs2_fill_super()
1011 osb->s_mount_opt = parsed_options.mount_opt; in ocfs2_fill_super()
1012 osb->s_atime_quantum = parsed_options.atime_quantum; in ocfs2_fill_super()
1013 osb->preferred_slot = parsed_options.slot; in ocfs2_fill_super()
1014 osb->osb_commit_interval = parsed_options.commit_interval; in ocfs2_fill_super()
1016 ocfs2_la_set_sizes(osb, parsed_options.localalloc_opt); in ocfs2_fill_super()
1017 osb->osb_resv_level = parsed_options.resv_level; in ocfs2_fill_super()
1018 osb->osb_dir_resv_level = parsed_options.resv_level; in ocfs2_fill_super()
1020 osb->osb_dir_resv_level = parsed_options.resv_level; in ocfs2_fill_super()
1022 osb->osb_dir_resv_level = parsed_options.dir_resv_level; in ocfs2_fill_super()
1024 status = ocfs2_verify_userspace_stack(osb, &parsed_options); in ocfs2_fill_super()
1031 ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ? SB_POSIXACL : 0); in ocfs2_fill_super()
1045 if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { in ocfs2_fill_super()
1052 status = ocfs2_check_journals_nolocks(osb); in ocfs2_fill_super()
1063 ocfs2_set_ro_flag(osb, 1); in ocfs2_fill_super()
1067 "Recovery will be skipped.\n", osb->dev_str); in ocfs2_fill_super()
1070 if (!ocfs2_is_hard_readonly(osb)) { in ocfs2_fill_super()
1072 ocfs2_set_ro_flag(osb, 0); in ocfs2_fill_super()
1075 status = ocfs2_verify_heartbeat(osb); in ocfs2_fill_super()
1081 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, in ocfs2_fill_super()
1084 debugfs_create_file("fs_state", S_IFREG|S_IRUSR, osb->osb_debug_root, in ocfs2_fill_super()
1085 osb, &ocfs2_osb_debug_fops); in ocfs2_fill_super()
1087 if (ocfs2_meta_ecc(osb)) in ocfs2_fill_super()
1088 ocfs2_blockcheck_stats_debugfs_install( &osb->osb_ecc_stats, in ocfs2_fill_super()
1089 osb->osb_debug_root); in ocfs2_fill_super()
1095 if (osb->root_inode) in ocfs2_fill_super()
1096 inode = igrab(osb->root_inode); in ocfs2_fill_super()
1104 osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL, in ocfs2_fill_super()
1106 if (!osb->osb_dev_kset) { in ocfs2_fill_super()
1114 if (ocfs2_filecheck_create_sysfs(osb)) { in ocfs2_fill_super()
1130 ocfs2_complete_mount_recovery(osb); in ocfs2_fill_super()
1132 if (ocfs2_mount_local(osb)) in ocfs2_fill_super()
1135 snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num); in ocfs2_fill_super()
1139 osb->dev_str, nodestr, osb->slot_num, in ocfs2_fill_super()
1140 osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : in ocfs2_fill_super()
1143 atomic_set(&osb->vol_state, VOLUME_MOUNTED); in ocfs2_fill_super()
1144 wake_up(&osb->osb_mount_event); in ocfs2_fill_super()
1150 status = ocfs2_enable_quotas(osb); in ocfs2_fill_super()
1155 atomic_set(&osb->vol_state, VOLUME_DISABLED); in ocfs2_fill_super()
1156 wake_up(&osb->osb_mount_event); in ocfs2_fill_super()
1161 ocfs2_complete_quota_recovery(osb); in ocfs2_fill_super()
1164 atomic_set(&osb->vol_state, VOLUME_MOUNTED_QUOTAS); in ocfs2_fill_super()
1165 wake_up(&osb->osb_mount_event); in ocfs2_fill_super()
1168 ocfs2_orphan_scan_start(osb); in ocfs2_fill_super()
1178 if (osb) { in ocfs2_fill_super()
1179 atomic_set(&osb->vol_state, VOLUME_DISABLED); in ocfs2_fill_super()
1180 wake_up(&osb->osb_mount_event); in ocfs2_fill_super()
1478 struct ocfs2_super *osb = OCFS2_SB(root->d_sb); in ocfs2_show_options() local
1479 unsigned long opts = osb->s_mount_opt; in ocfs2_show_options()
1509 if (osb->preferred_slot != OCFS2_INVALID_SLOT) in ocfs2_show_options()
1510 seq_printf(s, ",preferred_slot=%d", osb->preferred_slot); in ocfs2_show_options()
1512 seq_printf(s, ",atime_quantum=%u", osb->s_atime_quantum); in ocfs2_show_options()
1514 if (osb->osb_commit_interval) in ocfs2_show_options()
1516 (unsigned) (osb->osb_commit_interval / HZ)); in ocfs2_show_options()
1518 local_alloc_megs = osb->local_alloc_bits >> (20 - osb->s_clustersize_bits); in ocfs2_show_options()
1519 if (local_alloc_megs != ocfs2_la_default_mb(osb)) in ocfs2_show_options()
1525 if (osb->osb_cluster_stack[0]) in ocfs2_show_options()
1526 seq_show_option_n(s, "cluster_stack", osb->osb_cluster_stack, in ocfs2_show_options()
1551 if (osb->osb_resv_level != OCFS2_DEFAULT_RESV_LEVEL) in ocfs2_show_options()
1552 seq_printf(s, ",resv_level=%d", osb->osb_resv_level); in ocfs2_show_options()
1554 if (osb->osb_dir_resv_level != osb->osb_resv_level) in ocfs2_show_options()
1555 seq_printf(s, ",dir_resv_level=%d", osb->osb_resv_level); in ocfs2_show_options()
1620 struct ocfs2_super *osb; in ocfs2_statfs() local
1629 osb = OCFS2_SB(dentry->d_sb); in ocfs2_statfs()
1631 inode = ocfs2_get_system_file_inode(osb, in ocfs2_statfs()
1655 (osb->s_clustersize >> osb->sb->s_blocksize_bits); in ocfs2_statfs()
1657 (osb->s_clustersize >> osb->sb->s_blocksize_bits); in ocfs2_statfs()
1661 buf->f_fsid.val[0] = crc32_le(0, osb->uuid_str, OCFS2_VOL_UUID_LEN) in ocfs2_statfs()
1663 buf->f_fsid.val[1] = crc32_le(0, osb->uuid_str + OCFS2_VOL_UUID_LEN, in ocfs2_statfs()
1792 struct ocfs2_super *osb = OCFS2_SB(sb); in ocfs2_mount_volume() local
1794 if (ocfs2_is_hard_readonly(osb)) in ocfs2_mount_volume()
1797 mutex_init(&osb->obs_trim_fs_mutex); in ocfs2_mount_volume()
1799 status = ocfs2_dlm_init(osb); in ocfs2_mount_volume()
1802 if (status == -EBADR && ocfs2_userspace_stack(osb)) in ocfs2_mount_volume()
1808 status = ocfs2_super_lock(osb, 1); in ocfs2_mount_volume()
1816 status = ocfs2_find_slot(osb); in ocfs2_mount_volume()
1823 status = ocfs2_init_local_system_inodes(osb); in ocfs2_mount_volume()
1829 status = ocfs2_check_volume(osb); in ocfs2_mount_volume()
1835 status = ocfs2_truncate_log_init(osb); in ocfs2_mount_volume()
1841 ocfs2_super_unlock(osb, 1); in ocfs2_mount_volume()
1849 struct ocfs2_super *osb = NULL; in ocfs2_dismount_volume() local
1855 osb = OCFS2_SB(sb); in ocfs2_dismount_volume()
1856 BUG_ON(!osb); in ocfs2_dismount_volume()
1860 ocfs2_filecheck_remove_sysfs(osb); in ocfs2_dismount_volume()
1862 kset_unregister(osb->osb_dev_kset); in ocfs2_dismount_volume()
1865 ocfs2_orphan_scan_stop(osb); in ocfs2_dismount_volume()
1867 ocfs2_disable_quotas(osb); in ocfs2_dismount_volume()
1870 WARN_ON(!llist_empty(&osb->dquot_drop_list)); in ocfs2_dismount_volume()
1872 cancel_work_sync(&osb->dquot_drop_work); in ocfs2_dismount_volume()
1874 ocfs2_shutdown_local_alloc(osb); in ocfs2_dismount_volume()
1876 ocfs2_truncate_log_shutdown(osb); in ocfs2_dismount_volume()
1879 ocfs2_recovery_exit(osb); in ocfs2_dismount_volume()
1881 ocfs2_journal_shutdown(osb); in ocfs2_dismount_volume()
1885 ocfs2_purge_refcount_trees(osb); in ocfs2_dismount_volume()
1889 if (osb->cconn) { in ocfs2_dismount_volume()
1890 tmp = ocfs2_super_lock(osb, 1); in ocfs2_dismount_volume()
1897 if (osb->slot_num != OCFS2_INVALID_SLOT) in ocfs2_dismount_volume()
1898 ocfs2_put_slot(osb); in ocfs2_dismount_volume()
1900 if (osb->cconn) in ocfs2_dismount_volume()
1901 ocfs2_super_unlock(osb, 1); in ocfs2_dismount_volume()
1903 ocfs2_release_system_inodes(osb); in ocfs2_dismount_volume()
1911 if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str && in ocfs2_dismount_volume()
1912 !ocfs2_is_hard_readonly(osb)) in ocfs2_dismount_volume()
1915 if (osb->cconn) in ocfs2_dismount_volume()
1916 ocfs2_dlm_shutdown(osb, hangup_needed); in ocfs2_dismount_volume()
1918 ocfs2_blockcheck_stats_debugfs_remove(&osb->osb_ecc_stats); in ocfs2_dismount_volume()
1919 debugfs_remove_recursive(osb->osb_debug_root); in ocfs2_dismount_volume()
1922 ocfs2_cluster_hangup(osb->uuid_str, strlen(osb->uuid_str)); in ocfs2_dismount_volume()
1924 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); in ocfs2_dismount_volume()
1926 if (ocfs2_mount_local(osb)) in ocfs2_dismount_volume()
1929 snprintf(nodestr, sizeof(nodestr), "%u", osb->node_num); in ocfs2_dismount_volume()
1932 osb->dev_str, nodestr); in ocfs2_dismount_volume()
1934 ocfs2_delete_osb(osb); in ocfs2_dismount_volume()
1935 kfree(osb); in ocfs2_dismount_volume()
1940 static int ocfs2_setup_osb_uuid(struct ocfs2_super *osb, const unsigned char *uuid, in ocfs2_setup_osb_uuid() argument
1948 osb->uuid_str = kzalloc(OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL); in ocfs2_setup_osb_uuid()
1949 if (osb->uuid_str == NULL) in ocfs2_setup_osb_uuid()
1952 for (i = 0, ptr = osb->uuid_str; i < OCFS2_VOL_UUID_LEN; i++) { in ocfs2_setup_osb_uuid()
1967 static int ocfs2_journal_addressable(struct ocfs2_super *osb) in ocfs2_journal_addressable() argument
1971 ocfs2_clusters_to_blocks(osb->sb, in ocfs2_journal_addressable()
1972 osb->osb_clusters_at_boot) - 1; in ocfs2_journal_addressable()
1980 if (!(OCFS2_HAS_COMPAT_FEATURE(osb->sb, in ocfs2_journal_addressable()
1982 jbd2_journal_check_used_features(osb->journal->j_journal, 0, 0, in ocfs2_journal_addressable()
2004 struct ocfs2_super *osb; in ocfs2_initialize_super() local
2007 osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL); in ocfs2_initialize_super()
2008 if (!osb) { in ocfs2_initialize_super()
2014 sb->s_fs_info = osb; in ocfs2_initialize_super()
2031 osb->osb_dx_mask = (1 << (cbits - bbits)) - 1; in ocfs2_initialize_super()
2034 osb->osb_dx_seed[i] = le32_to_cpu(di->id2.i_super.s_dx_seed[i]); in ocfs2_initialize_super()
2035 osb->osb_dx_seed[3] = le32_to_cpu(di->id2.i_super.s_uuid_hash); in ocfs2_initialize_super()
2037 osb->sb = sb; in ocfs2_initialize_super()
2038 osb->s_sectsize_bits = blksize_bits(sector_size); in ocfs2_initialize_super()
2039 BUG_ON(!osb->s_sectsize_bits); in ocfs2_initialize_super()
2041 spin_lock_init(&osb->dc_task_lock); in ocfs2_initialize_super()
2042 init_waitqueue_head(&osb->dc_event); in ocfs2_initialize_super()
2043 osb->dc_work_sequence = 0; in ocfs2_initialize_super()
2044 osb->dc_wake_sequence = 0; in ocfs2_initialize_super()
2045 INIT_LIST_HEAD(&osb->blocked_lock_list); in ocfs2_initialize_super()
2046 osb->blocked_lock_count = 0; in ocfs2_initialize_super()
2047 spin_lock_init(&osb->osb_lock); in ocfs2_initialize_super()
2048 spin_lock_init(&osb->osb_xattr_lock); in ocfs2_initialize_super()
2049 ocfs2_init_steal_slots(osb); in ocfs2_initialize_super()
2051 mutex_init(&osb->system_file_mutex); in ocfs2_initialize_super()
2053 atomic_set(&osb->alloc_stats.moves, 0); in ocfs2_initialize_super()
2054 atomic_set(&osb->alloc_stats.local_data, 0); in ocfs2_initialize_super()
2055 atomic_set(&osb->alloc_stats.bitmap_data, 0); in ocfs2_initialize_super()
2056 atomic_set(&osb->alloc_stats.bg_allocs, 0); in ocfs2_initialize_super()
2057 atomic_set(&osb->alloc_stats.bg_extends, 0); in ocfs2_initialize_super()
2060 osb->osb_ecc_stats = *stats; in ocfs2_initialize_super()
2062 ocfs2_init_node_maps(osb); in ocfs2_initialize_super()
2064 snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", in ocfs2_initialize_super()
2065 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); in ocfs2_initialize_super()
2067 osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots); in ocfs2_initialize_super()
2068 if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) { in ocfs2_initialize_super()
2070 osb->max_slots); in ocfs2_initialize_super()
2075 ocfs2_orphan_scan_init(osb); in ocfs2_initialize_super()
2077 status = ocfs2_recovery_init(osb); in ocfs2_initialize_super()
2084 init_waitqueue_head(&osb->checkpoint_event); in ocfs2_initialize_super()
2086 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; in ocfs2_initialize_super()
2088 osb->slot_num = OCFS2_INVALID_SLOT; in ocfs2_initialize_super()
2090 osb->s_xattr_inline_size = le16_to_cpu( in ocfs2_initialize_super()
2093 osb->local_alloc_state = OCFS2_LA_UNUSED; in ocfs2_initialize_super()
2094 osb->local_alloc_bh = NULL; in ocfs2_initialize_super()
2095 INIT_DELAYED_WORK(&osb->la_enable_wq, ocfs2_la_enable_worker); in ocfs2_initialize_super()
2097 init_waitqueue_head(&osb->osb_mount_event); in ocfs2_initialize_super()
2099 status = ocfs2_resmap_init(osb, &osb->osb_la_resmap); in ocfs2_initialize_super()
2105 osb->vol_label = kmalloc(OCFS2_MAX_VOL_LABEL_LEN, GFP_KERNEL); in ocfs2_initialize_super()
2106 if (!osb->vol_label) { in ocfs2_initialize_super()
2112 osb->slot_recovery_generations = in ocfs2_initialize_super()
2113 kcalloc(osb->max_slots, sizeof(*osb->slot_recovery_generations), in ocfs2_initialize_super()
2115 if (!osb->slot_recovery_generations) { in ocfs2_initialize_super()
2121 init_waitqueue_head(&osb->osb_wipe_event); in ocfs2_initialize_super()
2122 osb->osb_orphan_wipes = kcalloc(osb->max_slots, in ocfs2_initialize_super()
2123 sizeof(*osb->osb_orphan_wipes), in ocfs2_initialize_super()
2125 if (!osb->osb_orphan_wipes) { in ocfs2_initialize_super()
2131 osb->osb_rf_lock_tree = RB_ROOT; in ocfs2_initialize_super()
2133 osb->s_feature_compat = in ocfs2_initialize_super()
2135 osb->s_feature_ro_compat = in ocfs2_initialize_super()
2137 osb->s_feature_incompat = in ocfs2_initialize_super()
2140 if ((i = OCFS2_HAS_INCOMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_INCOMPAT_SUPP))) { in ocfs2_initialize_super()
2146 …if (!sb_rdonly(osb->sb) && (i = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP… in ocfs2_initialize_super()
2153 if (ocfs2_clusterinfo_valid(osb)) { in ocfs2_initialize_super()
2160 osb->osb_stackflags = in ocfs2_initialize_super()
2162 memcpy(osb->osb_cluster_stack, in ocfs2_initialize_super()
2165 if (strlen(osb->osb_cluster_stack) != OCFS2_STACK_LABEL_LEN) { in ocfs2_initialize_super()
2169 osb->osb_cluster_stack); in ocfs2_initialize_super()
2173 memcpy(osb->osb_cluster_name, in ocfs2_initialize_super()
2179 osb->osb_cluster_stack[0] = '\0'; in ocfs2_initialize_super()
2182 get_random_bytes(&osb->s_next_generation, sizeof(u32)); in ocfs2_initialize_super()
2199 osb->journal = journal; in ocfs2_initialize_super()
2200 journal->j_osb = osb; in ocfs2_initialize_super()
2211 INIT_WORK(&osb->dquot_drop_work, ocfs2_drop_dquot_refs); in ocfs2_initialize_super()
2212 init_llist_head(&osb->dquot_drop_list); in ocfs2_initialize_super()
2215 osb->s_clustersize_bits = in ocfs2_initialize_super()
2217 osb->s_clustersize = 1 << osb->s_clustersize_bits; in ocfs2_initialize_super()
2219 if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE || in ocfs2_initialize_super()
2220 osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) { in ocfs2_initialize_super()
2222 osb->s_clustersize); in ocfs2_initialize_super()
2227 total_blocks = ocfs2_clusters_to_blocks(osb->sb, in ocfs2_initialize_super()
2230 status = generic_check_addressable(osb->sb->s_blocksize_bits, in ocfs2_initialize_super()
2239 if (ocfs2_setup_osb_uuid(osb, di->id2.i_super.s_uuid, in ocfs2_initialize_super()
2246 strlcpy(osb->vol_label, di->id2.i_super.s_label, in ocfs2_initialize_super()
2248 osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno); in ocfs2_initialize_super()
2249 osb->system_dir_blkno = le64_to_cpu(di->id2.i_super.s_system_dir_blkno); in ocfs2_initialize_super()
2250 osb->first_cluster_group_blkno = in ocfs2_initialize_super()
2252 osb->fs_generation = le32_to_cpu(di->i_fs_generation); in ocfs2_initialize_super()
2253 osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash); in ocfs2_initialize_super()
2254 trace_ocfs2_initialize_super(osb->vol_label, osb->uuid_str, in ocfs2_initialize_super()
2255 (unsigned long long)osb->root_blkno, in ocfs2_initialize_super()
2256 (unsigned long long)osb->system_dir_blkno, in ocfs2_initialize_super()
2257 osb->s_clustersize_bits); in ocfs2_initialize_super()
2259 osb->osb_dlm_debug = ocfs2_new_dlm_debug(); in ocfs2_initialize_super()
2260 if (!osb->osb_dlm_debug) { in ocfs2_initialize_super()
2266 atomic_set(&osb->vol_state, VOLUME_INIT); in ocfs2_initialize_super()
2269 status = ocfs2_init_global_system_inodes(osb); in ocfs2_initialize_super()
2278 inode = ocfs2_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, in ocfs2_initialize_super()
2286 osb->bitmap_blkno = OCFS2_I(inode)->ip_blkno; in ocfs2_initialize_super()
2287 osb->osb_clusters_at_boot = OCFS2_I(inode)->ip_clusters; in ocfs2_initialize_super()
2290 osb->bitmap_cpg = ocfs2_group_bitmap_size(sb, 0, in ocfs2_initialize_super()
2291 osb->s_feature_incompat) * 8; in ocfs2_initialize_super()
2293 status = ocfs2_init_slot_info(osb); in ocfs2_initialize_super()
2300 osb->ocfs2_wq = alloc_ordered_workqueue("ocfs2_wq", WQ_MEM_RECLAIM); in ocfs2_initialize_super()
2301 if (!osb->ocfs2_wq) { in ocfs2_initialize_super()
2381 static int ocfs2_check_volume(struct ocfs2_super *osb) in ocfs2_check_volume() argument
2391 status = ocfs2_journal_init(osb->journal, &dirty); in ocfs2_check_volume()
2399 status = ocfs2_journal_addressable(osb); in ocfs2_check_volume()
2407 status = ocfs2_journal_wipe(osb->journal, 0); in ocfs2_check_volume()
2414 "unmounted cleanly, recovering it.\n", osb->dev_str); in ocfs2_check_volume()
2417 local = ocfs2_mount_local(osb); in ocfs2_check_volume()
2420 status = ocfs2_journal_load(osb->journal, local, dirty); in ocfs2_check_volume()
2426 if (osb->s_mount_opt & OCFS2_MOUNT_JOURNAL_ASYNC_COMMIT) in ocfs2_check_volume()
2427 jbd2_journal_set_features(osb->journal->j_journal, in ocfs2_check_volume()
2431 jbd2_journal_clear_features(osb->journal->j_journal, in ocfs2_check_volume()
2437 status = ocfs2_begin_local_alloc_recovery(osb, in ocfs2_check_volume()
2438 osb->slot_num, in ocfs2_check_volume()
2448 status = ocfs2_load_local_alloc(osb); in ocfs2_check_volume()
2457 osb->local_alloc_copy = local_alloc; in ocfs2_check_volume()
2464 status = ocfs2_mark_dead_nodes(osb); in ocfs2_check_volume()
2470 status = ocfs2_compute_replay_slots(osb); in ocfs2_check_volume()
2488 static void ocfs2_delete_osb(struct ocfs2_super *osb) in ocfs2_delete_osb() argument
2493 if (osb->ocfs2_wq) in ocfs2_delete_osb()
2494 destroy_workqueue(osb->ocfs2_wq); in ocfs2_delete_osb()
2496 ocfs2_free_slot_info(osb); in ocfs2_delete_osb()
2498 kfree(osb->osb_orphan_wipes); in ocfs2_delete_osb()
2499 kfree(osb->slot_recovery_generations); in ocfs2_delete_osb()
2505 kfree(osb->journal); in ocfs2_delete_osb()
2506 kfree(osb->local_alloc_copy); in ocfs2_delete_osb()
2507 kfree(osb->uuid_str); in ocfs2_delete_osb()
2508 kfree(osb->vol_label); in ocfs2_delete_osb()
2509 ocfs2_put_dlm_debug(osb->osb_dlm_debug); in ocfs2_delete_osb()
2510 memset(osb, 0, sizeof(struct ocfs2_super)); in ocfs2_delete_osb()
2521 struct ocfs2_super *osb = OCFS2_SB(sb); in ocfs2_handle_error() local
2524 ocfs2_set_osb_flag(osb, OCFS2_OSB_ERROR_FS); in ocfs2_handle_error()
2528 if (osb->s_mount_opt & OCFS2_MOUNT_ERRORS_PANIC) { in ocfs2_handle_error()
2531 } else if (osb->s_mount_opt & OCFS2_MOUNT_ERRORS_CONT) { in ocfs2_handle_error()
2536 if (sb_rdonly(sb) && (ocfs2_is_soft_readonly(osb) || ocfs2_is_hard_readonly(osb))) in ocfs2_handle_error()
2541 ocfs2_set_ro_flag(osb, 0); in ocfs2_handle_error()