Linux-ext4 Archive on lore.kernel.org
 help / color / Atom feed
From: Haotian Li <lihaotian9@huawei.com>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	"liuzhiqiang (I)" <liuzhiqiang26@huawei.com>,
	linfeilong <linfeilong@huawei.com>
Subject: [PATCH] e2fsck: try write_primary_superblock() again when it failed
Date: Tue, 13 Apr 2021 11:19:30 +0800
Message-ID: <7486f08c-7f14-9fac-fdb2-0fe78a799d90@huawei.com> (raw)

Function write_primary_superblock() has two ways to flush
superblock, byte-by-byte as default. It may use
io_channel_write_byte() many times. If some errors occur
during these funcs, the superblock may become inconsistent
and produce checksum error.

Try write_primary_superblock() with whole-block way again
when it failed on byte-by-byte way.
---
 lib/ext2fs/closefs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 69cbdd8c..1fc27fb5 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -223,10 +223,8 @@ static errcode_t write_primary_superblock(ext2_filsys fs,
 		retval = io_channel_write_byte(fs->io,
 			       SUPERBLOCK_OFFSET + (2 * write_idx), size,
 					       new_super + write_idx);
-		if (retval == EXT2_ET_UNIMPLEMENTED)
-			goto fallback;
 		if (retval)
-			return retval;
+			goto fallback;
 	}
 	memcpy(fs->orig_super, super, SUPERBLOCK_SIZE);
 	return 0;
-- 
2.23.0

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  3:19 Haotian Li [this message]
2021-05-10  3:50 ` Zhiqiang Liu
2021-05-10 20:59 ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7486f08c-7f14-9fac-fdb2-0fe78a799d90@huawei.com \
    --to=lihaotian9@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ext4 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ext4/0 linux-ext4/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ext4 linux-ext4/ https://lore.kernel.org/linux-ext4 \
		linux-ext4@vger.kernel.org
	public-inbox-index linux-ext4

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ext4


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git