From: Nikolay Borisov <nborisov@suse.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/8] btrfs: cleanup btrfs_read_disk_super() to return std error
Date: Tue, 27 Mar 2018 11:07:29 +0300 [thread overview]
Message-ID: <1ed03ce2-9ebd-b126-e7c8-e879bbd15e44@suse.com> (raw)
In-Reply-To: <20180326082742.9235-4-anand.jain@oracle.com>
On 26.03.2018 11:27, Anand Jain wrote:
> The only caller btrfs_scan_one_device() sets -EINVAL for error from
> btrfs_read_disk_super(), so this patch returns -EINVAL from the latter
> function.
>
> A preparatory patch to add csum check in btrfs_read_disk_super().
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/volumes.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 87d183accdb2..ed22f0a3d239 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1154,23 +1154,23 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr,
>
> /* make sure our super fits in the device */
> if (bytenr + PAGE_SIZE >= i_size_read(bdev->bd_inode))
> - return 1;
> + return -EINVAL;
>
> /* make sure our super fits in the page */
> if (sizeof(**disk_super) > PAGE_SIZE)
> - return 1;
> + return -EINVAL;
>
> /* make sure our super doesn't straddle pages on disk */
> index = bytenr >> PAGE_SHIFT;
> if ((bytenr + sizeof(**disk_super) - 1) >> PAGE_SHIFT != index)
> - return 1;
> + return -EINVAL;
>
> /* pull in the page with our super */
> *page = read_cache_page_gfp(bdev->bd_inode->i_mapping,
> index, GFP_KERNEL);
>
> if (IS_ERR_OR_NULL(*page))
> - return 1;
> + return -EINVAL;
>
> p = kmap(*page);
>
> @@ -1180,7 +1180,7 @@ static int btrfs_read_disk_super(struct block_device *bdev, u64 bytenr,
> if (btrfs_super_bytenr(*disk_super) != bytenr ||
> btrfs_super_magic(*disk_super) != BTRFS_MAGIC) {
> btrfs_release_disk_super(*page);
> - return 1;
> + return -EINVAL;
> }
>
> if ((*disk_super)->label[0] &&
> @@ -1218,10 +1218,9 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
> if (IS_ERR(bdev))
> return PTR_ERR(bdev);
>
> - if (btrfs_read_disk_super(bdev, bytenr, &page, &disk_super)) {
> - ret = -EINVAL;
> + ret = btrfs_read_disk_super(bdev, bytenr, &page, &disk_super);
> + if (ret)
I'd rather have explicit ret < 0 check.
> goto error_bdev_put;
> - }
>
> mutex_lock(&uuid_mutex);
> device = device_list_add(path, disk_super);
>
next prev parent reply other threads:[~2018-03-27 8:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 8:27 [PATCH 0/8] Superblock read and verify cleanups Anand Jain
2018-03-26 8:27 ` [PATCH 1/8] btrfs: cleanup btrfs_check_super_csum() for better code flow Anand Jain
2018-03-27 12:10 ` Nikolay Borisov
2018-03-26 8:27 ` [PATCH 2/8] btrfs: return required error from btrfs_check_super_csum Anand Jain
2018-03-27 8:05 ` Nikolay Borisov
2018-03-27 19:16 ` David Sterba
2018-03-27 20:43 ` Anand Jain
2018-04-05 14:48 ` David Sterba
2018-03-26 8:27 ` [PATCH 3/8] btrfs: cleanup btrfs_read_disk_super() to return std error Anand Jain
2018-03-27 8:07 ` Nikolay Borisov [this message]
2018-03-26 8:27 ` [PATCH 4/8] btrfs: make btrfs_check_super_csum() non-static Anand Jain
2018-03-27 12:10 ` Nikolay Borisov
2018-03-26 8:27 ` [PATCH 5/8] btrfs: check if the fsid in the primary sb and copy sb are same Anand Jain
2018-03-27 8:49 ` Nikolay Borisov
2018-03-27 22:06 ` Anand Jain
2018-03-28 6:08 ` Nikolay Borisov
2018-03-28 7:05 ` Anand Jain
2018-03-26 8:27 ` [PATCH 6/8] btrfs: verify checksum when superblock is read for scan Anand Jain
2018-03-27 11:30 ` Nikolay Borisov
2018-03-27 12:09 ` Nikolay Borisov
2018-03-27 23:01 ` Anand Jain
2018-03-28 6:12 ` Nikolay Borisov
2018-03-26 8:27 ` [PATCH 7/8] btrfs: verify checksum for all devices in mount context Anand Jain
2018-03-27 12:21 ` Nikolay Borisov
2018-03-27 22:48 ` Anand Jain
2018-03-26 8:27 ` [PATCH 8/8] btrfs: drop the redundant invalidate_bdev() 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=1ed03ce2-9ebd-b126-e7c8-e879bbd15e44@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).