From patchwork Thu Aug 9 18:04:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 10561643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F14B13B4 for ; Thu, 9 Aug 2018 18:07:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A56C2B6CF for ; Thu, 9 Aug 2018 18:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C8862B7A6; Thu, 9 Aug 2018 18:07:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1BEF2B6CF for ; Thu, 9 Aug 2018 18:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727240AbeHIUb6 (ORCPT ); Thu, 9 Aug 2018 16:31:58 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44915 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbeHIUb5 (ORCPT ); Thu, 9 Aug 2018 16:31:57 -0400 Received: by mail-pf1-f195.google.com with SMTP id k21-v6so3198410pff.11; Thu, 09 Aug 2018 11:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vragor325c5+mkfaiNN9c9VU2fiaVIcgfu01gZ3wtGE=; b=tlikYUqnqLXIS0Lu1xCQBWPm6kMPZpvmTEwdsavB5f4HIPzW8ojZw3kHq0+w7RkWJA hO2fAfdnBrdBgqfYOfjhqq4k4LL4Xou+JK5rUGklaC6hsoGIyg5pqg4698tgZrm/zgB0 FMjZ0pRsfpNxd0QAhyf6IkUUtRLouYU1w9NYqBIy9uQyNzqGXdmzz0evhTNOeBnbbY5Q tLBYrBwM+uDnP8B/Ba4M7NmOztR5Qc1ShcybQPy+Gm2B8O+STacQkAplpBDppeuJhnEd TVHrOXjzWbwXDxDqtRO6DijH2Ri9bEocpusuhzK7iga3Zo7Mb5DZgOGr5Zduei85Wkvg wStA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Vragor325c5+mkfaiNN9c9VU2fiaVIcgfu01gZ3wtGE=; b=JXzqdK3qywX+IF6Rpc5BH7IaXArtW1BYPiLZURkxxbcgGiaT3CI8xfgkcMDttstdpq 3Z1LBURY7yzmhP12rpGMICivS0hrCPkO/L5Ug9qqDYmkwIFVhxJVXOduBrIU9Z9l7I78 jXg0jgntyA+dgJnwWgMtWm6r2emZ31ONSoGfxc1QVpctD6UfwCYMPBxkEOHF8mPTNSZY aGaJrNQL48SbZ0PWgyb6W+f0sbG9SDWjbWYdpfgN80hOr54d4DAUF5YdV+AznxM8ehbt i7CLh6B/DQsBtpkMF3VwFjmo1AeIsd5MD2T8vI40gtfzLFTEbdrcUfgFbO/ghDpsZ/pK Izuw== X-Gm-Message-State: AOUpUlFxkPOb9Y1K0j7+04LbZcIPmtaq7KB5RzvUg5nJIGHj56Gq3Gzs 04n3sJzFX1GyF229jEWw740= X-Google-Smtp-Source: AA+uWPzYZKRdXMUMuxDSXKi7uGDHmxq/C1675FqLvAgjwpq1e/Jj3mnK2RIgNPKd07Io1rA/Vshbnw== X-Received: by 2002:a62:5b85:: with SMTP id p127-v6mr3478638pfb.33.1533837957898; Thu, 09 Aug 2018 11:05:57 -0700 (PDT) Received: from localhost (h101-111-148-072.catv02.itscom.jp. [101.111.148.72]) by smtp.gmail.com with ESMTPSA id 143-v6sm12128663pfy.156.2018.08.09.11.05.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 11:05:57 -0700 (PDT) From: Naohiro Aota To: David Sterba , linux-btrfs@vger.kernel.org Cc: Chris Mason , Josef Bacik , linux-kernel@vger.kernel.org, Hannes Reinecke , Damien Le Moal , Bart Van Assche , Matias Bjorling , Naohiro Aota Subject: [RFC PATCH 04/17] btrfs: limit super block locations in HMZONED mode Date: Fri, 10 Aug 2018 03:04:37 +0900 Message-Id: <20180809180450.5091-5-naota@elisp.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809180450.5091-1-naota@elisp.net> References: <20180809180450.5091-1-naota@elisp.net> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When in HMZONED mode, make sure that device super blocks are located in randomly writable zones of zoned block devices. That is, do not write super blocks in sequential write required zones of host-managed zoned block devices as update would not be possible. Signed-off-by: Damien Le Moal Signed-off-by: Naohiro Aota --- fs/btrfs/disk-io.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 14f284382ba7..6a014632ca1e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3435,6 +3435,13 @@ struct buffer_head *btrfs_read_dev_super(struct block_device *bdev) return latest; } +static int check_super_location(struct btrfs_device *device, u64 pos) +{ + /* any address is good on a regular (zone_size == 0) device */ + /* non-SEQUENTIAL WRITE REQUIRED zones are capable on a zoned device */ + return device->zone_size == 0 || !btrfs_dev_is_sequential(device, pos); +} + /* * Write superblock @sb to the @device. Do not wait for completion, all the * buffer heads we write are pinned. @@ -3464,6 +3471,8 @@ static int write_dev_supers(struct btrfs_device *device, if (bytenr + BTRFS_SUPER_INFO_SIZE >= device->commit_total_bytes) break; + if (!check_super_location(device, bytenr)) + continue; btrfs_set_super_bytenr(sb, bytenr);