Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp635571pxv; Thu, 15 Jul 2021 12:05:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy67Jxl1i7ronvGewGtetbgoNCA6jpDevke3iqU56sfYNoZsbuFLpmZhNdyNn0hftbwgwi2 X-Received: by 2002:a02:a115:: with SMTP id f21mr5296879jag.3.1626375943399; Thu, 15 Jul 2021 12:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375943; cv=none; d=google.com; s=arc-20160816; b=J8F9S+WnwvViU5INA8vXDDV1krAKtbmCEWY5tx96Eh+SMnxYtd8FINE1AZJ4Ka8HR3 F3p9nEqteWGQpeWn8ux3WT/qAlj0OqI2lYgc4fmRQbpIA9pGe7lq8mL3UoPyowkHeC/e 8RzJaIkpsgAmeOW87wxvX680G+1PHS+GJxty7hyxEOWzhDa9Gq+fJ6x/6f9FgkUlxpX6 wFNlv81+RMXAIrqiHgQhXrmf+PLWuJO4ykRm1v55KMy2POsJEnW8nJWmeXoaKpo2ygNR wFbTh880YOrkDZJi6N4gKCeEeOk1J6h73gLgr20ZTJTA4M2eB8KZ8zfY4UxEoD21Tu7k MfEQ== 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=kEXNMDWpHepVOXI/16Ad2woMdsANCEy+xhHLOhsSjTq0tpgPBX+GBvG1R+vPcqrk4W bu50aaz3zjveSGxMCaAry3QGS7zOI+2tLFFui/aa1mpnwkWEkN8VyiVzf5XJ28XEpttM W4qtcKlwAoWSS42ZRiYTgtZTTFPJjM2kVy/vRwC9CGEr1RyVUYbAylleM11o08Bt9FVK xoejg+K0KPEQko8sPzioXemHjyPGxuG+u+cXHq9DbdD8E5J+yWczeRGHbbkDil33jd5g gb2b9lA88FnQxpiEqpYR6sZQ8eqTcJ7vOWfj9FcCQ6xGXZqxx2L+KdOMg4rAOQjQFS2s Qd0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LQhzO0H9; 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 x1si8393512jan.58.2021.07.15.12.05.31; Thu, 15 Jul 2021 12:05:43 -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=LQhzO0H9; 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 S242980AbhGOTHC (ORCPT + 99 others); Thu, 15 Jul 2021 15:07:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:33630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242086AbhGOS4s (ORCPT ); Thu, 15 Jul 2021 14:56:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF754613D7; Thu, 15 Jul 2021 18:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375235; bh=Q8tCaovNO/yY6nnNDbQcWGAtMidmnvcjFfhUOh6C8ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQhzO0H9yl/utouMa5xnjXMSKaAnG+l/QeaGaXoEqCs2fJNGdeyD41XnbdiG1lnU2 GxcGEjCkp1bKcRuKKs8EPX/foiJeCcbNh9171Oep7AABaSucAhQGI50xRqWwk0Mpq8 nk5FQYSOZtPn6nzEr1zGuWHgMRREddfdERtm0ziE= 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.10 195/215] dm zoned: check zone capacity Date: Thu, 15 Jul 2021 20:39:27 +0200 Message-Id: <20210715182633.618817941@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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);