Skip to content

Commit d461a67

Browse files
authored
Ensure that gang_copies is always at least as large as copies
As discussed in the comments of PR #17004, you can theoretically run into a case where a gang child has more copies than the gang header, which can lead to some odd accounting behavior (and even trip a VERIFY). While the accounting code could be changed to handle this, it fundamentally doesn't seem to make a lot of sense to allow this to happen. If the data is supposed to have a certain level of reliability, that isn't actually achieved unless the gang_copies property is set to match it. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #17484
1 parent 46a4075 commit d461a67

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

module/zfs/dmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,8 @@ dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
25002500
zp->zp_type = (wp & WP_SPILL) ? dn->dn_bonustype : type;
25012501
zp->zp_level = level;
25022502
zp->zp_copies = MIN(copies, spa_max_replication(os->os_spa));
2503-
zp->zp_gang_copies = MIN(gang_copies, spa_max_replication(os->os_spa));
2503+
zp->zp_gang_copies = MIN(MAX(gang_copies, copies),
2504+
spa_max_replication(os->os_spa));
25042505
zp->zp_dedup = dedup;
25052506
zp->zp_dedup_verify = dedup && dedup_verify;
25062507
zp->zp_nopwrite = nopwrite;

0 commit comments

Comments
 (0)