Bug 503726 - cannot create snapshot (inappropriate ioctl); wrong directory opened
cannot create snapshot (inappropriate ioctl); wrong directory opened
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: btrfs-progs (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Josef Bacik
Fedora Extras Quality Assurance
:
: 572958 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-02 08:21 EDT by Tomasz Torcz
Modified: 2010-03-12 08:27 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-06-02 09:59:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
name is first argument ot -s, and path is second (520 bytes, patch)
2009-06-02 08:38 EDT, Tomasz Torcz
no flags Details | Diff

  None (edit)
Description Tomasz Torcz 2009-06-02 08:21:25 EDT
Description of problem:
I cannot snapshot neither directory nor whole volume using btrfsprogs in F11.
I have LUKS-encrypted partition, over it I have single partition btrfs:

/dev/dm-5 on /media/WDP-Crypt type btrfs (rw,nosuid,nodev,uhelper=devkit)


Version-Release number of selected component (if applicable):
btrfs-progs-0.18-4.fc11.x86_64
kernel-2.6.29.4-167.fc11.x86_64


[root@gilbertus ~]# btrfsctl -s back_2009-06-02_01 /media/WDP-Crypt/Backup/
ioctl:: Inappropriate ioctl for device
[root@gilbertus ~]# btrfsctl -s back_2009-06-02_01 /media/WDP-Crypt/
ioctl:: Inappropriate ioctl for device
[root@gilbertus ~]# btrfsctl -s back_2009-06-02_01 /dev/dm-5 
ioctl:: Inappropriate ioctl for device
  

After some stracing and debugging I found following two errors in btrfsctl.c:
1) snapshot name is treated as directory to be snapshotted
2) dirname() strips the parameter and leaves "." as dir to be snapshotted. This happens after following lines in btrfsctl.c:

 snap_location = strdup(fullpath);
 snap_location = dirname(snap_location);

(snap_location equals "." afterwards). Look into following strace snippet:

stat(".", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=20480, ...}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
stat("/media/WDP-Crypt/Backup/", {st_mode=S_IFDIR|0755, st_size=82, ...}) = 0
open("/media/WDP-Crypt/Backup/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
ioctl(3, 0x50009401, 0x7ffff3e192e0)    = -1 ENOTTY (Inappropriate ioctl for device)


first "." is opened as fd3, then correct dir as fd4, and lastly *fd3* is snapshotted.
Comment 1 Tomasz Torcz 2009-06-02 08:38:41 EDT
Created attachment 346244 [details]
name is first argument ot -s, and path is second
Comment 2 Josef Bacik 2009-06-02 09:59:11 EDT
Ok looks like the documentation is wrong.  The way this is supposed to work is you do

btrfsctl -s /mnt/btrfs/snapshot_name /mnt/btrfs

that should work.  Sorry for the confusion, I'm fixing the wiki so it makes more sense.
Comment 3 Mario Ceresa 2010-03-12 08:27:41 EST
*** Bug 572958 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.