Optionally skip zil_close during zvol_create_minor_impl

If there were no zil entries to replay, skip zil_close.  zil_close waits
for a transaction to sync.  That can take several seconds, for example
during pool import of a resilvering pool.  Skipping zil_close can cut
the time for "zpool import" from 2 hours to 45 seconds on a resilvering
pool with a thousand zvols.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Sponsored-by: Axcient
Closes #13999 
Closes #14015
This commit is contained in:
Alan Somers
2022-11-08 13:38:08 -07:00
committed by GitHub
parent f224eddf92
commit e197bb24f1
4 changed files with 22 additions and 13 deletions
+5 -3
View File
@@ -1279,6 +1279,7 @@ zvol_os_create_minor(const char *name)
int error = 0;
int idx;
uint64_t hash = zvol_name_hash(name);
bool replayed_zil = B_FALSE;
if (zvol_inhibit_dev)
return (0);
@@ -1420,11 +1421,12 @@ zvol_os_create_minor(const char *name)
zv->zv_zilog = zil_open(os, zvol_get_data, &zv->zv_kstat.dk_zil_sums);
if (spa_writeable(dmu_objset_spa(os))) {
if (zil_replay_disable)
zil_destroy(zv->zv_zilog, B_FALSE);
replayed_zil = zil_destroy(zv->zv_zilog, B_FALSE);
else
zil_replay(os, zv, zvol_replay_vector);
replayed_zil = zil_replay(os, zv, zvol_replay_vector);
}
zil_close(zv->zv_zilog);
if (replayed_zil)
zil_close(zv->zv_zilog);
zv->zv_zilog = NULL;
/*