Skip to content

Commit 277324e

Browse files
robnPaul Dagnelie
authored andcommitted
spa_sync_props: remove pool userprops by setting empty-string
People have noted there's no way to remove a pool userprop, only zero it. Turns vdev userprops had a method, by setting empty-string. So this makes pool userprops follow the same behaviour. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#16887
1 parent a34a854 commit 277324e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

module/zfs/spa.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9727,9 +9727,17 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
97279727
if (nvpair_type(elem) == DATA_TYPE_STRING) {
97289728
ASSERT(proptype == PROP_TYPE_STRING);
97299729
strval = fnvpair_value_string(elem);
9730-
VERIFY0(zap_update(mos,
9731-
spa->spa_pool_props_object, propname,
9732-
1, strlen(strval) + 1, strval, tx));
9730+
if (strlen(strval) == 0) {
9731+
/* remove the property if value == "" */
9732+
(void) zap_remove(mos,
9733+
spa->spa_pool_props_object,
9734+
propname, tx);
9735+
} else {
9736+
VERIFY0(zap_update(mos,
9737+
spa->spa_pool_props_object,
9738+
propname, 1, strlen(strval) + 1,
9739+
strval, tx));
9740+
}
97339741
spa_history_log_internal(spa, "set", tx,
97349742
"%s=%s", elemname, strval);
97359743
} else if (nvpair_type(elem) == DATA_TYPE_UINT64) {

0 commit comments

Comments
 (0)