Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jan 2022 15:55:58 +1100
From:      Greg 'groggy' Lehey <grog@FreeBSD.org>
To:        "Kevin P. Neal" <kpn@neutralgood.org>
Cc:        David Christensen <dpchrist@holgerdanske.com>, freebsd-questions@freebsd.org
Subject:   Re: zero filling a storage device (was: dd and mbr)
Message-ID:  <20220114045558.GQ61872@eureka.lemis.com>
In-Reply-To: <YeDryNdYe1S20wd2@neutralgood.org>
References:  <77680665-7ddb-23c5-e866-05d112339b60@holgerdanske.com> <20220114023002.GP61872@eureka.lemis.com> <YeDryNdYe1S20wd2@neutralgood.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--eLe8FOcWSbbyMVJD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thursday, 13 January 2022 at 22:19:36 -0500, Kevin P. Neal wrote:
> On Fri, Jan 14, 2022 at 01:30:02PM +1100, Greg 'groggy' Lehey wrote:
>> On Thursday, 13 January 2022 at 17:26:12 -0800, David Christensen wrote:
>>> If the program writes the buffer to the storage device starting at
>>> block-aligned location P, where P + N * B <= M * B, will the storage
>>> device write zero bytes to the storage device blocks that already
>>> contain only zero bytes?
>>
>> Yes.  The storage device doesn't know the current contents of the
>> disk.  To do so it would first have to read them, which takes far too
>> long.
>>
>>> Is the answer different for a HDD, an SSD, a USB flash drive, an SD
>>> card, a compact flash card, etc.?
>>
>> No.  It's also not different for other operating systems.
>
> Are we certain that an SSD won't at least track that there is
> nothing written to a logical block and therefore it must be all
> zeros?

We're talking about physical blocks here.  I have to guess that you're
thinking about the block remapping that SSDs do, but I've never heard
them called "logical" and "physical".

Writing all zeroes to a physical block and writing nothing to a
physical block are two very different things.  Writing nothing doesn't
change anything.  Writing zeroes to a block with content will change it.

> I'm not 100% that an SSD will always keep a logical block assigned
> to a physical block.  And I'm not 100% certain that an SSD won't
> notice that all zeros are being written to a block and just optimize
> out the write.

If I understand what you mean here, you're suggesting that SSDs may
keep a list of zeroed-out blocks and just optimize them away?  It's
possible, though I haven't heard of it.  I don't know how often blocks
are completely zeroed out, but I suspect that it wouldn't be worth
it.  If they did, it would be a good advertisement, because it would
indirectly increase the storage capacity of the SSD.

Until proof of the contrary, I'd say "no, this doesn't happen".

Greg
--
Sent from my desktop computer.
See complete headers for address and phone numbers.
This message is digitally signed.  If your Microsoft mail program
reports problems, please read http://lemis.com/broken-MUA.php

--eLe8FOcWSbbyMVJD
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAmHhAl4ACgkQIubykFB6QiNTegCgr3Bdv5rOqnlJ0KrHf161+0BQ
f/wAmwRj3IisjZhhcyCNvpB1l85PIrvp
=cgVs
-----END PGP SIGNATURE-----

--eLe8FOcWSbbyMVJD--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20220114045558.GQ61872>