From patchwork Wed Jan 26 08:59:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12724748 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 EA0E3C28CF5 for ; Wed, 26 Jan 2022 08:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238649AbiAZI7p (ORCPT ); Wed, 26 Jan 2022 03:59:45 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:42046 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238645AbiAZI7o (ORCPT ); Wed, 26 Jan 2022 03:59:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1643187585; x=1674723585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2PJr/wWWWuGCLH6OKkXYdEB9XN18Htc0qqBmHDe/CRI=; b=OFACKbXh3dEbzzOFRDhBAdo/f3KbeScIRbVXwovutwgi+lyZzlDOjMPB Ym2AtVLRfnGxzYT8TGkI4rIbzCKwAP97Xq7fHATFs6I6vAGI+MG19+OLK bMegBOW5SVSmLZBlgrQ/9C9ZSGlBD304uMfkHdr/083ONmK5cHUqM1msU NJRX9zPnkF4JXVmBjS80Nq86SdvXOwYNbY28JrKyMc7I2hAa4zLk5O8a9 EtXP0vzd7wPDOuEBrtNtRCWaVptMmpPygT3fWKwcU1bQSWRNy9xMGAnLk QIXydXV8iQNqZV067pJeD7SsYT2UPQBUNtd+nQPEQbwLKqxd6rJW4C5o7 Q==; X-IronPort-AV: E=Sophos;i="5.88,317,1635177600"; d="scan'208";a="192406582" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Jan 2022 16:59:45 +0800 IronPort-SDR: 4rw3YXBix3uLEt5o/Uqvy1MjrpsidS1jtqpi2m5F5fQJfpAj+tZkjDwhBRwsoov9iWWgWuU0RQ NJ7mwtsREii0gkJ/YsnkwCifemVjz0F0IEi2ReBcrnjhlomqJkLtc0I1+o+nTke5KRnJCRVOei AFfNqmriEjMFZHOxWfOuenV4nFko5/bpdgFAMuFxPiMgF0C2kIeiK6XTNlqzZd0K1mxAGMB8Wy uH6Gqm86wqcP9gz3hYd7cCXPcuT1rGtDkSxx3ThDueN26TmHhNQoJLDhnfPe6qyiBdk/zwv+Ty f4ffFzu3xJwrNlByq4spsE6O Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 00:31:49 -0800 IronPort-SDR: gXBl5AIMUN5pk+r4sdfBLSvccvJbJr1BO5MaRZPKOJ9EmrEQPwpxe7yINdyv6iOewLeYGsjBQu GsqYiujEl+iJilaE6VYxzI2EfCkJq6uTT5DmLQ4cdE51vf0whuIlqhHWlYW0xouE1Pp+9gzNn8 Ppiw/vgAaWYsrZ/omTz4SXRw6yRJzqWfEpD3NuJaK6Ea2AmzNJ7mth4fcKX4P2Dq5drTe3mwd6 Zd2vaGwDHbf1LCVF6ccKyiXD9wtRqnvyLxbSiwuxY1DwpHCUqOqePnb15aWO6oAcrxuindSLFN gmw= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Jan 2022 00:59:44 -0800 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org Subject: [PATCH 1/4] btrfs: zoned: make zone activation multi stripe capable Date: Wed, 26 Jan 2022 00:59:30 -0800 Message-Id: <64affb64a778431d1eb5158958b5c7db0c99fabf.1643185812.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Currently activation of a zone only works if the block group isn't spanning more than one zone. This limitation is purely artificial and can be easily expanded to block groups being places across multiple zones. This is a preparation for allowing DUP and later more complex block-group profiles on zoned btrfs. Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 57 ++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index f559d517c7c4..e3d198405d39 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1781,50 +1781,55 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group) struct btrfs_device *device; u64 physical; bool ret; + int i; if (!btrfs_is_zoned(block_group->fs_info)) return true; map = block_group->physical_map; - /* Currently support SINGLE profile only */ - ASSERT(map->num_stripes == 1); - device = map->stripes[0].dev; - physical = map->stripes[0].physical; - - if (device->zone_info->max_active_zones == 0) - return true; spin_lock(&block_group->lock); - if (block_group->zone_is_active) { ret = true; goto out_unlock; } - /* No space left */ - if (block_group->alloc_offset == block_group->zone_capacity) { - ret = false; - goto out_unlock; - } + for (i = 0; i < map->num_stripes; i++) { + device = map->stripes[i].dev; + physical = map->stripes[i].physical; - if (!btrfs_dev_set_active_zone(device, physical)) { - /* Cannot activate the zone */ - ret = false; - goto out_unlock; - } + if (device->zone_info->max_active_zones == 0) + continue; + + /* No space left */ + if (block_group->alloc_offset == block_group->zone_capacity) { + ret = false; + goto out_unlock; + } + + if (!btrfs_dev_set_active_zone(device, physical)) { + /* Cannot activate the zone */ + ret = false; + goto out_unlock; + } + + /* Successfully activated all the zones */ + if (i == map->num_stripes - 1) + block_group->zone_is_active = 1; - /* Successfully activated all the zones */ - block_group->zone_is_active = 1; + } spin_unlock(&block_group->lock); - /* For the active block group list */ - btrfs_get_block_group(block_group); + if (block_group->zone_is_active) { + /* For the active block group list */ + btrfs_get_block_group(block_group); - spin_lock(&fs_info->zone_active_bgs_lock); - ASSERT(list_empty(&block_group->active_bg_list)); - list_add_tail(&block_group->active_bg_list, &fs_info->zone_active_bgs); - spin_unlock(&fs_info->zone_active_bgs_lock); + spin_lock(&fs_info->zone_active_bgs_lock); + list_add_tail(&block_group->active_bg_list, + &fs_info->zone_active_bgs); + spin_unlock(&fs_info->zone_active_bgs_lock); + } return true; From patchwork Wed Jan 26 08:59:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12724751 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 6CA06C63682 for ; Wed, 26 Jan 2022 08:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238651AbiAZI7p (ORCPT ); Wed, 26 Jan 2022 03:59:45 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:42046 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbiAZI7p (ORCPT ); Wed, 26 Jan 2022 03:59:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1643187585; x=1674723585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3sC7Vc10YDRV+Tyq4v+r5wxd/11qhsQd0P2aO8FBxEM=; b=LT5/uGksPp1KS3NPzNlaJrM1C2O77ArHmRQ2TFsaxVYUF2ZOerablAip 9Lp6enUOwZ0t8vpFeiAi44YgZiCAUExMU+VPGSEJDlmrx7+lbmEAiW2bS CWzqYRdXNZsijoLVJwi20w5mF6wRXvGwdesD1b2ZE+ruJJtyeLgbcBkV9 y2QlnXAlCjlu2avGKUpqcbrKw45qm3rj+GBNB76kxRjjXH6bmE3bbYt07 C2wXzgw8gff7tGwOngeOKTH69jJlIihPhGJhfqql9aK/LoIo3DkV16ZV/ lKPHK4u7oKnVEbK3UOcjb4IGZ5zIB8kHZk6CiZ0As3/bzzVcDeG9QB8BG w==; X-IronPort-AV: E=Sophos;i="5.88,317,1635177600"; d="scan'208";a="192406583" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Jan 2022 16:59:45 +0800 IronPort-SDR: Ee74hUER8b33mmwrwl/guUfgR3wc8p/vkLHnqHzmZ2n7uJ4KBlvvdfetyxxihOy9DbzKWU81bC ooafH95yV0cDw6O5b+IQlcearffBQG5DLCXKuSEnf1vOLB+DANRK0/oF9eXDeC4IL/G234xpL0 nAxNOnwGfGOeXJfTdLlb0LwH/5GbijVx9upn8FUPXhbbxOfleyH5SjYPF8s2pViEOrRb08SnGb zVCa9UqwMdll6PePHR015XSWM949IDCHEf0Z+QpVlo7GBl19TpoFl7yameUGPqKLVOK2xLgC34 pQDYw5my8QWKognDssJpG23L Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 00:31:49 -0800 IronPort-SDR: ZoC6Il5f4h4a1RRvDYp6/6KMTQDeRN2jEq9UdJh7TWVUOrBrO0/sijThwLzjwT3/k7OgLmVtRW RlEP6f/9JedgXzbUCtY4g+0CZQ9120BPWjTI/r4b1jxm7z93S7GW3aCMvwoLEOjRqpc7l5iN/D 85b4kzZoW5QsTRneqYXq5bzTQN+JwR5jj86eaW4tZKxPA8U9SU1w1zhJv+GbsfwvmGxuz2hAh4 l3udhOy9b2FfgQnRiXpkFWpekZqm1kjKbQ2PvkIdlwAMhGhYlDj2bYR507hoDEZeycZN7Gkzfm lS0= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Jan 2022 00:59:45 -0800 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org Subject: [PATCH 2/4] btrfs: zoned: make zone finishing multi stripe capable Date: Wed, 26 Jan 2022 00:59:31 -0800 Message-Id: <37ef057e777624647a1ab5988115707e77c53aae.1643185812.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Currently finishing of a zone only works if the block group isn't spanning more than one zone. This limitation is purely artificial and can be easily expanded to block groups being places across multiple zones. This is a preparation for allowing DUP and later more complex block-group profiles on zoned btrfs. Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index e3d198405d39..987d2456d398 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1845,19 +1845,12 @@ int btrfs_zone_finish(struct btrfs_block_group *block_group) struct btrfs_device *device; u64 physical; int ret = 0; + int i; if (!btrfs_is_zoned(fs_info)) return 0; map = block_group->physical_map; - /* Currently support SINGLE profile only */ - ASSERT(map->num_stripes == 1); - - device = map->stripes[0].dev; - physical = map->stripes[0].physical; - - if (device->zone_info->max_active_zones == 0) - return 0; spin_lock(&block_group->lock); if (!block_group->zone_is_active) { @@ -1909,25 +1902,34 @@ int btrfs_zone_finish(struct btrfs_block_group *block_group) btrfs_clear_data_reloc_bg(block_group); spin_unlock(&block_group->lock); - ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH, - physical >> SECTOR_SHIFT, - device->zone_info->zone_size >> SECTOR_SHIFT, - GFP_NOFS); - btrfs_dec_block_group_ro(block_group); + for (i = 0; i < map->num_stripes; i++) { + device = map->stripes[i].dev; + physical = map->stripes[i].physical; - if (!ret) { - btrfs_dev_clear_active_zone(device, physical); + if (device->zone_info->max_active_zones == 0) + continue; - spin_lock(&fs_info->zone_active_bgs_lock); - ASSERT(!list_empty(&block_group->active_bg_list)); - list_del_init(&block_group->active_bg_list); - spin_unlock(&fs_info->zone_active_bgs_lock); + ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH, + physical >> SECTOR_SHIFT, + device->zone_info->zone_size >> SECTOR_SHIFT, + GFP_NOFS); + + if (ret) + return ret; - /* For active_bg_list */ - btrfs_put_block_group(block_group); + btrfs_dev_clear_active_zone(device, physical); } + btrfs_dec_block_group_ro(block_group); - return ret; + spin_lock(&fs_info->zone_active_bgs_lock); + ASSERT(!list_empty(&block_group->active_bg_list)); + list_del_init(&block_group->active_bg_list); + spin_unlock(&fs_info->zone_active_bgs_lock); + + /* For active_bg_list */ + btrfs_put_block_group(block_group); + + return 0; } bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags) From patchwork Wed Jan 26 08:59:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12724749 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 E8B8AC63686 for ; Wed, 26 Jan 2022 08:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238655AbiAZI7q (ORCPT ); Wed, 26 Jan 2022 03:59:46 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:42046 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238653AbiAZI7p (ORCPT ); Wed, 26 Jan 2022 03:59:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1643187586; x=1674723586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RuRvHdePduPq0jBMBOuMJJORQvw0ilIInwK8TI6ctRs=; b=g/GbNPR3hcmfz6XWdZ6nqyOu/RqkTfp3RAR/MyV7qJcFYp34i7rcLEqE cb+pSn1KOtM4rhA1SYjgY3tjsJFRI0JnbXQDtMZeQL/IxR0FVbZsQeQ7g P0gUJ7iXWn0xfqb5oKZpVL+s4CXdk17ny4ftyyL7n4OwV9/6/jv+vQ/pJ sVt7AFcV4XHc4pyGlIVD9ypoOhzCWZh8aWO6jyOH9ilQUj3BoFgj7gM5K vvey5cU21NG3P6WYcc0wO/mPGIas/yvZghyvpcJX3pFf+5OBEPERr+aUV CHmYnbtT0YCFiYoYJb1d+oOolNF4eF6f2rnjDZau7KOT+w+sTRwcnSTK0 w==; X-IronPort-AV: E=Sophos;i="5.88,317,1635177600"; d="scan'208";a="192406585" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Jan 2022 16:59:46 +0800 IronPort-SDR: kAqpClybUgx1i9WSh72XdZ6fLGkyuay2x4uLLo7Y/w0td3gplyN83gfqr43S4ppGfWEtGK54J/ SFgx2rXNiT4nv0kc3Fg5eHDw2/pMV/dXiAzEP98PgeOd6M72CACy/2zKX9OtqK4OLJbxOdGeyI ql0Ak3W4QCgSvLCbByXl8Ab7y1IvEDRDQuWffeuSFwq/m8HgrgzCt4JQrUC6MQ+icsoQ+OpUHw 1MFLhkIDXDQnARu8kCTDIIkRXrkscPqAygTz4FwUV2YGdP2xbLY3f0OC1+hPuWXM4Lq3FegHyB vHNX/t0JSOLR2jLO6K1SQtuS Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 00:31:50 -0800 IronPort-SDR: kb/kFhL7szpqHjDFDQQo+Dz/LloYO9vtGEGUZZnHJ0xYUUmwJezUjR8QgqoWgn9HoBu/6tPnDM JKb32tVE/43AE2cevVS4owlzCKaj3Kb/zdlAG2Q002396XyZ0c3/yrL4R7mN7BxqlgmEToJUDP KN9OQy84pIumgt/pp8xyqvbScoXOSMmXptI3aMEnREnjQe+2+WjY1p0BViILVsmMDwEHkMbtMz hWTTjClM9Ql6MdLjqMP+sr6e09fBrsxo3cII59jaZz8p/9RrRjYOm2+rDm803E0q6Q2rwpA/WZ jk0= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Jan 2022 00:59:46 -0800 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org Subject: [PATCH 3/4] btrfs: zoned: prepare for allowing DUP on zoned Date: Wed, 26 Jan 2022 00:59:32 -0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Allow for a block-group to be placed on more than one physical zone. This is a preparation for allowing DUP profiles for meta-data on a zoned file-system. Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 987d2456d398..4f6f7afaa5a2 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1215,12 +1215,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) struct btrfs_device *device; u64 logical = cache->start; u64 length = cache->length; - u64 physical = 0; int ret; int i; unsigned int nofs_flag; u64 *alloc_offsets = NULL; u64 *caps = NULL; + u64 *physical = NULL; unsigned long *active = NULL; u64 last_alloc = 0; u32 num_sequential = 0, num_conventional = 0; @@ -1264,6 +1264,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) goto out; } + physical = kcalloc(map->num_stripes, sizeof(*physical), GFP_NOFS); + if (!physical) { + ret = -ENOMEM; + goto out; + } + active = bitmap_zalloc(map->num_stripes, GFP_NOFS); if (!active) { ret = -ENOMEM; @@ -1277,14 +1283,14 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) int dev_replace_is_ongoing = 0; device = map->stripes[i].dev; - physical = map->stripes[i].physical; + physical[i] = map->stripes[i].physical; if (device->bdev == NULL) { alloc_offsets[i] = WP_MISSING_DEV; continue; } - is_sequential = btrfs_dev_is_sequential(device, physical); + is_sequential = btrfs_dev_is_sequential(device, physical[i]); if (is_sequential) num_sequential++; else @@ -1299,21 +1305,21 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) * This zone will be used for allocation, so mark this zone * non-empty. */ - btrfs_dev_clear_zone_empty(device, physical); + btrfs_dev_clear_zone_empty(device, physical[i]); down_read(&dev_replace->rwsem); dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(dev_replace); if (dev_replace_is_ongoing && dev_replace->tgtdev != NULL) - btrfs_dev_clear_zone_empty(dev_replace->tgtdev, physical); + btrfs_dev_clear_zone_empty(dev_replace->tgtdev, physical[i]); up_read(&dev_replace->rwsem); /* * The group is mapped to a sequential zone. Get the zone write * pointer to determine the allocation offset within the zone. */ - WARN_ON(!IS_ALIGNED(physical, fs_info->zone_size)); + WARN_ON(!IS_ALIGNED(physical[i], fs_info->zone_size)); nofs_flag = memalloc_nofs_save(); - ret = btrfs_get_dev_zone(device, physical, &zone); + ret = btrfs_get_dev_zone(device, physical[i], &zone); memalloc_nofs_restore(nofs_flag); if (ret == -EIO || ret == -EOPNOTSUPP) { ret = 0; @@ -1339,7 +1345,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) case BLK_ZONE_COND_READONLY: btrfs_err(fs_info, "zoned: offline/readonly zone %llu on device %s (devid %llu)", - physical >> device->zone_info->zone_size_shift, + physical[i] >> device->zone_info->zone_size_shift, rcu_str_deref(device->name), device->devid); alloc_offsets[i] = WP_MISSING_DEV; break; @@ -1404,7 +1410,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) if (alloc_offsets[0] == WP_MISSING_DEV) { btrfs_err(fs_info, "zoned: cannot recover write pointer for zone %llu", - physical); + physical[0]); ret = -EIO; goto out; } @@ -1465,6 +1471,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) cache->physical_map = NULL; } bitmap_free(active); + kfree(physical); kfree(caps); kfree(alloc_offsets); free_extent_map(em); From patchwork Wed Jan 26 08:59:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12724750 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 AB1ACC63697 for ; Wed, 26 Jan 2022 08:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238656AbiAZI7r (ORCPT ); Wed, 26 Jan 2022 03:59:47 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:42046 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238653AbiAZI7q (ORCPT ); Wed, 26 Jan 2022 03:59:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1643187587; x=1674723587; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q1cUaiDcfbSiGq3krcKECh3PAsXKRPRXty879J9R5JQ=; b=SEBwxEjqBWPh0PurUoIrFfWI/o+z9k13iNK7Ln9YTE5lg9rkwqqNeSSD CM2i+StTN0m2aRZLJH0gOavMGbFUR9Uv9QcCNaDj4tTcVPxm5JPoKhgu2 S/bkRvWnRJxQai7bxxMxkNdVd0vUZVCu5rQxqKMXdeL6t61T8JEG0Fhtb QAQPNjbOyF8wIlDuG6Pt1f657ezhfXzt4lezKTD88EQAkU6jgLzkyl9Is E6kqoBdKmuhvGYZQtj5Aaz9D0cCScrjXcvGcz6rl1KUz5nxjzoEUyZZU1 ZDpjLclxo8DYTvc/nhwT+ZpvfivfazrcWEIOc6i0lDAmYd0vM3/NxD1xm Q==; X-IronPort-AV: E=Sophos;i="5.88,317,1635177600"; d="scan'208";a="192406588" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Jan 2022 16:59:47 +0800 IronPort-SDR: pWUvseSmXN+/JmBpc6yQ7PN8mMHBG0eEbrg6HRuy9TtZqQtkJKtY3ns3Rv6inBBMhFGOwog4Ru QJnbzO9tDST1HGSKuSKVGeyENF5OVA1CvsOruQeqA6pncOro4MijOU7HtzcrpuDRjIkj5MrDx/ o6bckMS9HBCanc6j6n19zrd22gLWb7lOdNfhVProNJEvv/AEcjVVR+nErGtGqcA6Jbd/499xwy nMJDmjzULgh2R7inoUnYitsHjdMalaBPZgVaX+YJaW3wUt6TqFLh/N9RZjaAhORGhj55OAaT96 TRT1FigqkEf3lmgvbC06Y9Od Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 00:31:51 -0800 IronPort-SDR: luVsi5dmcqMkKxIPmk7t3pdHvrYwp+Qg43k+vPTErpu9Q0ek83xfTrqWMYJ0v2qc5v5yHfyDbx 6jRkTPv8LdNldKq2HfdyTiifGfaPoMNYUY5LCgy3GaJpk+45nsFLmfikO0WD1ta8Mj2hcKPNL5 k2nPwS8fqlyS4SBy4keeoGHjGSH2x0J6rZ80qZO8nevMfeodZ/zFs7LRma7YgTaAPTjGmVSDrn MBDaOjwxyj7/BQae69dZmiGAwAQvLs2ffBrrUc4bsLgudgSMqosR3ipTUhs7DcNYLkisuTr7zW 0Vg= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Jan 2022 00:59:46 -0800 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org Subject: [PATCH 4/4] btrfs: zoned: allow DUP on meta-data block groups Date: Wed, 26 Jan 2022 00:59:33 -0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Allow creating or reading block-groups on a zoned device with DUP as a meta-data profile. This works because we're using the zoned_meta_io_lock and REQ_OP_WRITE operations for meta-data on zoned btrfs, so all writes to meta-data zones are aligned to the zone's write-pointer. Upon loading of the block-group, it is ensured both zones do have the same zone capacity and write-pointer offsets, so no extra machinery is needed to keep the write-pointers in sync for the meta-data zones. If this prerequisite is not met, loading of the block-group is refused. Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 4f6f7afaa5a2..39fc5487e78c 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1419,6 +1419,40 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new) cache->zone_is_active = test_bit(0, active); break; case BTRFS_BLOCK_GROUP_DUP: + if (map->type & BTRFS_BLOCK_GROUP_DATA) { + btrfs_err(fs_info, "zoned: profile DUP not yet supported on data bg"); + ret = -EINVAL; + goto out; + } + if (alloc_offsets[0] == WP_MISSING_DEV) { + btrfs_err(fs_info, + "zoned: cannot recover write pointer for zone %llu", + physical[0]); + ret = -EIO; + goto out; + } + if (alloc_offsets[1] == WP_MISSING_DEV) { + btrfs_err(fs_info, + "zoned: cannot recover write pointer for zone %llu", + physical[1]); + ret = -EIO; + goto out; + } + if (alloc_offsets[0] != alloc_offsets[1]) { + btrfs_err(fs_info, + "zoned: write pointer offset mismatch of zones in DUP profile"); + ret = -EIO; + goto out; + } + if (test_bit(0, active) != test_bit(1, active)) { + btrfs_err(fs_info, "zoned: active zone mismatch"); + ret = -EIO; + goto out; + } + cache->alloc_offset = alloc_offsets[0]; + cache->zone_capacity = min(caps[0], caps[1]); + cache->zone_is_active = test_bit(0, active); + break; case BTRFS_BLOCK_GROUP_RAID1: case BTRFS_BLOCK_GROUP_RAID0: case BTRFS_BLOCK_GROUP_RAID10: