Bug 1222816 - BTRFS_IOC_SNAP_CREATE_V2 returns error but did some of the work
Summary: BTRFS_IOC_SNAP_CREATE_V2 returns error but did some of the work
Status: RESOLVED INVALID
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Kernel:Filesystems (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Wenruo Qu
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-15 09:35 UTC by Arvin Schnell
Modified: 2024-04-22 06:51 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arvin Schnell 2024-04-15 09:35:07 UTC
While working on bug #1222674 I noticed that the BTRFS_IOC_SNAP_CREATE_V2
ioctl when passed a non existing qgroup does create the snapshot but also
reports an error (ENOENT). Is that desired behavior? Can I really on that
it (ioctl does everything except adding to the qgroup)?
Comment 1 Arvin Schnell 2024-04-15 12:16:56 UTC
David, you were involved in https://github.com/gregkh/linux/commit/f19dad4f440af4ef09ca3c76bda83290391f4d2d. Please comment.
Comment 2 Wenruo Qu 2024-04-22 05:40:48 UTC
Mind to explain what did you mean by "does create the snapshot"?

In my test environment with upstream kernel, it doesn't create the snapshot at all:

```
$ sudo mkfs.btrfs  -f /dev/test/scratch1
$ sudo mount /dev/test/scratch1  /mnt/btrfs/
$ sudo btrfs subv create /mnt/btrfs/subv1
Create subvolume '/mnt/btrfs/subv1'
$ sudo mount /dev/test/scratch1  /mnt/btrfs/
$ sudo btrfs subv create /mnt/btrfs/subv1
Create subvolume '/mnt/btrfs/subv1'
```

And in above case, the behavior is correct, the snapshot creation is rejected due to invalid qgroup inherit parameters.
Comment 3 Wenruo Qu 2024-04-22 05:42:32 UTC
(In reply to Wenruo Qu from comment #2)
> Mind to explain what did you mean by "does create the snapshot"?
> 
> In my test environment with upstream kernel, it doesn't create the snapshot
> at all:
> 
> ```
> $ sudo mkfs.btrfs  -f /dev/test/scratch1
> $ sudo mount /dev/test/scratch1  /mnt/btrfs/
> $ sudo btrfs subv create /mnt/btrfs/subv1
> Create subvolume '/mnt/btrfs/subv1'
> $ sudo mount /dev/test/scratch1  /mnt/btrfs/
> $ sudo btrfs subv create /mnt/btrfs/subv1
> Create subvolume '/mnt/btrfs/subv1'
> ```

My bad, the command line options are copied incorrectly.

The correct one is:

```
$ sudo mkfs.btrfs  -f /dev/test/scratch1
$ sudo mount /dev/test/scratch1  /mnt/btrfs/
$ sudo btrfs subv create /mnt/btrfs/subv1
Create subvolume '/mnt/btrfs/subv1'
$ sudo btrfs subv snapshot -i 1/0 /mnt/btrfs/subv1 /mnt/btrfs/snap1
ERROR: cannot snapshot '/mnt/btrfs/subv1': No such file or directory
$ ls /mnt/btrfs/
subv1
```
> 
> And in above case, the behavior is correct, the snapshot creation is
> rejected due to invalid qgroup inherit parameters.
Comment 4 Arvin Schnell 2024-04-22 06:51:44 UTC
Sorry, I cannot reproduce the problem myself. Maybe I was confused.