Skip to contentSkip to conversation

xfs_copy: flush target devices before exiting

PATCH Superseded Darrick J. Wong 1 participant 2 messages Jun 8, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_copy: flush target devices before exiting

From: Darrick J. Wong <[email protected]>

Flush the devices we're copying to before exiting, so that we can report any write errors.

---
 copy/xfs_copy.c |    4 ++++
 1 file changed, 4 insertions(+)
copy/xfs_copy.c +4 -0
index 2d087f71..45ee2e06 100644
@@ -12,6 +12,7 @@
 #include <stdarg.h>
 #include "xfs_copy.h"
 #include "libxlog.h"
+#include "libfrog/platform.h"
 
 #define	rounddown(x, y)	(((x)/(y))*(y))
 #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)
@@ -150,6 +151,9 @@ check_errors(void)
 			else
 				do_log(_("lseek error"));
 			do_log(_(" at offset %lld\n"), target[i].position);
+		} else if (platform_flush_device(target[i].fd, 0)) {
+			do_log(_("    %s -- flush error %d"),
+					target[i].name, errno);
 		}
 	}
 	if (first_error == 0)  {
author NAK
#1 lore raw
Quoted 23 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Flush the devices we're copying to before exiting, so that we can report any write errors.

---
 copy/xfs_copy.c |    4 ++++
 1 file changed, 4 insertions(+)
copy/xfs_copy.c +1 -0
index 2d087f71..45ee2e06 100644
@@ -12,6 +12,7 @@
 #include <stdarg.h>
 #include "xfs_copy.h"
 #include "libxlog.h"
+#include "libfrog/platform.h"
 
 #define	rounddown(x, y)	(((x)/(y))*(y))
 #define uuid_equal(s,d) (platform_uuid_compare((s),(d)) == 0)

copy/xfs_copy.c check_errors(void) · line 156

Quoted 6 lines
copy/xfs_copy.c +3 -0
@@ -150,6 +151,9 @@ check_errors(void)
 			else
 				do_log(_("lseek error"));
 			do_log(_(" at offset %lld\n"), target[i].position);
+		} else if (platform_flush_device(target[i].fd, 0)) {
+			do_log(_("    %s -- flush error %d"),
+					target[i].name, errno);

NAK, this should set first_error. Boooo...

--D

Quoted 3 lines
copy/xfs_copy.c +0 -0
 		}
 	}
 	if (first_error == 0)  {