aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_mount.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-02-04 03:31:52 -0500
committerChristoph Hellwig <hch@brick.lst.de>2009-02-04 03:31:52 -0500
commitf9057e3da79d18fdbd9d6adbb183f032c614feeb (patch)
tree4d8942472dc02548650932d2cad25565c6c5af42 /fs/xfs/xfs_mount.c
parent3228149ceb8b045e324cd268be9182bb26e6488b (diff)
xfs: cleanup error handling in xfs_mountfs:
Clean up the error handling in xfs_mountfs. Use readable goto label names, simplify the uuid handling and other error conditions. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_mount.c')
-rw-r--r--fs/xfs/xfs_mount.c77
1 files changed, 35 insertions, 42 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 35300250e86d..86ac80c897c3 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -886,8 +886,6 @@ xfs_check_sizes(xfs_mount_t *mp)
886} 886}
887 887
888/* 888/*
889 * xfs_mountfs
890 *
891 * This function does the following on an initial mount of a file system: 889 * This function does the following on an initial mount of a file system:
892 * - reads the superblock from disk and init the mount struct 890 * - reads the superblock from disk and init the mount struct
893 * - if we're a 32-bit kernel, do a size check on the superblock 891 * - if we're a 32-bit kernel, do a size check on the superblock
@@ -905,7 +903,6 @@ xfs_mountfs(
905 xfs_inode_t *rip; 903 xfs_inode_t *rip;
906 __uint64_t resblks; 904 __uint64_t resblks;
907 uint quotamount, quotaflags; 905 uint quotamount, quotaflags;
908 int uuid_mounted = 0;
909 int error = 0; 906 int error = 0;
910 907
911 xfs_mount_common(mp, sbp); 908 xfs_mount_common(mp, sbp);
@@ -960,7 +957,7 @@ xfs_mountfs(
960 */ 957 */
961 error = xfs_update_alignment(mp); 958 error = xfs_update_alignment(mp);
962 if (error) 959 if (error)
963 goto error1; 960 goto out;
964 961
965 xfs_alloc_compute_maxlevels(mp); 962 xfs_alloc_compute_maxlevels(mp);
966 xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK); 963 xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK);
@@ -977,12 +974,11 @@ xfs_mountfs(
977 * since a single partition filesystem is identical to a single 974 * since a single partition filesystem is identical to a single
978 * partition volume/filesystem. 975 * partition volume/filesystem.
979 */ 976 */
980 if ((mp->m_flags & XFS_MOUNT_NOUUID) == 0) { 977 if (!(mp->m_flags & XFS_MOUNT_NOUUID)) {
981 if (xfs_uuid_mount(mp)) { 978 if (xfs_uuid_mount(mp)) {
982 error = XFS_ERROR(EINVAL); 979 error = XFS_ERROR(EINVAL);
983 goto error1; 980 goto out;
984 } 981 }
985 uuid_mounted=1;
986 } 982 }
987 983
988 /* 984 /*
@@ -1007,7 +1003,7 @@ xfs_mountfs(
1007 */ 1003 */
1008 error = xfs_check_sizes(mp); 1004 error = xfs_check_sizes(mp);
1009 if (error) 1005 if (error)
1010 goto error1; 1006 goto out_remove_uuid;
1011 1007
1012 /* 1008 /*
1013 * Initialize realtime fields in the mount structure 1009 * Initialize realtime fields in the mount structure
@@ -1015,7 +1011,7 @@ xfs_mountfs(
1015 error = xfs_rtmount_init(mp); 1011 error = xfs_rtmount_init(mp);
1016 if (error) { 1012 if (error) {
1017 cmn_err(CE_WARN, "XFS: RT mount failed"); 1013 cmn_err(CE_WARN, "XFS: RT mount failed");
1018 goto error1; 1014 goto out_remove_uuid;
1019 } 1015 }
1020 1016
1021 /* 1017 /*
@@ -1045,26 +1041,26 @@ xfs_mountfs(
1045 mp->m_perag = kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), 1041 mp->m_perag = kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t),
1046 KM_MAYFAIL); 1042 KM_MAYFAIL);
1047 if (!mp->m_perag) 1043 if (!mp->m_perag)
1048 goto error1; 1044 goto out_remove_uuid;
1049 1045
1050 mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount); 1046 mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount);
1051 1047
1048 if (!sbp->sb_logblocks) {
1049 cmn_err(CE_WARN, "XFS: no log defined");
1050 XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp);
1051 error = XFS_ERROR(EFSCORRUPTED);
1052 goto out_free_perag;
1053 }
1054
1052 /* 1055 /*
1053 * log's mount-time initialization. Perform 1st part recovery if needed 1056 * log's mount-time initialization. Perform 1st part recovery if needed
1054 */ 1057 */
1055 if (likely(sbp->sb_logblocks > 0)) { /* check for volume case */ 1058 error = xfs_log_mount(mp, mp->m_logdev_targp,
1056 error = xfs_log_mount(mp, mp->m_logdev_targp, 1059 XFS_FSB_TO_DADDR(mp, sbp->sb_logstart),
1057 XFS_FSB_TO_DADDR(mp, sbp->sb_logstart), 1060 XFS_FSB_TO_BB(mp, sbp->sb_logblocks));
1058 XFS_FSB_TO_BB(mp, sbp->sb_logblocks)); 1061 if (error) {
1059 if (error) { 1062 cmn_err(CE_WARN, "XFS: log mount failed");
1060 cmn_err(CE_WARN, "XFS: log mount failed"); 1063 goto out_free_perag;
1061 goto error2;
1062 }
1063 } else { /* No log has been defined */
1064 cmn_err(CE_WARN, "XFS: no log defined");
1065 XFS_ERROR_REPORT("xfs_mountfs_int(1)", XFS_ERRLEVEL_LOW, mp);
1066 error = XFS_ERROR(EFSCORRUPTED);
1067 goto error2;
1068 } 1064 }
1069 1065
1070 /* 1066 /*
@@ -1086,15 +1082,14 @@ xfs_mountfs(
1086 * If we are currently making the filesystem, the initialisation will 1082 * If we are currently making the filesystem, the initialisation will
1087 * fail as the perag data is in an undefined state. 1083 * fail as the perag data is in an undefined state.
1088 */ 1084 */
1089
1090 if (xfs_sb_version_haslazysbcount(&mp->m_sb) && 1085 if (xfs_sb_version_haslazysbcount(&mp->m_sb) &&
1091 !XFS_LAST_UNMOUNT_WAS_CLEAN(mp) && 1086 !XFS_LAST_UNMOUNT_WAS_CLEAN(mp) &&
1092 !mp->m_sb.sb_inprogress) { 1087 !mp->m_sb.sb_inprogress) {
1093 error = xfs_initialize_perag_data(mp, sbp->sb_agcount); 1088 error = xfs_initialize_perag_data(mp, sbp->sb_agcount);
1094 if (error) { 1089 if (error)
1095 goto error2; 1090 goto out_free_perag;
1096 }
1097 } 1091 }
1092
1098 /* 1093 /*
1099 * Get and sanity-check the root inode. 1094 * Get and sanity-check the root inode.
1100 * Save the pointer to it in the mount structure. 1095 * Save the pointer to it in the mount structure.
@@ -1102,7 +1097,7 @@ xfs_mountfs(
1102 error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip, 0); 1097 error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip, 0);
1103 if (error) { 1098 if (error) {
1104 cmn_err(CE_WARN, "XFS: failed to read root inode"); 1099 cmn_err(CE_WARN, "XFS: failed to read root inode");
1105 goto error3; 1100 goto out_log_dealloc;
1106 } 1101 }
1107 1102
1108 ASSERT(rip != NULL); 1103 ASSERT(rip != NULL);
@@ -1116,7 +1111,7 @@ xfs_mountfs(
1116 XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW, 1111 XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW,
1117 mp); 1112 mp);
1118 error = XFS_ERROR(EFSCORRUPTED); 1113 error = XFS_ERROR(EFSCORRUPTED);
1119 goto error4; 1114 goto out_rele_rip;
1120 } 1115 }
1121 mp->m_rootip = rip; /* save it */ 1116 mp->m_rootip = rip; /* save it */
1122 1117
@@ -1131,7 +1126,7 @@ xfs_mountfs(
1131 * Free up the root inode. 1126 * Free up the root inode.
1132 */ 1127 */
1133 cmn_err(CE_WARN, "XFS: failed to read RT inodes"); 1128 cmn_err(CE_WARN, "XFS: failed to read RT inodes");
1134 goto error4; 1129 goto out_rele_rip;
1135 } 1130 }
1136 1131
1137 /* 1132 /*
@@ -1143,7 +1138,7 @@ xfs_mountfs(
1143 error = xfs_mount_log_sb(mp, mp->m_update_flags); 1138 error = xfs_mount_log_sb(mp, mp->m_update_flags);
1144 if (error) { 1139 if (error) {
1145 cmn_err(CE_WARN, "XFS: failed to write sb changes"); 1140 cmn_err(CE_WARN, "XFS: failed to write sb changes");
1146 goto error4; 1141 goto out_rele_rip;
1147 } 1142 }
1148 } 1143 }
1149 1144
@@ -1152,7 +1147,7 @@ xfs_mountfs(
1152 */ 1147 */
1153 error = XFS_QM_INIT(mp, &quotamount, &quotaflags); 1148 error = XFS_QM_INIT(mp, &quotamount, &quotaflags);
1154 if (error) 1149 if (error)
1155 goto error4; 1150 goto out_rele_rip;
1156 1151
1157 /* 1152 /*
1158 * Finish recovering the file system. This part needed to be 1153 * Finish recovering the file system. This part needed to be
@@ -1162,7 +1157,7 @@ xfs_mountfs(
1162 error = xfs_log_mount_finish(mp); 1157 error = xfs_log_mount_finish(mp);
1163 if (error) { 1158 if (error) {
1164 cmn_err(CE_WARN, "XFS: log mount finish failed"); 1159 cmn_err(CE_WARN, "XFS: log mount finish failed");
1165 goto error4; 1160 goto out_rele_rip;
1166 } 1161 }
1167 1162
1168 /* 1163 /*
@@ -1170,7 +1165,7 @@ xfs_mountfs(
1170 */ 1165 */
1171 error = XFS_QM_MOUNT(mp, quotamount, quotaflags); 1166 error = XFS_QM_MOUNT(mp, quotamount, quotaflags);
1172 if (error) 1167 if (error)
1173 goto error4; 1168 goto out_rele_rip;
1174 1169
1175 /* 1170 /*
1176 * Now we are mounted, reserve a small amount of unused space for 1171 * Now we are mounted, reserve a small amount of unused space for
@@ -1194,18 +1189,16 @@ xfs_mountfs(
1194 1189
1195 return 0; 1190 return 0;
1196 1191
1197 error4: 1192 out_rele_rip:
1198 /*
1199 * Free up the root inode.
1200 */
1201 IRELE(rip); 1193 IRELE(rip);
1202 error3: 1194 out_log_dealloc:
1203 xfs_log_unmount_dealloc(mp); 1195 xfs_log_unmount_dealloc(mp);
1204 error2: 1196 out_free_perag:
1205 xfs_free_perag(mp); 1197 xfs_free_perag(mp);
1206 error1: 1198 out_remove_uuid:
1207 if (uuid_mounted) 1199 if (!(mp->m_flags & XFS_MOUNT_NOUUID))
1208 uuid_table_remove(&mp->m_sb.sb_uuid); 1200 uuid_table_remove(&mp->m_sb.sb_uuid);
1201 out:
1209 return error; 1202 return error;
1210} 1203}
1211 1204