Bug 980788 - fstrim returns error "FITRIM ioctl failed: Inappropriate ioctl for device" in rhel6
fstrim returns error "FITRIM ioctl failed: Inappropriate ioctl for device" in...
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs (Show other bugs)
6.5
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Richard W.M. Jones
Virtualization Bugs
:
Depends On:
Blocks: 980790
  Show dependency treegraph
 
Reported: 2013-07-03 04:51 EDT by bfan
Modified: 2013-07-05 10:17 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 980790 (view as bug list)
Environment:
Last Closed: 2013-07-05 10:17:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description bfan 2013-07-03 04:51:49 EDT
Description of problem:
fstrim returns error "FITRIM ioctl failed: Inappropriate ioctl for device" in rhel6, through its help output,

"If this support isn't
    present it may give an error or even appear to run but do nothing"

we are not sure, whether it's not support or it's a bug


Version-Release number of selected component (if applicable):
libguestfs-1.20.9-6.el6.x86_64
kernel: 2.6.32-358.el6.x86_64
qemu-kvm-0.12.1.2-2.375.el6.x86_64


How reproducible:
100%


Steps to Reproduce:
[root]# qemu-img create -f qcow2 test.qcow2 100M
[root]# guestfish -a test.qcow2

><fs> run
><fs> mkfs ext2 /dev/sda
><fs> mount /dev/sda /
><fs> df
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    98036         0     98036   0% /run
/dev                    241996       128    241868   1% /dev
/dev/sda                 99150      1550     92480   2% /sysroot

><fs> fstrim /
libguestfs: error: fstrim: fstrim: /: FITRIM ioctl failed: Inappropriate ioctl for device


Actual results:
fstrim give an error


Expected results:
fstrim works well


Additional info:
in rhel7, fstrim does not give error but do nothing,

><fs> df
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs              97952    76     97876   1% /run
/dev              243196     0    243196   0% /dev
/dev/sda           99150  1550     90432   2% /sysroot

><fs> fstrim /
><fs> df
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs              97952    76     97876   1% /run
/dev              243196     0    243196   0% /dev
/dev/sda           99150  1550     90432   2% /sysroot
Comment 1 Richard W.M. Jones 2013-07-05 10:17:31 EDT
Yup, fstrim isn't supported (by the kernel) in RHEL 6:

><rescue> mke2fs -t ext4 /dev/sda1 
mke2fs 1.41.12 (17-May-2010)
[...]
><rescue> mount /dev/sda1 /
[   75.237242] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: 
><rescue> fstrim /         
fstrim: /: FITRIM ioctl failed: Inappropriate ioctl for device
><rescue> strace fstrim /
[...]
ioctl(3, 0xc0185879, 0x7fff0dcc0940)    = -1 ENOTTY (Inappropriate ioctl for device)
[...]

Thus this error message is correct.

However we could remove/disable the fstrim API completely
from libguestfs, although I'm not really sure that would
help anyone.  Anyone running the guestfish fstrim command
blindly would get an error in both cases.

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