Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp293892lqr; Wed, 5 Jun 2024 06:26:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXM3jDJcJJMZc1sTSUkUo0683LEaWsHh5rslaLmBUWUrQ+AUYXBTRZsl8LJGQcKLq2bqJwHe+9G3RFC2l2xvc/e3SYl50Wn4ftibwQ4fg== X-Google-Smtp-Source: AGHT+IHvzyt6+ka8SfxkXT8CbZRQxHxXGpurCwg7cvcjX1j3kjUIdiANRnD9VPK9J5AVkwAjDcqb X-Received: by 2002:a17:90a:cb96:b0:2a5:e087:768a with SMTP id 98e67ed59e1d1-2c27db1b64cmr2669702a91.29.1717593984825; Wed, 05 Jun 2024 06:26:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717593984; cv=pass; d=google.com; s=arc-20160816; b=drJ2EtyngPggJa+kdnJOA+AjA6s0bUATs46e7uwFMwLdMD3+lvWsWEfxF8WNOYY5On 7d3HmxxlMHC3OFQVveEls8aVdltoWom0jnLNjuAWCM6Gti7rR2zP7nsgsldvrdRJeW7U 3uTSrn6QZk+JU6BVcyyfUR2PguLiZbNYonvV0nADZusqFcc6Uu9Zt1KFVNOoBnlulQIP KoAepYkD3hjqBZIwVR3oEo4wFjgUHbZK6UtIVwqV+7IBtTbA71bg31GUW9U9sTwCBh73 wx0kVbbhOE/hVfcLLm57wSXxEfZUL0MLe5z5ekYK4G1u5jFsLJpJeCzDyz2vYeO2pATE 03HQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2y7TFj4ShDJp1O+Wzur/k+pNhnxdirxEmFgZ8KdIkCQ=; fh=wVbiCAryI6WCVex5FF/VDWE3/hXz6ukgEs6/jiE+qbw=; b=S8N05n5fNXBcvYYAiNzStq/A0c42lWXzYaN2e+QkoFD6snh/4HkLNmy/uRBPrZfmHq 2XpghrTe3cNXpjL3u/TAJz/CEcknPT1r9XhodtCxQ/7ueeFfvPwiS/xQNJcCIlvKi6mv HlkkSNc8pZdXrt6xSMzPuJErmuOjqCjWJGNryx4uGonfLPRTJGb8to8qJ7e4lkf9Rj6u iudFvfjNXVxRG437oojR3vrrn5zb+O4BLkXKj7VSH+xZBheDdSyBd1QY49LKqKIg4xOj aOF3kybQpMgFoGPznEp5L5HVDQyjq5FDlthj/rgjhycJGFVwLXpG6KLaSs40Y0JKOCED ekjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NGOLfDW5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2806eec0esi1238659a91.164.2024.06.05.06.26.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:26:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NGOLfDW5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202527-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202527-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4437BB2D838 for ; Wed, 5 Jun 2024 12:47:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE5051CDD9F; Wed, 5 Jun 2024 12:05:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NGOLfDW5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11B081CDD8F; Wed, 5 Jun 2024 12:05:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589122; cv=none; b=D9Y4Sy0WuHfknWwmpCQIvtl0hE76sJ4xvyWZbWQIlmad0IfaBwXPynDgx6evHkKSjA7YdJ5BFgLa6hF5tGeFDI2C2zAp93idJIHgFL+uZ73zvQsoo3tDr9748vBk+vLuDKooOMAQx4Apfs7G3xv1ap6qokW5XMgDxG2n+FimXdQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589122; c=relaxed/simple; bh=MxfLOCffjklREETylsVnFm1EwGWA0u0V6NbQJzOHIMg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+gDclJXgGUIBVzXOOb2n+R9XfWfeUZ7GPK4YQHoSDfgVQySXNRbaRVLTXKApROFq9/hkCpReKXGkpaXTYHQgPO8ZD03r23IJtSOGoDPPqjkIyOnACZX6ysBMllquKSVgiW7/bYDD4auEJnxXMXL7bKHTlFzN4+3VLSn6BdN0eA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NGOLfDW5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D121AC3277B; Wed, 5 Jun 2024 12:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589121; bh=MxfLOCffjklREETylsVnFm1EwGWA0u0V6NbQJzOHIMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGOLfDW5txuiTuf66kFlEKBAGyaJUpJM4/oBO9H4Q787kA/Mv6Klw2SXqU4XSRvKv S5yQoYH5OjG+ym8zqfvMOiUUBnpGt+WqQt1JcpuzKwvsPCIR+1iUM5SPWtkZ+qQl5O byaFIo5TcoCAsVgGlPCI20XobG6tZz/m5WPxNYCrmFrEEK/RJBVVsxE1IxphW0K5qG AmG1FuiLEe+c4pwPxLVqbvNADOb6U7So7DWzkcde75aCQ3bssli2vEXBfMn4PLc13m 95YOWabnn+YcduHEax1HLEer/at73GBzw5pur54H847IkWnjGeR8azRexuRW9ZLuNI MHit8CA4ipwqw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Damien Le Moal , Niklas Cassel , Bart Van Assche , Jens Axboe , Sasha Levin , martin.petersen@oracle.com, hare@suse.de, linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 14/14] null_blk: Do not allow runt zone with zone capacity smaller then zone size Date: Wed, 5 Jun 2024 08:04:47 -0400 Message-ID: <20240605120455.2967445-14-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120455.2967445-1-sashal@kernel.org> References: <20240605120455.2967445-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.92 Content-Transfer-Encoding: 8bit From: Damien Le Moal [ Upstream commit b164316808ec5de391c3e7b0148ec937d32d280d ] A zoned device with a smaller last zone together with a zone capacity smaller than the zone size does make any sense as that does not correspond to any possible setup for a real device: 1) For ZNS and zoned UFS devices, all zones are always the same size. 2) For SMR HDDs, all zones always have the same capacity. In other words, if we have a smaller last runt zone, then this zone capacity should always be equal to the zone size. Add a check in null_init_zoned_dev() to prevent a configuration to have both a smaller zone size and a zone capacity smaller than the zone size. Signed-off-by: Damien Le Moal Reviewed-by: Niklas Cassel Reviewed-by: Bart Van Assche Link: https://lore.kernel.org/r/20240530054035.491497-2-dlemoal@kernel.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/null_blk/zoned.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index 55a69e48ef8bc..d1a8730f61a71 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -83,6 +83,17 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) return -EINVAL; } + /* + * If a smaller zone capacity was requested, do not allow a smaller last + * zone at the same time as such zone configuration does not correspond + * to any real zoned device. + */ + if (dev->zone_capacity != dev->zone_size && + dev->size & (dev->zone_size - 1)) { + pr_err("A smaller last zone is not allowed with zone capacity smaller than zone size.\n"); + return -EINVAL; + } + zone_capacity_sects = mb_to_sects(dev->zone_capacity); dev_capacity_sects = mb_to_sects(dev->size); dev->zone_size_sects = mb_to_sects(dev->zone_size); -- 2.43.0