Skip to content

Commit 221b949

Browse files
committed
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. Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Fixes openzfs#15604
1 parent fc48ddf commit 221b949

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>
@@ -5560,6 +5561,13 @@ spa_remap_blkptr(spa_t *spa, blkptr_t *bp, spa_remap_cb_t callback, void *arg)
55605561
if (BP_GET_NDVAS(bp) < 1)
55615562
return (B_FALSE);
55625563

5564+
/*
5565+
* Cloned blocks can not be remapped since BRT depends on specific
5566+
* vdev id and offset in the DVA[0] for its reference counting.
5567+
*/
5568+
if (!BP_IS_METADATA(bp) && brt_maybe_exists(spa, bp))
5569+
return (B_FALSE);
5570+
55635571
/*
55645572
* Note: we only remap dva[0]. If we remapped other dvas, we
55655573
* would no longer know what their phys birth txg is.

0 commit comments

Comments
 (0)