hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/ocfs2/super.c
....@@ -956,8 +956,10 @@
956956 for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
957957 if (!sb_has_quota_loaded(sb, type))
958958 continue;
959
- oinfo = sb_dqinfo(sb, type)->dqi_priv;
960
- cancel_delayed_work_sync(&oinfo->dqi_sync_work);
959
+ if (!sb_has_quota_suspended(sb, type)) {
960
+ oinfo = sb_dqinfo(sb, type)->dqi_priv;
961
+ cancel_delayed_work_sync(&oinfo->dqi_sync_work);
962
+ }
961963 inode = igrab(sb->s_dquot.files[type]);
962964 /* Turn off quotas. This will remove all dquot structures from
963965 * memory and so they will be automatically synced to global
....@@ -985,28 +987,27 @@
985987
986988 if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) {
987989 status = -EINVAL;
988
- goto read_super_error;
990
+ goto out;
989991 }
990992
991993 /* probe for superblock */
992994 status = ocfs2_sb_probe(sb, &bh, &sector_size, &stats);
993995 if (status < 0) {
994996 mlog(ML_ERROR, "superblock probe failed!\n");
995
- goto read_super_error;
997
+ goto out;
996998 }
997999
9981000 status = ocfs2_initialize_super(sb, bh, sector_size, &stats);
999
- osb = OCFS2_SB(sb);
1000
- if (status < 0) {
1001
- mlog_errno(status);
1002
- goto read_super_error;
1003
- }
10041001 brelse(bh);
10051002 bh = NULL;
1003
+ if (status < 0)
1004
+ goto out;
1005
+
1006
+ osb = OCFS2_SB(sb);
10061007
10071008 if (!ocfs2_check_set_options(sb, &parsed_options)) {
10081009 status = -EINVAL;
1009
- goto read_super_error;
1010
+ goto out_super;
10101011 }
10111012 osb->s_mount_opt = parsed_options.mount_opt;
10121013 osb->s_atime_quantum = parsed_options.atime_quantum;
....@@ -1023,7 +1024,7 @@
10231024
10241025 status = ocfs2_verify_userspace_stack(osb, &parsed_options);
10251026 if (status)
1026
- goto read_super_error;
1027
+ goto out_super;
10271028
10281029 sb->s_magic = OCFS2_SUPER_MAGIC;
10291030
....@@ -1037,7 +1038,7 @@
10371038 status = -EACCES;
10381039 mlog(ML_ERROR, "Readonly device detected but readonly "
10391040 "mount was not specified.\n");
1040
- goto read_super_error;
1041
+ goto out_super;
10411042 }
10421043
10431044 /* You should not be able to start a local heartbeat
....@@ -1046,7 +1047,7 @@
10461047 status = -EROFS;
10471048 mlog(ML_ERROR, "Local heartbeat specified on readonly "
10481049 "device.\n");
1049
- goto read_super_error;
1050
+ goto out_super;
10501051 }
10511052
10521053 status = ocfs2_check_journals_nolocks(osb);
....@@ -1055,9 +1056,7 @@
10551056 mlog(ML_ERROR, "Recovery required on readonly "
10561057 "file system, but write access is "
10571058 "unavailable.\n");
1058
- else
1059
- mlog_errno(status);
1060
- goto read_super_error;
1059
+ goto out_super;
10611060 }
10621061
10631062 ocfs2_set_ro_flag(osb, 1);
....@@ -1073,10 +1072,8 @@
10731072 }
10741073
10751074 status = ocfs2_verify_heartbeat(osb);
1076
- if (status < 0) {
1077
- mlog_errno(status);
1078
- goto read_super_error;
1079
- }
1075
+ if (status < 0)
1076
+ goto out_super;
10801077
10811078 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
10821079 ocfs2_debugfs_root);
....@@ -1090,15 +1087,14 @@
10901087
10911088 status = ocfs2_mount_volume(sb);
10921089 if (status < 0)
1093
- goto read_super_error;
1090
+ goto out_debugfs;
10941091
10951092 if (osb->root_inode)
10961093 inode = igrab(osb->root_inode);
10971094
10981095 if (!inode) {
10991096 status = -EIO;
1100
- mlog_errno(status);
1101
- goto read_super_error;
1097
+ goto out_dismount;
11021098 }
11031099
11041100 osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL,
....@@ -1106,7 +1102,7 @@
11061102 if (!osb->osb_dev_kset) {
11071103 status = -ENOMEM;
11081104 mlog(ML_ERROR, "Unable to create device kset %s.\n", sb->s_id);
1109
- goto read_super_error;
1105
+ goto out_dismount;
11101106 }
11111107
11121108 /* Create filecheck sysfs related directories/files at
....@@ -1115,14 +1111,13 @@
11151111 status = -ENOMEM;
11161112 mlog(ML_ERROR, "Unable to create filecheck sysfs directory at "
11171113 "/sys/fs/ocfs2/%s/filecheck.\n", sb->s_id);
1118
- goto read_super_error;
1114
+ goto out_dismount;
11191115 }
11201116
11211117 root = d_make_root(inode);
11221118 if (!root) {
11231119 status = -ENOMEM;
1124
- mlog_errno(status);
1125
- goto read_super_error;
1120
+ goto out_dismount;
11261121 }
11271122
11281123 sb->s_root = root;
....@@ -1169,17 +1164,22 @@
11691164
11701165 return status;
11711166
1172
-read_super_error:
1173
- brelse(bh);
1167
+out_dismount:
1168
+ atomic_set(&osb->vol_state, VOLUME_DISABLED);
1169
+ wake_up(&osb->osb_mount_event);
1170
+ ocfs2_free_replay_slots(osb);
1171
+ ocfs2_dismount_volume(sb, 1);
1172
+ goto out;
11741173
1175
- if (status)
1176
- mlog_errno(status);
1177
-
1178
- if (osb) {
1179
- atomic_set(&osb->vol_state, VOLUME_DISABLED);
1180
- wake_up(&osb->osb_mount_event);
1181
- ocfs2_dismount_volume(sb, 1);
1182
- }
1174
+out_debugfs:
1175
+ debugfs_remove_recursive(osb->osb_debug_root);
1176
+out_super:
1177
+ ocfs2_release_system_inodes(osb);
1178
+ kfree(osb->recovery_map);
1179
+ ocfs2_delete_osb(osb);
1180
+ kfree(osb);
1181
+out:
1182
+ mlog_errno(status);
11831183
11841184 return status;
11851185 }
....@@ -1788,11 +1788,10 @@
17881788 static int ocfs2_mount_volume(struct super_block *sb)
17891789 {
17901790 int status = 0;
1791
- int unlock_super = 0;
17921791 struct ocfs2_super *osb = OCFS2_SB(sb);
17931792
17941793 if (ocfs2_is_hard_readonly(osb))
1795
- goto leave;
1794
+ goto out;
17961795
17971796 mutex_init(&osb->obs_trim_fs_mutex);
17981797
....@@ -1802,44 +1801,58 @@
18021801 if (status == -EBADR && ocfs2_userspace_stack(osb))
18031802 mlog(ML_ERROR, "couldn't mount because cluster name on"
18041803 " disk does not match the running cluster name.\n");
1805
- goto leave;
1804
+ goto out;
18061805 }
18071806
18081807 status = ocfs2_super_lock(osb, 1);
18091808 if (status < 0) {
18101809 mlog_errno(status);
1811
- goto leave;
1810
+ goto out_dlm;
18121811 }
1813
- unlock_super = 1;
18141812
18151813 /* This will load up the node map and add ourselves to it. */
18161814 status = ocfs2_find_slot(osb);
18171815 if (status < 0) {
18181816 mlog_errno(status);
1819
- goto leave;
1817
+ goto out_super_lock;
18201818 }
18211819
18221820 /* load all node-local system inodes */
18231821 status = ocfs2_init_local_system_inodes(osb);
18241822 if (status < 0) {
18251823 mlog_errno(status);
1826
- goto leave;
1824
+ goto out_super_lock;
18271825 }
18281826
18291827 status = ocfs2_check_volume(osb);
18301828 if (status < 0) {
18311829 mlog_errno(status);
1832
- goto leave;
1830
+ goto out_system_inodes;
18331831 }
18341832
18351833 status = ocfs2_truncate_log_init(osb);
1836
- if (status < 0)
1834
+ if (status < 0) {
18371835 mlog_errno(status);
1836
+ goto out_check_volume;
1837
+ }
18381838
1839
-leave:
1840
- if (unlock_super)
1841
- ocfs2_super_unlock(osb, 1);
1839
+ ocfs2_super_unlock(osb, 1);
1840
+ return 0;
18421841
1842
+out_check_volume:
1843
+ ocfs2_free_replay_slots(osb);
1844
+out_system_inodes:
1845
+ if (osb->local_alloc_state == OCFS2_LA_ENABLED)
1846
+ ocfs2_shutdown_local_alloc(osb);
1847
+ ocfs2_release_system_inodes(osb);
1848
+ /* before journal shutdown, we should release slot_info */
1849
+ ocfs2_free_slot_info(osb);
1850
+ ocfs2_journal_shutdown(osb);
1851
+out_super_lock:
1852
+ ocfs2_super_unlock(osb, 1);
1853
+out_dlm:
1854
+ ocfs2_dlm_shutdown(osb, 0);
1855
+out:
18431856 return status;
18441857 }
18451858
....@@ -1912,8 +1925,7 @@
19121925 !ocfs2_is_hard_readonly(osb))
19131926 hangup_needed = 1;
19141927
1915
- if (osb->cconn)
1916
- ocfs2_dlm_shutdown(osb, hangup_needed);
1928
+ ocfs2_dlm_shutdown(osb, hangup_needed);
19171929
19181930 ocfs2_blockcheck_stats_debugfs_remove(&osb->osb_ecc_stats);
19191931 debugfs_remove_recursive(osb->osb_debug_root);