Bug 1170771

Summary: virt-sparsify fails to sparsify CentOS 7 SWAP
Product: [Community] Virtualization Tools Reporter: Yogesh Sharma <yogeshsharma>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: mbooth, ptoscano, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-24 03:23:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
verbose output none

Description Yogesh Sharma 2014-12-04 19:55:51 UTC
virt-sparsify --in-place /dev/KVMVol/C7Image 
....
Trimming /dev/sda1 ...
Clearing Linux swap on /dev/sda2 ...
virt-sparsify: libguestfs error: blkdiscard: ioctl: /dev/sda2: BLKDISCARD: Input/output error

Here is fdisk -l of given volume

Device                         Boot     Start       End   Blocks  Id System
/dev/ThinVol/C7Image1 *         2048   1026047   512000  83 Linux
/dev/ThinVol/C7Image2        1026048   9185279  4079616  82 Linux swap / Solaris
/dev/ThinVol/C7Image3        9185280  83881983 37348352  83 Linux

Comment 1 Yogesh Sharma 2014-12-04 20:02:35 UTC
Created attachment 964804 [details]
verbose output

Comment 2 Yogesh Sharma 2014-12-04 20:04:49 UTC
I meant to type "virt-sparsify --in-place /dev/ThinVol/C7Image"

Comment 3 Richard W.M. Jones 2014-12-04 20:05:30 UTC
Thanks for filing the bug.  Is there anything special about how the
CentOS 7 guest was installed?  I think you mentioned something about
LVM thinp, which I've never used in CentOS (wouldn't even know how
you'd get the installer to use it).

Comment 4 Richard W.M. Jones 2014-12-04 20:19:47 UTC
The actual failure is interesting:

guestfsd calls ioctl (BLKDISCARD) on the swap device, and we see:

[    3.253330] sd 2:0:0:0: [sda]  
[    3.253936] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[    3.254316] sd 2:0:0:0: [sda]  
[    3.254316] Sense Key : Aborted Command [current] 
[    3.254316] sd 2:0:0:0: [sda]  
[    3.254316] Add. Sense: I/O process terminated
[    3.254316] sd 2:0:0:0: [sda] CDB: 
[    3.254316] Write same(16): 93 08 00 00 00 00 00 0f a8 00 00 7c 80 00 00 00
[    3.254316] end_request: I/O error, dev sda, sector 1026048
guestfsd: error: ioctl: /dev/sda2: BLKDISCARD: Input/output error

There are several possible things that might be indicated by that:

 - actual disk corruption (unlikely, but something to check)

 - LVM thinp doesn't support/pass through the SCSI WRITESAME command properly

 - partition table mismatches or overlaps somehow

 - not all guest disks are being presented to libguestfs (is it a
   multi-disk guest?)

Comment 5 Richard W.M. Jones 2014-12-04 20:28:33 UTC
This Debian bug is interesting:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757927

Comment 6 Yogesh Sharma 2014-12-05 02:52:34 UTC
My setup
Host Fedora 20 running on SSD + LVM
Additional spinning disk with Thin LVM Volumes used mostly for KVM Disks
For any KVM guest a LVM Thin Volume is created and used for Guest.

CentOS 7 was installed using desk setting using DVD. Partition scheme was to use btrfs (/ ext3, / btrfs and swap). Disk was added to guest as Virtio-SCSI. Looking at fdisk -l at least not showing overlap.

virt-sparsify only fails on swap cleaning.

I get no error when I do it manually:
kpartx -av <lvm thin vol>
mount partitions with discard options and run fstrim.

Comment 7 Yogesh Sharma 2017-04-24 03:23:55 UTC
Looks like this issues was resolved, I am not getting this error with F25 + updates.