Bug 1039501

Summary: [provisioning] discard=on broken
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Paolo Bonzini <pbonzini>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, areis, chayang, hhuang, huding, juzhang, michen, pbonzini, qzhang, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-22.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 12:09:35 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:

Description Sibiao Luo 2013-12-09 09:49:59 UTC
Description of problem:
when i do provisioning test for ide/ahci interface with discard=on under UNMAP mode, but it fail to discard the free space after remove the data in guest.
Also tried the scsi-hd/scsi-block did not hit such issue.

Version-Release number of selected component (if applicable):
host info:
3.10.0-60.el7.x86_64
qemu-kvm-rhev-1.5.3-21.el7.x86_64
seabios-1.7.2.2-4.el7.x86_64
guest info:
3.10.0-60.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.generate a scsi disk with scsi_debug using UNMAP mode.
# modprobe scsi_debug dev_size_mb=1024 lbpu=1
# lsscsi
[0:0:0:0]    disk    ATA      ST3500413AS      HP64  /dev/sda 
[2:0:0:0]    cd/dvd  hp       DVD-RAM GH80N    RF01  /dev/sr0 
[6:0:0:0]    disk    EQLOGIC  100E-00          5.0   /dev/sdb 
[9:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdc 
# cat /sys/block/sdc/device/scsi_disk/9\:0\:0\:0/provisioning_mode
unmap
# cat /sys/bus/pseudo/drivers/scsi_debug/map
                <----------nothing output
2.boot a guest with /dev/sdc as a ide/ahci data disk, like:
# /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge -enable-kvm...-drive file=/dev/sdc,if=none,id=drive-data-disk,cache=none,format=raw,aio=native,discard=on -device ide-hd,drive=drive-data-disk,id=data-disk

3.Make file system (both xfs and ext4 hit it) to the disk in the guest.
# mkfs.xfs /dev/sdb
meta-data=/dev/sdb               isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

4.On the host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

5.in the guest
# mount /dev/sdb /home/test
# dd if=/dev/zero of=/home/test/file
dd: writing to ‘/home/test/file’: No space left on device
1928857+0 records in
1928856+0 records out
987574272 bytes (988 MB) copied, 2.05315 s, 481 MB/s

6.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

7.in guest.
# rm -f /home/test/file
# fstrim /home/test

8.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

Actual results:
after step 4,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-255,524288-524291,524296-524319,1048576-1048579,1048584-1151007,1572864-1572867,1572872-1572895,2096896-2097151
after step 6,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-524279,524288-524291,524296-524319,524352-1048567,1048576-1048579,1048584-1151007,1151040-1539975,1572864-1572867,1572872-1572895,1572928-2064447,2096896-2097151
after step 8, the cat map output did not change. 
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-524279,524288-524291,524296-524319,524352-1048567,1048576-1048579,1048584-1151007,1151040-1539975,1572864-1572867,1572872-1572895,1572928-2064447,2096896-2097151

Expected results:
discard the free space successfully after remove the data in guest. like the scsi-hd test results:
after step 4,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-535,544-567,576-623,648-655,776-33551,262144-262159,786432-786447,1048576-1114111,1310720-1310735,1835008-1835023,2097024-2097151
after step 6,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-535,544-567,576-623,648-655,776-246543,262144-262159,278528-786447,786952-1310735,1311240-1311759,1327104-1835023,1835528-1837751,1851392-2097151
after step 8,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-623,648-655,776-246543,262144-262159,278528-786447,786952-1310735,1311240-1311759,1327104-1835023,1835528-1837751,1851392-2097151

Additional info:
# /usr/libexec/qemu-kvm -M pc -S -cpu SandyBridge -enable-kvm -m 2048 -smp 2,sockets=2,cores=1,threads=1 -no-kvm-pit-reinjection -usb -device usb-tablet,id=input0 -name sluo -uuid 990ea161-6b67-47b2-b803-19fb01d30d30 -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev socket,id=channel2,path=/tmp/helloworld2,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=iscsi://10.66.90.100:3260/iqn.2001-05.com.equallogic:0-8a0906-4c41f7d03-453f49b421052a57-s2-sluo-270305-1/0,if=none,id=drive-system-disk,cache=none,format=raw,aio=native,werror=stop,rerror=stop -iscsi id=iqn0 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x4 -device scsi-block,drive=drive-system-disk,bus=scsi0.0,id=libiscsi-system-disk,bootindex=1 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device rtl8139,netdev=hostnet0,id=rtl8139-net-pci0,mac=00:01:02:B6:40:21,bus=pci.0,addr=0x5 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x6 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -drive file=/dev/sdc,if=none,id=drive-data-disk,cache=none,format=raw,aio=native,discard=on -device ide-hd,drive=drive-data-disk,id=data-disk -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -spice disable-ticketing,port=5931 -monitor stdio

Comment 1 Sibiao Luo 2013-12-10 05:24:18 UTC
(In reply to Sibiao Luo from comment #0)
> Expected results:
> discard the free space successfully after remove the data in guest. like the
> scsi-hd test results:
> after step 4,
> # cat /sys/bus/pseudo/drivers/scsi_debug/map
> 0-535,544-567,576-623,648-655,776-33551,262144-262159,786432-786447,1048576-
> 1114111,1310720-1310735,1835008-1835023,2097024-2097151
> after step 6,
> # cat /sys/bus/pseudo/drivers/scsi_debug/map
> 0-535,544-567,576-623,648-655,776-246543,262144-262159,278528-786447,786952-
> 1310735,1311240-1311759,1327104-1835023,1835528-1837751,1851392-2097151
> after step 8,
> # cat /sys/bus/pseudo/drivers/scsi_debug/map
> 0-623,648-655,776-246543,262144-262159,278528-786447,786952-1310735,1311240-
> 1311759,1327104-1835023,1835528-1837751,1851392-2097151
> 
Sorry, above is the virtio-blk interface testing results which should not support discard, and the scsi-hd interface also hit the same issue, i will separate a new bug for it.

The expected results should like the scsi-block interface with discard=on,like:
e.g:...-drive file=/dev/sdc,if=none,id=drive-data-disk,cache=none,format=raw,aio=native,werror=stop,rerror=stop,discard=on -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x7 -device scsi-block,drive=drive-data-disk,bus=scsi1.0,id=data-disk

after step 4,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-255,262144-262147,262152-262175,524288-524291,524296-524319,786432-786435,786440-786463,1048576-1048579,1048584-1151007,1310720-1310723,1310728-1310751,1572864-1572867,1572872-1572895,1835008-1835011,1835016-1835039,2096896-2097151
after step 6,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-262135,262144-262147,262152-262175,262208-524279,524288-524291,524296-524319,524352-786423,786432-786435,786440-786463,786496-1048567,1048576-1048579,1048584-1151007,1151040-1310479,1310720-1310723,1310728-1310751,1310784-1572855,1572864-1572867,1572872-1572895,1572928-1769607,1769616-1834991,1835008-1835011,1835016-1835039,1835072-2031839,2096896-2097151
after step 8,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-95,262144-262147,262152-262175,524288-524291,524296-524319,786432-786435,786440-786463,1048576-1048579,1048584-1151007,1310720-1310723,1310728-1310751,1572864-1572867,1572872-1572895,1835008-1835011,1835016-1835039

Best Regards,
sluo

Comment 2 Paolo Bonzini 2013-12-10 13:47:44 UTC
*** Bug 1039823 has been marked as a duplicate of this bug. ***

Comment 3 Paolo Bonzini 2013-12-10 13:50:12 UTC
Fixed by upstream commit 8b7a5415f9297c1fbae5bff28dcb059d50c1b045.

Comment 8 huiqingding 2013-12-23 05:29:03 UTC
Reproduce this bug using the following version:
host info:
3.10.0-63.el7.x86_64
qemu-kvm-rhev-1.5.3-21.el7.x86_64
seabios-bin-1.7.2.2-4.el7.noarch
guest info:
3.10.0-54.0.1.el7.x86_64

Steps to Reproduce:
1.generate a scsi disk with scsi_debug using UNMAP mode.
# modprobe scsi_debug dev_size_mb=1024 lbpu=1
# lsscsi
[0:0:0:0]    disk    ATA      ST500DM002-1BD14 HP73  /dev/sda 
[2:0:0:0]    cd/dvd  hp       DVD-RAM GH82N    R203  /dev/sr0 
[6:0:0:0]    storage IET      Controller       0001  -        
[6:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdc 
[6:0:0:2]    disk    IET      VIRTUAL-DISK     0001  /dev/sdd 
[6:0:0:3]    disk    IET      VIRTUAL-DISK     0001  /dev/sde 
[6:0:0:4]    disk    IET      VIRTUAL-DISK     0001  /dev/sdf 
[7:0:0:0]    storage IET      Controller       0001  -        
[7:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb 
[8:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdg 
# cat /sys/block/sdg/device/scsi_disk/8\:0\:0\:0/provisioning_mode 
unmap
# cat /sys/bus/pseudo/drivers/scsi_debug/map
                <----------nothing output
2.boot a guest with /dev/sdg as a ide/ahci data disk, like:
# /usr/libexec/qemu-kvm -S -M pc-i440fx-rhel7.0.0 -cpu SandyBridge -enable-kvm -m 4G -smp 4,sockets=2,cores=2,threads=1 -name rhel7 -uuid 355a2475-4e03-4cdd-bf7b-5d6a59edaa61 -rtc base=localtime,clock=host,driftfix=slew -drive file=/home/RHEL-7.0-20131127.1.qcow2_v3-bak,if=none,id=drive-system-disk,cache=writeback -iscsi id=iqn,initiator-name=iqn.1994-05.com.redhat:sluo, -device virtio-scsi-pci,bus=pci.0,addr=0x5,id=scsi0,ioeventfd=off -device virtio-balloon-pci,id=ballooning -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -netdev tap,id=tap1,vhost=on,queues=4,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -device rtl8139,netdev=tap1,id=nic1,mac=1a:59:0a:4b:5a:94 -k en-us -boot menu=on,reboot-timeout=-1,strict=on -qmp tcp:0:4445,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :3 -spice port=5932,disable-ticketing -vga qxl -monitor stdio -monitor tcp:0:7445,server,nowait -monitor unix:/tmp/monitor1,server,nowait -drive file=/dev/sdg,if=none,id=drive-data-disk,cache=none,format=raw,aio=native,discard=on -device ide-hd,drive=drive-data-disk,id=data-disk

3.Make file system (both xfs and ext4 hit it) to the disk in the guest.
# mkfs.xfs /dev/sdb
meta-data=/dev/sdb               isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

4.On the host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

5.in the guest
# mount /dev/sdb /home/test
# dd if=/dev/zero of=/home/test/file
dd: writing to ‘/home/test/file’: No space left on device
1928857+0 records in
1928856+0 records out
987574272 bytes (988 MB) copied, 2.05315 s, 481 MB/s

6.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

7.in guest.
# rm -f /home/test/file
# fstrim /home/test

8.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

Actual results:
after step 4,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-391,524288-524291,524296-524319,1048576-1048579,1048584-1151007,1572864-1572867,1572872-1572895,2096896-2097151
after step 6,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-524279,524288-524291,524296-524319,524352-1048567,1048576-1048579,1048584-1151007,1151040-1507287,1572864-1572867,1572872-1572895,1572928-2097151
after step 8, the cat map output did not change. 
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-524279,524288-524291,524296-524319,524352-1048567,1048576-1048579,1048584-1151007,1151040-1507287,1572864-1572867,1572872-1572895,1572928-2097151
Additional info:
I also test scsi-hd interface using the above steps, also hit this bug.

Verify this bug using the following version:
host info:
3.10.0-63.el7.x86_64
qemu-kvm-1.5.3-30.el7.x86_64
seabios-bin-1.7.2.2-4.el7.noarch
guest info:
3.10.0-54.0.1.el7.x86_64

Steps to Reproduce:
1.generate a scsi disk with scsi_debug using UNMAP mode.
# modprobe scsi_debug dev_size_mb=1024 lbpu=1
# lsscsi
[0:0:0:0]    disk    ATA      ST500DM002-1BD14 HP73  /dev/sda 
[2:0:0:0]    cd/dvd  hp       DVD-RAM GH82N    R203  /dev/sr0 
[6:0:0:0]    storage IET      Controller       0001  -        
[6:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdc 
[6:0:0:2]    disk    IET      VIRTUAL-DISK     0001  /dev/sdd 
[6:0:0:3]    disk    IET      VIRTUAL-DISK     0001  /dev/sde 
[6:0:0:4]    disk    IET      VIRTUAL-DISK     0001  /dev/sdf 
[7:0:0:0]    storage IET      Controller       0001  -        
[7:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb 
[8:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdg 
# cat /sys/block/sdg/device/scsi_disk/8\:0\:0\:0/provisioning_mode 
unmap
# cat /sys/bus/pseudo/drivers/scsi_debug/map
                <----------nothing output
2.boot a guest with /dev/sdg as a ide/ahci data disk, like:
# /usr/libexec/qemu-kvm -S -M pc-i440fx-rhel7.0.0 -cpu SandyBridge -enable-kvm -m 4G -smp 4,sockets=2,cores=2,threads=1 -name rhel7 -uuid 355a2475-4e03-4cdd-bf7b-5d6a59edaa61 -rtc base=localtime,clock=host,driftfix=slew -drive file=/home/RHEL-7.0-20131127.1.qcow2_v3-bak,if=none,id=drive-system-disk,cache=writeback -iscsi id=iqn,initiator-name=iqn.1994-05.com.redhat:sluo, -device virtio-scsi-pci,bus=pci.0,addr=0x5,id=scsi0,ioeventfd=off -device virtio-balloon-pci,id=ballooning -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -netdev tap,id=tap1,vhost=on,queues=4,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -device rtl8139,netdev=tap1,id=nic1,mac=1a:59:0a:4b:5a:94 -k en-us -boot menu=on,reboot-timeout=-1,strict=on -qmp tcp:0:4445,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :3 -spice port=5932,disable-ticketing -vga qxl -monitor stdio -monitor tcp:0:7445,server,nowait -monitor unix:/tmp/monitor1,server,nowait -drive file=/dev/sdg,if=none,id=drive-data-disk,cache=none,format=raw,aio=native,discard=on -device ide-hd,drive=drive-data-disk,id=data-disk

3.Make file system (both xfs and ext4 hit it) to the disk in the guest.
# mkfs.xfs /dev/sdb
meta-data=/dev/sdb               isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=12800, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

4.On the host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

5.in the guest
# mount /dev/sdb /home/test
# dd if=/dev/zero of=/home/test/file
dd: writing to ‘/home/test/file’: No space left on device
1928857+0 records in
1928856+0 records out
987574272 bytes (988 MB) copied, 2.05315 s, 481 MB/s

6.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

7.in guest.
# rm -f /home/test/file
# fstrim /home/test

8.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

after step 4,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-255,524288-524291,524296-524319,1048576-1048579,1048584-1151007,1572864-1572867,1572872-1572895,2096896-2097151
after step 6,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-524279,524288-524291,524296-524319,524352-1048567,1048576-1048579,1048584-1151007,1151040-1507287,1572864-1572867,1572872-1572895,1572928-2097151
after step 8, discard the free space successfully after remove the data in guest
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-95,524288-524291,524296-524319,1048576-1048579,1048584-1151007,1572864-1572867,1572872-1572895

Additional info:
I also test scsi-hd interface using the above steps, the result is same as the above: after step 8, discard the free space successfully after remove the data in guest

Based on the above result, I think this bug is fixed.

Comment 10 Ludek Smid 2014-06-13 12:09:35 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.