Xin Li
2013-08-13 20:08:33 UTC
Hi,
I have run into an assertion in zio.c on FreeBSD while trying to
import a pool read-only and believes it affects Illumos too:
zio->io_type != ZIO_TYPE_WRITE || spa_writeable(spa)
Looking more closely, it seems that the write was initiated by
vdev_label_init, which is in turn called from spa_import via
spa_validate_aux.
If my understanding is correct, the call of spa_validate_aux is not
really necessary when pool is imported read only, so something like
this would be needed:
diff --git a/usr/src/uts/common/fs/zfs/spa.c
b/usr/src/uts/common/fs/zfs/spa.c
index 7334d39..2ce775d 100644
- --- a/usr/src/uts/common/fs/zfs/spa.c
+++ b/usr/src/uts/common/fs/zfs/spa.c
@@ -3888,12 +3888,14 @@ spa_import(const char *pool, nvlist_t *config,
nvlist_t *props, uint64_t flags)
VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
- - if (error == 0)
- - error = spa_validate_aux(spa, nvroot, -1ULL,
- - VDEV_ALLOC_SPARE);
- - if (error == 0)
- - error = spa_validate_aux(spa, nvroot, -1ULL,
- - VDEV_ALLOC_L2CACHE);
+ if (mode & FWRITE) {
+ if (error == 0)
+ error = spa_validate_aux(spa, nvroot, -1ULL,
+ VDEV_ALLOC_SPARE);
+ if (error == 0)
+ error = spa_validate_aux(spa, nvroot, -1ULL,
+ VDEV_ALLOC_L2CACHE);
+ }
spa_config_exit(spa, SCL_ALL, FTAG);
if (props != NULL)
Cheers,
- --
Xin LI <***@delphij.net> https://www.delphij.net/
FreeBSD - The Power to Serve! Live free or die
I have run into an assertion in zio.c on FreeBSD while trying to
import a pool read-only and believes it affects Illumos too:
zio->io_type != ZIO_TYPE_WRITE || spa_writeable(spa)
Looking more closely, it seems that the write was initiated by
vdev_label_init, which is in turn called from spa_import via
spa_validate_aux.
If my understanding is correct, the call of spa_validate_aux is not
really necessary when pool is imported read only, so something like
this would be needed:
diff --git a/usr/src/uts/common/fs/zfs/spa.c
b/usr/src/uts/common/fs/zfs/spa.c
index 7334d39..2ce775d 100644
- --- a/usr/src/uts/common/fs/zfs/spa.c
+++ b/usr/src/uts/common/fs/zfs/spa.c
@@ -3888,12 +3888,14 @@ spa_import(const char *pool, nvlist_t *config,
nvlist_t *props, uint64_t flags)
VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
- - if (error == 0)
- - error = spa_validate_aux(spa, nvroot, -1ULL,
- - VDEV_ALLOC_SPARE);
- - if (error == 0)
- - error = spa_validate_aux(spa, nvroot, -1ULL,
- - VDEV_ALLOC_L2CACHE);
+ if (mode & FWRITE) {
+ if (error == 0)
+ error = spa_validate_aux(spa, nvroot, -1ULL,
+ VDEV_ALLOC_SPARE);
+ if (error == 0)
+ error = spa_validate_aux(spa, nvroot, -1ULL,
+ VDEV_ALLOC_L2CACHE);
+ }
spa_config_exit(spa, SCL_ALL, FTAG);
if (props != NULL)
Cheers,
- --
Xin LI <***@delphij.net> https://www.delphij.net/
FreeBSD - The Power to Serve! Live free or die