aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/lib/libzfs/libzfs_status.c
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2021-02-18 14:17:31 +0000
committerMartin Matuska <mm@FreeBSD.org>2021-02-18 14:19:35 +0000
commitee36e25a86cbe2a9474c1d61f2c4b450da8ef952 (patch)
tree1f9e503fe3f154ff3ebc542840b892419ad85314 /sys/contrib/openzfs/lib/libzfs/libzfs_status.c
parentfa2528ac643519072c498b483d0dcc1fa5d99bc1 (diff)
parent62ceb3c592a54fc54d9cb3beee91906979c3df14 (diff)
downloadsrc-ee36e25a86cbe2a9474c1d61f2c4b450da8ef952.tar.gz
src-ee36e25a86cbe2a9474c1d61f2c4b450da8ef952.zip
zfs: merge OpenZFS master-bf156c966
Notable upstream changes: bf156c966 Remove unused abd_alloc_scatter_offset_chunkcnt 658fb8020 Add "compatibility" property for zpool feature sets This update introduces a new pool property called "compatibility" that can be used to enable a limited set of pool features on pool creation and "stick" to it, so the "zpool upgrade" does not accidentally enable features that are not desired. The value of this property may then be changed later. See zpool-features(5) for more information about the "compatibility" pool property. Obtained from: OpenZFS MFC after: 2 weeks
Diffstat (limited to 'sys/contrib/openzfs/lib/libzfs/libzfs_status.c')
-rw-r--r--sys/contrib/openzfs/lib/libzfs/libzfs_status.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_status.c b/sys/contrib/openzfs/lib/libzfs/libzfs_status.c
index 435937041608..fadae9388ac1 100644
--- a/sys/contrib/openzfs/lib/libzfs/libzfs_status.c
+++ b/sys/contrib/openzfs/lib/libzfs/libzfs_status.c
@@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
*/
/*
@@ -87,6 +88,7 @@ static char *zfs_msgid_table[] = {
* ZPOOL_STATUS_REMOVED_DEV
* ZPOOL_STATUS_REBUILDING
* ZPOOL_STATUS_REBUILD_SCRUB
+ * ZPOOL_STATUS_COMPATIBILITY_ERR
* ZPOOL_STATUS_OK
*/
};
@@ -218,7 +220,8 @@ find_vdev_problem(nvlist_t *vdev, int (*func)(vdev_stat_t *, uint_t),
* only picks the most damaging of all the current errors to report.
*/
static zpool_status_t
-check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap)
+check_status(nvlist_t *config, boolean_t isimport,
+ zpool_errata_t *erratap, const char *compat)
{
nvlist_t *nvroot;
vdev_stat_t *vs;
@@ -471,9 +474,16 @@ check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap)
ZPOOL_CONFIG_FEATURE_STATS);
}
+ /* check against all features, or limited set? */
+ boolean_t pool_features[SPA_FEATURES];
+
+ if (zpool_load_compat(compat, pool_features, NULL, NULL) !=
+ ZPOOL_COMPATIBILITY_OK)
+ return (ZPOOL_STATUS_COMPATIBILITY_ERR);
for (i = 0; i < SPA_FEATURES; i++) {
zfeature_info_t *fi = &spa_feature_table[i];
- if (!nvlist_exists(feat, fi->fi_guid))
+ if (pool_features[i] &&
+ !nvlist_exists(feat, fi->fi_guid))
return (ZPOOL_STATUS_FEAT_DISABLED);
}
}
@@ -484,7 +494,18 @@ check_status(nvlist_t *config, boolean_t isimport, zpool_errata_t *erratap)
zpool_status_t
zpool_get_status(zpool_handle_t *zhp, char **msgid, zpool_errata_t *errata)
{
- zpool_status_t ret = check_status(zhp->zpool_config, B_FALSE, errata);
+ /*
+ * pass in the desired feature set, as
+ * it affects check for disabled features
+ */
+ char compatibility[ZFS_MAXPROPLEN];
+ if (zpool_get_prop(zhp, ZPOOL_PROP_COMPATIBILITY, compatibility,
+ ZFS_MAXPROPLEN, NULL, B_FALSE) != 0)
+ compatibility[0] = '\0';
+
+ zpool_status_t ret = check_status(zhp->zpool_config, B_FALSE, errata,
+ compatibility);
+
if (msgid != NULL) {
if (ret >= NMSGID)
*msgid = NULL;
@@ -497,7 +518,7 @@ zpool_get_status(zpool_handle_t *zhp, char **msgid, zpool_errata_t *errata)
zpool_status_t
zpool_import_status(nvlist_t *config, char **msgid, zpool_errata_t *errata)
{
- zpool_status_t ret = check_status(config, B_TRUE, errata);
+ zpool_status_t ret = check_status(config, B_TRUE, errata, NULL);
if (ret >= NMSGID)
*msgid = NULL;