Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9911BC678D4 for ; Thu, 2 Mar 2023 23:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbjCBXch (ORCPT ); Thu, 2 Mar 2023 18:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbjCBXcg (ORCPT ); Thu, 2 Mar 2023 18:32:36 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C426584A4 for ; Thu, 2 Mar 2023 15:32:34 -0800 (PST) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MqJqD-1qKdNB3GR1-00nMZs; Fri, 03 Mar 2023 00:32:27 +0100 Message-ID: Date: Fri, 3 Mar 2023 07:32:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH 10/10] btrfs: make btrfs_split_bio work on struct btrfs_bio Content-Language: en-US To: Christoph Hellwig , Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org References: <20230301134244.1378533-1-hch@lst.de> <20230301134244.1378533-11-hch@lst.de> From: Qu Wenruo In-Reply-To: <20230301134244.1378533-11-hch@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:VPyFFoxafO3HF+IjGA5sQ1bA0xKSr1JXxxvkBHnqjzhRJ0z7zlx 4T5ubgR/kq5z0n0CY3VqVHX9vwpNr/pIrkBw6V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fQRr3u8JajixWqabtPY0uM7+d4gtDPgQmFUPW9ccGmo5zHu+lXg+6m7qB0EP4Q+b8i sC2GX0kNlvzvSGwQtrgeOarREOw= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/3/1 21:42, Christoph Hellwig wrote: > btrfs_split_bio expects a btrfs_bio as argument and always allocates one. > Type both the orig_bio argument and the return value as struct btrfs_bio > to improve type safety. > > Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Thanks, Qu > --- > fs/btrfs/bio.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c > index 527081abca026f..cf09c6271edbee 100644 > --- a/fs/btrfs/bio.c > +++ b/fs/btrfs/bio.c > @@ -61,30 +61,31 @@ struct btrfs_bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf, > return bbio; > } > > -static struct bio *btrfs_split_bio(struct btrfs_fs_info *fs_info, > - struct bio *orig, u64 map_length, > - bool use_append) > +static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_info *fs_info, > + struct btrfs_bio *orig_bbio, > + u64 map_length, bool use_append) > { > - struct btrfs_bio *orig_bbio = btrfs_bio(orig); > + struct btrfs_bio *bbio; > struct bio *bio; > > if (use_append) { > unsigned int nr_segs; > > - bio = bio_split_rw(orig, &fs_info->limits, &nr_segs, > + bio = bio_split_rw(&orig_bbio->bio, &fs_info->limits, &nr_segs, > &btrfs_clone_bioset, map_length); > } else { > - bio = bio_split(orig, map_length >> SECTOR_SHIFT, GFP_NOFS, > - &btrfs_clone_bioset); > + bio = bio_split(&orig_bbio->bio, map_length >> SECTOR_SHIFT, > + GFP_NOFS, &btrfs_clone_bioset); > } > - btrfs_bio_init(btrfs_bio(bio), orig_bbio->inode, NULL, orig_bbio); > + bbio = btrfs_bio(bio); > + btrfs_bio_init(bbio, orig_bbio->inode, NULL, orig_bbio); > > - btrfs_bio(bio)->file_offset = orig_bbio->file_offset; > - if (!(orig->bi_opf & REQ_BTRFS_ONE_ORDERED)) > + bbio->file_offset = orig_bbio->file_offset; > + if (!(orig_bbio->bio.bi_opf & REQ_BTRFS_ONE_ORDERED)) > orig_bbio->file_offset += map_length; > > atomic_inc(&orig_bbio->pending_ios); > - return bio; > + return bbio; > } > > static void btrfs_orig_write_end_io(struct bio *bio); > @@ -633,8 +634,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) > map_length = min(map_length, fs_info->max_zone_append_size); > > if (map_length < length) { > - bio = btrfs_split_bio(fs_info, bio, map_length, use_append); > - bbio = btrfs_bio(bio); > + bbio = btrfs_split_bio(fs_info, bbio, map_length, use_append); > + bio = &bbio->bio; > } > > /*