From 10fc0759444f35f868ce1a0e300a89ec0846331b Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Sun, 1 Mar 2020 12:33:38 -0500 Subject: [PATCH] mkfs: check that metadata updates have been committed 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 Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- 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 e303519a1..b70499d43 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3895,8 +3895,11 @@ main( (XFS_BUF_TO_SBP(buf))->sb_inprogress = 0; libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - libxfs_umount(mp); - libxfs_destroy(&xi); + /* Exit w/ failure if anything failed to get written to our new fs. */ + error = -libxfs_umount(mp); + if (error) + exit(1); + libxfs_destroy(&xi); return 0; } -- 2.47.2