vdev_label.c (294805) | vdev_label.c (294811) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 1180 unchanged lines hidden (view full) --- 1189 * if the system panics or loses power at any time, the state on disk 1190 * is still transactionally consistent. The in-line comments below 1191 * describe the failure semantics at each stage. 1192 * 1193 * Moreover, vdev_config_sync() is designed to be idempotent: if it fails 1194 * at any time, you can just call it again, and it will resume its work. 1195 */ 1196int | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 1180 unchanged lines hidden (view full) --- 1189 * if the system panics or loses power at any time, the state on disk 1190 * is still transactionally consistent. The in-line comments below 1191 * describe the failure semantics at each stage. 1192 * 1193 * Moreover, vdev_config_sync() is designed to be idempotent: if it fails 1194 * at any time, you can just call it again, and it will resume its work. 1195 */ 1196int |
1197vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard) | 1197vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg) |
1198{ 1199 spa_t *spa = svd[0]->vdev_spa; 1200 uberblock_t *ub = &spa->spa_uberblock; 1201 vdev_t *vd; 1202 zio_t *zio; | 1198{ 1199 spa_t *spa = svd[0]->vdev_spa; 1200 uberblock_t *ub = &spa->spa_uberblock; 1201 vdev_t *vd; 1202 zio_t *zio; |
1203 int error; | 1203 int error = 0; |
1204 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL; 1205 | 1204 int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL; 1205 |
1206retry: |
|
1206 /* 1207 * Normally, we don't want to try too hard to write every label and 1208 * uberblock. If there is a flaky disk, we don't want the rest of the 1209 * sync process to block while we retry. But if we can't write a 1210 * single label out, we should retry with ZIO_FLAG_TRYHARD before 1211 * bailing out and declaring the pool faulted. 1212 */ | 1207 /* 1208 * Normally, we don't want to try too hard to write every label and 1209 * uberblock. If there is a flaky disk, we don't want the rest of the 1210 * sync process to block while we retry. But if we can't write a 1211 * single label out, we should retry with ZIO_FLAG_TRYHARD before 1212 * bailing out and declaring the pool faulted. 1213 */ |
1213 if (tryhard) | 1214 if (error != 0) { 1215 if ((flags & ZIO_FLAG_TRYHARD) != 0) 1216 return (error); |
1214 flags |= ZIO_FLAG_TRYHARD; | 1217 flags |= ZIO_FLAG_TRYHARD; |
1218 } |
|
1215 1216 ASSERT(ub->ub_txg <= txg); 1217 1218 /* 1219 * If this isn't a resync due to I/O errors, 1220 * and nothing changed in this transaction group, 1221 * and the vdev configuration hasn't changed, 1222 * then there's nothing to do. --- 27 unchanged lines hidden (view full) --- 1250 * system dies in the middle of this process, that's OK: all of the 1251 * even labels that made it to disk will be newer than any uberblock, 1252 * and will therefore be considered invalid. The odd labels (L1, L3), 1253 * which have not yet been touched, will still be valid. We flush 1254 * the new labels to disk to ensure that all even-label updates 1255 * are committed to stable storage before the uberblock update. 1256 */ 1257 if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0) | 1219 1220 ASSERT(ub->ub_txg <= txg); 1221 1222 /* 1223 * If this isn't a resync due to I/O errors, 1224 * and nothing changed in this transaction group, 1225 * and the vdev configuration hasn't changed, 1226 * then there's nothing to do. --- 27 unchanged lines hidden (view full) --- 1254 * system dies in the middle of this process, that's OK: all of the 1255 * even labels that made it to disk will be newer than any uberblock, 1256 * and will therefore be considered invalid. The odd labels (L1, L3), 1257 * which have not yet been touched, will still be valid. We flush 1258 * the new labels to disk to ensure that all even-label updates 1259 * are committed to stable storage before the uberblock update. 1260 */ 1261 if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0) |
1258 return (error); | 1262 goto retry; |
1259 1260 /* 1261 * Sync the uberblocks to all vdevs in svd[]. 1262 * If the system dies in the middle of this step, there are two cases 1263 * to consider, and the on-disk state is consistent either way: 1264 * 1265 * (1) If none of the new uberblocks made it to disk, then the 1266 * previous uberblock will be the newest, and the odd labels 1267 * (which had not yet been touched) will be valid with respect 1268 * to that uberblock. 1269 * 1270 * (2) If one or more new uberblocks made it to disk, then they 1271 * will be the newest, and the even labels (which had all 1272 * been successfully committed) will be valid with respect 1273 * to the new uberblocks. 1274 */ 1275 if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0) | 1263 1264 /* 1265 * Sync the uberblocks to all vdevs in svd[]. 1266 * If the system dies in the middle of this step, there are two cases 1267 * to consider, and the on-disk state is consistent either way: 1268 * 1269 * (1) If none of the new uberblocks made it to disk, then the 1270 * previous uberblock will be the newest, and the odd labels 1271 * (which had not yet been touched) will be valid with respect 1272 * to that uberblock. 1273 * 1274 * (2) If one or more new uberblocks made it to disk, then they 1275 * will be the newest, and the even labels (which had all 1276 * been successfully committed) will be valid with respect 1277 * to the new uberblocks. 1278 */ 1279 if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0) |
1276 return (error); | 1280 goto retry; |
1277 1278 /* 1279 * Sync out odd labels for every dirty vdev. If the system dies 1280 * in the middle of this process, the even labels and the new 1281 * uberblocks will suffice to open the pool. The next time 1282 * the pool is opened, the first thing we'll do -- before any 1283 * user data is modified -- is mark every vdev dirty so that 1284 * all labels will be brought up to date. We flush the new labels 1285 * to disk to ensure that all odd-label updates are committed to 1286 * stable storage before the next transaction group begins. 1287 */ 1288 if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0) | 1281 1282 /* 1283 * Sync out odd labels for every dirty vdev. If the system dies 1284 * in the middle of this process, the even labels and the new 1285 * uberblocks will suffice to open the pool. The next time 1286 * the pool is opened, the first thing we'll do -- before any 1287 * user data is modified -- is mark every vdev dirty so that 1288 * all labels will be brought up to date. We flush the new labels 1289 * to disk to ensure that all odd-label updates are committed to 1290 * stable storage before the next transaction group begins. 1291 */ 1292 if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0) |
1289 return (error); | 1293 goto retry;; |
1290 1291 trim_thread_wakeup(spa); 1292 1293 return (0); 1294} | 1294 1295 trim_thread_wakeup(spa); 1296 1297 return (0); 1298} |