Skip to content

Commit

Permalink
6414 vdev_config_sync could be simpler
Browse files Browse the repository at this point in the history
Reviewed by: George Wilson <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
  • Loading branch information
wca authored and ahrens committed Nov 2, 2015
1 parent 7b07063 commit eb5bb58
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 2 additions & 8 deletions usr/src/uts/common/fs/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -6424,16 +6424,10 @@ spa_sync(spa_t *spa, uint64_t txg)
if (svdcount == SPA_DVAS_PER_BP)
break;
}
error = vdev_config_sync(svd, svdcount, txg, B_FALSE);
if (error != 0)
error = vdev_config_sync(svd, svdcount, txg,
B_TRUE);
error = vdev_config_sync(svd, svdcount, txg);
} else {
error = vdev_config_sync(rvd->vdev_child,
rvd->vdev_children, txg, B_FALSE);
if (error != 0)
error = vdev_config_sync(rvd->vdev_child,
rvd->vdev_children, txg, B_TRUE);
rvd->vdev_children, txg);
}

if (error == 0)
Expand Down
3 changes: 1 addition & 2 deletions usr/src/uts/common/fs/zfs/sys/vdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ extern void vdev_queue_io_done(zio_t *zio);

extern void vdev_config_dirty(vdev_t *vd);
extern void vdev_config_clean(vdev_t *vd);
extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
boolean_t);
extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg);

extern void vdev_state_dirty(vdev_t *vd);
extern void vdev_state_clean(vdev_t *vd);
Expand Down
19 changes: 13 additions & 6 deletions usr/src/uts/common/fs/zfs/vdev_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,24 +1177,28 @@ vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, int flags)
* at any time, you can just call it again, and it will resume its work.
*/
int
vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
{
spa_t *spa = svd[0]->vdev_spa;
uberblock_t *ub = &spa->spa_uberblock;
vdev_t *vd;
zio_t *zio;
int error;
int error = 0;
int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;

retry:
/*
* Normally, we don't want to try too hard to write every label and
* uberblock. If there is a flaky disk, we don't want the rest of the
* sync process to block while we retry. But if we can't write a
* single label out, we should retry with ZIO_FLAG_TRYHARD before
* bailing out and declaring the pool faulted.
*/
if (tryhard)
if (error != 0) {
if ((flags & ZIO_FLAG_TRYHARD) != 0)
return (error);
flags |= ZIO_FLAG_TRYHARD;
}

ASSERT(ub->ub_txg <= txg);

Expand Down Expand Up @@ -1238,7 +1242,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* are committed to stable storage before the uberblock update.
*/
if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0)
return (error);
goto retry;

/*
* Sync the uberblocks to all vdevs in svd[].
Expand All @@ -1256,7 +1260,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* to the new uberblocks.
*/
if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0)
return (error);
goto retry;

/*
* Sync out odd labels for every dirty vdev. If the system dies
Expand All @@ -1268,5 +1272,8 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* to disk to ensure that all odd-label updates are committed to
* stable storage before the next transaction group begins.
*/
return (vdev_label_sync_list(spa, 1, txg, flags));
if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0)
goto retry;

return (0);
}

0 comments on commit eb5bb58

Please sign in to comment.