xfs_restore: Return error if error occurs restoring extent
diff mbox series

Message ID 20191114074538.1220512-1-sorenson@redhat.com
State New
Headers show
Series
  • xfs_restore: Return error if error occurs restoring extent
Related show

Commit Message

Frank Sorenson Nov. 14, 2019, 7:45 a.m. UTC
If an error occurs during write while restoring an extent,
no error is currently propagated back to the caller, so
xfsrestore can return SUCCESS on a failed restore.

Make restore_extent return an error code indicating the
restore was incomplete.

Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
 restore/content.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Darrick J. Wong Nov. 14, 2019, 6:26 p.m. UTC | #1
On Thu, Nov 14, 2019 at 01:45:38AM -0600, Frank Sorenson wrote:
> If an error occurs during write while restoring an extent,
> no error is currently propagated back to the caller, so
> xfsrestore can return SUCCESS on a failed restore.
> 
> Make restore_extent return an error code indicating the
> restore was incomplete.
> 
> Signed-off-by: Frank Sorenson <sorenson@redhat.com>
> ---
>  restore/content.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/restore/content.c b/restore/content.c
> index 6b22965..c267234 100644
> --- a/restore/content.c
> +++ b/restore/content.c
> @@ -8446,6 +8446,7 @@ restore_extent(filehdr_t *fhdrp,
>  	off64_t new_off;
>  	struct dioattr da;
>  	bool_t isrealtime = BOOL_FALSE;
> +	rv_t rv = RV_OK;
>  
>  	*bytesreadp = 0;
>  
> @@ -8496,7 +8497,6 @@ restore_extent(filehdr_t *fhdrp,
>  		req_bufsz = (size_t)min((off64_t)INTGENMAX, sz);
>  		bufp = (*dop->do_read)(drivep, req_bufsz, &sup_bufsz, &rval);
>  		if (rval) {
> -			rv_t rv;
>  			char *reasonstr;
>  			switch(rval) {
>  			case DRIVE_ERROR_EOF:
> @@ -8665,12 +8665,13 @@ restore_extent(filehdr_t *fhdrp,
>  			fd = -1;
>  			assert(ntowrite <= (size_t)INTGENMAX);
>  			nwritten = (int)ntowrite;
> +			rv = RV_INCOMPLETE;

							I think this is
							reasonable but
							it's very hard
							to understand
							what this
							function does
							when so much of
							the loop body is
							all jammed
							against the
							right margin.

							Reviewed-by:
							Darrick J. Wong
							<darrick.wong@oracle.com>

							--D

>  		}
>  		sz -= (off64_t)sup_bufsz;
>  		off += (off64_t)nwritten;
>  	}
>  
> -	return RV_OK;
> +	return rv;
>  }
>  
>  static char *extattrbufp = 0; /* ptr to start of all the extattr buffers */
> -- 
> 2.20.1
>

Patch
diff mbox series

diff --git a/restore/content.c b/restore/content.c
index 6b22965..c267234 100644
--- a/restore/content.c
+++ b/restore/content.c
@@ -8446,6 +8446,7 @@  restore_extent(filehdr_t *fhdrp,
 	off64_t new_off;
 	struct dioattr da;
 	bool_t isrealtime = BOOL_FALSE;
+	rv_t rv = RV_OK;
 
 	*bytesreadp = 0;
 
@@ -8496,7 +8497,6 @@  restore_extent(filehdr_t *fhdrp,
 		req_bufsz = (size_t)min((off64_t)INTGENMAX, sz);
 		bufp = (*dop->do_read)(drivep, req_bufsz, &sup_bufsz, &rval);
 		if (rval) {
-			rv_t rv;
 			char *reasonstr;
 			switch(rval) {
 			case DRIVE_ERROR_EOF:
@@ -8665,12 +8665,13 @@  restore_extent(filehdr_t *fhdrp,
 			fd = -1;
 			assert(ntowrite <= (size_t)INTGENMAX);
 			nwritten = (int)ntowrite;
+			rv = RV_INCOMPLETE;
 		}
 		sz -= (off64_t)sup_bufsz;
 		off += (off64_t)nwritten;
 	}
 
-	return RV_OK;
+	return rv;
 }
 
 static char *extattrbufp = 0; /* ptr to start of all the extattr buffers */