From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/3] btrfs: return required error from btrfs_check_super_csum
Date: Tue, 20 Mar 2018 12:13:32 +0200 [thread overview]
Message-ID: <fc5778d9-1674-395b-c010-571d96b0228a@suse.com> (raw)
In-Reply-To: <20180320095310.6355-3-anand.jain@oracle.com>
On 20.03.2018 11:53, Anand Jain wrote:
> Return the required -EINVAL from the function btrfs_check_super_csum()
> and move the error logging into the btrfs_check_super_csum() itself.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/disk-io.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 582ed6af3c50..aafd836af61d 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -406,7 +406,7 @@ static int btrfs_check_super_csum(struct btrfs_fs_info *fs_info,
> if (csum_type != BTRFS_CSUM_TYPE_CRC32) {
> btrfs_err(fs_info, "unsupported checksum algorithm %u",
> csum_type);
> - return 1;
> + return -EINVAL;
> }
>
> /*
> @@ -418,8 +418,10 @@ static int btrfs_check_super_csum(struct btrfs_fs_info *fs_info,
> crc, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
> btrfs_csum_final(crc, result);
>
> - if (memcmp(raw_disk_sb, result, sizeof(result)))
> - return 1;
> + if (memcmp(raw_disk_sb, result, sizeof(result))) {
> + btrfs_err(fs_info, "superblock checksum mismatch");
> + return -EINVAL;
Don't we want EUCLEAN here, since an error in the checksum indicates
corruption?
> + }
>
> return 0;
> }
> @@ -2571,9 +2573,8 @@ int open_ctree(struct super_block *sb,
> * We want to check superblock checksum, the type is stored inside.
> * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k).
> */
> - if (btrfs_check_super_csum(fs_info, bh->b_data)) {
> - btrfs_err(fs_info, "superblock checksum mismatch");
> - err = -EINVAL;
> + err = btrfs_check_super_csum(fs_info, bh->b_data);
> + if (err) {
> brelse(bh);
> goto fail_alloc;
> }
>
next prev parent reply other threads:[~2018-03-20 10:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 9:53 [PATCH 0/3] Preparatory to add the csum check in the scan context Anand Jain
2018-03-20 9:53 ` [PATCH 1/3] btrfs: cleanup btrfs_check_super_csum() to check the csum_type to the type Anand Jain
2018-03-20 10:11 ` Nikolay Borisov
2018-03-20 10:12 ` Nikolay Borisov
2018-03-20 9:53 ` [PATCH 2/3] btrfs: return required error from btrfs_check_super_csum Anand Jain
2018-03-20 10:13 ` Nikolay Borisov [this message]
2018-03-20 22:23 ` Anand Jain
2018-03-21 2:37 ` Anand Jain
2018-03-21 3:01 ` Anand Jain
2018-03-20 9:53 ` [PATCH 3/3] btrfs: refactor btrfs_check_super_csum() for scan Anand Jain
2018-03-20 11:10 ` Nikolay Borisov
2018-03-20 22:32 ` Anand Jain
2018-03-21 8:14 ` [PATCH v3 0/2] Preparatory to add the csum check in the scan context Anand Jain
2018-03-21 8:14 ` [PATCH v3 1/2] btrfs: cleanup btrfs_check_super_csum() to check the csum_type to the type Anand Jain
2018-03-21 8:14 ` [PATCH v3 2/2] btrfs: return required error from btrfs_check_super_csum Anand Jain
2018-03-26 6:40 ` [PATCH v3 0/2] Preparatory to add the csum check in the scan context Anand Jain
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=fc5778d9-1674-395b-c010-571d96b0228a@suse.com \
--to=nborisov@suse.com \
--cc=anand.jain@oracle.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;
as well as URLs for NNTP newsgroup(s).