mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] rc-once: make sure data makes it to the medium
@ 2020-08-10 10:17 Robert Schwebel
  2020-08-10 13:46 ` Uwe Kleine-König
  2020-08-17  6:18 ` [ptxdist] [APPLIED] " Michael Olbrich
  0 siblings, 2 replies; 6+ messages in thread
From: Robert Schwebel @ 2020-08-10 10:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Robert Schwebel

We have seen that, if the first boot runs under a testsuite that powers
the board off after rc-once is finished, data hasn't found its way to
the medium. This has been observed to result in an empty ssh key.

Adding a sync helps.

Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
---
 projectroot/usr/lib/systemd/systemd-rc-once | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/projectroot/usr/lib/systemd/systemd-rc-once b/projectroot/usr/lib/systemd/systemd-rc-once
index e14936e40..db3d84e3c 100644
--- a/projectroot/usr/lib/systemd/systemd-rc-once
+++ b/projectroot/usr/lib/systemd/systemd-rc-once
@@ -21,6 +21,8 @@ start() {
 }
 
 umount() {
+	# make sure rc-once generated data makes it to the medium
+	sync
 	if ! mount_root_restore; then
 		# remounting rw/ro during the second boot will flush anything
 		# left in the filesystem journal
-- 
2.27.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] [PATCH] rc-once: make sure data makes it to the medium
  2020-08-10 10:17 [ptxdist] [PATCH] rc-once: make sure data makes it to the medium Robert Schwebel
@ 2020-08-10 13:46 ` Uwe Kleine-König
  2020-08-10 13:59   ` Robert Schwebel
  2020-08-17  6:18 ` [ptxdist] [APPLIED] " Michael Olbrich
  1 sibling, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2020-08-10 13:46 UTC (permalink / raw)
  To: ptxdist; +Cc: Robert Schwebel


[-- Attachment #1.1: Type: text/plain, Size: 1397 bytes --]

On Mon, Aug 10, 2020 at 12:17:13PM +0200, Robert Schwebel wrote:
> We have seen that, if the first boot runs under a testsuite that powers
> the board off after rc-once is finished, data hasn't found its way to
> the medium. This has been observed to result in an empty ssh key.
> 
> Adding a sync helps.
> 
> Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
> ---
>  projectroot/usr/lib/systemd/systemd-rc-once | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/projectroot/usr/lib/systemd/systemd-rc-once b/projectroot/usr/lib/systemd/systemd-rc-once
> index e14936e40..db3d84e3c 100644
> --- a/projectroot/usr/lib/systemd/systemd-rc-once
> +++ b/projectroot/usr/lib/systemd/systemd-rc-once
> @@ -21,6 +21,8 @@ start() {
>  }
>  
>  umount() {
> +	# make sure rc-once generated data makes it to the medium
> +	sync
>  	if ! mount_root_restore; then
>  		# remounting rw/ro during the second boot will flush anything
>  		# left in the filesystem journal

I would expect that the mount -o remount,ro that is done (sometimes) as
part of mount_root_restore should handle this just fine.

How is your use case? Are you muddying the waters of a bug somewhere
else here?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 181 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] [PATCH] rc-once: make sure data makes it to the medium
  2020-08-10 13:46 ` Uwe Kleine-König
@ 2020-08-10 13:59   ` Robert Schwebel
  2020-08-10 16:03     ` Bruno Thomsen
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Schwebel @ 2020-08-10 13:59 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 1046 bytes --]

On Mon, Aug 10, 2020 at 03:46:15PM +0200, Uwe Kleine-König wrote:
> >  umount() {
> > +	# make sure rc-once generated data makes it to the medium
> > +	sync
> >  	if ! mount_root_restore; then
> >  		# remounting rw/ro during the second boot will flush anything
> >  		# left in the filesystem journal
> 
> I would expect that the mount -o remount,ro that is done (sometimes) as
> part of mount_root_restore should handle this just fine.

In my case the system is always booted rw, so remounting ro doesn't
happen here at all, the script exits and the labgrid server powers the
board off before the data is written to disk.

Most other systems mount / ro, so remounting happens here and acts as a
flush barrier.

rsc
-- 
Pengutronix e.K.                           | Dipl.-Ing. Robert Schwebel  |
Steuerwalder Str. 21                       | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-9    |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 181 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] [PATCH] rc-once: make sure data makes it to the medium
  2020-08-10 13:59   ` Robert Schwebel
@ 2020-08-10 16:03     ` Bruno Thomsen
  2020-08-11 10:24       ` Ladislav Michl
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Thomsen @ 2020-08-10 16:03 UTC (permalink / raw)
  To: ptxdist; +Cc: Uwe Kleine-König

Den man. 10. aug. 2020 kl. 15.59 skrev Robert Schwebel
<r.schwebel@pengutronix.de>:
>
> On Mon, Aug 10, 2020 at 03:46:15PM +0200, Uwe Kleine-König wrote:
> > >  umount() {
> > > +   # make sure rc-once generated data makes it to the medium
> > > +   sync
> > >     if ! mount_root_restore; then
> > >             # remounting rw/ro during the second boot will flush anything
> > >             # left in the filesystem journal
> >
> > I would expect that the mount -o remount,ro that is done (sometimes) as
> > part of mount_root_restore should handle this just fine.
>
> In my case the system is always booted rw, so remounting ro doesn't
> happen here at all, the script exits and the labgrid server powers the
> board off before the data is written to disk.
>
> Most other systems mount / ro, so remounting happens here and acts as a
> flush barrier.

We do something similar, "sync; sleep 3; umount", as it seems that emmc caches
writes internally in RAM so data is lost if power is removed too fast.
In an ideal world
both sync and umount should block until all data has been written.

Bruno

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] [PATCH] rc-once: make sure data makes it to the medium
  2020-08-10 16:03     ` Bruno Thomsen
