// clean up
volargs.fd = 0;
- r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &volargs);
- if (r != 0) {
- dout(0) << "mount btrfs SNAP_DESTROY failed: " << strerror_r(-r, buf, sizeof(buf)) << dendl;
+ r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY_ASYNC, &volargs);
+ if (r == 0) {
+ dout(0) << "mount btrfs SNAP_DESTROY_ASYNC is supported" << dendl;
+ btrfs_snap_destroy_async = true;
+ } else {
+ dout(0) << "mount btrfs SNAP_DESTROY_ASYNC is NOT supported: "
+ << strerror_r(-r, buf, sizeof(buf)) << dendl;
+ r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &volargs);
+ if (r != 0) {
+ dout(0) << "mount btrfs SNAP_DESTROY failed: " << strerror_r(-r, buf, sizeof(buf)) << dendl;
+ }
}
} else {
dout(0) << "mount btrfs SNAP_CREATE_ASYNC is NOT supported: "
// drop current
snapargs.fd = 0;
strcpy(snapargs.name, "current");
- int r = ::ioctl(basedir_fd, BTRFS_IOC_SNAP_DESTROY, &snapargs);
+ int r = ::ioctl(basedir_fd,
+ btrfs_snap_destroy_async ? BTRFS_IOC_SNAP_DESTROY_ASYNC:BTRFS_IOC_SNAP_DESTROY,
+ &snapargs);
if (r) {
char buf[80];
dout(0) << "error removing old current subvol: " << strerror_r(errno, buf, sizeof(buf)) << dendl;
bool btrfs_snap_create;
bool btrfs_snap_destroy;
bool btrfs_snap_create_async;
+ bool btrfs_snap_destroy_async;
bool btrfs_wait_sync;
int fsid_fd, op_fd;
btrfs_snap_create(false),
btrfs_snap_destroy(false),
btrfs_snap_create_async(false),
+ btrfs_snap_destroy_async(false),
btrfs_wait_sync(false),
fsid_fd(-1), op_fd(-1),
attrs(this), fake_attrs(false),
#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
#define BTRFS_IOC_SNAP_CREATE_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 23, \
struct btrfs_ioctl_vol_args)
+#define BTRFS_IOC_SNAP_DESTROY_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 24, \
+ struct btrfs_ioctl_vol_args)
#endif