Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1039823

Summary: [provisioning] scsi-hd interface fail to work with discard=on
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED DUPLICATE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, chayang, juzhang, michen, pbonzini, qzhang, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-10 13:47:44 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:

Description Sibiao Luo 2013-12-10 05:31:46 UTC
Description of problem:
when i do provisioning test for scsi-hd interface with discard=on under UNMAP mode, but it fail to discard the free space after remove the data in guest, we could not see any sector rollback.
Also tried the 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 
[12:0:0:0]   disk    Linux    scsi_debug       0004  /dev/sdc 
# cat /sys/block/sdc/device/scsi_disk/12\: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,werror=stop,rerror=stop,discard=on -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x7 -device scsi-hd,drive=drive-data-disk,bus=scsi1.0,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, 1.74507 s, 566 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:
see SCSI disc map info and compare with step8, we should see some sector rollback, just like scsi-block, 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

Additional info:

Comment 1 Paolo Bonzini 2013-12-10 13:35:53 UTC
I cannot reproduce this with a RHEL6.3 (2.6.32-358.el6) guest.

After step 4:
$ cat /sys/bus/pseudo/drivers/scsi_debug/map
0-255,524288-524291,524296-524319,1048576-1048579,1048584-1069087,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-1069087,1069120-1539455,1572864-1572867,1572872-1572895,1572928-2064967,2096896-2097151

After step 8:
0-95,524288-524291,524296-524319,1048576-1048579,1048584-1069087,1572864-1572867,1572872-1572895

Will try RHEL7 later.

Comment 2 Paolo Bonzini 2013-12-10 13:47:44 UTC

*** This bug has been marked as a duplicate of bug 1039501 ***