From: Chester Gregg Date: Thu, 28 Aug 2025 02:22:30 +0000 (+0000) Subject: Add reflink support for ZFS. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58cf2752fb74751828f56f4d3f289e02f052aaf0;p=thirdparty%2Futil-linux.git Add reflink support for ZFS. OpenZFS has added the block cloning feature, which implements reflinks for its copy-on-write filesystem. It is now stable and enabled by default on OpenZFS 2.3.0. --- diff --git a/include/statfs_magic.h b/include/statfs_magic.h index e87b78474..857058a73 100644 --- a/include/statfs_magic.h +++ b/include/statfs_magic.h @@ -101,6 +101,7 @@ #define STATFS_VXFS_MAGIC 0xa501FCF5 #define STATFS_XENFS_MAGIC 0xabba1974 #define STATFS_XFS_MAGIC 0x58465342 +#define STATFS_ZFS_MAGIC 0x2FC12FC1 #endif /* UTIL_LINUX_STATFS_MAGIC_H */ diff --git a/misc-utils/hardlink.1.adoc b/misc-utils/hardlink.1.adoc index 613f7a1d4..29d6dca3e 100644 --- a/misc-utils/hardlink.1.adoc +++ b/misc-utils/hardlink.1.adoc @@ -108,7 +108,7 @@ This option implies *--skip-reflinks* to ignore already cloned files. + The optional argument _when_ can be *never*, *always*, or *auto*. If the _when_ argument is omitted, it defaults to *auto*, which means that *hardlink* checks the filesystem type -and uses reflinks on BTRFS and XFS only, and falls back to hardlinks when creating a +and uses reflinks on BTRFS, XFS and ZFS only, and falls back to hardlinks when creating a reflink is impossible. The argument *always* disables filesystem-type detection and the fallback to hardlinks, which means that only reflinks are allowed. diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c index cd28fe018..114b5c4c9 100644 --- a/misc-utils/hardlink.c +++ b/misc-utils/hardlink.c @@ -974,6 +974,7 @@ static int is_reflink_compatible(dev_t devno, const char *filename) switch (vfs.f_type) { case STATFS_BTRFS_MAGIC: case STATFS_XFS_MAGIC: + case STATFS_ZFS_MAGIC: last_status = 1; break; default: