BBK BBK - 11 months ago 93
Linux Question

Which version of Linux Kernel start to support SPC-4 for VMware 6.5 UNMAP

VMware 6.5 announced to support UNMAP commands (Space Reclamation from thin LUNs on storage systems) with VMFS6 and Linux virtual machines which supports SCSI Primary Commands - 4 (SPC-4).
Which version of Linux Kernel start to support SPC-4 for VMware 6.5 UNMAP?

Answer Source

It's less of a question of "When will Linux support SPC-4 for UNMAP" (you can always try and send raw SCSI commands and Linux doesn't have to actually "understand" those) so I think you meant to ask "which version of Linux automatically advertises discard on appropriate ESXi disks?".

For the past few years so long as the "disk" says it can support the SCSI standard SPC-2 or higher Linux will go on to check and expose discard (aka TRIM or UNMAP) support if available. Exposing discard support went in with commit which eventually turned up in 2.6.39. See which shows how reading the VPD pages only happens if a) It is somehow forced (via explicit quirks for er, "quirky" devices) or b) the device claims to implement at least the SCSI SPC-2 specifcation. In turn being able to read VPD pages is needed for checking if the device supports thin provisioning over on .

I've checked a thin provisioned VMDK disk on ESXi 6.0, version 11 VM running Ubuntu 16.04, Guest OS set to Ubuntu 64 bit. If you look at the "Logical block provisioning" VPD page (via sg_vpd -p lbpv) for the disk you are told:

Logical block provisioning VPD page (SBC):
  Unmap command supported (LBPU): 1
  Write same (16) with unmap bit supported (LBWS): 0
  Write same (10) with unmap bit supported (LBWS10): 0

(I had to set the advanced option EnableBlockDelete to 1 on the VM to get this)

If you look at the READCAPACITY(16) results (via sg_readcap -16):

Read Capacity results:
   Protection: prot_en=0, p_type=0, p_i_exponent=0
   Logical block provisioning: lbpme=1, lbprz=1

So again it's claiming to be thin.

However sg_inq shows the disk only claims to support SCSI-2:

standard INQUIRY:
  PQual=0  Device_type=0  RMB=0  LU_CONG=0  version=0x02  [SCSI-2]

(SCSI-2 is a few revision below SPC-2 see for how Linux orders SCSI spec versions).

So Linux won't advertise discard:

grep . /sys/block/sdc/queue/discard_max_bytes

and anything that tries to use discard will fail for me:

# blkdiscard --offset 0 --length=2048 /dev/sdc
blkdiscard: /dev/sdc: BLKDISCARD ioctl failed: Operation not supported

Despite this it's possible to manually send raw SCSI UNMAPs down:

# sg_unmap --lba=0 --num=2048 /dev/sdc

(note that there's a minimum size of 1MByte for unmap operations or you'll get an error back)

TLDR; Advertising discard in Linux was added in 2.6.39 but nearly any Linux can be made to manually passthrough SCSI UNMAP commands (and on ESXi your VM must meet the correct requirements).