Re: Recognizing SMR HDDs

From: Kenneth D. Merry <ken_at_FreeBSD.ORG>
Date: Thu, 26 May 2016 08:34:45 -0400
On Thu, May 26, 2016 at 08:42:53 +0200, Gary Jennejohn wrote:
> Now that ken_at_ has checked in the SMR code I'm wondering how I can see
> whether it's having any effect.
> 
> I have a 8TB SMR disk in a USB3 enclosure.  Does the kernel emit any
> sort of trace to indicate that it sees the drive as SMR and takes
> that into account?

There is nothing extra emitted in the dmesg to tell you it is an SMR drive,
you have to look.

> I have the probe trace enabled in my kernel config, but I don't see
> anything special pop out when I turn the drive on.

You'll see extra states in the probe compared to a standard drive if it 
is Host Aware or Host Managed.  You won't see those states if it is Drive
Managed.

> Does the fact that the drive appears as a /dev/daX play any role?

It shouldn't matter.  I put changes in both the da(4) and ada(4) drivers to
support SMR drives.  And the changes should work even when you have an ATA
protocol drive attached via a SCSI transport.  Which is likely the case
with your drive.  What kind of drive is it?

Here are some things you can do on any disk to see what it is:

diskinfo -v /dev/daX

For example:

# diskinfo -v /dev/da18
/dev/da18
        512             # sectorsize
        8001563222016   # mediasize in bytes (7.3T)
        15628053168     # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        972801          # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
                    Z84003SK    # Disk ident.
        id1,enc_at_n5003048001f311fd/type_at_0/slot_at_13/elmdesc_at_Slot_19        #
Physical path
        Host_Aware      # Zone Mode

So this is a Host Aware drive.

zonectl -c params -d /dev/daX

# zonectl -c params -d /dev/da18
Zone Mode: Host Aware
Command support: Report Zones, Open, Close, Finish, Reset Write Pointer
Unrestricted Read in Sequential Write Required Zone (URSWRZ): No
Optimal Number of Open Sequential Write Preferred Zones: 128
Optimal Number of Non-Sequentially Written Sequential Write Preferred
Zones: 8
Maximum Number of Open Sequential Write Required Zones: Unlimited

If I issue the same command on a drive managed SMR drive:

# zonectl -c params -d /dev/da19
Zone Mode: Drive Managed
Command support: None
Unrestricted Read in Sequential Write Required Zone (URSWRZ): No
Optimal Number of Open Sequential Write Preferred Zones: Not Set
Optimal Number of Non-Sequentially Written Sequential Write Preferred Zones: Not Set
Maximum Number of Open Sequential Write Required Zones: Not Set

sysctl kern.cam.da.X

# sysctl kern.cam.da.18
kern.cam.da.18.sort_io_queue: -1
kern.cam.da.18.rotating: 1
kern.cam.da.18.unmapped_io: 1
kern.cam.da.18.error_inject: 0
[ begin SMR fields ]
kern.cam.da.18.max_seq_zones: 4294967295
kern.cam.da.18.optimal_nonseq_zones: 8
kern.cam.da.18.optimal_seq_zones: 128
kern.cam.da.18.zone_support: Report Zones, Open, Close, Finish, Reset Write
Pointer
kern.cam.da.18.zone_mode: Host Aware
[ end SMR fields ]
kern.cam.da.18.minimum_cmd_size: 6
kern.cam.da.18.delete_max: 262144
kern.cam.da.18.delete_method: NONE

# sysctl kern.cam.da.19
kern.cam.da.19.sort_io_queue: -1
kern.cam.da.19.rotating: 1
kern.cam.da.19.unmapped_io: 1
kern.cam.da.19.error_inject: 0
[ begin SMR fields ]
kern.cam.da.19.max_seq_zones: 0
kern.cam.da.19.optimal_nonseq_zones: 0
kern.cam.da.19.optimal_seq_zones: 0
kern.cam.da.19.zone_support: None
kern.cam.da.19.zone_mode: Drive Managed
[ begin SMR fields ]
kern.cam.da.19.minimum_cmd_size: 6
kern.cam.da.19.delete_max: 262144
kern.cam.da.19.delete_method: NONE

If you have a Host Aware or Host Managed drive, you can get the list of
zones and their status, reset the write pointer, etc.  

Ask the drive (via camcontrol(8)) to list all zones on a Host Aware drive 
(but truncate the output to 10 lines):

# camcontrol zone da18 -v -c rz |head -10
29809 zones, Maximum LBA 0x3a3812aaf (15628053167)
Zone lengths and types may vary
  Start LBA  Length       WP LBA      Zone Type      Condition      Sequential             Reset
          0, 524288,     0x80000,  Conventional,           NWP,     Sequential,  No Reset Needed
    0x80000, 524288,    0x100000,  Conventional,           NWP,     Sequential,  No Reset Needed
   0x100000, 524288,    0x180000,  Conventional,           NWP,     Sequential,  No Reset Needed
   0x180000, 524288,    0x200000,  Conventional,           NWP,     Sequential,  No Reset Needed
   0x200000, 524288,    0x280000,  Conventional,           NWP,     Sequential,  No Reset Needed
   0x280000, 524288,    0x300000,  Conventional,           NWP,     Sequential,  No Reset Needed
   0x300000, 524288,    0x380000,  Conventional,           NWP,     Sequential,  No Reset Needed

Ask the drive (via zonectl(8)) to report zones that are in the Full state:

# zonectl -d /dev/da18 -c rz -o full |head -10
192 zones, Maximum LBA 0x3a3812aaf (15628053167)
Zone lengths and types may vary
  Start LBA  Length       WP LBA      Zone Type      Condition      Sequential             Reset
  0x2000000, 524288,   0x2080000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2080000, 524288,   0x2100000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2100000, 524288,   0x2180000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2180000, 524288,   0x2200000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2200000, 524288,   0x2280000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2280000, 524288,   0x2300000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2300000, 524288,   0x2380000, Seq Preferred,          Full,     Sequential,  No Reset Needed

Note that there are 192 zones in that state, versus 29809 zones total.

You can also reset write pointers.  For example, reset the zone beginning
at LBA 0x2000000, which we see above is in the full state:

# zonectl -d /dev/da18 -c rwp -l 0x2000000

Now ask for the zone report beginning at LBA 0x2000000:

# zonectl -d /dev/da18 -c rz -l 0x2000000 |head -10
29745 zones, Maximum LBA 0x3a3812aaf (15628053167)
Zone lengths and types may vary
  Start LBA  Length       WP LBA      Zone Type      Condition      Sequential             Reset
  0x2000000, 524288,   0x2000000, Seq Preferred,         Empty,     Sequential,  No Reset Needed
  0x2080000, 524288,   0x2100000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2100000, 524288,   0x2180000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2180000, 524288,   0x2200000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2200000, 524288,   0x2280000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2280000, 524288,   0x2300000, Seq Preferred,          Full,     Sequential,  No Reset Needed
  0x2300000, 524288,   0x2380000, Seq Preferred,          Full,     Sequential,  No Reset Needed

The zone is empty, and the write pointer is at the beginning of the zone 
instead of the end.

You can only do that for Host Aware and Host Managed drives.  Host Managed
drives aren't yet supported via the ada(4) driver.  They should in theory
attach to the da(4) driver, but I haven't seen one yet.

> BTW the disk returns an error when multiple LUNs are probed.

That should just be because you've got the probe debugging turned on.

Ken
-- 
Kenneth Merry
ken_at_FreeBSD.ORG
Received on Thu May 26 2016 - 10:34:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:05 UTC