mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
storage: Rename btrfsCloneFile to support other filesystems.
This commit renames and adds other macros to support aother filesystems when a reflink is performed. After that, XFS filesystems (and others) with reflink support will be able to clone. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1565004 Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
2e11298f93
commit
8ed874b39b
@ -48,6 +48,12 @@
|
|||||||
|
|
||||||
#if HAVE_LINUX_BTRFS_H
|
#if HAVE_LINUX_BTRFS_H
|
||||||
# include <linux/btrfs.h>
|
# include <linux/btrfs.h>
|
||||||
|
# define REFLINK_IOC_CLONE BTRFS_IOC_CLONE
|
||||||
|
#elif HAVE_XFS_XFS_H
|
||||||
|
# include <xfs/xfs.h>
|
||||||
|
# define REFLINK_IOC_CLONE XFS_IOC_CLONE
|
||||||
|
#elif defined(FICLONE)
|
||||||
|
# define REFLINK_IOC_CLONE FICLONE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
@ -80,15 +86,15 @@ VIR_LOG_INIT("storage.storage_util");
|
|||||||
* Perform the O(1) btrfs clone operation, if possible.
|
* Perform the O(1) btrfs clone operation, if possible.
|
||||||
* Upon success, return 0. Otherwise, return -1 and set errno.
|
* Upon success, return 0. Otherwise, return -1 and set errno.
|
||||||
*/
|
*/
|
||||||
#if HAVE_LINUX_BTRFS_H
|
#ifdef REFLINK_IOC_CLONE
|
||||||
static inline int
|
static inline int
|
||||||
btrfsCloneFile(int dest_fd, int src_fd)
|
reflinkCloneFile(int dest_fd, int src_fd)
|
||||||
{
|
{
|
||||||
return ioctl(dest_fd, BTRFS_IOC_CLONE, src_fd);
|
return ioctl(dest_fd, REFLINK_IOC_CLONE, src_fd);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline int
|
static inline int
|
||||||
btrfsCloneFile(int dest_fd ATTRIBUTE_UNUSED,
|
reflinkCloneFile(int dest_fd ATTRIBUTE_UNUSED,
|
||||||
int src_fd ATTRIBUTE_UNUSED)
|
int src_fd ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
@ -96,6 +102,7 @@ btrfsCloneFile(int dest_fd ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int ATTRIBUTE_NONNULL(2)
|
static int ATTRIBUTE_NONNULL(2)
|
||||||
virStorageBackendCopyToFD(virStorageVolDefPtr vol,
|
virStorageBackendCopyToFD(virStorageVolDefPtr vol,
|
||||||
virStorageVolDefPtr inputvol,
|
virStorageVolDefPtr inputvol,
|
||||||
@ -142,7 +149,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reflink_copy) {
|
if (reflink_copy) {
|
||||||
if (btrfsCloneFile(fd, inputfd) < 0) {
|
if (reflinkCloneFile(fd, inputfd) < 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("failed to clone files from '%s'"),
|
_("failed to clone files from '%s'"),
|
||||||
|
Loading…
Reference in New Issue
Block a user