Skip to content

Commit 03b7cfd

Browse files
robnbehlendorf
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 #16887
1 parent 779c5a5 commit 03b7cfd

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
@@ -9683,9 +9683,17 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
96839683
if (nvpair_type(elem) == DATA_TYPE_STRING) {
96849684
ASSERT(proptype == PROP_TYPE_STRING);
96859685
strval = fnvpair_value_string(elem);
9686-
VERIFY0(zap_update(mos,
9687-
spa->spa_pool_props_object, propname,
9688-
1, strlen(strval) + 1, strval, tx));
9686+
if (strlen(strval) == 0) {
9687+
/* remove the property if value == "" */
9688+
(void) zap_remove(mos,
9689+
spa->spa_pool_props_object,
9690+
propname, tx);
9691+
} else {
9692+
VERIFY0(zap_update(mos,
9693+
spa->spa_pool_props_object,
9694+
propname, 1, strlen(strval) + 1,
9695+
strval, tx));
9696+
}
96899697
spa_history_log_internal(spa, "set", tx,
96909698
"%s=%s", elemname, strval);
96919699
} else if (nvpair_type(elem) == DATA_TYPE_UINT64) {

0 commit comments

Comments
 (0)