Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp712225pxv; Thu, 15 Jul 2021 14:10:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkoybW07fpFhBPkaERXkKCp2LacSg2x6ofFHlQeh4VWYg5RSyp443jgYSUDI2Jh8UWvY7t X-Received: by 2002:a17:906:a98e:: with SMTP id jr14mr7678454ejb.450.1626383433286; Thu, 15 Jul 2021 14:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383433; cv=none; d=google.com; s=arc-20160816; b=nwnViWh2xWlKHktoqR5qbIgNRQsuk/d1WkyVBXLE9s9abYWtZ7kBwgvMlo3I6F4uqd 5NZJFKsGd5E5W6U3/v8he9/ap8b+cE3lSWcjnvKik1HS2ya6s1i4Xi9OM+Wy14+Z0q32 kwZy/KF4EdsMLQyke7R3sVUZNSayusozgHROjRdz3KkJlot+flduMjKhyLIJDbt0bLD7 DZJwV8WtZpEhh981qQ3GIlHfNvqYOrRDgMP11dngigJfZkcLFm3L/gCsjezgJ7effndP 1Ey+Yy48v3E1ar4XNkyW8fmH2lmJvNdow3bPbbiPgb/uLuFYy1lnzM0nbRRROdMLUJ+1 +dCQ== 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=fWT4AflC0Pj2r8JrxCL3UTg8pZwDHoLaxU9r2yKhoqeZpVpRKlMAERg8Dn8knnnVV4 woY4UMHn2hxBX6/Fh5ojT2ZBrw3apg9VaKhIzW+/d1f6HTFcpjSsEuthmJ/neLabf6Ue axiy5z7TWwfw2/HstuHjUdsBkE1qnTfiuPQ821sFyCI2YOhXEfVxwXsn0Db56DSnDtU6 LqPj1gfAuMuIQlXfE7TiRHeEY2QlCMGIF7mNz6jtMEqk01L831XFOoAfQ6h3w9MhG+5w q54VvXyv79fsUY1HZwzuAt+bRAbPTS/+QMmnimNhj5eK/HhjlHBlzMNXaRf24zihkCEx 08Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2VHxcTcG; 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 r26si7505713ejz.423.2021.07.15.14.10.09; Thu, 15 Jul 2021 14:10:33 -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=2VHxcTcG; 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 S243814AbhGOTW3 (ORCPT + 99 others); Thu, 15 Jul 2021 15:22:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241245AbhGOTFu (ORCPT ); Thu, 15 Jul 2021 15:05:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED68C613F2; Thu, 15 Jul 2021 19:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375736; bh=Q8tCaovNO/yY6nnNDbQcWGAtMidmnvcjFfhUOh6C8ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2VHxcTcGC1Iys1hjZrUWEDSQT9ZfWjwIS42ZDS3DG78nJOv9J4HKa1a/5pJcaS1Mb nQaVve68rpI2WyMtsRk+yQRQuUugIiersqlxNxDeWjEuxCCFEkX63gpkDXd1/Zv3Uf bsitOa/KUM+Xl+l1z0D/5UrBWWZA6feSyv2+WpYA= 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.12 215/242] dm zoned: check zone capacity Date: Thu, 15 Jul 2021 20:39:37 +0200 Message-Id: <20210715182630.990899192@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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);