Skip to content

Commit b6fcb79

Browse files
committed
Illumos 6414 - vdev_config_sync could be simpler
6414 vdev_config_sync could be simpler Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Approved by: Robert Mustacchi <rm@joyent.com> References: https://www.illumos.org/issues/6414 illumos/illumos-gate@eb5bb58 Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
1 parent 1a04bab commit b6fcb79

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

include/sys/vdev.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ extern void vdev_queue_io_done(zio_t *zio);
121121

122122
extern void vdev_config_dirty(vdev_t *vd);
123123
extern void vdev_config_clean(vdev_t *vd);
124-
extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
125-
boolean_t);
124+
extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg);
126125

127126
extern void vdev_state_dirty(vdev_t *vd);
128127
extern void vdev_state_clean(vdev_t *vd);

module/zfs/spa.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6518,16 +6518,10 @@ spa_sync(spa_t *spa, uint64_t txg)
65186518
if (svdcount == SPA_DVAS_PER_BP)
65196519
break;
65206520
}
6521-
error = vdev_config_sync(svd, svdcount, txg, B_FALSE);
6522-
if (error != 0)
6523-
error = vdev_config_sync(svd, svdcount, txg,
6524-
B_TRUE);
6521+
error = vdev_config_sync(svd, svdcount, txg);
65256522
} else {
65266523
error = vdev_config_sync(rvd->vdev_child,
6527-
rvd->vdev_children, txg, B_FALSE);
6528-
if (error != 0)
6529-
error = vdev_config_sync(rvd->vdev_child,
6530-
rvd->vdev_children, txg, B_TRUE);
6524+
rvd->vdev_children, txg);
65316525
}
65326526

65336527
if (error == 0)

module/zfs/vdev_label.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,24 +1187,28 @@ vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, int flags)
11871187
* at any time, you can just call it again, and it will resume its work.
11881188
*/
11891189
int
1190-
vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
1190+
vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
11911191
{
11921192
spa_t *spa = svd[0]->vdev_spa;
11931193
uberblock_t *ub = &spa->spa_uberblock;
11941194
vdev_t *vd;
11951195
zio_t *zio;
1196-
int error;
1196+
int error = 0;
11971197
int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
11981198

1199+
retry:
11991200
/*
12001201
* Normally, we don't want to try too hard to write every label and
12011202
* uberblock. If there is a flaky disk, we don't want the rest of the
12021203
* sync process to block while we retry. But if we can't write a
12031204
* single label out, we should retry with ZIO_FLAG_TRYHARD before
12041205
* bailing out and declaring the pool faulted.
12051206
*/
1206-
if (tryhard)
1207+
if (error != 0) {
1208+
if ((flags & ZIO_FLAG_TRYHARD) != 0)
1209+
return (error);
12071210
flags |= ZIO_FLAG_TRYHARD;
1211+
}
12081212

12091213
ASSERT(ub->ub_txg <= txg);
12101214

@@ -1248,7 +1252,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
12481252
* are committed to stable storage before the uberblock update.
12491253
*/
12501254
if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0)
1251-
return (error);
1255+
goto retry;
12521256

12531257
/*
12541258
* Sync the uberblocks to all vdevs in svd[].
@@ -1266,7 +1270,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
12661270
* to the new uberblocks.
12671271
*/
12681272
if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0)
1269-
return (error);
1273+
goto retry;
12701274

12711275
/*
12721276
* Sync out odd labels for every dirty vdev. If the system dies
@@ -1278,5 +1282,8 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
12781282
* to disk to ensure that all odd-label updates are committed to
12791283
* stable storage before the next transaction group begins.
12801284
*/
1281-
return (vdev_label_sync_list(spa, 1, txg, flags));
1285+
if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0)
1286+
goto retry;
1287+
1288+
return (0);
12821289
}

0 commit comments

Comments
 (0)