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 X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9EF8C2D0A3 for ; Tue, 3 Nov 2020 14:56:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F98E206B6 for ; Tue, 3 Nov 2020 14:56:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="jDQUxxXr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728143AbgKCO41 (ORCPT ); Tue, 3 Nov 2020 09:56:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727999AbgKCOzw (ORCPT ); Tue, 3 Nov 2020 09:55:52 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA8E4C0613D1 for ; Tue, 3 Nov 2020 06:55:51 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id k9so14858498qki.6 for ; Tue, 03 Nov 2020 06:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=8VPRX7j7phOFHA/HGSPnfhf8wZ3YY5gqt01OiEVW1GA=; b=jDQUxxXrnXwWUXV3zxriJ0Ymv/r2J+gqeMcPf46pOBSxTATI7cs7BAOjGhSqigKfnh JodhK13sjp2X5xp3J9PjRrOIe1Yuunkg9wytJllRLNErmY8CkVSX40SAKo92SopgFHGb S8fWSQiQH7AvkV+tXZkOVOTvZRAPjxiWPhZero9JP8KbHd/cAOBT7JArd3Ux5iD3ppKn QfJqhE+GUawRk19E87HunQLPcBDNiAeXi9sN4OqXdYMYNqr0Qa91iKIlrwLlv85neiT9 BfpNky0v0+nfWf9m/FmBe/T8UwuwyThtDtZZp81nRsswqYVtw4AwmwFvhgyiiYHZNZVh YlLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8VPRX7j7phOFHA/HGSPnfhf8wZ3YY5gqt01OiEVW1GA=; b=gv3jGunn7Yt5G2nWYxrktYgyHL+HOnqwQInbsjcMA2Z9iIbExOE/tBK5dKyB7NYAD+ vvsPjSsoM+8o1clCszhvmGwJIeiBBcbvsIDC687bH2QZ81uXk1nfZxlN2yr+hWM9lt+L 0AJiI0ocXLqJlhhuLbUsphtUKKk//qrTkrkmMCRjehrL7BPDW7HhNwxCKuEneTBsDmQg UjkWaRToAh9niJM+8V3SFFnreMlKpPOoqRmKKRQvPnG7S4o8L3U7QcnBuzWZSUq/t6EB PBx2ZsTPq2II2xJ6Uks6oasoe70HJUQPuvpfH4+3TzR+XF7Ebs1j8yUWeXjdAdXXQ9tL cVmg== X-Gm-Message-State: AOAM532GHfgKmEB7S78VfMCr4I+fB3qtqVS+yEY8FbVk3niyJXd3ecN6 0Olpen5MDZeyUctxOOf7zOj2UQ== X-Google-Smtp-Source: ABdhPJw1xRJzmSgYNMFYTp9TNZ1bu95oZJjxUhxz/bPThaDRYMZptVwhtkBRzlcFeruwj7HptOsUrg== X-Received: by 2002:a05:620a:697:: with SMTP id f23mr18718130qkh.374.1604415351117; Tue, 03 Nov 2020 06:55:51 -0800 (PST) Received: from [192.168.1.45] (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id o63sm5783972qkd.96.2020.11.03.06.55.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Nov 2020 06:55:50 -0800 (PST) Subject: Re: [PATCH v9 21/41] btrfs: use bio_add_zone_append_page for zoned btrfs To: Naohiro Aota , linux-btrfs@vger.kernel.org, dsterba@suse.com Cc: hare@suse.com, linux-fsdevel@vger.kernel.org References: From: Josef Bacik Message-ID: <0883ec98-4b59-5e74-ba81-d477ca4e185f@toxicpanda.com> Date: Tue, 3 Nov 2020 09:55:49 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 10/30/20 9:51 AM, Naohiro Aota wrote: > Zoned device has its own hardware restrictions e.g. max_zone_append_size > when using REQ_OP_ZONE_APPEND. To follow the restrictions, use > bio_add_zone_append_page() instead of bio_add_page(). We need target device > to use bio_add_zone_append_page(), so this commit reads the chunk > information to memoize the target device to btrfs_io_bio(bio)->device. > > Currently, zoned btrfs only supports SINGLE profile. In the feature, > btrfs_io_bio can hold extent_map and check the restrictions for all the > devices the bio will be mapped. > > Signed-off-by: Naohiro Aota > --- > fs/btrfs/extent_io.c | 37 ++++++++++++++++++++++++++++++++++--- > 1 file changed, 34 insertions(+), 3 deletions(-) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 17285048fb5a..764257eb658f 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -3032,6 +3032,7 @@ bool btrfs_bio_add_page(struct bio *bio, struct page *page, u64 logical, > { > sector_t sector = logical >> SECTOR_SHIFT; > bool contig; > + int ret; > > if (prev_bio_flags != bio_flags) > return false; > @@ -3046,7 +3047,19 @@ bool btrfs_bio_add_page(struct bio *bio, struct page *page, u64 logical, > if (btrfs_bio_fits_in_stripe(page, size, bio, bio_flags)) > return false; > > - return bio_add_page(bio, page, size, pg_offset) == size; > + if (bio_op(bio) == REQ_OP_ZONE_APPEND) { > + struct bio orig_bio; > + > + memset(&orig_bio, 0, sizeof(orig_bio)); > + bio_copy_dev(&orig_bio, bio); > + bio_set_dev(bio, btrfs_io_bio(bio)->device->bdev); > + ret = bio_add_zone_append_page(bio, page, size, pg_offset); > + bio_copy_dev(bio, &orig_bio); Why do we need this in the first place, since we're only supporting single right now? latest_bdev should be the same, so this serves no purpose, right? And if it does, we need to figure out another solution, because right now this leaks references to the bio->bi_blkg, each copy inc's the refcount on the blkg for that bio so we're going to leak blkg's like crazy here. Thanks, Josef