Skip to content

Commit 0a73e91

Browse files
amotinbehlendorf
authored andcommitted
Block remap for cloned blocks on device removal
When after device removal we handle block pointers remap, skip blocks that might be cloned. BRTs are indexed by vdev id and offset from block pointer's DVA[0]. So if we start addressing the same block by some different DVA, we won't get the proper reference counter. As result, we might either remap the block twice, that may result in assertion during indirect mapping condense, or free it prematurely, that may result in data overwrite, or free it twice, that may result in assertion in spacemap code. Reviewed-by: Ameer Hamza <[email protected]> Reviewed-by: Paul Dagnelie <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes openzfs#15604 Closes openzfs#17180
1 parent b7e24dc commit 0a73e91

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

module/zfs/metaslab.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828

2929
#include <sys/zfs_context.h>
30+
#include <sys/brt.h>
3031
#include <sys/dmu.h>
3132
#include <sys/dmu_tx.h>
3233
#include <sys/space_map.h>
@@ -5506,6 +5507,13 @@ spa_remap_blkptr(spa_t *spa, blkptr_t *bp, spa_remap_cb_t callback, void *arg)
55065507
if (BP_GET_NDVAS(bp) < 1)
55075508
return (B_FALSE);
55085509

5510+
/*
5511+
* Cloned blocks can not be remapped since BRT depends on specific
5512+
* vdev id and offset in the DVA[0] for its reference counting.
5513+
*/
5514+
if (!BP_IS_METADATA(bp) && brt_maybe_exists(spa, bp))
5515+
return (B_FALSE);
5516+
55095517
/*
55105518
* Note: we only remap dva[0]. If we remapped other dvas, we
55115519
* would no longer know what their phys birth txg is.

0 commit comments

Comments
 (0)