From a7e70a3983ae516ae74f96326d340c9fd09698b8 Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Thu, 6 Aug 2020 10:28:47 +0900 Subject: [PATCH] upstream: hack - retry destroy until diskarb goes away A more portable solution is perhaps desired. Signed-off-by: Jorgen Lundman --- lib/libzfs/libzfs_dataset.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 32104c24192e..181547c7e85c 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -3859,7 +3859,24 @@ zfs_destroy(zfs_handle_t *zhp, boolean_t defer) error = lzc_destroy_snaps(nv, defer, NULL); fnvlist_free(nv); } else { + +#ifdef __APPLE__ + /* DiskArbitrationd gets in the way a lot */ + int retry = 0; + do { + if ((retry++) != 1) { + printf("retry\n"); + sleep(1); + } +#endif + error = lzc_destroy(zhp->zfs_name); + +#ifdef __APPLE__ + } while ((error == EBUSY) && (retry <= 5)); +#endif + + } if (error != 0 && error != ENOENT) {