@ 2020-08-11 10:24       ` Ladislav Michl
  0 siblings, 0 replies; 6+ messages in thread
From: Ladislav Michl @ 2020-08-11 10:24 UTC (permalink / raw)
  To: ptxdist

On Mon, Aug 10, 2020 at 06:03:03PM +0200, Bruno Thomsen wrote:
> Den man. 10. aug. 2020 kl. 15.59 skrev Robert Schwebel
> <r.schwebel@pengutronix.de>:
> >
> > On Mon, Aug 10, 2020 at 03:46:15PM +0200, Uwe Kleine-König wrote:
> > > >  umount() {
> > > > +   # make sure rc-once generated data makes it to the medium
> > > > +   sync
> > > >     if ! mount_root_restore; then
> > > >             # remounting rw/ro during the second boot will flush anything
> > > >             # left in the filesystem journal
> > >
> > > I would expect that the mount -o remount,ro that is done (sometimes) as
> > > part of mount_root_restore should handle this just fine.
> >
> > In my case the system is always booted rw, so remounting ro doesn't
> > happen here at all, the script exits and the labgrid server powers the
> > board off before the data is written to disk.
> >
> > Most other systems mount / ro, so remounting happens here and acts as a
> > flush barrier.
> 
> We do something similar, "sync; sleep 3; umount", as it seems that emmc caches
> writes internally in RAM so data is lost if power is removed too fast.

Hmm, mmc_shutdown() calls the cache flush, so either something went wrong
and mmc_shutdown() was not called before power off driver did its job or...

> In an ideal world
> both sync and umount should block until all data has been written.

...your not ideal world just powers your board (instead asking it to do so).
In the latter case just use mmc-utils to flush the cache.

> Bruno

	ladis

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] [APPLIED] rc-once: make sure data makes it to the medium
  2020-08-10 10:17 [ptxdist] [PATCH] rc-once: make sure data makes it to the medium Robert Schwebel
  2020-08-10 13:46 ` Uwe Kleine-König
@ 2020-08-17  6:18 ` Michael Olbrich
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Olbrich @ 2020-08-17  6:18 UTC (permalink / raw)
  To: ptxdist; +Cc: Robert Schwebel

Thanks, applied as 96e952f118896288343003866c02384f09e7a28b.

Michael

[sent from post-receive hook]

On Mon, 17 Aug 2020 08:18:24 +0200, Robert Schwebel <r.schwebel@pengutronix.de> wrote:
> We have seen that, if the first boot runs under a testsuite that powers
> the board off after rc-once is finished, data hasn't found its way to
> the medium. This has been observed to result in an empty ssh key.
> 
> Adding a sync helps.
> 
> Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
> Message-Id: <20200810101713.247725-1-r.schwebel@pengutronix.de>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> diff --git a/projectroot/usr/lib/systemd/systemd-rc-once b/projectroot/usr/lib/systemd/systemd-rc-once
> index e14936e40b03..db3d84e3c342 100644
> --- a/projectroot/usr/lib/systemd/systemd-rc-once
> +++ b/projectroot/usr/lib/systemd/systemd-rc-once
> @@ -21,6 +21,8 @@ start() {
>  }
>  
>  umount() {
> +	# make sure rc-once generated data makes it to the medium
> +	sync
>  	if ! mount_root_restore; then
>  		# remounting rw/ro during the second boot will flush anything
>  		# left in the filesystem journal

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-17  6:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10 10:17 [ptxdist] [PATCH] rc-once: make sure data makes it to the medium Robert Schwebel
2020-08-10 13:46 ` Uwe Kleine-König
2020-08-10 13:59   ` Robert Schwebel
2020-08-10 16:03     ` Bruno Thomsen
2020-08-11 10:24       ` Ladislav Michl
2020-08-17  6:18 ` [ptxdist] [APPLIED] " Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox