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=-15.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 F2048C433E6 for ; Mon, 11 Jan 2021 19:48:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCDDE22BF3 for ; Mon, 11 Jan 2021 19:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403803AbhAKTsK (ORCPT ); Mon, 11 Jan 2021 14:48:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391127AbhAKTsK (ORCPT ); Mon, 11 Jan 2021 14:48:10 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A358AC061786 for ; Mon, 11 Jan 2021 11:47:29 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id n142so644828qkn.2 for ; Mon, 11 Jan 2021 11:47:29 -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=5lBtEYiIuyDpkn580so2o0MKfXnt8d1SY83rV91WVek=; b=gaB8QJuAv3JjaKbID8UYwJa5ALw573Ic8rHebFTnp0HrTbYcxTzhBtp3ckQiWMSck+ gWPP1F4qnguqf19IJAhxDFpgUjuhrvk5wINAfIlPqEwYyLwUCNwyjQYttOqXkHWTHKIB SPBb9QsrxYjSGSnrd/7gfStEP+dHjHrD4gNeb0VTTXscjCjmhF8jzaY1jXKvUM+/pcAm BKa4NqRpgXy5UuJATpdkN3uAD2hkEpYNJt9spU9f2zuxNNL2LXxG5EaLokerFaPBkRZG yVIYymmMN9RISeRAVFRMMcYsbbH1s4HivkLkP3UtVeKqWmrgGLiMeRllmeqUVjl/qniT FTbA== 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=5lBtEYiIuyDpkn580so2o0MKfXnt8d1SY83rV91WVek=; b=fuhJkO28fBnAjsCGH8s80BvnBIuASDL0fUAfDC56DjRbNniSB0ONOrnDayIkGrSFXG KDwI4b0wPYKgEeMF4LBwwo8J3hg47j6Hj/2OuqPI/5zfdJY+eDWISJ3WGqHIUoy14Ubh 3g8obCarm8BR5z+NlykjOk01cmZNy0nLvy7aXP15eog8LPdcKlDfBkG5f4mtNnDcoxsB gAgBgAliTYRgEDW92Nxva/7yLpMIFXhprfPr4yMFvbWe256JqNX8jOJ7qxbFrbtAm1FQ gzKCUiDJAffP9l/aoqaCnBmYyb+ICVkfsdyy4clYnX4OsaTVaIIpx+E1m369FH8xx+wq imNQ== X-Gm-Message-State: AOAM533+l17dmw/XaRsLnlDPADMh3ck+QtCnQqyeFJ26vjZSgenuil0u f39s8xWoOP4s8zBIrwcjtyehTw== X-Google-Smtp-Source: ABdhPJw5pHYCaxPhuLsOv0uhHXJGsVmGF8y+ND8jYZNHwVB+NwjjNhkvlDHKgVUpYq1aO2YMloX8bw== X-Received: by 2002:ae9:d801:: with SMTP id u1mr949350qkf.79.1610394448719; Mon, 11 Jan 2021 11:47:28 -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 d25sm426544qkl.97.2021.01.11.11.47.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Jan 2021 11:47:27 -0800 (PST) Subject: Re: [PATCH v11 04/40] btrfs: change superblock location on conventional zone To: Naohiro Aota , linux-btrfs@vger.kernel.org, dsterba@suse.com Cc: hare@suse.com, linux-fsdevel@vger.kernel.org, Jens Axboe , Christoph Hellwig , "Darrick J. Wong" References: <06add214bc16ef08214de1594ecdfcc4cdcdbd78.1608608848.git.naohiro.aota@wdc.com> <42c1712556e6865837151ad58252fb5f6ecff8f7.1608608848.git.naohiro.aota@wdc.com> From: Josef Bacik Message-ID: <83c5e084-dbee-a0ae-4a1b-38fa271701a2@toxicpanda.com> Date: Mon, 11 Jan 2021 14:47:26 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <42c1712556e6865837151ad58252fb5f6ecff8f7.1608608848.git.naohiro.aota@wdc.com> 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 12/21/20 10:48 PM, Naohiro Aota wrote: > We cannot use log-structured superblock writing in conventional zones since > there is no write pointer to determine the last written superblock > position. So, we write a superblock at a static location in a conventional > zone. > > The written position is at the beginning of a zone, which is different from > an SB position of regular btrfs. This difference causes a "chicken-and-egg > problem" when supporting zoned emulation on a regular device. To know if > btrfs is (emulated) zoned btrfs, we need to load an SB and check the > feature flag. However, to load an SB, we need to know that it is zoned > btrfs to load it from a different position. > > This patch moves the SB location on conventional zones so that the first SB > location will be the same as regular btrfs. > > Signed-off-by: Naohiro Aota > --- > fs/btrfs/zoned.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c > index 90b8d1d5369f..e5619c8bcebb 100644 > --- a/fs/btrfs/zoned.c > +++ b/fs/btrfs/zoned.c > @@ -465,7 +465,8 @@ static int sb_log_location(struct block_device *bdev, struct blk_zone *zones, > int ret; > > if (zones[0].type == BLK_ZONE_TYPE_CONVENTIONAL) { > - *bytenr_ret = zones[0].start << SECTOR_SHIFT; > + *bytenr_ret = (zones[0].start << SECTOR_SHIFT) + > + btrfs_sb_offset(0); > return 0; > } > I'm confused, we call btrfs_sb_log_location_bdev(), which does if (!bdev_is_zoned(bdev)) { *bytenr_ret = btrfs_sb_offset(mirror); return 0; } so how does the emulation work, if we short circuit this if the block device isn't zoned? And then why does it matter where in the conventional zone that we put the super block? Can't we just emulate a conventional zone that starts at offset 0, and then the btrfs_sb_offset() will be the same as zones[0].start + btrfs_sb_offset(0)? Thanks, Josef