diff mbox series

[5/7] mkfs: check that metadata updates have been committed

Message ID 158258945969.451075.3231072619586225611.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfsprogs: actually check that writes succeeded | expand

Commit Message

Darrick J. Wong Feb. 25, 2020, 12:10 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Make sure that all the metadata we wrote in the process of formatting
the filesystem have been written correctly, or exit with failure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 mkfs/xfs_mkfs.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Brian Foster Feb. 25, 2020, 3:08 p.m. UTC | #1
On Mon, Feb 24, 2020 at 04:10:59PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure that all the metadata we wrote in the process of formatting
> the filesystem have been written correctly, or exit with failure.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  mkfs/xfs_mkfs.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 1f5d2105..1038e604 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3940,13 +3940,16 @@ main(
>  	(XFS_BUF_TO_SBP(buf))->sb_inprogress = 0;
>  	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
>  
> -	libxfs_umount(mp);
> +	/* Report failure if anything failed to get written to our new fs. */
> +	error = -libxfs_umount(mp);
> +	if (error)
> +		exit(1);
> +
>  	if (xi.rtdev)
>  		libxfs_device_close(xi.rtdev);
>  	if (xi.logdev && xi.logdev != xi.ddev)
>  		libxfs_device_close(xi.logdev);
>  	libxfs_device_close(xi.ddev);
>  	libxfs_destroy();
> -
>  	return 0;
>  }
>
Christoph Hellwig Feb. 25, 2020, 5:37 p.m. UTC | #2
On Mon, Feb 24, 2020 at 04:10:59PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Make sure that all the metadata we wrote in the process of formatting
> the filesystem have been written correctly, or exit with failure.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 1f5d2105..1038e604 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3940,13 +3940,16 @@  main(
 	(XFS_BUF_TO_SBP(buf))->sb_inprogress = 0;
 	libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
-	libxfs_umount(mp);
+	/* Report failure if anything failed to get written to our new fs. */
+	error = -libxfs_umount(mp);
+	if (error)
+		exit(1);
+
 	if (xi.rtdev)
 		libxfs_device_close(xi.rtdev);
 	if (xi.logdev && xi.logdev != xi.ddev)
 		libxfs_device_close(xi.logdev);
 	libxfs_device_close(xi.ddev);
 	libxfs_destroy();
-
 	return 0;
 }