[libvirt PATCH 0/3] storage: Use the FICLONE ioctl unconditionally on Linux

Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/438075320 Andrea Bolognani (3): storage: Use the FICLONE ioctl unconditionally on Linux meson: Don't look for btrfs and xfs headers spec: Drop BuildRequires on xfsprogs-devel libvirt.spec.in | 2 -- meson.build | 4 ---- src/storage/storage_util.c | 14 ++------------ 3 files changed, 2 insertions(+), 18 deletions(-) -- 2.31.1

According to ioctl_ficlonerange(2) These ioctl operations [FICLONE and FICLONERANGE] first appeared in Linux 4.5. They were previously known as BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE, and were private to Btrfs. We no longer target any distro that comes with a kernel older than 4.5, so we can stop looking for the btrfs and xfs specific versions of the constant and just use the generic version directly. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/storage/storage_util.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 03874d6ca3..21388cd255 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -43,16 +43,6 @@ # include <selinux/selinux.h> #endif -#ifdef FICLONE -# define REFLINK_IOC_CLONE FICLONE -#elif WITH_LINUX_BTRFS_H -# include <linux/btrfs.h> -# define REFLINK_IOC_CLONE BTRFS_IOC_CLONE -#elif WITH_XFS_XFS_H -# include <xfs/xfs.h> -# define REFLINK_IOC_CLONE XFS_IOC_CLONE -#endif - #include "datatypes.h" #include "virerror.h" #include "viralloc.h" @@ -107,11 +97,11 @@ virStorageBackendNamespaceInit(int poolType, * Perform the O(1) btrfs clone operation, if possible. * Upon success, return 0. Otherwise, return -1 and set errno. */ -#ifdef REFLINK_IOC_CLONE +#ifdef __linux__ static inline int reflinkCloneFile(int dest_fd, int src_fd) { - return ioctl(dest_fd, REFLINK_IOC_CLONE, src_fd); + return ioctl(dest_fd, FICLONE, src_fd); } #else static inline int -- 2.31.1

We no longer use them anywhere. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 4 ---- 1 file changed, 4 deletions(-) diff --git a/meson.build b/meson.build index 57561adf51..a28de34a4b 100644 --- a/meson.build +++ b/meson.build @@ -613,10 +613,6 @@ headers = [ ] if host_machine.system() == 'linux' - # check for kernel headers required by btrfs ioctl - headers += 'linux/btrfs.h' - # check for xfs dev headers required by xfs ioctl - headers += 'xfs/xfs.h' # check for DEVLINK_CMD_ESWITCH_GET headers += 'linux/devlink.h' endif -- 2.31.1

We no longer need its contents. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- libvirt.spec.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 7bd74da2c9..6bf5e038ac 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -307,8 +307,6 @@ BuildRequires: libiscsi-devel BuildRequires: parted-devel # For Multipath support BuildRequires: device-mapper-devel -# For XFS reflink clone support -BuildRequires: xfsprogs-devel %if %{with_storage_rbd} BuildRequires: librados-devel BuildRequires: librbd-devel -- 2.31.1

On Tue, Dec 28, 2021 at 1:40 PM Andrea Bolognani <abologna@redhat.com> wrote:
Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/438075320
Andrea Bolognani (3): storage: Use the FICLONE ioctl unconditionally on Linux meson: Don't look for btrfs and xfs headers spec: Drop BuildRequires on xfsprogs-devel
libvirt.spec.in | 2 -- meson.build | 4 ---- src/storage/storage_util.c | 14 ++------------ 3 files changed, 2 insertions(+), 18 deletions(-)
-- 2.31.1
LGTM. Reviewed-by: Neal Gompa <ngompa13@gmail.com> -- 真実はいつも一つ!/ Always, there's only one truth!

On 12/28/21 19:40, Andrea Bolognani wrote:
Test pipeline: https://gitlab.com/abologna/libvirt/-/pipelines/438075320
Andrea Bolognani (3): storage: Use the FICLONE ioctl unconditionally on Linux meson: Don't look for btrfs and xfs headers spec: Drop BuildRequires on xfsprogs-devel
libvirt.spec.in | 2 -- meson.build | 4 ---- src/storage/storage_util.c | 14 ++------------ 3 files changed, 2 insertions(+), 18 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (3)
-
Andrea Bolognani
-
Michal Prívozník
-
Neal Gompa