From owner-freebsd-current@FreeBSD.ORG Sat Dec 24 14:49:54 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A5B12106564A for ; Sat, 24 Dec 2011 14:49:54 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id 3128B8FC0A for ; Sat, 24 Dec 2011 14:49:53 +0000 (UTC) Received: by eaaf13 with SMTP id f13so12877013eaa.13 for ; Sat, 24 Dec 2011 06:49:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=2E4ZSRME6EpjjgJppQRSrPEcItdFeBXlp55WITAgLJ8=; b=gncboF6w210tSFIiZY/26df4IolCBG72lVupnTjlifQAg31idVSual+hMSUBG6BOIw MnfbkfNbTs8RoGpMAoL3/HIrQmMA9UCxrR4BFTeGZd56gQ81lyehprUecrvYwu2uccLG BAYPHSoDUnKjDZc1E8DLm1cd9PTJkwUSsev38= Received: by 10.213.17.146 with SMTP id s18mr6695895eba.109.1324736823528; Sat, 24 Dec 2011 06:27:03 -0800 (PST) Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua. [212.86.226.226]) by mx.google.com with ESMTPS id b49sm32495505eec.9.2011.12.24.06.27.02 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 24 Dec 2011 06:27:02 -0800 (PST) Sender: Alexander Motin Message-ID: <4EF5E134.9040903@FreeBSD.org> Date: Sat, 24 Dec 2011 16:27:00 +0200 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111123 Thunderbird/8.0 MIME-Version: 1.0 To: freebsd-scsi@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: RFC: SCSI UNMAP (TRIM) support X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 24 Dec 2011 14:49:54 -0000 Hi. I've implemented patch for logical block provisioning (aka UNMAP, TRIM, BIO_DELETE) support for the CAM da driver in HEAD and would like to ask for review, testing and hardware support information. Depending on device capabilities I use several different methods to implement it. Method can be read/set via kern.cam.da.X.delete_method sysctls. Possible values are: NONE - no provisioning support reported by the device; DISABLE - provisioning support was disabled because of errors; ZERO - use WRITE SAME (10) command to write zeroes; WS10 - use WRITE SAME (10) command with UNMAP bit set; WS16 - use WRITE SAME (16) command with UNMAP bit set; UNMAP - use UNMAP command. Last two methods (UNMAP and WS16) are defined by SBC specification and UNMAP method is the most advanced one. The rest of methods I've found supported in Linux, and as soon as they were trivial to implement, then why not? Hope they will be useful in some cases. Unluckily at this moment I have no devices reporting parameters of the logical block provisioning support via respective VPD pages (0xB0 and 0xB2). So all info I have/use now is the flag telling whether logical block provisioning is supported or not. As result specific methods chosen now by trying different ones in order (UNMAP, WS16, DISABLE) and checking completion status to fallback if needed. I don't expect problems from this, as if something go wrong, it should just disable itself. It may disable even too aggressively. Unlike Linux, which executes each delete with separate request, I've implemented here the same request aggregation as implemented in ada driver. Tests on SSDs I have show much better results doing it this way: above 8GB/s of the linear delete on Intel SATA SSD on LSI SAS HBA (mps). The patch can be found here: http://people.freebsd.org/~mav/scsi_unmap.patch Work sponsored by iXsystems, Inc. If somebody has SAS SSDs with UNMAP support, I would be grateful for additional information about them, such as: camcontrol cmd da0 -c "12 01 00 00 ff 00" -i 255 - >pages camcontrol cmd da0 -c "12 01 b0 00 ff 00" -i 255 - >page_b0 camcontrol cmd da0 -c "12 01 b2 00 ff 00" -i 255 - >page_b2 camcontrol cmd da0 -c "9e 10 00 00 00 00 00 00 00 00 00 00 00 ff 00 00" -i 255 - >rc16 Thank you! -- Alexander Motin