Implementation of block cloning for ZFS

Block Cloning allows to manually clone a file (or a subset of its
blocks) into another (or the same) file by just creating additional
references to the data blocks without copying the data itself.
Those references are kept in the Block Reference Tables (BRTs).

The whole design of block cloning is documented in module/zfs/brt.c.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Christian Schwarz <christian.schwarz@nutanix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #13392
This commit is contained in:
Pawel Jakub Dawidek
2023-03-10 20:59:53 +01:00
committed by GitHub
parent da19d919a8
commit 67a1b03791
51 changed files with 3480 additions and 120 deletions
+25 -16
View File
@@ -77,6 +77,12 @@ extern "C" {
* and zstd. Compression occurs as part of the write pipeline and is
* performed in the ZIO_STAGE_WRITE_BP_INIT stage.
*
* Block cloning:
* The block cloning functionality introduces ZIO_STAGE_BRT_FREE stage which
* is called during a free pipeline. If the block is referenced in the
* Block Cloning Table (BRT) we will just decrease its reference counter
* instead of actually freeing the block.
*
* Dedup:
* Dedup reads are handled by the ZIO_STAGE_DDT_READ_START and
* ZIO_STAGE_DDT_READ_DONE stages. These stages are added to an existing
@@ -127,28 +133,30 @@ enum zio_stage {
ZIO_STAGE_NOP_WRITE = 1 << 8, /* -W--- */
ZIO_STAGE_DDT_READ_START = 1 << 9, /* R---- */
ZIO_STAGE_DDT_READ_DONE = 1 << 10, /* R---- */
ZIO_STAGE_DDT_WRITE = 1 << 11, /* -W--- */
ZIO_STAGE_DDT_FREE = 1 << 12, /* --F-- */
ZIO_STAGE_BRT_FREE = 1 << 9, /* --F-- */
ZIO_STAGE_GANG_ASSEMBLE = 1 << 13, /* RWFC- */
ZIO_STAGE_GANG_ISSUE = 1 << 14, /* RWFC- */
ZIO_STAGE_DDT_READ_START = 1 << 10, /* R---- */
ZIO_STAGE_DDT_READ_DONE = 1 << 11, /* R---- */
ZIO_STAGE_DDT_WRITE = 1 << 12, /* -W--- */
ZIO_STAGE_DDT_FREE = 1 << 13, /* --F-- */
ZIO_STAGE_DVA_THROTTLE = 1 << 15, /* -W--- */
ZIO_STAGE_DVA_ALLOCATE = 1 << 16, /* -W--- */
ZIO_STAGE_DVA_FREE = 1 << 17, /* --F-- */
ZIO_STAGE_DVA_CLAIM = 1 << 18, /* ---C- */
ZIO_STAGE_GANG_ASSEMBLE = 1 << 14, /* RWFC- */
ZIO_STAGE_GANG_ISSUE = 1 << 15, /* RWFC- */
ZIO_STAGE_READY = 1 << 19, /* RWFCI */
ZIO_STAGE_DVA_THROTTLE = 1 << 16, /* -W--- */
ZIO_STAGE_DVA_ALLOCATE = 1 << 17, /* -W--- */
ZIO_STAGE_DVA_FREE = 1 << 18, /* --F-- */
ZIO_STAGE_DVA_CLAIM = 1 << 19, /* ---C- */
ZIO_STAGE_VDEV_IO_START = 1 << 20, /* RW--I */
ZIO_STAGE_VDEV_IO_DONE = 1 << 21, /* RW--I */
ZIO_STAGE_VDEV_IO_ASSESS = 1 << 22, /* RW--I */
ZIO_STAGE_READY = 1 << 20, /* RWFCI */
ZIO_STAGE_CHECKSUM_VERIFY = 1 << 23, /* R---- */
ZIO_STAGE_VDEV_IO_START = 1 << 21, /* RW--I */
ZIO_STAGE_VDEV_IO_DONE = 1 << 22, /* RW--I */
ZIO_STAGE_VDEV_IO_ASSESS = 1 << 23, /* RW--I */
ZIO_STAGE_DONE = 1 << 24 /* RWFCI */
ZIO_STAGE_CHECKSUM_VERIFY = 1 << 24, /* R---- */
ZIO_STAGE_DONE = 1 << 25 /* RWFCI */
};
#define ZIO_INTERLOCK_STAGES \
@@ -233,6 +241,7 @@ enum zio_stage {
#define ZIO_FREE_PIPELINE \
(ZIO_INTERLOCK_STAGES | \
ZIO_STAGE_FREE_BP_INIT | \
ZIO_STAGE_BRT_FREE | \
ZIO_STAGE_DVA_FREE)
#define ZIO_DDT_FREE_PIPELINE \