Bug 747510

Summary: automatically expose backstore block size in exported LUN
Product: Red Hat Enterprise Linux 6 Reporter: Andy Grover <agrover>
Component: scsi-target-utilsAssignee: Andy Grover <agrover>
Status: CLOSED ERRATA QA Contact: Storage QE <storage-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: bdonahue, bgoncalv, kzhang, msnitzer
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 873474 (view as bug list) Environment:
Last Closed: 2012-06-20 14:52:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 732980, 767187, 873474    

Description Andy Grover 2011-10-20 05:34:02 UTC
snitzer sez:

OK, ideally the target will provide support for both of these:

1) READ CAPACITY(16) provides the block sizes and alignment offset:
LOGICAL BLOCK LENGTH IN BYTES:
/sys/block/<disk>/queue/physical_block_size

LOGICAL BLOCKS PER PHYSICAL BLOCK EXPONENT is used to derive:
/sys/block/<disk>/queue/logical_block_size

LOWEST ALIGNED LOGICAL BLOCK ADDRESS:
/sys/block/<disk>/alignment_offset
/sys/block/<disk>/<partition>/alignment_offset

2) BLOCK LIMITS VPD provides the "I/O hints":
OPTIMAL TRANSFER LENGTH GRANULARITY and OPTIMAL TRANSFER LENGTH are used
to derive:
/sys/block/<disk>/queue/minimum_io_size
/sys/block/<disk>/queue/optimal_io_size

The sg3_utils package provides the 'sg_inq' utility that can be used to
access the BLOCK LIMITS VPD page (0xb0), using:
 sg_inq -p 0xb0 <device>

Comment 2 Andy Grover 2012-01-06 23:56:16 UTC
fix implemented and accepted upstream.

Comment 4 RHEL Program Management 2012-01-31 18:29:16 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux maintenance release. Product Management has 
requested further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed 
products. This request is not yet committed for inclusion in an Update release.

Comment 6 Bruno Goncalves 2012-03-15 13:40:26 UTC
The following information are presented correctly on the exported LUN

LOGICAL BLOCK LENGTH IN BYTES
LOGICAL BLOCKS PER PHYSICAL BLOCK EXPONENT
LOWEST ALIGNED LOGICAL BLOCK ADDRESS
OPTIMAL TRANSFER LENGTH GRANULARITY
OPTIMAL TRANSFER LENGTH

----

rpm -q scsi-target-utils
scsi-target-utils-1.0.24-1.el6.x86_64

rpm -q iscsi-initiator-utils
iscsi-initiator-utils-6.2.0.872-36.el6.x86_64


Configure LUN on the Target
modprobe scsi_debug sector_size=4096 dev_size_mb=10 lowest_aligned=512 physblk_exp=1 num_parts=1


edit /etc/tgt/targets.conf 
default-driver iscsi
<target iqn.2009-10.com.redhat:storage-1>
    write-cache off
    allow-in-use yes
    <direct-store /dev/sda>
    </direct-store>
</target>


service tgtd restart
Stopping SCSI target daemon: not running                   [FAILED]
Starting SCSI target daemon:                               [  OK  ]


Discover LUN on the Initiator
iscsiadm -m discovery -t st -p "127.0.0.1" -I default  -P1
Starting iscsid:                                           [  OK  ]
Target: iqn.2009-10.com.redhat:storage-1
        Portal: 127.0.0.1:3260,1
                Iface Name: default
iscsiadm -m node -l 

sg_inq -p 0xb0 /dev/sda
VPD INQUIRY: Block limits page (SBC)
  Optimal transfer length granularity: 2 blocks
  Maximum transfer length: 2560 blocks
  Optimal transfer length: 64 blocks
  Maximum prefetch, xdread, xdwrite transfer length: 0 blocks
  Maximum unmap LBA count: 0
  Maximum unmap block descriptor count: 0
  Optimal unmap granularity: 1
  Unmap granularity alignment valid: 0
  Unmap granularity alignment: 0

sg_inq -p 0xb0 /dev/sdb
VPD INQUIRY: Block limits page (SBC)
  Optimal transfer length granularity: 2 blocks
  Maximum transfer length: 0 blocks
  Optimal transfer length: 64 blocks
  Maximum prefetch, xdread, xdwrite transfer length: 0 blocks
  Maximum unmap LBA count: 0
  Maximum unmap block descriptor count: 0
  Optimal unmap granularity: 0
  Unmap granularity alignment valid: 0
  Unmap granularity alignment: 0


cat /sys/block/sda/queue/physical_block_size
8192
sg_readcap -l /dev/sda
Read Capacity results:
   Protection: prot_en=0, p_type=0, p_i_exponent=0
   Thin provisioning: tpe=0, tprz=0
   Last logical block address=2559 (0x9ff), Number of logical blocks=2560
   Logical block length=4096 bytes
   Logical blocks per physical block exponent=1
   Lowest aligned logical block address=512
Hence:
   Device size: 10485760 bytes, 10.0 MiB, 0.01 GB
cat /sys/block/sda/sda1/alignment_offset
0

cat /sys/block/sdb/queue/physical_block_size
8192
sg_readcap -l /dev/sdb
Read Capacity results:
   Protection: prot_en=0, p_type=0, p_i_exponent=0
   Thin provisioning: tpe=0, tprz=0
   Last logical block address=2559 (0x9ff), Number of logical blocks=2560
   Logical block length=4096 bytes
   Logical blocks per physical block exponent=1
   Lowest aligned logical block address=512
Hence:
   Device size: 10485760 bytes, 10.0 MiB, 0.01 GB
cat /sys/block/sdb/sdb1/alignment_offset
0

Comment 7 errata-xmlrpc 2012-06-20 14:52:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2012-0970.html