All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tools/fw_env: use fsync to ensure that data is physically stored
@ 2017-07-13 13:11 Vincent Prince
  2017-07-14  9:07 ` Vincent Prince
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Prince @ 2017-07-13 13:11 UTC (permalink / raw)
  To: u-boot

Hi all,

We had the same issue on our custom board, and this patch fixed it.

We use fw_setenv for updating our BSP, and before the patch, 100 boards
over 170 didn't work,
and after, 170/170 did get the update.

This patches worked well for us,
Thanks Michael

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] tools/fw_env: use fsync to ensure that data is physically stored
@ 2013-05-20 19:34 Michael Heimpold
  2013-05-21 12:47 ` Wolfgang Denk
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Heimpold @ 2013-05-20 19:34 UTC (permalink / raw)
  To: u-boot

Closing a file descriptor does not guarantee that the data has been
successfully saved to disk, as the kernel might defer the write.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
 tools/env/fw_env.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 428e374..0420495 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1033,7 +1033,19 @@ static int flash_io (int mode)
 
 		rc = flash_write (fd_current, fd_target, dev_target);
 
+		if (fsync (fd_current)) {
+			fprintf (stderr,
+				 "fsync failed on %s: %s\n",
+				 DEVNAME (dev_current), strerror (errno));
+		}
+
 		if (HaveRedundEnv) {
+			if (fsync (fd_target)) {
+				fprintf (stderr,
+					 "fsync failed on %s: %s\n",
+					 DEVNAME (dev_current), strerror (errno));
+			}
+
 			if (close (fd_target)) {
 				fprintf (stderr,
 					"I/O error on %s: %s\n",
-- 
1.7.10.4

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

end of thread, other threads:[~2017-07-14  9:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 13:11 [U-Boot] [PATCH] tools/fw_env: use fsync to ensure that data is physically stored Vincent Prince
2017-07-14  9:07 ` Vincent Prince
  -- strict thread matches above, loose matches on Subject: below --
2013-05-20 19:34 Michael Heimpold
2013-05-21 12:47 ` Wolfgang Denk
2013-05-21 17:34   ` Michael Heimpold
2013-05-22 14:32     ` Mats Kärrman
2013-05-22 15:33     ` Mark Jackson
2013-05-22 18:32       ` Michael Heimpold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.