Blame SOURCES/e2fsprogs-1.43.3-libext2fs-don-t-ignore-fsync-errors.patch

252946
From 2ded6409b3a22e68c19236153f0456e1c079d0da Mon Sep 17 00:00:00 2001
252946
From: Eric Sandeen <sandeen@redhat.com>
252946
Date: Tue, 20 Dec 2016 09:23:29 -0600
252946
Subject: [PATCH] libext2fs: don't ignore fsync errors
252946
252946
Today, if mke2fs experiences IO errors (say, on a thin device
252946
which filled up during mkfs), mke2fs is silent and returns
252946
success even though the filesystem was not properly created.
252946
252946
Catch errors from the io_channel_flush() callchain to
252946
fix this up.  Fix formatting of the printed error as
252946
well:
252946
252946
...
252946
Creating journal (262144 blocks): done
252946
Writing superblocks and filesystem accounting information:
252946
Warning, had trouble writing out superblocks.
252946
# echo $?
252946
5
252946
252946
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
252946
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
252946
---
252946
 lib/ext2fs/closefs.c | 10 ++++++++--
252946
 lib/ext2fs/unix_io.c |  3 ++-
252946
 misc/mke2fs.c        |  2 +-
252946
 3 files changed, 11 insertions(+), 4 deletions(-)
252946
252946
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
252946
index a73c53f..000ebd8 100644
252946
--- a/lib/ext2fs/closefs.c
252946
+++ b/lib/ext2fs/closefs.c
252946
@@ -410,16 +410,22 @@ write_primary_superblock_only:
252946
 	ext2fs_swap_super(super_shadow);
252946
 #endif
252946
 
252946
-	if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC))
252946
+	if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC)) {
252946
 		retval = io_channel_flush(fs->io);
252946
+		if (retval)
252946
+			goto errout;
252946
+	}
252946
 	retval = write_primary_superblock(fs, super_shadow);
252946
 	if (retval)
252946
 		goto errout;
252946
 
252946
 	fs->flags &= ~EXT2_FLAG_DIRTY;
252946
 
252946
-	if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC))
252946
+	if (!(flags & EXT2_FLAG_FLUSH_NO_SYNC)) {
252946
 		retval = io_channel_flush(fs->io);
252946
+		if (retval)
252946
+			goto errout;
252946
+	}
252946
 errout:
252946
 	fs->super->s_state = fs_state;
252946
 #ifdef WORDS_BIGENDIAN
252946
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
252946
index 19be630..a2069f0 100644
252946
--- a/lib/ext2fs/unix_io.c
252946
+++ b/lib/ext2fs/unix_io.c
252946
@@ -885,7 +885,8 @@ static errcode_t unix_flush(io_channel channel)
252946
 #ifndef NO_IO_CACHE
252946
 	retval = flush_cached_blocks(channel, data, 0);
252946
 #endif
252946
-	fsync(data->dev);
252946
+	if (!retval && fsync(data->dev) != 0)
252946
+		return errno;
252946
 	return retval;
252946
 }
252946
 
252946
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
252946
index 3e3ef95..8952a5f 100644
252946
--- a/misc/mke2fs.c
252946
+++ b/misc/mke2fs.c
252946
@@ -2764,7 +2764,7 @@ no_journal:
252946
 	retval = ext2fs_close(fs);
252946
 	if (retval) {
252946
 		fprintf(stderr, "%s",
252946
-			_("\nWarning, had trouble writing out superblocks."));
252946
+			_("\nWarning, had trouble writing out superblocks.\n"));
252946
 	} else if (!quiet) {
252946
 		printf("%s", _("done\n\n"));
252946
 		if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
252946
-- 
252946
2.7.4
252946