-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subvolume snapshot broken? #8
Comments
I think this is most likely a library issue. Right now, after issuing the snapshot creation we try to get the subvolume at that path btrfsutil-rs/src/subvolume/subvol.rs Line 248 in 97aea30
btrfsutil-rs/src/subvolume/subvol.rs Line 243 in 97aea30
|
I managed to reproduce the error (though it might be a different one) and figure out the cause. First, version Another one appeared instead: "Could not create subvolume", with The function |
AFAIK that error was caused by attempting to always use a function that required superuser permissions btrfsutil-rs/src/subvolume/subvol.rs Line 234 in 375010d
which uses btrfsutil-rs/src/subvolume/subvol.rs Line 168 in 375010d
I think this was fixed on
This is (or was?) the Here there is no sign that async transaction IDs are not supported: https://github.com/kdave/btrfs-progs/blob/471b4cf7e3a46222531a895f90228ea164b1b857/libbtrfsutil/btrfsutil.h#L415-L431. Are you saying that support for async transactions has been dropped? By the way, I looked over the implementation and I might have found an issue. btrfsutil-rs/src/subvolume/subvol.rs Lines 294 to 306 in 003fa61
btrfsutil-rs/src/subvolume/subvol.rs Line 308 in 003fa61
The transaction is set to 0 - essentially NULL (might've been better to use std::ptr::null() tbh). After that, the library uses btrfs_util_wait_sync to wait on a NULL async transaction id.
I haven't tested this, but I feel like there's something wrong with that.
At the moment the library returns the error as reported by Thanks for sharing your findings! |
It's that kernel code that's supposed to create the snapshot and return the transaction id by setting a field in the However, if you trace the ioctl invocation:
You'll find the place where EOPNOTSUPP is returned. It seems that libbtrfsutil passes an unsupported flag — namely, the one which asks the kernel code to return the transaction. It's set here: https://github.com/kdave/btrfs-progs/blob/471b4cf7e3a46222531a895f90228ea164b1b857/libbtrfsutil/subvolume.c#L1156-L1157. That flag is no longer supported though (its definition is commented out in btrfs-devel), and you won't find any usages of
That's not quire correct. You declare a variable and set its value to 0. Then you send the address of that variable to libbtrfsutil — and the address is not zero/nullptr. The libbtrfs function detects that, adds the flag for ioctl and, if the ioctl invocation is successful, uses the pointer to write the transaction id into your variable, thus overwriting the zero that you initialized it with: https://github.com/kdave/btrfs-progs/blob/471b4cf7e3a46222531a895f90228ea164b1b857/libbtrfsutil/subvolume.c#L1178-L1179. After that, it'd be correct to use the newly written value of the variable to wait for the transaction. |
Option 1: add a Option 2: make LibError a composite type which has both a In any case, be sure to handle the case of errno 0 (aka "no error") :) |
For some reason, I can't take a snapshot of a volume using
Subvolume::snapshot
. I keep getting a SearchFalied response no matter the path I provide as the destination. Here is the code I am using to take the snapshot:/mnt
is a the root of a btrfs filesystem with a subvolume atimages/alpine
. When I try it using thebtrfs
command line, it works with no issue. Even when I call it usingstd::process::Command
it works properly. Am I doing something wrong, or is it within the library?Edit: I should also add that I am running the program as root, so permissions shouldn't be an issue?
The text was updated successfully, but these errors were encountered: