From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH URGENT v1.1 1/2] btrfs-progs: disk-io: Make super block write error easier to read
Date: Wed, 27 Mar 2019 17:46:51 +0800 [thread overview]
Message-ID: <20190327094652.16078-2-wqu@suse.com> (raw)
In-Reply-To: <20190327094652.16078-1-wqu@suse.com>
When we failed to write super blocks, we just output something like:
WARNING: failed to write sb: I/O error
Or
WARNING: failed to write all sb data
There is no info about which device failed and there are two different
error message for the same write error.
This patch will change it to something more detailed:
ERROR: failed to write super block for devid 1: write error: I/O error
This provides the basis for later super block flush error handling.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
disk-io.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/disk-io.c b/disk-io.c
index 797b9b79ea3c..f7fb7026cd94 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1599,8 +1599,13 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
ret = pwrite64(device->fd, fs_info->super_copy,
BTRFS_SUPER_INFO_SIZE,
fs_info->super_bytenr);
- if (ret != BTRFS_SUPER_INFO_SIZE)
- goto write_err;
+ if (ret != BTRFS_SUPER_INFO_SIZE) {
+ errno = EIO;
+ error(
+ "failed to write super block for devid %llu: write error: %m",
+ device->devid);
+ return -EIO;
+ }
return 0;
}
@@ -1622,18 +1627,16 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
*/
ret = pwrite64(device->fd, fs_info->super_copy,
BTRFS_SUPER_INFO_SIZE, bytenr);
- if (ret != BTRFS_SUPER_INFO_SIZE)
- goto write_err;
+ if (ret != BTRFS_SUPER_INFO_SIZE) {
+ errno = EIO;
+ error(
+ "failed to write super block for devid %llu: write error: %m",
+ device->devid);
+ return -errno;
+ }
}
return 0;
-
-write_err:
- if (ret > 0)
- fprintf(stderr, "WARNING: failed to write all sb data\n");
- else
- fprintf(stderr, "WARNING: failed to write sb: %m\n");
- return ret;
}
int write_all_supers(struct btrfs_fs_info *fs_info)
--
2.21.0
next prev parent reply other threads:[~2019-03-27 9:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-27 9:46 [PATCH URGENT v1.1 0/2] btrfs-progs: Fix the nobarrier behavior of write Qu Wenruo
2019-03-27 9:46 ` Qu Wenruo [this message]
2019-03-27 11:34 ` [PATCH URGENT v1.1 1/2] btrfs-progs: disk-io: Make super block write error easier to read Nikolay Borisov
2019-03-27 9:46 ` [PATCH URGENT v1.1 2/2] btrfs-progs: disk-io: Flush to ensure super block write is FUA Qu Wenruo
2019-03-27 14:07 ` [PATCH URGENT v1.1 0/2] btrfs-progs: Fix the nobarrier behavior of write Adam Borowski
2019-03-27 14:17 ` Hugo Mills
2019-03-27 14:39 ` Qu Wenruo
2019-03-27 14:42 ` Qu Wenruo
2019-03-27 14:48 ` Qu Wenruo
2019-03-31 14:42 ` Qu Wenruo
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=20190327094652.16078-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox