From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Christoph Hellwig <hch@lst.de>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 8/8] btrfs: use btrfs_bio_for_each_sector in btrfs_check_read_dio_bio
Date: Sun, 22 May 2022 20:21:47 +0800 [thread overview]
Message-ID: <d3065bfe-c7ae-5182-84de-17101afbd39e@gmx.com> (raw)
In-Reply-To: <20220522114754.173685-9-hch@lst.de>
On 2022/5/22 19:47, Christoph Hellwig wrote:
> Use the new btrfs_bio_for_each_sector iterator to simplify
> btrfs_check_read_dio_bio.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
In fact, in my version I also want to convert the buffered read endio to
use the helper, and get rid of the error bitmap thing.
But you're so fast sending out the patchset...
Thanks,
Qu
> ---
> fs/btrfs/inode.c | 56 +++++++++++++++++++-----------------------------
> 1 file changed, 22 insertions(+), 34 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 095632977a798..34466b543ed97 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7886,47 +7886,35 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
> {
> struct inode *inode = dip->inode;
> struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
> - const u32 sectorsize = fs_info->sectorsize;
> struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
> struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
> const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
> - struct bio_vec bvec;
> - struct bvec_iter iter;
> - u32 bio_offset = 0;
> blk_status_t err = BLK_STS_OK;
> + struct bvec_iter iter;
> + struct bio_vec bv;
> + u32 offset;
> +
> + btrfs_bio_for_each_sector(fs_info, bv, bbio, iter, offset) {
> + u64 start = bbio->file_offset + offset;
> +
> + if (uptodate &&
> + (!csum || !check_data_csum(inode, bbio, offset, bv.bv_page,
> + bv.bv_offset, start))) {
> + clean_io_failure(fs_info, failure_tree, io_tree, start,
> + bv.bv_page, btrfs_ino(BTRFS_I(inode)),
> + bv.bv_offset);
> + } else {
> + int ret;
>
> - __bio_for_each_segment(bvec, &bbio->bio, iter, bbio->iter) {
> - unsigned int i, nr_sectors, pgoff;
> -
> - nr_sectors = BTRFS_BYTES_TO_BLKS(fs_info, bvec.bv_len);
> - pgoff = bvec.bv_offset;
> - for (i = 0; i < nr_sectors; i++) {
> - u64 start = bbio->file_offset + bio_offset;
> -
> - ASSERT(pgoff < PAGE_SIZE);
> - if (uptodate &&
> - (!csum || !check_data_csum(inode, bbio,
> - bio_offset, bvec.bv_page,
> - pgoff, start))) {
> - clean_io_failure(fs_info, failure_tree, io_tree,
> - start, bvec.bv_page,
> - btrfs_ino(BTRFS_I(inode)),
> - pgoff);
> - } else {
> - int ret;
> -
> - ret = btrfs_repair_one_sector(inode, &bbio->bio,
> - bio_offset, bvec.bv_page, pgoff,
> - start, bbio->mirror_num,
> - submit_dio_repair_bio);
> - if (ret)
> - err = errno_to_blk_status(ret);
> - }
> - ASSERT(bio_offset + sectorsize > bio_offset);
> - bio_offset += sectorsize;
> - pgoff += sectorsize;
> + ret = btrfs_repair_one_sector(inode, &bbio->bio, offset,
> + bv.bv_page, bv.bv_offset, start,
> + bbio->mirror_num,
> + submit_dio_repair_bio);
> + if (ret)
> + err = errno_to_blk_status(ret);
> }
> }
> +
> return err;
> }
>
next prev parent reply other threads:[~2022-05-22 12:22 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-22 11:47 misc btrfs cleanups Christoph Hellwig
2022-05-22 11:47 ` [PATCH 1/8] btrfs: quit early if the fs has no RAID56 support for raid56 related checks Christoph Hellwig
2022-05-22 11:47 ` [PATCH 2/8] btrfs: introduce a pure data checksum checking helper Christoph Hellwig
2022-05-23 0:38 ` Qu Wenruo
2022-05-24 7:24 ` Christoph Hellwig
2022-05-24 8:07 ` Qu Wenruo
2022-05-24 8:11 ` Christoph Hellwig
2022-05-25 16:20 ` David Sterba
2022-05-22 11:47 ` [PATCH 3/8] btrfs: remove duplicated parameters from submit_data_read_repair() Christoph Hellwig
2022-05-22 11:47 ` [PATCH 4/8] btrfs: factor out a helper to end a single sector buffere I/O Christoph Hellwig
2022-05-25 14:54 ` Nikolay Borisov
2022-05-22 11:47 ` [PATCH 5/8] btrfs: refactor end_bio_extent_readpage Christoph Hellwig
2022-05-25 14:57 ` Nikolay Borisov
2022-05-22 11:47 ` [PATCH 6/8] btrfs: factor out a btrfs_csum_ptr helper Christoph Hellwig
2022-05-25 14:32 ` Nikolay Borisov
2022-05-22 11:47 ` [PATCH 7/8] btrfs: add a helper to iterate through a btrfs_bio with sector sized chunks Christoph Hellwig
2022-05-26 12:58 ` Nikolay Borisov
2022-05-22 11:47 ` [PATCH 8/8] btrfs: use btrfs_bio_for_each_sector in btrfs_check_read_dio_bio Christoph Hellwig
2022-05-22 12:21 ` Qu Wenruo [this message]
2022-05-22 12:31 ` Christoph Hellwig
2022-05-22 12:38 ` Qu Wenruo
2022-05-22 12:53 ` Christoph Hellwig
2022-05-23 0:07 ` Qu Wenruo
2022-05-23 6:26 ` Christoph Hellwig
2022-05-23 7:46 ` Qu Wenruo
2022-05-24 7:32 ` Christoph Hellwig
2022-05-24 8:04 ` Qu Wenruo
2022-05-24 8:21 ` Qu Wenruo
2022-05-24 12:08 ` Christoph Hellwig
2022-05-24 13:13 ` Qu Wenruo
2022-05-24 14:02 ` Qu Wenruo
2022-05-25 15:12 ` Nikolay Borisov
2022-05-25 22:46 ` Qu Wenruo
2022-05-26 12:58 ` Nikolay Borisov
2022-05-25 20:20 ` misc btrfs cleanups David Sterba
2022-05-27 15:20 ` 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=d3065bfe-c7ae-5182-84de-17101afbd39e@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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