Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"The four building blocks of the universe are fire, water, gravel and vinyl." -- Dave Barry


devel / comp.arch.embedded / Shutdown behavior and flash storage devices

SubjectAuthor
* Shutdown behavior and flash storage devicesDave Nadler
+- Re: Shutdown behavior and flash storage devicesTheo
+* Re: Shutdown behavior and flash storage devicesDon Y
|+* Re: Shutdown behavior and flash storage devicesDimiter_Popoff
||`- Re: Shutdown behavior and flash storage devicesDon Y
|`* Re: Shutdown behavior and flash storage devicesDave Nadler
| +- Re: Shutdown behavior and flash storage devicesDon Y
| `* Re: Shutdown behavior and flash storage devicesDimiter_Popoff
|  `* Re: Shutdown behavior and flash storage devicesDon Y
|   `* Re: Shutdown behavior and flash storage devicesDimiter_Popoff
|    `- Re: Shutdown behavior and flash storage devicesDon Y
+* Re: Shutdown behavior and flash storage devicesKent Dickey
|`- Re: Shutdown behavior and flash storage devicesDon Y
`* Re: Shutdown behavior and flash storage devicesJaded Hobo
 `- Re: Shutdown behavior and flash storage devicesDon Y

1
Shutdown behavior and flash storage devices

<sdhb29$ibh$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=551&group=comp.arch.embedded#551

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!aioe.org!exK6Qtha8nqZIk8Be/wGrA.user.46.165.242.91.POSTED!not-for-mail
From: drn...@nadler.com (Dave Nadler)
Newsgroups: comp.arch.embedded
Subject: Shutdown behavior and flash storage devices
Date: Sat, 24 Jul 2021 11:19:36 -0400
Organization: Aioe.org NNTP Server
Message-ID: <sdhb29$ibh$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="18801"; posting-host="exK6Qtha8nqZIk8Be/wGrA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-US
X-Mozilla-News-Host: news://news.aioe.org:119
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dave Nadler - Sat, 24 Jul 2021 15:19 UTC

Hi All - I'm wondering what other folks do about this issue...

Consumer flash storage devices (USB memory stick, SD card, etc)
have a nice internal wear-leveling controller. When one does a write
operation, lots of sectors may be internally rejiggered to provide
uniform wear (so things that are never rewritten from the application
point of view are actually moved around and rewritten). This activity is
invisible from normal application's point of view, but takes some time.
If the device is powered off during such activity, data corruption...
So, its necessary to provide the device some time after the last write
before it is powered off. Plenty of embedded stuff I've seen too often
corrupts memory at power off, and of course the device manufacturers
blame the memory manufacturers...

So, how do you avoid this kind of corruption in your designs?

Thanks,
Best Regards, Dave

Re: Shutdown behavior and flash storage devices

<Rfv*RZWpy@news.chiark.greenend.org.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=552&group=comp.arch.embedded#552

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!aioe.org!nntp.terraraq.uk!nntp-feed.chiark.greenend.org.uk!ewrotcd!.POSTED!not-for-mail
From: theom+n...@chiark.greenend.org.uk (Theo)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: 24 Jul 2021 16:37:19 +0100 (BST)
Organization: University of Cambridge, England
Lines: 30
Message-ID: <Rfv*RZWpy@news.chiark.greenend.org.uk>
References: <sdhb29$ibh$1@gioia.aioe.org>
NNTP-Posting-Host: chiark.greenend.org.uk
X-Trace: chiark.greenend.org.uk 1627141041 26524 212.13.197.229 (24 Jul 2021 15:37:21 GMT)
X-Complaints-To: abuse@chiark.greenend.org.uk
NNTP-Posting-Date: Sat, 24 Jul 2021 15:37:21 +0000 (UTC)
User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (Linux/3.16.0-11-amd64 (x86_64))
Originator: theom@chiark.greenend.org.uk ([212.13.197.229])
 by: Theo - Sat, 24 Jul 2021 15:37 UTC

Dave Nadler <drn@nadler.com> wrote:
> Hi All - I'm wondering what other folks do about this issue...
>
> Consumer flash storage devices (USB memory stick, SD card, etc)
> have a nice internal wear-leveling controller. When one does a write
> operation, lots of sectors may be internally rejiggered to provide
> uniform wear (so things that are never rewritten from the application
> point of view are actually moved around and rewritten). This activity is
> invisible from normal application's point of view, but takes some time.
> If the device is powered off during such activity, data corruption...
> So, its necessary to provide the device some time after the last write
> before it is powered off. Plenty of embedded stuff I've seen too often
> corrupts memory at power off, and of course the device manufacturers
> blame the memory manufacturers...
>
> So, how do you avoid this kind of corruption in your designs?

If it's a USB stick, SCSI has an UNLOAD command which is what you do when
you eject removable media like a CD. I would hope that a USB stick (USB
mass storage = SCSI protocol) would use it as a hint to flush its write
cache and get ready to be removed, but I don't actually know if it does.

Maybe they can also detect the USB signalling going away, which is what
happens when you pull the stick, a few ms before the power disconnects, due
to the layout of the USB A connector.

Enterprise SSDs have power loss protection so you can pull the power at any
time and they'll tidy up nicely using stored energy in a bank of capacitors.

Theo

Re: Shutdown behavior and flash storage devices

<sdidmc$d9c$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=553&group=comp.arch.embedded#553

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sat, 24 Jul 2021 18:10:23 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <sdidmc$d9c$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 01:10:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2aa6f39a7dd1d7384df141f77dac3d4";
logging-data="13612"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EgJFY1qGhpBqkdDZnrb4J"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:SWXmPQ8jdQFJL3m+9Jiysf3F1r4=
In-Reply-To: <sdhb29$ibh$1@gioia.aioe.org>
Content-Language: en-US
 by: Don Y - Sun, 25 Jul 2021 01:10 UTC

On 7/24/2021 8:19 AM, Dave Nadler wrote:
> Hi All - I'm wondering what other folks do about this issue...
>
> Consumer flash storage devices (USB memory stick, SD card, etc)
> have a nice internal wear-leveling controller. When one does a write operation,
> lots of sectors may be internally rejiggered to provide uniform wear (so things
> that are never rewritten from the application point of view are actually moved
> around and rewritten). This activity is invisible from normal application's
> point of view, but takes some time. If the device is powered off during such
> activity, data corruption... So, its necessary to provide the device some time
> after the last write before it is powered off. Plenty of embedded stuff I've
> seen too often corrupts memory at power off, and of course the device
> manufacturers blame the memory manufacturers...
>
> So, how do you avoid this kind of corruption in your designs?

Two (transient) copies of each "chunk" of data. Update the second
copy (on or before impending power fail). When complete, toggle
a pointer to reference it as the most recent (assuming you don't
have metadata that automatically provides that sort of information).

The "first" copy can now be removed and its space reallocated to
some other "second copy"

Then, move on to the next "chunk". Design your algorithms so that
you can tolerate some chunks being "stale" (not updated in time)
wrt the others.

Re: Shutdown behavior and flash storage devices

<sdjh9u$4oh$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=554&group=comp.arch.embedded#554

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dp...@tgi-sci.com (Dimiter_Popoff)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 14:18:20 +0300
Organization: TGI
Lines: 36
Message-ID: <sdjh9u$4oh$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
Reply-To: dp@tgi-sci.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Jul 2021 11:18:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="afca09934ccf42d0e0318079ca8f8803";
logging-data="4881"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Lj9t0ycL+8PPBw7UFOYwEsIR42RAOyMo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:ftPWFH5gOCKfQwjfsMminGnR7oU=
In-Reply-To: <sdidmc$d9c$1@dont-email.me>
Content-Language: en-US
 by: Dimiter_Popoff - Sun, 25 Jul 2021 11:18 UTC

On 7/25/2021 4:10, Don Y wrote:
> On 7/24/2021 8:19 AM, Dave Nadler wrote:
>> Hi All - I'm wondering what other folks do about this issue...
>>
>> Consumer flash storage devices (USB memory stick, SD card, etc)
>> have a nice internal wear-leveling controller. When one does a write
>> operation, lots of sectors may be internally rejiggered to provide
>> uniform wear (so things that are never rewritten from the application
>> point of view are actually moved around and rewritten). This activity
>> is invisible from normal application's point of view, but takes some
>> time. If the device is powered off during such activity, data
>> corruption... So, its necessary to provide the device some time after
>> the last write before it is powered off. Plenty of embedded stuff I've
>> seen too often corrupts memory at power off, and of course the device
>> manufacturers blame the memory manufacturers...
>>
>> So, how do you avoid this kind of corruption in your designs?
>
> Two (transient) copies of each "chunk" of data.  Update the second
> copy (on or before impending power fail).  When complete, toggle
> a pointer to reference it as the most recent (assuming you don't
> have metadata that automatically provides that sort of information).
>
> The "first" copy can now be removed and its space reallocated to
> some other "second copy"
>
> Then, move on to the next "chunk".  Design your algorithms so that
> you can tolerate some chunks being "stale" (not updated in time)
> wrt the others.

Don, this strategy is obviously good (standard?) for say disk writes
etc., but I don't know if it will be OK for flash as it involves erase
then write, AFAIK "erase" is the most killing part. Perhaps they do
a lot of "refresh", i.e. read while they can then rewrite the same
locations? I don't really know, just wondering how they do it.

Re: Shutdown behavior and flash storage devices

<sdjmlo$4ji$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=555&group=comp.arch.embedded#555

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!aioe.org!exK6Qtha8nqZIk8Be/wGrA.user.46.165.242.91.POSTED!not-for-mail
From: drn...@nadler.com (Dave Nadler)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 08:49:59 -0400
Organization: Aioe.org NNTP Server
Message-ID: <sdjmlo$4ji$1@gioia.aioe.org>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="4722"; posting-host="exK6Qtha8nqZIk8Be/wGrA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dave Nadler - Sun, 25 Jul 2021 12:49 UTC

On 7/24/2021 9:10 PM, Don Y wrote:
>> So, how do you avoid this kind of corruption in your designs?
>
> Two (transient) copies of each "chunk" of data.  Update the second
> copy (on or before impending power fail).  When complete, toggle
> a pointer to reference it as the most recent (assuming you don't
> have metadata that automatically provides that sort of information).
>
> The "first" copy can now be removed and its space reallocated to
> some other "second copy"
>
> Then, move on to the next "chunk".  Design your algorithms so that
> you can tolerate some chunks being "stale" (not updated in time)
> wrt the others.

Don, I don't think that works. The entire contents of the volume can
be corrupted if power is removed during wear-leveling operations that
are invisible to the host OS. And I guess you are assuming no file
system is in use (because file system internals would still get corrupted)?

Re: Shutdown behavior and flash storage devices

<sdk30h$oit$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=556&group=comp.arch.embedded#556

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 09:20:29 -0700
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <sdk30h$oit$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
<sdjh9u$4oh$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 16:20:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2aa6f39a7dd1d7384df141f77dac3d4";
logging-data="25181"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7Y+8bd5sOGwGKzFweIaZ/"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:9f64X3F5zI+7NmKnGLhVAuLsy8M=
In-Reply-To: <sdjh9u$4oh$1@dont-email.me>
Content-Language: en-US
 by: Don Y - Sun, 25 Jul 2021 16:20 UTC

On 7/25/2021 4:18 AM, Dimiter_Popoff wrote:
> On 7/25/2021 4:10, Don Y wrote:
>> On 7/24/2021 8:19 AM, Dave Nadler wrote:
>>> Hi All - I'm wondering what other folks do about this issue...
>>>
>>> Consumer flash storage devices (USB memory stick, SD card, etc)
>>> have a nice internal wear-leveling controller. When one does a write
>>> operation, lots of sectors may be internally rejiggered to provide uniform
>>> wear (so things that are never rewritten from the application point of view
>>> are actually moved around and rewritten). This activity is invisible from
>>> normal application's point of view, but takes some time. If the device is
>>> powered off during such activity, data corruption... So, its necessary to
>>> provide the device some time after the last write before it is powered off.
>>> Plenty of embedded stuff I've seen too often corrupts memory at power off,
>>> and of course the device manufacturers blame the memory manufacturers...
>>>
>>> So, how do you avoid this kind of corruption in your designs?
>>
>> Two (transient) copies of each "chunk" of data. Update the second
>> copy (on or before impending power fail). When complete, toggle
>> a pointer to reference it as the most recent (assuming you don't
>> have metadata that automatically provides that sort of information).
>>
>> The "first" copy can now be removed and its space reallocated to
>> some other "second copy"
>>
>> Then, move on to the next "chunk". Design your algorithms so that
>> you can tolerate some chunks being "stale" (not updated in time)
>> wrt the others.
>
> Don, this strategy is obviously good (standard?) for say disk writes
> etc., but I don't know if it will be OK for flash as it involves erase
> then write, AFAIK "erase" is the most killing part. Perhaps they do
> a lot of "refresh", i.e. read while they can then rewrite the same
> locations? I don't really know, just wondering how they do it.

Keep a spare block (or two) that are already erased, on hand
(this cuts into the capacity of the device but not in a meaningful way).

As you need to write data to the device, select a page from the
erased block to accept your data. When the number of "clean pages"
falls below a threshold, schedule another (free!) block to be erased.

If the erasure is interrupted, then you see the "free" block as
free-but-not-erased.

If the page write is interrupted, then you see the page as unclean
*and* the data it WANTED to contain as still residing in the
"previous" location.

There is always going to be a window in which you can get screwed
by unfortunate power cycling. But, you can shrink this window
(at some manageable cost).

If, instead, you only perform the program/erase/write cycle
on the "parameter block" when you need to update the "parameters",
then you have to move the existing parameters into volatile storage.
Then, program/erase the block. Then write the parameters back.
Then, verify the write.

This leaves the parameters (in volatile memory) "exposed" for a long
time -- seconds per block. If you "set up" the write operation ahead
of time, you can trim this to a millisecond, or so.

Re: Shutdown behavior and flash storage devices

<sdk3jg$si2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=557&group=comp.arch.embedded#557

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 09:30:36 -0700
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <sdk3jg$si2$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
<sdjmlo$4ji$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 16:30:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2aa6f39a7dd1d7384df141f77dac3d4";
logging-data="29250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rovynPr7xFt/BCo+bRulT"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:UIzAdnHXf+/ZBbhGCrxiwiKLmGI=
In-Reply-To: <sdjmlo$4ji$1@gioia.aioe.org>
Content-Language: en-US
 by: Don Y - Sun, 25 Jul 2021 16:30 UTC

On 7/25/2021 5:49 AM, Dave Nadler wrote:
> On 7/24/2021 9:10 PM, Don Y wrote:
>>> So, how do you avoid this kind of corruption in your designs?
>>
>> Two (transient) copies of each "chunk" of data. Update the second
>> copy (on or before impending power fail). When complete, toggle
>> a pointer to reference it as the most recent (assuming you don't
>> have metadata that automatically provides that sort of information).
>>
>> The "first" copy can now be removed and its space reallocated to
>> some other "second copy"
>>
>> Then, move on to the next "chunk". Design your algorithms so that
>> you can tolerate some chunks being "stale" (not updated in time)
>> wrt the others.
>
> Don, I don't think that works. The entire contents of the volume can
> be corrupted if power is removed during wear-leveling operations that are
> invisible to the host OS. And I guess you are assuming no file system is in use
> (because file system internals would still get corrupted)?

[I don't use filesystems; do you use a filesystem to manage your *RAM*? :> ]

I use "raw" devices and have the FTL (and wear-leveling) in my firmware.
So, I know what the hardware is being asked to do when I talk to it;
there's no "black magic" sitting in the middle that I can't quantify/qualify.

If you're going to use a "smart" device, then you have to come up with a
strategy that lets you recover from arbitrary levels of corruption
(because you don't know what that device is going to be doing when the
fit hits the shan).

I suspect you will see your losses limited to a single block (or so) as
it would require more resources to transfer a block's contents into
RAM while another block is nominated to receive them.

There might be different strategies employed by different device vendors.
E.g., one may defer the program/erase of that block until a later time;
another may opt to do it "now".

I don't see how you can expose enough of the internals of a "smart" device
in a manufacturer/model-independent manner. I.e., even storing a hash with
each "file", there's no guarantee as to WHERE that will reside on the device.
And, when it might "move" (be exposed to loss).

[You also have to be prepared for "good data" being lost in such a reshuffling;
in my case, I can ensure "what I have, I keep (but may lose something NEW)"]

If your needs are for things like configuration parameters (presumably few),
can you consider an EEPROM? Use FLASH for bigger things -- that tend to
change less frequently (and in more user-visible ways)?

Re: Shutdown behavior and flash storage devices

<HtidnVhHvbu2LmD9nZ2dnUU7-UPNnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=558&group=comp.arch.embedded#558

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 25 Jul 2021 13:53:31 -0500
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
References: <sdhb29$ibh$1@gioia.aioe.org>
Organization: provalid.com
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
From: keg...@provalid.com (Kent Dickey)
Originator: kegs@provalid.com (Kent Dickey)
Message-ID: <HtidnVhHvbu2LmD9nZ2dnUU7-UPNnZ2d@giganews.com>
Date: Sun, 25 Jul 2021 13:53:31 -0500
Lines: 53
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-coKbGO5bphGrwjo2EHe3celaeOA4quI3ZpKd0SwoK4rLuhx03GjBZFtTjFP6UeTdT4KzErBfBlJzhR1!POrcUdmGGc0wMi95d+lbRebTHdinh8W8CFbmvLhO03Y4qcfENGsk9js2aAxzB/GNmdQd+LOI1+c=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 3765
 by: Kent Dickey - Sun, 25 Jul 2021 18:53 UTC

In article <sdhb29$ibh$1@gioia.aioe.org>, Dave Nadler <drn@nadler.com> wrote:
>Hi All - I'm wondering what other folks do about this issue...
>
>Consumer flash storage devices (USB memory stick, SD card, etc)
>have a nice internal wear-leveling controller. When one does a write
>operation, lots of sectors may be internally rejiggered to provide
>uniform wear (so things that are never rewritten from the application
>point of view are actually moved around and rewritten). This activity is
>invisible from normal application's point of view, but takes some time.
>If the device is powered off during such activity, data corruption...
>So, its necessary to provide the device some time after the last write
>before it is powered off. Plenty of embedded stuff I've seen too often
>corrupts memory at power off, and of course the device manufacturers
>blame the memory manufacturers...
>
>So, how do you avoid this kind of corruption in your designs?
>
>Thanks,
>Best Regards, Dave

It is not necessary to do this. Here's a very simple way to recover with
no data loss ever. It is simply "log-only" or "journal-only" storage.

The device keeps 10% capacity reserved (pre-erased) (or less, this is a
performance number). The driver has enough RAM to track where every logical
block is (this isn't much RAM). And then writing is always done as a
logfile--write whatever the user data is starting at block 0, and move up.
After writing user data, write a log entry (this can be just right after the
user data). Writes never go to the block the user indicates, they always go
only to the log pointer. Reading looks up where that block's latest copy is,
and reads that.

When you're at less than 10% space left (near the end of the device for
first-pass writes), you simply read from +10% from the current log write
position, and write it to the log (compacting it to avoid re-writing any
blocks which are now obsolete) until you free up space. Since many blocks are
rewritten, when we compact them we free space. Once copied, then erase the
blocks which were compacted. Then just keep growing the "log" through the
newly erased blocks.

Upon power up, scan entire device for the log info, and rebuild the RAM index.

Power can be removed at any time, and fully recovered, although obviously the
most recent data may be lost, but we can roll back to the last consistent
state just like journaled file systems (the log entries need a checksum so
we can validate them). Wear leveling is achieved by design.

There are lots of small ways to improve the above, so do that.

I have no idea what actual devices do, I suspect it's something much more
complex and less robust.

Kent

Re: Shutdown behavior and flash storage devices

<sdkfcj$ddf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=559&group=comp.arch.embedded#559

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dp...@tgi-sci.com (Dimiter_Popoff)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 22:51:46 +0300
Organization: TGI
Lines: 52
Message-ID: <sdkfcj$ddf$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
<sdjmlo$4ji$1@gioia.aioe.org>
Reply-To: dp@tgi-sci.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Jul 2021 19:51:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="afca09934ccf42d0e0318079ca8f8803";
logging-data="13743"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19miaIXcRqOCojEjOfbQ5IKWfMGULMFJHw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:ggLeB39LjoWBhqRcZlnk8uqYArQ=
In-Reply-To: <sdjmlo$4ji$1@gioia.aioe.org>
Content-Language: en-US
 by: Dimiter_Popoff - Sun, 25 Jul 2021 19:51 UTC

On 7/25/2021 15:49, Dave Nadler wrote:
> On 7/24/2021 9:10 PM, Don Y wrote:
>>> So, how do you avoid this kind of corruption in your designs?
>>
>> Two (transient) copies of each "chunk" of data.  Update the second
>> copy (on or before impending power fail).  When complete, toggle
>> a pointer to reference it as the most recent (assuming you don't
>> have metadata that automatically provides that sort of information).
>>
>> The "first" copy can now be removed and its space reallocated to
>> some other "second copy"
>>
>> Then, move on to the next "chunk".  Design your algorithms so that
>> you can tolerate some chunks being "stale" (not updated in time)
>> wrt the others.
>
> Don, I don't think that works. The entire contents of the volume can
> be corrupted if power is removed during wear-leveling operations that
> are invisible to the host OS. And I guess you are assuming no file
> system is in use (because file system internals would still get corrupted)?
>

If you have no knowledge of how the flash medium is written - which
would normally be the case with USB sticks or SD cards etc. - the most
efficient way to mitigate data loss probability is to do as much
write cacheing as you can afford at system level. Of course again
you will be prone to data loss on unexpected power loss but updating
the write cache will be done at (much) longer intervals and in
relatively brief bursts, thus the probability to be hit gets lower.
The rest can only be got rid of by having large enough caps on
the power supply and an early warning that power has been lost
(usually at the input of the stepdowns and you are running on fumes.

Of course you can employ various strategies to mimick flash drive
behaviour at a higher level, Don suggested one, Kent also did,
but these mean having different drivers for different media and
all the consequences of that. I prefer to talk to standard SCSI
or ATA behaving things and leave it to them to handle their
unique specifics. [I remember how I *had to* introduce write
cacheing at system level, in the mid 90-s I started to do backups
under DPS to magneto-optical devices; early days DPS would
simply update its CAT (Cluster Allocation Table) every time
it got modifier and these sectors got corrupted before the backup
would finish.... :-) ].

Dimiter

======================================================
Dimiter Popoff, TGI http://www.tgi-sci.com
======================================================
http://www.flickr.com/photos/didi_tgi/

Re: Shutdown behavior and flash storage devices

<sdkh1n$pi5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=560&group=comp.arch.embedded#560

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 13:20:03 -0700
Organization: A noiseless patient Spider
Lines: 102
Message-ID: <sdkh1n$pi5$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org>
<HtidnVhHvbu2LmD9nZ2dnUU7-UPNnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 20:20:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2aa6f39a7dd1d7384df141f77dac3d4";
logging-data="26181"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181S+r8Ymj36OL/KnuqinFu"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:HzQu7eBEr2ECsRDsP+4Og6tIcg0=
In-Reply-To: <HtidnVhHvbu2LmD9nZ2dnUU7-UPNnZ2d@giganews.com>
Content-Language: en-US
 by: Don Y - Sun, 25 Jul 2021 20:20 UTC

On 7/25/2021 11:53 AM, Kent Dickey wrote:
> In article <sdhb29$ibh$1@gioia.aioe.org>, Dave Nadler <drn@nadler.com> wrote:
>> Hi All - I'm wondering what other folks do about this issue...
>>
>> Consumer flash storage devices (USB memory stick, SD card, etc)
>> have a nice internal wear-leveling controller. When one does a write
>> operation, lots of sectors may be internally rejiggered to provide
>> uniform wear (so things that are never rewritten from the application
>> point of view are actually moved around and rewritten). This activity is
>> invisible from normal application's point of view, but takes some time.
>> If the device is powered off during such activity, data corruption...
>> So, its necessary to provide the device some time after the last write
>> before it is powered off. Plenty of embedded stuff I've seen too often
>> corrupts memory at power off, and of course the device manufacturers
>> blame the memory manufacturers...
>>
>> So, how do you avoid this kind of corruption in your designs?
>>
>> Thanks,
>> Best Regards, Dave
>
> It is not necessary to do this. Here's a very simple way to recover with
> no data loss ever. It is simply "log-only" or "journal-only" storage.
>
> The device keeps 10% capacity reserved (pre-erased) (or less, this is a
> performance number). The driver has enough RAM to track where every logical
> block is (this isn't much RAM). And then writing is always done as a
> logfile--write whatever the user data is starting at block 0, and move up.
> After writing user data, write a log entry (this can be just right after the
> user data). Writes never go to the block the user indicates, they always go
> only to the log pointer. Reading looks up where that block's latest copy is,
> and reads that.
>
> When you're at less than 10% space left (near the end of the device for
> first-pass writes), you simply read from +10% from the current log write
> position, and write it to the log (compacting it to avoid re-writing any
> blocks which are now obsolete) until you free up space. Since many blocks are
> rewritten, when we compact them we free space. Once copied, then erase the
> blocks which were compacted. Then just keep growing the "log" through the
> newly erased blocks.
>
> Upon power up, scan entire device for the log info, and rebuild the RAM index.
>
> Power can be removed at any time, and fully recovered, although obviously the
> most recent data may be lost, but we can roll back to the last consistent
> state just like journaled file systems (the log entries need a checksum so
> we can validate them). Wear leveling is achieved by design.
>
> There are lots of small ways to improve the above, so do that.
>
> I have no idea what actual devices do, I suspect it's something much more
> complex and less robust.

You're missing the point/role of the internal controller in the mix.

Imagine 8 blocks of memory in the device. Blocks 1, 2 and 3 (no special
significance) contain highly static code/data. They get written *once*
when the device is manufactured. So, each has seen *1* program/erase/write
cycle.

Meanwhile, blocks 4-8 are constantly hammered on. The code is constantly
updating the "files" that occupy those blocks (the files don't TOUCH the
first 3 blocks, by definition).

After 1,000 updates, blocks 4-8 have seen 1,000 program/erase/write cycles.

The underlying FLASH device will have a MAXCYCLES specified, based on the
technology used (SLC, MLC, TLC, QLC, etc.), process geometry, etc.
For consumer devices, this number tends to be lower -- because consumers
tend to want to purchase "big" instead of "durable" (so, MLC/TLC/etc.
technology).

Assume the MAXCYCLES is 1,002 (actual numbers are unimportant -- if Dave feels
he will be taxing the medium over the life of his design).

So, after two more updates, the device is *broken*. Because blocks 4-8 will
each have hit their 1,002 cycle limit and stopped working (yeah, I know it's
not a brick wall; but there is *some* number at which ECC errors prove
unmanageable and the controller marks those blocks (4-8) as bad.

Meanwhile, 1,2 and 3 each have 1,001 cycles of wear available -- that they
aren't (and WON'T!) be using. Had those 3,003 cycles been "shared" among
all of the blocks, then the files being stored in 4-8 would still be
writable (even though the next write might be into blocks 1, 3, 5, 6 and 8).

So, the controller has to deliberately *move* a copy of the data in blocks
1, 2 and/or 3 into 4-8 -- consuming one cycle of 4-8. But, freeing up
1001 cycles in 1, 2, 3!

You, on the outside, can't tell how it is doing this, when it is doing this
or even *if* it is doing this! So, you can't predict what parts of the flash
will be corrupted as power goes away. Maybe the VTOC gets hosed (so you can't
even FIND the files). Or, some bookkeeping metadata used by the controller.

The logging idea works for magnetic media where what's there, stays there,
and all you have to worry about is whether or not the *new* stuff made it in
"under the wire", or not.

As an analogy, next time your RAID array is rebuilding, cycle power.
See how easily it sorts out WHERE it was, in the process (and think
about the resources that it spent to make that possible -- all in a $5
thumb drive??)

Re: Shutdown behavior and flash storage devices

<sdkheo$t29$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=561&group=comp.arch.embedded#561

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 13:27:00 -0700
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <sdkheo$t29$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
<sdjmlo$4ji$1@gioia.aioe.org> <sdkfcj$ddf$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 25 Jul 2021 20:27:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2aa6f39a7dd1d7384df141f77dac3d4";
logging-data="29769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/b90FVYQQIDsOnxvq2gPoJ"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:yEUI/3tK/y11uFwSsa28vsjP+E4=
In-Reply-To: <sdkfcj$ddf$1@dont-email.me>
Content-Language: en-US
 by: Don Y - Sun, 25 Jul 2021 20:27 UTC

On 7/25/2021 12:51 PM, Dimiter_Popoff wrote:
> If you have no knowledge of how the flash medium is written - which
> would normally be the case with USB sticks or SD cards etc. - the most
> efficient way to mitigate data loss probability is to do as much
> write cacheing as you can afford at system level.

One would assume you'd adopt such a strategy regardless -- as the
durability of FLASH is limited. (write a piece of code that
just keeps rewriting the contents of FLASH and see how long before
you get write/verify errors)

> Of course again
> you will be prone to data loss on unexpected power loss but updating
> the write cache will be done at (much) longer intervals and in
> relatively brief bursts, thus the probability to be hit gets lower.

The usual trick is to just have a mirror of the FLASH contents
and flush that to the media when you're pretty sure the ship
is sinking.

But, if this is *large*, then you risk only partial writes before
power drops to an unusable/unreliable level.

> The rest can only be got rid of by having large enough caps on
> the power supply and an early warning that power has been lost
> (usually at the input of the stepdowns and you are running on fumes.

I'm not sure that will work with consumer devices. You have no way of
knowing how long it will take to reliably flush ALL of the data
out to the physical store.

Remember, if you have a USB interface, then the interface limits the
write rate as well as the media in the device.

> Of course you can employ various strategies to mimick flash drive
> behaviour at a higher level, Don suggested one, Kent also did,
> but these mean having different drivers for different media and
> all the consequences of that.

Exactly. I use "bare" devices so I can see how they respond -- because
the datasheet gives me hard limits.

So, I have to worry about a write *failing* (in which case, it's as if
I lost power prematurely) but not *other* "unchanged" data being corrupted
in the process (neglecting read/write disturb events).

> I prefer to talk to standard SCSI
> or ATA behaving things and leave it to them to handle their
> unique specifics. [I remember how I *had to* introduce write
> cacheing at system level, in the mid 90-s I started to do backups
> under DPS to magneto-optical devices; early days DPS would
> simply update its CAT (Cluster Allocation Table) every time
> it got modifier and these sectors got corrupted before the backup
> would finish.... :-) ].

I think much of that is inconsistent with Dave's idea of "consumer"
(which I read as "inexpensive")

Re: Shutdown behavior and flash storage devices

<sdkjdb$999$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=562&group=comp.arch.embedded#562

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dp...@tgi-sci.com (Dimiter_Popoff)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Mon, 26 Jul 2021 00:00:26 +0300
Organization: TGI
Lines: 46
Message-ID: <sdkjdb$999$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
<sdjmlo$4ji$1@gioia.aioe.org> <sdkfcj$ddf$1@dont-email.me>
<sdkheo$t29$1@dont-email.me>
Reply-To: dp@tgi-sci.com
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 Jul 2021 21:00:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="afca09934ccf42d0e0318079ca8f8803";
logging-data="9513"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Ul/4KFtJzyFquZlrXyWB3z9ObnNSewnQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:I1armVTg7u2vCQoT8f0CT5J2rFY=
In-Reply-To: <sdkheo$t29$1@dont-email.me>
Content-Language: en-US
 by: Dimiter_Popoff - Sun, 25 Jul 2021 21:00 UTC

On 7/25/2021 23:27, Don Y wrote:
> On 7/25/2021 12:51 PM, Dimiter_Popoff wrote:
> ......
>
>> Of course again
>> you will be prone to data loss on unexpected power loss but updating
>> the write cache will be done at (much) longer intervals and in
>> relatively brief bursts, thus the probability to be hit gets lower.
>
> The usual trick is to just have a mirror of the FLASH contents
> and flush that to the media when you're pretty sure the ship
> is sinking.
>
> But, if this is *large*, then you risk only partial writes before
> power drops to an unusable/unreliable level.

Well I think tens of gigabytes for small drives nowadays, what can you
do. Cacheing it all just is not feasible.
What DPS does is cache directories and CATs on a 4k piece basis
(regardless of the disk block size, 512 2048, 4k) and maintains a
bitmap for its dirty regions - so when it updates to the medium
it writes at least 4k and no more than twice 4095 excessive bytes
or something like that.

>
>> The rest can only be got rid of by having large enough caps on
>> the power supply and an early warning that power has been lost
>> (usually at the input of the stepdowns and you are running on fumes.
>
> I'm not sure that will work with consumer devices.  You have no way of
> knowing how long it will take to reliably flush ALL of the data
> out to the physical store.

Oh with consumer devices you have not built yourself it will probably
never work, of course. They are unlikely to give you an early warning
in the first place. If you want to be safer you just use good rotating
disks.... I think I read somewhere they do their soft shutdown using the
energy in the rotor (and do that since times immemorial), but I have
never verified this.

Dimiter

======================================================
Dimiter Popoff, TGI http://www.tgi-sci.com
======================================================
http://www.flickr.com/photos/didi_tgi/

Re: Shutdown behavior and flash storage devices

<sdl00m$fb4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=563&group=comp.arch.embedded#563

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Sun, 25 Jul 2021 17:35:29 -0700
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <sdl00m$fb4$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org> <sdidmc$d9c$1@dont-email.me>
<sdjmlo$4ji$1@gioia.aioe.org> <sdkfcj$ddf$1@dont-email.me>
<sdkheo$t29$1@dont-email.me> <sdkjdb$999$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 26 Jul 2021 00:35:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="fd6dea0002853d1ae7c4c57125146e40";
logging-data="15716"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19asUpllmfCXRNu8IZPlVWF"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:Tan9s+Q1fB+8MFVki2wrf73le4A=
In-Reply-To: <sdkjdb$999$1@dont-email.me>
Content-Language: en-US
 by: Don Y - Mon, 26 Jul 2021 00:35 UTC

On 7/25/2021 2:00 PM, Dimiter_Popoff wrote:
> On 7/25/2021 23:27, Don Y wrote:
>> On 7/25/2021 12:51 PM, Dimiter_Popoff wrote:
>> ......
>>
>>> Of course again
>>> you will be prone to data loss on unexpected power loss but updating
>>> the write cache will be done at (much) longer intervals and in
>>> relatively brief bursts, thus the probability to be hit gets lower.
>>
>> The usual trick is to just have a mirror of the FLASH contents
>> and flush that to the media when you're pretty sure the ship
>> is sinking.
>>
>> But, if this is *large*, then you risk only partial writes before
>> power drops to an unusable/unreliable level.
>
> Well I think tens of gigabytes for small drives nowadays, what can you
> do. Cacheing it all just is not feasible.

Right. OTOH, if your software is pushing large objects to long term
storage, it likely WANTS them to be written, there. Caching is
a more prudent strategy for small things that may change often
(e.g., configuration parameters, "state", etc.) Pushing them
to the physical store is LOGICALLY correct (from the application's
standpoint) but usually a performance hit and a durability hit
(for media that wear).

> What DPS does is cache directories and CATs on a 4k piece basis
> (regardless of the disk block size, 512 2048, 4k) and maintains a
> bitmap for its dirty regions - so when it updates to the medium
> it writes at least 4k and no more than twice 4095 excessive bytes
> or something like that.

I only have persistent memory in my RDBMS -- everything else is
just RAM (save for small bootloaders). But, the RDBMS node can
afford to have gobs of disk cache to avoid physical writes.

And, I can use different "tablespaces" (the "disk" on which
particular "tables" reside) to deliberately avoid backing certain
tables (like temporary ones) to durable memory.

>>> The rest can only be got rid of by having large enough caps on
>>> the power supply and an early warning that power has been lost
>>> (usually at the input of the stepdowns and you are running on fumes.
>>
>> I'm not sure that will work with consumer devices. You have no way of
>> knowing how long it will take to reliably flush ALL of the data
>> out to the physical store.
>
> Oh with consumer devices you have not built yourself it will probably
> never work, of course. They are unlikely to give you an early warning
> in the first place. If you want to be safer you just use good rotating
> disks.... I think I read somewhere they do their soft shutdown using the
> energy in the rotor (and do that since times immemorial), but I have
> never verified this.

I think the first step is questioning what you *need* to store.

E.g., I trade memory for time with a lot of my algorithms -- pulling
data from disk and using that to build large structures in RAM that
I can use to expedite the algorithms. It would be *nice* to be
able to save those structures in their "large" state -- to save
the time/effort of having to rebuild them when I restart those
applications. But, this gets to be costly if you try to adopt
that practice universally (with all applications).

And, of course, making sure you can "recognize" data that is
corrupt...

Re: Shutdown behavior and flash storage devices

<nnd$0a5908ee$3a9716e7@d5a763e0a23fc394>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=564&group=comp.arch.embedded#564

  copy link   Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Newsgroups: comp.arch.embedded
References: <sdhb29$ibh$1@gioia.aioe.org>
From: bad...@heaven.org (Jaded Hobo)
Date: Tue, 27 Jul 2021 19:44:26 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
MIME-Version: 1.0
In-Reply-To: <sdhb29$ibh$1@gioia.aioe.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$0a5908ee$3a9716e7@d5a763e0a23fc394>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe002.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 33
Injection-Date: Tue, 27 Jul 2021 19:44:27 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2434
 by: Jaded Hobo - Tue, 27 Jul 2021 17:44 UTC

On 24-07-2021 17:19, Dave Nadler wrote:
> Hi All - I'm wondering what other folks do about this issue...
>
> Consumer flash storage devices (USB memory stick, SD card, etc)
> have a nice internal wear-leveling controller. When one does a write
> operation, lots of sectors may be internally rejiggered to provide
> uniform wear (so things that are never rewritten from the application
> point of view are actually moved around and rewritten). This activity is
> invisible from normal application's point of view, but takes some time.
> If the device is powered off during such activity, data corruption...
> So, its necessary to provide the device some time after the last write
> before it is powered off. Plenty of embedded stuff I've seen too often
> corrupts memory at power off, and of course the device manufacturers
> blame the memory manufacturers...
>
> So, how do you avoid this kind of corruption in your designs?
>
> Thanks,
> Best Regards, Dave

A number of upper tier memory device manufacturers sell flash drives,
USB sticks, SS Sata drives and M2 drives with "UPS" capabilities. When
they sense a loss of power they will have just enough onboard juice to
power down in a controller manner.

I have used drives from InnoDisk (
https://www.innodisk.com/en/products/flash-storage/ssd ) on Linux boxes
inside machines with hard on/off switches. With regular drives we'd see
boot problems after 20 to 30 power cycles, with the "UPS" protected ones
we could do hundreds of hard cycles without ill effect.

Antoon

Re: Shutdown behavior and flash storage devices

<sdpj5t$7h3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=565&group=comp.arch.embedded#565

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: blockedo...@foo.invalid (Don Y)
Newsgroups: comp.arch.embedded
Subject: Re: Shutdown behavior and flash storage devices
Date: Tue, 27 Jul 2021 11:27:06 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <sdpj5t$7h3$1@dont-email.me>
References: <sdhb29$ibh$1@gioia.aioe.org>
<nnd$0a5908ee$3a9716e7@d5a763e0a23fc394>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 27 Jul 2021 18:27:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2cd3f9c81806cc74858c53f4af4fb8eb";
logging-data="7715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GUU2phiXWLLF8Jkzg/xIu"
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.1.1
Cancel-Lock: sha1:svknl1YKrVnF5FDXpSOh2k7RBL0=
In-Reply-To: <nnd$0a5908ee$3a9716e7@d5a763e0a23fc394>
Content-Language: en-US
 by: Don Y - Tue, 27 Jul 2021 18:27 UTC

On 7/27/2021 10:44 AM, Jaded Hobo wrote:
> On 24-07-2021 17:19, Dave Nadler wrote:
>> Hi All - I'm wondering what other folks do about this issue...
>>
>> Consumer flash storage devices (USB memory stick, SD card, etc)
>> have a nice internal wear-leveling controller. When one does a write
>> operation, lots of sectors may be internally rejiggered to provide uniform
>> wear (so things that are never rewritten from the application point of view
>> are actually moved around and rewritten). This activity is invisible from
>> normal application's point of view, but takes some time. If the device is
>> powered off during such activity, data corruption... So, its necessary to
>> provide the device some time after the last write before it is powered off.
>> Plenty of embedded stuff I've seen too often corrupts memory at power off,
>> and of course the device manufacturers blame the memory manufacturers...
>>
>> So, how do you avoid this kind of corruption in your designs?
>>
>> Thanks,
>> Best Regards, Dave
>
> A number of upper tier memory device manufacturers sell flash drives, USB
> sticks, SS Sata drives and M2 drives with "UPS" capabilities. When they sense a
> loss of power they will have just enough onboard juice to power down in a
> controller manner.
>
> I have used drives from InnoDisk (
> https://www.innodisk.com/en/products/flash-storage/ssd ) on Linux boxes inside
> machines with hard on/off switches. With regular drives we'd see boot problems
> after 20 to 30 power cycles, with the "UPS" protected ones we could do hundreds
> of hard cycles without ill effect.

What's the (typical) price premium for that "feature"?

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor