From owner-freebsd-hackers@freebsd.org Sat Nov 24 21:31:13 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F16F7113A29C for ; Sat, 24 Nov 2018 21:31:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it1-x133.google.com (mail-it1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 36E238CFD8 for ; Sat, 24 Nov 2018 21:31:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it1-x133.google.com with SMTP id g85so22943174ita.3 for ; Sat, 24 Nov 2018 13:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kQOgAzY2B//rMDWtej74YMRdIuMuRlx7DV55WuU/suk=; b=H0o/zIZBjEAqWL8DoUIrAXvZccH0PzBr+Z34qDIhskcHSm/Qxt6T9jn9mgYIml3r/g fs9u3r0/GT927/rLb7RpAz8503+igNEaGSOuWIcOWqoBoUlsX0QpOUxovZ+6f8kUWmF5 yEb0Zu4skIJVF5WSXY81NCfhUz6tk5Xy1reFz8QvuxyOiIFcISRnI9wRlgNQF0Gn21Z1 WHPaPmRaL9woshZ3s67CAxWOQ25doFmC5mYrZnw3bQmnlzZrVVB4fGfevrnU735Nyie1 70upWL9xj8sn4DjzqTVDIXXLVMMi2/jDTxiADDZzhlUdjJdNWYQdxitOgpZEA9mASFGk HB8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kQOgAzY2B//rMDWtej74YMRdIuMuRlx7DV55WuU/suk=; b=ZQD4lM4yviHCicA8580OZQz2pgS2G4035ynnk9MeJzARM79kQIhB+E9PS4JRpYhLU7 RfmuyN9jJrICY+OnDlVyoEkfAaSGU7zfWCyfMN1KcdZvXIwSJlHEj+IDCNPe5Pjr6z7v xQAi2d6ZsrhBCOIS0s8MTzfmrjVG9tDBrBnTxDLVyRgL/1znEKbmnrQ7vV0C8vimIqZY pkYyGAR3JjHEXHlvJ+6y0YxqE/B/F4niXfZL3mkogI/V60NH8gEga7rmdiDe5j7b49Lb yApsB8iwlAjvNpQq54DPC1xSv+UaxyrsEpk3NsRpo2x8e6vVkDlByeo8XqhT1WgQwAvk LTRA== X-Gm-Message-State: AA+aEWZCJ7BlND07QCHUVwkhDyDNy2dTNSRzoPcccgAZKc7ZkmysahQD 2n9qaLYa8dibUV9tmL6rNZ/RFJxlmipALcdxeuDHWw== X-Google-Smtp-Source: AFSGD/W4JFnCNRTtQF1O5x0EmcspuU7xA72tOFogswAIlCAkEgvB99gJgbrWYVnLl4pIvY004c7m3sOLNvnGRbJkWdU= X-Received: by 2002:a02:3da:: with SMTP id e87mr16909006jae.78.1543095071369; Sat, 24 Nov 2018 13:31:11 -0800 (PST) MIME-Version: 1.0 References: <201811231600.wANG0wHc083199@pdx.rh.CN85.dnsmgr.net> In-Reply-To: From: Warner Losh Date: Sat, 24 Nov 2018 14:31:00 -0700 Message-ID: Subject: Re: TRIM utility To: Dimitry Andric Cc: Wojciech Puchar , "freebsd-hackers@freebsd.org" , Poul-Henning Kamp , Lev Serebryakov , "Rodney W. Grimes" , Eugene Grosbein X-Rspamd-Queue-Id: 36E238CFD8 X-Spamd-Result: default: False [-4.98 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.98)[-0.983,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: ALT1.aspmx.l.google.com]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[3.3.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; RCPT_COUNT_SEVEN(0.00)[7]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_LAST(0.00)[]; IP_SCORE(-1.99)[ip: (-6.48), ipnet: 2607:f8b0::/32(-1.93), asn: 15169(-1.43), country: US(-0.09)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Server: mx1.freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Nov 2018 21:31:13 -0000 On Sat, Nov 24, 2018 at 9:09 AM Dimitry Andric wrote: > On 24 Nov 2018, at 15:44, Wojciech Puchar wrote: > > > >> Yes. It would. That's hard with the current storage stack to do via the > >> disk interface. And often the underlying protocols do not support > partial > >> ranges. There is no good way to do this with buf/bio interface we have. > So > > > > what is an actual difference between "secure erase" and trimming whole > disk? > > It depends a lot on the device. Some devices encrypt all blocks > automatically, and a Secure Erase command might just throw away the key, > not go over all the data and actively wipe it. > When there's a difference, sanitize is usually the variant that does this. In all the SSDs I've had problems with, however, both Secure Erase and Sanitize reset the NAND pool (which effectively causes all the NAND erase blocks to be erased). TRIM is a 'logical' command, not a physical one. It doesn't tell the drive to erase anything. It just marks the data as being free. Most drives will then garbage collect things because certain low-water threshold marks are hit causing the blocks to be erased, but TRIM is definitely not a command to erase. Also, Secure Erase and Sanitize both are more destructive an thorough than a simple TRIM in that they potentially remove extra metadata that you'd need to keep intact if you wanted to keep using the drive (such as the current encryption keys). > Most SSDs will likely also trim all the blocks to be erased, since userave > come to expect the SSD performance to go back to the 'out of box' > level, after such an operation. > Correct. I've not found any that don't, even though they are allowed to. It also maximizes future performance because there's no need to stop and wait for erase blocks to go through and an erase cycle before programming them. And there's some advantage, in some of the NAND technology nodes, to keeping things in the erased state a long as possible. > If you are lucky, the manufacturer's documentation will explain the > specifics, but don't count on it. :) > Very lucky :) Warner