All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: fix a wrong return value for write_and_map_eb()
Date: Mon, 18 Apr 2022 09:54:24 +0800	[thread overview]
Message-ID: <d3d68b4a612208acf1624238d11a3cf414f65ace.1650246860.git.wqu@suse.com> (raw)

[BUG]
With commit "btrfs-progs: use write_data_to_disk() to replace
write_extent_to_disk()", "mkfs.btrfs -m raid5" will always fail:

 kernel-shared/transaction.c:155: __commit_transaction: BUG_ON `ret` triggered, value 65536
 ./mkfs.btrfs(+0x57dd2)[0x557e610addd2]
 ./mkfs.btrfs(+0x57e70)[0x557e610ade70]
 ./mkfs.btrfs(__commit_transaction+0x139)[0x557e610ae4d4]
 ./mkfs.btrfs(btrfs_commit_transaction+0x214)[0x557e610ae746]
 ./mkfs.btrfs(main+0x19d9)[0x557e61066d34]
 /usr/lib/libc.so.6(+0x2d310)[0x7f2bf222d310]
 /usr/lib/libc.so.6(__libc_start_main+0x81)[0x7f2bf222d3c1]
 ./mkfs.btrfs(_start+0x25)[0x557e61062925]
 Aborted (core dumped)

[CAUSE]
Commit "btrfs-progs: use write_data_to_disk() to replace
write_extent_to_disk()" refactor write_and_map_eb() very slightly, but
it changed the return value on successful writeback for RAID56.

Previously we return 0, but now we return the stripe length, causing
btrfs_commit_transaction() to freak out.

[FIX]
Fix it by just reseting ret to 0 if nothing wrong happened for RAID56.

Please fold this fix into commit "btrfs-progs: use write_data_to_disk()
to replace write_extent_to_disk()".

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 kernel-shared/disk-io.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 4aae7a35768c..26b1c9aa192a 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -477,6 +477,8 @@ int write_and_map_eb(struct btrfs_fs_info *fs_info, struct extent_buffer *eb)
 			error(
 		"failed to write raid56 stripe for bytenr %llu length %llu: %m",
 				eb->start, length);
+		} else {
+			ret = 0;
 		}
 		goto out;
 	}
-- 
2.35.1


             reply	other threads:[~2022-04-18  1:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18  1:54 Qu Wenruo [this message]
2022-04-25 17:13 ` [PATCH] btrfs-progs: fix a wrong return value for write_and_map_eb() David Sterba

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=d3d68b4a612208acf1624238d11a3cf414f65ace.1650246860.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.