From mboxrd@z Thu Jan 1 00:00:00 1970 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 73CDFC433EF for ; Wed, 18 May 2022 12:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236965AbiERMs6 (ORCPT ); Wed, 18 May 2022 08:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237452AbiERMse (ORCPT ); Wed, 18 May 2022 08:48:34 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BEAD175682 for ; Wed, 18 May 2022 05:48:23 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 04A2E68E10; Wed, 18 May 2022 14:48:16 +0200 (CEST) Date: Wed, 18 May 2022 14:48:15 +0200 From: Christoph Hellwig To: Qu Wenruo Cc: Christoph Hellwig , Chris Mason , Josef Bacik , David Sterba , Qu Wenruo , linux-btrfs@vger.kernel.org Subject: Re: [PATCH 12/15] btrfs: add new read repair infrastructure Message-ID: <20220518124815.GA24176@lst.de> References: <20220517145039.3202184-1-hch@lst.de> <20220517145039.3202184-13-hch@lst.de> <20220518085409.GG6933@lst.de> <779bd017-ad7c-10d0-0943-9c0080c55795@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <779bd017-ad7c-10d0-0943-9c0080c55795@gmx.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, May 18, 2022 at 06:20:53PM +0800, Qu Wenruo wrote: > My bad, I see the bio_alloc_bioset() but didn't check it's allocating a > bi_io_vec with size 0, and soon utilize the original bi_io_vec. > > So the function matches its name, it's really bio clone. > > And it's very different from my version, which really allocates a new > bio with larger enough bi_io_vec then adding back the needed sectors > from the original bio. > > Then I guess the BIO_CLONE flag is completely fine. > > But in that case, you may want to call bio_alloc_clone() directly? Which > can handle bioset without problem. The big difference is that bio_alloc_clone directly looks at bio->bi_iter, while we must look at btrfs_bio->iter as bio->bi_iter may already be consumed by the driver. I though the comment in the code explains that, but maybe I need to improve it.