From owner-freebsd-current@freebsd.org Mon Jan 18 22:37:08 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E40F3A86981 for ; Mon, 18 Jan 2016 22:37:07 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id CF1D31FB2 for ; Mon, 18 Jan 2016 22:37:07 +0000 (UTC) (envelope-from ken@kdm.org) Received: by mailman.ysv.freebsd.org (Postfix) id CDC3EA8697F; Mon, 18 Jan 2016 22:37:07 +0000 (UTC) Delivered-To: current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD279A8697E; Mon, 18 Jan 2016 22:37:07 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (mithlond.kdm.org [96.89.93.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "A1-33714", Issuer "A1-33714" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D1C11FB1; Mon, 18 Jan 2016 22:37:07 +0000 (UTC) (envelope-from ken@kdm.org) Received: from mithlond.kdm.org (localhost [127.0.0.1]) by mithlond.kdm.org (8.15.2/8.14.9) with ESMTPS id u0IMb4DH087661 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Jan 2016 17:37:04 -0500 (EST) (envelope-from ken@mithlond.kdm.org) Received: (from ken@localhost) by mithlond.kdm.org (8.15.2/8.14.9/Submit) id u0IMb4mE087660; Mon, 18 Jan 2016 17:37:04 -0500 (EST) (envelope-from ken) Date: Mon, 18 Jan 2016 17:37:04 -0500 From: "Kenneth D. Merry" To: scsi@freebsd.org, current@freebsd.org Subject: Re: CAM Shingled Disk support patches available Message-ID: <20160118223704.GA87506@mithlond.kdm.org> References: <20151118171309.GA3564@mithlond.kdm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151118171309.GA3564@mithlond.kdm.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mithlond.kdm.org [127.0.0.1]); Mon, 18 Jan 2016 17:37:04 -0500 (EST) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mithlond.kdm.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2016 22:37:08 -0000 I have a new set of SMR patches available. See below for the full explanation. The primary change here is that I have added SMR support to the ada(4) driver. I spent some time considering whether to try to make the da(4) and ada(4) probe infrastructure somewhat common, but in the end concluded it would be too involved with not enough code reduction (if any) in the end. So, although the ideas are similar, the probe logic is separate. Note that NCQ support for SMR commands (Report Zones, Reset Write Pointer, etc.) for SATA protocol shingled drives isn't active. For both the da(4) and ada(4) driver this is for lack of a way to plumb the ATA Auxiliary register down to the drive. In the ada(4) case, we need to add the register to struct ccb_ataio and add support in one or more of the underlying SATA drivers, e.g. ahci(4). In the da(4) case, it will require an update of the T-10 SAT spec to provide a way to pass the Auxiliary register down via the SCSI ATA PASS-THROUGH command, and then a subsquent update of the SAT layer in various vendors' SAS controller firmware. At that point, there may be an official mapping of the SCSI ZBC commands to the ATA ZAC commands, and we may be able to just issue the SCSI version of the commands instead of composing ATA commands in the da(4) driver. (We'll still need to keep the ATA passthrough version for a while at least to support controllers that don't have the updated translation code.) FreeBSD/head as of SVN revision 294105: https://people.freebsd.org/~ken/cam_smr.head.20160118.1.txt FreeBSD stable/10 as of SVN revision 294100: https://people.freebsd.org/~ken/cam_smr.stable10.20160118.1.txt Testing and comments are welcome. Ken On Wed, Nov 18, 2015 at 12:13:09 -0500, Kenneth D. Merry wrote: > > I have work in progress patches to add SMR (Shingled Magnetic Recording) > support to CAM and GEOM here: > > FreeBSD/head as of SVN revision 290997: > > https://people.freebsd.org/~ken/cam_smr.head.20151117.1.txt > > FreeBSD stable/10 as of SVN revision 290995: > > https://people.freebsd.org/~ken/cam_smr.stable10.20151117.1.txt > > This includes support for Host Managed, Host Aware and Drive Managed SMR > drives that are either SCSI (ZBC) or ATA (ZAC) attached via a SAS > controller. This does not include support for SMR ATA drives attched via > an ATA controller. Also, I have not yet figured out how to properly detect > a Host Managed ATA drive, so this code won't do that. > > The big drive vendors are moving to SMR for at least some of their drives. > The primary challenge with SMR is that it requires writing a relatively > large zone sequentially starting at the beginning of the zone. The usual > zone size is 256MB. It is conceptually almost like having a 256MB sector > size. > > We (Spectra Logic) are working on ZFS changes that will use this CAM and > GEOM infrastructure to make ZFS play well with SMR drives. Those changes > aren't yet done. > > The patches linked above include: > o A new 'camcontrol zone' command that allows displaying and managing > drive zones via SCSI/ATA passthrough. > o A new zonectl(8) utility that uses the new DIOCZONECMD ioctl to display > and manage zones via the da(4) (and later ada(4)) driver. > o Changes to diskinfo -v to display the zone mode of a drive. > o A new disk zone API, sys/sys/disk_zone.h. > o A new bio type, BIO_ZONE, and modifications to GEOM to support it. This > new bio will allow filesystems to query zone support in a drive and > manage zoned drives. > o Extensive modifications to the da(4) driver to handle probing SCSI and > SATA behind SAS SMR drives. > o Additional CAM CDB building functions for zone commands. > > The current issues that need to be addressed are: > o The da(4) driver now has 6 additional probe states, 5 of which are > needed for probing ATA drives behind SAS controllers. I have not yet > added support for BIO_ZONE bios to ada(4), but it will be very similar > to the da(4) driver version. The ATA probe code needs to be pulled > out of the da(4) driver and changed into a form that will allow it to > work for either the ada(4) or da(4) driver. Otherwise we'll have a fair > amount of code duplication between the two drivers. > > o There is a reasonable amount of code duplication between 'camcontrol zone' > and zonectl(8). This was done for speed / expediency's sake, but it may > be possible to make more of the code common there. > > o In order to add the new BIO_ZONE bio command, I had to change the bio_cmd > field in struct bio from a uint8_t to a uint16_t. This will cause > binary compatibility problems with any 3rd party loadable modules. > Advice on how to handle this would be welcome. > > o In the process of developing these changes, I discovered that the > dxfer_len paramter for scsi_ata_pass_16() was too small (uint16_t, and > it needed to be uint32_t). I increased it, but that will potentially > cause a binary incompatibility problem with any existing applications > that use the current API via libcam. Advice on how to handle that > would be welcome. > > If you look through the code, you'll notice that the disk_zone.h API is > separate from the SCSI and ATA APIs. The intent is to allow filesystems > and other consumers of the API to just talk to the disk zone API without > dealing with the SCSI and ATA specifics. Another reason behind all of this > is that even though the SCSI ZBC and ATA ZAC specs were developed in > concert, and are intended to be functionally identical, they are still SCSI > and ATA. As usual, SCSI is big endian and ATA is little endian. So to > present a common API to the filesystem, we give all of the zone data back > in native byte order, regardless of the underlying device protocol. > > Another thing to note is the extensive use of ATA passthrough in the da(4) > driver. This is necessary because the SCSI SAT (SCSI to ATA Translation) > specification has not yet caught up with translating SCSI zone commands > (ZBC) to ATA zone commands (ZAC). So, until the spec is updated and LSI > and other vendors update their SCSI to ATA translation layers, we'll have > to use the ATA version of the commands when talking to ATA drives via SAS > controllers. > > I have only tested the code so far with Seagate SATA Drive Managed and Host > Aware drives. I would appreciate testing with any drives. (And testing to > make sure that the patches don't cause problems with existing hardware.) > Right now, all you can really do is manage the zones manually using > camcontrol(8) or zonectl(8). Automatic management will come with the ZFS > changes. (Or changes to other filesysems if people want to do it.) > > If you have a SATA Host Aware drive, in theory camcontrol(8) should allow > you to manage the drive if you have it attached to a SATA controller. > > Here is an example of some of the commands. > > Get general zoning information: > > [root@sm4u-1 ~]# zonectl -c params -d /dev/da21 > 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 > > Look at information from the da(4) driver: > > [root@sm4u-1 ~]# sysctl kern.cam.da.21 > kern.cam.da.21.delete_method: NONE > kern.cam.da.21.delete_max: 1081344 > kern.cam.da.21.minimum_cmd_size: 6 > kern.cam.da.21.sort_io_queue: -1 > kern.cam.da.21.zone_mode: Host Aware > kern.cam.da.21.zone_support: Report Zones, Open, Close, Finish, Reset Write Pointer > kern.cam.da.21.optimal_seq_zones: 128 > kern.cam.da.21.optimal_nonseq_zones: 8 > kern.cam.da.21.max_seq_zones: 4294967295 > kern.cam.da.21.error_inject: 0 > > Display all of the zones with zonectl(8): > > [root@sm4u-1 ~]# zonectl -d /dev/da21 -c rz > 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 > 0x380000, 524288, 0x400000, Conventional, NWP, Sequential, No Reset Needed > 0x400000, 524288, 0x480000, Conventional, NWP, Sequential, No Reset Needed > 0x480000, 524288, 0x500000, Conventional, NWP, Sequential, No Reset Needed > 0x500000, 524288, 0x580000, Conventional, NWP, Sequential, No Reset Needed > 0x580000, 524288, 0x600000, Conventional, NWP, Sequential, No Reset Needed > 0x600000, 524288, 0x680000, Conventional, NWP, Sequential, No Reset Needed > 0x680000, 524288, 0x700000, Conventional, NWP, Sequential, No Reset Needed > 0x700000, 524288, 0x780000, Conventional, NWP, Sequential, No Reset Needed > [ ... ] > 0x1f00000, 524288, 0x1f80000, Conventional, NWP, Sequential, No Reset Needed > 0x1f80000, 524288, 0x2000000, Conventional, NWP, Sequential, No Reset Needed > 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 > [ ... ] > > Use camcontrol zone to reset the write pointer for the first shingled zone > listed above: > > [root@sm4u-1 ~]# camcontrol zone da21 -v -c rwp -l 0x2000000 > > Use camcontrol zone to ask the drive to report empty zones: > > [root@sm4u-1 ~]# camcontrol zone da21 -v -c rz -o empty > 1 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 > > Get information on a Host Aware drive: > > root@sm4u-1 ~]# diskinfo -v da21 > da21 > 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. > Z84008NY # Disk ident. > enc@5003048001f311fd/elmtype@array_device/slot@22 # Physical path > Host Aware # Zone Mode > > Get information on a drive managed drive: > > [root@sm4u-1 ~]# diskinfo -v da20 > da20 > 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. > Z8405938 # Disk ident. > enc@5003048001f311fd/elmtype@array_device/slot@21 # Physical path > Drive Managed # Zone Mode > > Get information on a non-zoned drive: > > [root@sm4u-1 ~]# diskinfo -v da4 > da4 > 512 # sectorsize > 100030242816 # mediasize in bytes (93G) > 195371568 # mediasize in sectors > 0 # stripesize > 0 # stripeoffset > 12161 # Cylinders according to firmware. > 255 # Heads according to firmware. > 63 # Sectors according to firmware. > 124903574F36 # Disk ident. > enc@5003048001f311fd/elmtype@array_device/slot@5 # Physical path > Not Zoned # Zone Mode > > Testing and comments are welcome. > > Thanks, > > Ken > -- > Kenneth Merry > ken@FreeBSD.ORG -- Kenneth Merry ken@FreeBSD.ORG