From patchwork Mon Mar 7 10:47:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12771575 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 9522FC433EF for ; Mon, 7 Mar 2022 11:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234276AbiCGLW1 (ORCPT ); Mon, 7 Mar 2022 06:22:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238997AbiCGLWP (ORCPT ); Mon, 7 Mar 2022 06:22:15 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46CA24F0B for ; Mon, 7 Mar 2022 02:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1646650044; x=1678186044; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ul9GXlz1m+drUDFZI0YV7rX7GRPyTWgtJ0WYupYmPhU=; b=aQaZh+mA4j7K/Hq6k8Dpu44PceR+5f2f86mYhZX8H66aaEnxeRASrkyf 1c5eh+XwGSm89LaK0qk64VNpBRQoQDoybeMjQPGfAnDy6RrrDPa+u4Jaw 461arJj/s02uUOt98Fthg14cwxtyrreC1sb2ndi4AyKvlkuqxgAnJlxf0 w1OzWWvovg/9cqHn4IeDQ6p2GnEqjUGLqiqdauSz9jEi4Igk6ikMzaFLd ykGUrH1V5PatKYCHLxAgA7/tdp7oRYAKswrLzoBWqB9Y25/qfvkaL1jUa 4BlhN4h7dFukKyST6hds7CGjwCPgLOvzefLjvPALux/JEno44zRBKhsWU Q==; X-IronPort-AV: E=Sophos;i="5.90,161,1643644800"; d="scan'208";a="195615431" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Mar 2022 18:47:23 +0800 IronPort-SDR: 1hX98ryyCoBeP1+zl7dwzzHq+S2iY1zPl2et0tliWhosNp7XxbGP/p7U/Znw6+9oF1GnKKMWoG TAIb+d19hWou9yX7IcCBfWR/MQoc7kszzyOeFumqfaEl2pzp4kZId0+8j4yIL4NEwYXzRd1yna /PkAJg9mqyfFyDfF/EczpKnu+aGCtYdH727ak1vtsJyK9sZbm3esnwfA5HOmuWZzM+xTsMFPpV GEyzgQ75hNfxGixw17AdAp4gx/Hw9EHI7csqtad57RdJTskp+KLHrIcEcQB18raOzHxJRS0+yp 4w/mlfeEWQcitXfOagDSbHDu Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 02:19:41 -0800 IronPort-SDR: ir8oMu0Womgku/2PXxmaMwBMvcNsnSpnJwhuNpKYDXeD9kL1AMLKZDdLrIhEO7X2wb0GW3aFmZ gZfBOjfsSq241ANRFnmEaFfSt0VGC9YxdjksbpO/duuCp2wZS0GO83VWlxdfryblshDRg/L44C NbPv4HHy++52qYBzS1nFXYPNyr8OEE1F6Sj2SSd6VNe7CfHeDZIlOulcmF/RQLchka0Oc+0JDa bi1LmfZTm9+ToSxErhqMNB0lA5aQWtJ4oMZ/b8ikdsbTlPQrw1Ma0vclzc2r8WCHFTKXrgTlZ8 sts= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip02.wdc.com with ESMTP; 07 Mar 2022 02:47:23 -0800 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org, Naohiro Aota Subject: [PATCH v2 1/2] btrfs: zoned: use rcu list in btrfs_can_activate_zone Date: Mon, 7 Mar 2022 02:47:17 -0800 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_can_activate_zone() can be called with the device_list_mutex already held, which will lead to a deadlock. As we're only traversing the list for reads we can switch from the device_list_mutex to an rcu traversal of the list. Fixes: a85f05e59bc1 ("btrfs: zoned: avoid chunk allocation if active block group has enough space") Cc: Naohiro Aota Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index b7b5fac1c779..cf6341d45689 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1986,8 +1986,8 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags) ASSERT((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0); /* Check if there is a device with active zones left */ - mutex_lock(&fs_devices->device_list_mutex); - list_for_each_entry(device, &fs_devices->devices, dev_list) { + rcu_read_lock(); + list_for_each_entry_rcu(device, &fs_devices->devices, dev_list) { struct btrfs_zoned_device_info *zinfo = device->zone_info; if (!device->bdev) @@ -1999,7 +1999,7 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags) break; } } - mutex_unlock(&fs_devices->device_list_mutex); + rcu_read_unlock(); return ret; } From patchwork Mon Mar 7 10:47:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 12771576 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 1B9DAC4332F for ; Mon, 7 Mar 2022 11:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238354AbiCGLWa (ORCPT ); Mon, 7 Mar 2022 06:22:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238944AbiCGLWP (ORCPT ); Mon, 7 Mar 2022 06:22:15 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A224610F5 for ; Mon, 7 Mar 2022 02:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1646650046; x=1678186046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vk0GZhtGBRJSzfj162tVREae07WencQ07QTx1GTOx3Y=; b=kjXPOCm1f7poK+ZYf/YUlheI6o8+/Qr+8PMWdGT/oZQ610n94q9GygfN n3xIkLyJeUJW+PUv814t0bRYcvIYC6EBKmsVraWs0pFHED+tnUXSbTF1C CLoRAzCtlSI+x/ohVwlH+bZN3Ngbm4VFF3imgamfnObqCXhITALRehGVy u+nZ4esKcKMGCAM3u44f8pL7r04J9J+w0ohDxkhB0iPECYGzw9P6jyWxR tidfHzypbhzUo3LuJJdTC/Dh+yEPY4iBuDgOpBZ7PWm+2hw1Qso5W5ygt ATbTwmqTlUgUcWyQpQg+G8rS9ODLT3r3ZCR/Bzi26e2sLO4uipbZ9qiqB A==; X-IronPort-AV: E=Sophos;i="5.90,161,1643644800"; d="scan'208";a="195615433" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Mar 2022 18:47:24 +0800 IronPort-SDR: 9cw2G+0CUrwtO7/06YQz1X7gqSKbFdJen+Ltxg8Gm8cSCxaZjKE3OxQjxHpm8OENKgSO61uDgZ Hepx4+SVcV2fsO/k32gAvoucHDFt1PfoFW/j2aOA36UdaO2Pb1HTOULWb70HNMPi+F3mOLPHRV i8WtfLszUU7r5ccY79xANXzb7hdKgE5IdLUnGkiGHXlKD2LZ90spPH0SY6xlwRBN59H3iesQZ+ +uhR0SxkrtBJB8Q3fSO4ZZsZ7L0JPhFAAu2fFsrjN9m1Z+rSMakfr2NsRRfSS+WvxYaLsvfkoz VGp4h6KYbrG2WQ82iDM6j2yw Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 02:19:42 -0800 IronPort-SDR: OmsSNRa5+ijisqkdex1DPuv4wc2Z0ES0Hx9a00cd1k7MK+dUBFi0S1uT997HZbHPl7nRMoz3GR gW65L69yDgYZGW42G1s0RyoYQkmTpTDPHMlRuhW8MC0MX+9ZBSaj9/sxpJ+OfH6oYY4JvCFeMR tSsHT1L1LjMIHZ15W01mVxHNxSp9rfXKJ6WNr2lUCjMhSwo+fSdmhMASHP3lzrCbnDtFnN6cXb lTQDhKfygOU9GYH0DblNmtYMi76M8fuYP2Q8i8qlokixjFG4F4Hkt/O3eLdPfTMZs9HlBO69vB Vhs= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip02.wdc.com with ESMTP; 07 Mar 2022 02:47:23 -0800 From: Johannes Thumshirn To: David Sterba Cc: Johannes Thumshirn , linux-btrfs@vger.kernel.org Subject: [PATCH v2 2/2] btrfs: zoned: remove left over ASSERT() Date: Mon, 7 Mar 2022 02:47:18 -0800 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org With commit dcf5652291f6 ("btrfs: zoned: allow DUP on meta-data block groups") we started allowing DUP on meta-data block-groups, so the ASSERT()s in btrfs_can_activate_zone() and btrfs_zoned_get_device() are no longer valid and in fact even harmful. Fixes: dcf5652291f6 ("btrfs: zoned: allow DUP on meta-data block groups") Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index cf6341d45689..49446bb5a5d1 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1801,7 +1801,6 @@ struct btrfs_device *btrfs_zoned_get_device(struct btrfs_fs_info *fs_info, map = em->map_lookup; /* We only support single profile for now */ - ASSERT(map->num_stripes == 1); device = map->stripes[0].dev; free_extent_map(em); @@ -1982,9 +1981,6 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags) if (!btrfs_is_zoned(fs_devices->fs_info)) return true; - /* Non-single profiles are not supported yet */ - ASSERT((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0); - /* Check if there is a device with active zones left */ rcu_read_lock(); list_for_each_entry_rcu(device, &fs_devices->devices, dev_list) {