From patchwork Mon Mar 17 11:24:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 14019087 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0AC323536A for ; Mon, 17 Mar 2025 11:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742210714; cv=none; b=uXDh9rceoIWSjbwe55cIq7Y6qp6KWwNqXUBj1ruYPkES7EK+uFn9j8KSGDe67rKJckd67vegG2DS5fPRi37y5Og9DVasv1C6Rw/VW9BTLt9YqYdMaQzXn62nnW4nPePp5hjFxfuCd+i1gMIGqbWSmr9kjyl6MtOsYDElUQkxaUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742210714; c=relaxed/simple; bh=WFTQObJeBgqTifLsJnZAZr146fA5suikahPaynSlOAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=svxTVTiEMCiB/n3HJIWOkLQFxY+VZLc5hPeJCKvcnVgY/hA6vWOzIYQqn80fi0+1va9jbpx+2WFsf73SFYFrhvxUUBwHQaVm6HDWdjON0wQXDIWvf78cZGq0Xt2Qmac49dS3V8ZBOZ+dvp5sRn+00yWhyseJ2QVWOo6LTNo837c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43d0618746bso14574265e9.2 for ; Mon, 17 Mar 2025 04:25:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742210711; x=1742815511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/iZg1OnuY3zc1SWvxo4hgdT/28NnoisoH5cdKdOxKck=; b=cX1l+IzD+dHPvP39bNxXgYuQC+muEKCwTllbXgRJsGWCiJLCQq6EZ5+tepZbpzrzKw Qvlx3sLot3Ogm1tiOkaSlQN3FGug1Hlmp6AGEMEta4Z4cWWfT6G460R/R+FDsK7wT8tg HwdwAR6Js3noDwakcEFZHcSSYf8qgDXGk2U/eEbVAJfuetI3k7bfAiZaKn+pVre2LDJt WGJMnTietsu02J3aIZTQ0B09vNoUF7UUrHOe07ND0jWqb3CxLv0CWFRcMG3WZNkXmLCn AFw2IDvcy+0izdIzYd2HWIcFkigUu45V97HWjzFlaVyi9WHsAPrN+ey40yFeND8KkqIg vAUQ== X-Gm-Message-State: AOJu0YxZTdS55Jm4hFcWC5ezXUbtiIDMGuoOvaoAGdIpDuN5ScFxeQdA vNYXLav30iSVU9ON0+qCq9sBqhf7LyeGIks5Bn4c4/WjjDl74Yh7mBkJ1w== X-Gm-Gg: ASbGncuXnWMyzJfJHR4mnFDn4dGUyPWPHlW/mr1Q7Mua/aNeUPGzPnxMI+qsFduCQNw 2ZfOS8oT9PWKQ83qU0nWXofouBtvey8boEBMJMqgCB/EpiZb+QgtcAetjDDoBLlkcMnVNfZaPpc csvZtdRCE0TqpfKIK+1Xk5GWSRo1lIr/fbCoBpq12EgZ4gY6swF56HdqDGu0Bxz5JK3+bhQbnip Ggk+WBO5qSyNwfujTjX+MAJgQc93TzJs+SxRFUHG1h8euLaLyLn/PXw5+oCwblm/hWtoRYvjC2I Dl9Mtyjr0To/RcFP7wvVQwDjLMqQiJd6gmClPUS1y0eCUFi6KafnD4MvwDxnLnt+JcUlUoo/s/N OOBRAiwddbmcHSwEtn2Ky1jiVAIU= X-Google-Smtp-Source: AGHT+IF6SApgx/ewA0fbNm4YIaoMVYR4is5G+EahS7hhkC3pLdrkvCUpKUhlaOuEttqyn3XLzioA9w== X-Received: by 2002:a5d:64e7:0:b0:391:29c0:83f5 with SMTP id ffacd0b85a97d-39720d47357mr12583608f8f.44.1742210710676; Mon, 17 Mar 2025 04:25:10 -0700 (PDT) Received: from nuc.fritz.box (p200300f6f71d1000fa633ffffe02074c.dip0.t-ipconnect.de. [2003:f6:f71d:1000:fa63:3fff:fe02:74c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d200fad59sm103188675e9.26.2025.03.17.04.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 04:25:10 -0700 (PDT) From: Johannes Thumshirn To: linux-btrfs@vger.kernel.org Cc: Naohiro Aota , Damien Le Moal , Josef Bacik , David Sterba , Johannes Thumshirn Subject: [PATCH 1/2] btrfs: zoned: fix zone activation with missing devices Date: Mon, 17 Mar 2025 12:24:58 +0100 Message-ID: <5a221a55c0a170aa6073b997a160d94f9880e40e.1742210138.git.jth@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Thumshirn If btrfs_zone_activate() is called with a filesystem that has missing devices (e.g. a RAID file system mounted in degraded mode) it is accessing the btrfs_device::zone_info pointer, which will not be set if the device in question is missing. Check if the device is present (by checking if it has a valid block device pointer associated) and if not, skip zone activation for it. Fixes: f9a912a3c45f ("btrfs: zoned: make zone activation multi stripe capable") Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index c21a97b32f9a..8924f58919e8 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -2110,6 +2110,9 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group) physical = map->stripes[i].physical; zinfo = device->zone_info; + if (!device->bdev) + continue; + if (zinfo->max_active_zones == 0) continue; From patchwork Mon Mar 17 11:24:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 14019088 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E9E9236436 for ; Mon, 17 Mar 2025 11:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742210715; cv=none; b=LhLfnAuIbANA/nhKjY0wNYEC6NWa0waxLoUCrzzkOkcXr4auepkEphN6lndaat3x0GFRlhcyf2Vmzh8v/Otc9eXznICopEkjVoqxEHw/Vrp7cTMquK2Udju14KQlezMG5Q+uwUQ2TQ3jWrvkbkdaQvtomf+yB9Yicu+3eDJeuhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742210715; c=relaxed/simple; bh=qi7VHB8UAsRcO9WqNQuT5FhbFUG3E5EP6F0/7Wloljo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qi+b9sYTYRZFwzRIDjVphoAz1iKT3hEsREG9w7C+12pIfQI56X2vwN/neoxwUBLeWVLfIZa7n4dqk62eCaovWTOqNp7kfJr/DypkzBnD5HwIDBAD/v3Aj2cWTOtGZZ8o4fIOuMzF1/DRXB1SSkscFioq1W1CV3CnDSPkUCnXpYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43948021a45so21023465e9.1 for ; Mon, 17 Mar 2025 04:25:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742210712; x=1742815512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nhjxRerMIcX2nnI7NwAcm2gGoaocl9fCFjyXyIfHZAw=; b=Jhr7I4drwlVZNfQe41xCS/dNViK5DoooFKG8BcXxnhXPr6ktLVr0I2APyV1UoQMxdS 4wvZf1AVZzIFMJVKxnqF3pMvbMmP8F9vEUHUbjLDOJh7JsqaXWBwie075iWICs3Kf1sU pyw8KrqWfv+A4rvwQQOuybzsJzUFfif24FgmrdC0KUTSKiXYhFJ8iV/SpuX1mEILqwV8 8F2smRvf1NQTxDE893EuVSopWeMY95jtK92F7SQXa4wCYQMv6QLm+z4bW6UAxQXUE/yL 8lUGdA+Cbe2KZ9q6cJJ3IlwRrFspFAKXRZFq4WKwaxVGyaAPAroS+QvbfVZKBfix81aR R2Nw== X-Gm-Message-State: AOJu0Ywr+AkT0gWYCKCbbInfFtz+YcorVo/z5kOGIYeeOimbzxapu8g0 6DCQu4CYrxkBRzs5C9TjnHQrGvRo+QOI8aM7dAia3nU6TDKtC/13XzBZ1A== X-Gm-Gg: ASbGncvc/6u4uOa66EFCTF0ZWpugfmhO/RvNALe9Gf71081aHnIPkG4DmLEilz6i89H DTjk62co/HyGFh5a0EbbidJQS7EQolCwuKJMNCadQLCK5y5Clt8L23JG4Jc2U8CIdNmBOT3MQlE 7xwGMNBC+M4KaF4S/yyEbgVUN8GCOOKF+kJArbQJKLC3XTdAM/H0IiF91fqTmcfrEgkYGrCAlJL ElhlItOER+LRGGUO9+DVaqInY4KeRL730+wJUI6VgybNMgVyCU3xuI8u+2UEYuAGVLWc1FrF5Ev 0O1W+EgqE3t/VmubQUeKYWf5iO4t2jcS9+9QrLOLua/RgLTHKrisGEq+ox6053Dqq0nOnzvrvte 2MV1zIwOhSInMe5+8kS8WrpMaL0VOgcPOwYryYQ== X-Google-Smtp-Source: AGHT+IGIijIGDwhio1lPeK3Q1uDVF4gxxain8MNUUe8X3319+5U8XW0+QMV+O0MV5EN8z6cda5SrNg== X-Received: by 2002:a05:600c:470e:b0:43c:f4df:4870 with SMTP id 5b1f17b1804b1-43d1ecd0eb5mr109681035e9.25.1742210711660; Mon, 17 Mar 2025 04:25:11 -0700 (PDT) Received: from nuc.fritz.box (p200300f6f71d1000fa633ffffe02074c.dip0.t-ipconnect.de. [2003:f6:f71d:1000:fa63:3fff:fe02:74c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d200fad59sm103188675e9.26.2025.03.17.04.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 04:25:11 -0700 (PDT) From: Johannes Thumshirn To: linux-btrfs@vger.kernel.org Cc: Naohiro Aota , Damien Le Moal , Josef Bacik , David Sterba , Johannes Thumshirn Subject: [PATCH 2/2] btrfs: zoned: fix zone finishing with missing devices Date: Mon, 17 Mar 2025 12:24:59 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Thumshirn If do_zone_finish() is called with a filesystem that has missing devices (e.g. a RAID file system mounted in degraded mode) it is accessing the btrfs_device::zone_info pointer, which will not be set if the device in question is missing. Check if the device is present (by checking if it has a valid block device pointer associated) and if not, skip zone finishing for it. Fixes: 4dcbb8ab31c1 ("btrfs: zoned: make zone finishing multi stripe capable") Signed-off-by: Johannes Thumshirn --- fs/btrfs/zoned.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 8924f58919e8..7c502192cd6b 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -2274,6 +2274,9 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ struct btrfs_zoned_device_info *zinfo = device->zone_info; unsigned int nofs_flags; + if (!device->bdev) + continue; + if (zinfo->max_active_zones == 0) continue;