Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp663330pxv; Thu, 15 Jul 2021 12:50:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI1RnGmyRbPOANJ7n9Ep/x9yqgIDt+B32+SN4fZoWm14eC+p5OdRpTABhwtcg0gqa9Xyiv X-Received: by 2002:a05:6402:31a6:: with SMTP id dj6mr9462493edb.248.1626378635396; Thu, 15 Jul 2021 12:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378635; cv=none; d=google.com; s=arc-20160816; b=SrPEGcO/ETLrDHfGV7JGPhhCr9VzmqXbud0qtuFXFp6JfmCG1NN0DfeB8OjveUc1BZ 0Aclp+4Czw9T6fKz8w3opueOPaO827TT+j0W1s/ou1trX3CErjYTbdFAxEna/D36r7fc CGkeGRCe0hkEQFeQs9U0ljUyZGp4rBAv+sDaBkvPHN8wj2YmS1U93avWbDEACSReB7q1 dXBPfBhkBYNziIgI3gI8y8HZDHtihClwAM7MWYV0q9pd8lKAqB+jPRZB6fJnwSkvHiL7 C2l5FeBUsKHcL8+AtZMC/24DJkUTgfkeERvmvjQVyUuYSUPYICvMJpRLycj1lC4wMvE8 DmtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ht5qElIOfaSpIx6BpwkaNifrkS4sz33Z+AymaI8It34=; b=XJYR0GJE1f9u0908JMwsxnZ2qgdK81EzG5xJtzjmODrOjP8N7mDYmUJp+CUeuBZhEV ZBghNRcmAfOAY9riociAgLQS3IQLzlr4Wo5bXrc3rFs4z486oFMIDDz21b028nsAmuod rk3JoaWNGqwG+RjZU3dnZqtk4LZ83tI82zxAFmBKnH4C8WzIVjKfiS6M5o2Scl28avmV 7ckJthaymn9F83swi0cM5JRolFZdwFxGTfBu0s5vz/W9mkp5E7UKG9Wv3IyTBRX7gaBp 1Q1LjSgiCVQOqBNHUebswWHtNlytaOPGypPUOxO0nHVYaAFK216PyLVJ/lPPdsP8LrMf q3EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y9vPZcSM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si10415139edj.399.2021.07.15.12.50.12; Thu, 15 Jul 2021 12:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y9vPZcSM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245569AbhGOTrE (ORCPT + 99 others); Thu, 15 Jul 2021 15:47:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:51470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244664AbhGOTQh (ORCPT ); Thu, 15 Jul 2021 15:16:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ACA29613E6; Thu, 15 Jul 2021 19:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376365; bh=Q8tCaovNO/yY6nnNDbQcWGAtMidmnvcjFfhUOh6C8ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9vPZcSMC4eje52tJE1oXNsW5oO0VUYP08vZwkcYrT9q3AtpSS8VdTJYU402CY8+s NoZeq72k7iOiBYwO2Xpi47AyvUiMJOP9ZYBA3CcPw0v7EyojUzH8nBM/I8e2/YPBtd HGgr4DOToGK06q74hQxA0JawNYYYkSyfBmO6OwUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Mike Snitzer Subject: [PATCH 5.13 239/266] dm zoned: check zone capacity Date: Thu, 15 Jul 2021 20:39:54 +0200 Message-Id: <20210715182650.898977679@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Damien Le Moal commit bab68499428ed934f0493ac74197ed6f36204260 upstream. The dm-zoned target cannot support zoned block devices with zones that have a capacity smaller than the zone size (e.g. NVMe zoned namespaces) due to the current chunk zone mapping implementation as it is assumed that zones and chunks have the same size with all blocks usable. If a zoned drive is found to have zones with a capacity different from the zone size, fail the target initialization. Signed-off-by: Damien Le Moal Cc: stable@vger.kernel.org # v5.9+ Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-zoned-metadata.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -1390,6 +1390,13 @@ static int dmz_init_zone(struct blk_zone return -ENXIO; } + /* + * Devices that have zones with a capacity smaller than the zone size + * (e.g. NVMe zoned namespaces) are not supported. + */ + if (blkz->capacity != blkz->len) + return -ENXIO; + switch (blkz->type) { case BLK_ZONE_TYPE_CONVENTIONAL: set_bit(DMZ_RND, &zone->flags);