From patchwork Fri Mar 27 07:14:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 11461831 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E82CF13A4 for ; Fri, 27 Mar 2020 07:15:37 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ACD0820663 for ; Fri, 27 Mar 2020 07:15:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dbnlxem+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACD0820663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585293336; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GMOpx1qRkkmn3TEyhWCO/VCmkiM8fQ5C26OjrLuo6js=; b=dbnlxem+Arewn/c+HggjsFOAC1h7cHnT6i7iCUBdVSaUp2M960bdYib6gZYEGAYZm4wapT OMpQRxoDDR0b5gKfP76Yer6mXQp9xORZSmJ6DP8BkFg/OmKrSiEDdQ5VSgAokiEf390doN /xnmOno5GCptTfX8UPxj2KAaiOYNpxY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-gAPj909NO9ONpkD_t5fSvw-1; Fri, 27 Mar 2020 03:15:33 -0400 X-MC-Unique: gAPj909NO9ONpkD_t5fSvw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47D241005516; Fri, 27 Mar 2020 07:15:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C8B65DA2C; Fri, 27 Mar 2020 07:15:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BA9688A054; Fri, 27 Mar 2020 07:15:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02R7FG3H027401 for ; Fri, 27 Mar 2020 03:15:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 952661054FCD; Fri, 27 Mar 2020 07:15:16 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 90D5B1054FCC for ; Fri, 27 Mar 2020 07:15:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A62518007D2 for ; Fri, 27 Mar 2020 07:15:14 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-2XtGMyTwOHaADEPE3AsZQQ-1; Fri, 27 Mar 2020 03:15:10 -0400 X-MC-Unique: 2XtGMyTwOHaADEPE3AsZQQ-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AF2A5AFB1; Fri, 27 Mar 2020 07:15:08 +0000 (UTC) From: Hannes Reinecke To: Mike Snitzer Date: Fri, 27 Mar 2020 08:14:56 +0100 Message-Id: <20200327071459.67796-2-hare@suse.de> In-Reply-To: <20200327071459.67796-1-hare@suse.de> References: <20200327071459.67796-1-hare@suse.de> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02R7FG3H027401 X-loop: dm-devel@redhat.com Cc: Damien LeMoal , Bob Liu , dm-devel@redhat.com Subject: [dm-devel] [PATCH 1/4] dm-zoned: store zone id within the zone structure X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of calculating the zone index by the offset within the zone array store the index within the structure itself. Signed-off-by: Hannes Reinecke --- drivers/md/dm-zoned-metadata.c | 3 ++- drivers/md/dm-zoned.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c index c8787560fa9f..afce594067fb 100644 --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -189,7 +189,7 @@ struct dmz_metadata { */ unsigned int dmz_id(struct dmz_metadata *zmd, struct dm_zone *zone) { - return ((unsigned int)(zone - zmd->zones)); + return zone->id; } sector_t dmz_start_sect(struct dmz_metadata *zmd, struct dm_zone *zone) @@ -1119,6 +1119,7 @@ static int dmz_init_zone(struct blk_zone *blkz, unsigned int idx, void *data) INIT_LIST_HEAD(&zone->link); atomic_set(&zone->refcount, 0); + zone->id = idx; zone->chunk = DMZ_MAP_UNMAPPED; switch (blkz->type) { diff --git a/drivers/md/dm-zoned.h b/drivers/md/dm-zoned.h index 884c0e586082..39d59898abbe 100644 --- a/drivers/md/dm-zoned.h +++ b/drivers/md/dm-zoned.h @@ -87,6 +87,9 @@ struct dm_zone { /* Zone activation reference count */ atomic_t refcount; + /* Zone id */ + unsigned int id; + /* Zone write pointer block (relative to the zone start block) */ unsigned int wp_block; From patchwork Fri Mar 27 07:14:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 11461829 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB22C81 for ; Fri, 27 Mar 2020 07:15:33 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FA1920663 for ; Fri, 27 Mar 2020 07:15:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E7IwhI2a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FA1920663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585293332; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yzmgJbgNDEoZMaluJBpqVNAhbp/l0L+e/mmNHYjkwcg=; b=E7IwhI2ajHZE/EXkXfSOYDoNmAdiaF9NwcG3971BE4OLtEtMQUhwfiaRX1H2pYv9j0v4hL YgyONirO2+RSwqeP6VE5k6/tyzjY6SB4gfKMuxpD26DpwGQ88A3vYyz+gdCcVBgX72yqXa hYzW9rAqVkmk71vwe6R7zHyFJewLds0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-nyKuT_pbNLS3UJxHBPAJig-1; Fri, 27 Mar 2020 03:15:30 -0400 X-MC-Unique: nyKuT_pbNLS3UJxHBPAJig-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EAB018C35A0; Fri, 27 Mar 2020 07:15:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 658F75DA2C; Fri, 27 Mar 2020 07:15:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 13ADF18089CE; Fri, 27 Mar 2020 07:15:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02R7FFQ8027388 for ; Fri, 27 Mar 2020 03:15:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 942822037E56; Fri, 27 Mar 2020 07:15:15 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 906AA2037E45 for ; Fri, 27 Mar 2020 07:15:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BE198007C9 for ; Fri, 27 Mar 2020 07:15:12 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-zYUdeJo6PJKRxJfh7twMPA-1; Fri, 27 Mar 2020 03:15:10 -0400 X-MC-Unique: zYUdeJo6PJKRxJfh7twMPA-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AE1FCADDD; Fri, 27 Mar 2020 07:15:08 +0000 (UTC) From: Hannes Reinecke To: Mike Snitzer Date: Fri, 27 Mar 2020 08:14:58 +0100 Message-Id: <20200327071459.67796-4-hare@suse.de> In-Reply-To: <20200327071459.67796-1-hare@suse.de> References: <20200327071459.67796-1-hare@suse.de> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02R7FFQ8027388 X-loop: dm-devel@redhat.com Cc: Damien LeMoal , Bob Liu , dm-devel@redhat.com Subject: [dm-devel] [PATCH 3/4] dm-zoned: V2 metadata handling X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add 'V2' metadata which includes UUIDs for the dmz set and for the device itself. Signed-off-by: Hannes Reinecke Reviewed-by: Damien Le Moal Reviewed-by: Bob Liu --- drivers/md/dm-zoned-metadata.c | 80 +++++++++++++++++++++++++++++++++--------- drivers/md/dm-zoned-target.c | 2 +- 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c index dc1d17bc3bbb..026f285fba33 100644 --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -16,7 +16,8 @@ /* * Metadata version. */ -#define DMZ_META_VER 1 +#define DMZ_META_COMPAT_VER 1 +#define DMZ_META_VER 2 /* * On-disk super block magic. @@ -69,8 +70,17 @@ struct dmz_super { /* Checksum */ __le32 crc; /* 48 */ - /* Padding to full 512B sector */ - u8 reserved[464]; /* 512 */ + /* DM-Zoned label */ + u8 dmz_label[32]; /* 80 */ + + /* DM-Zoned UUID */ + u8 dmz_uuid[16]; /* 96 */ + + /* Device UUID */ + u8 dev_uuid[16]; /* 112 */ + + /* Padding to full 512B - CRC sector */ + u8 reserved[400]; /* 512 */ }; /* @@ -133,6 +143,10 @@ struct dmz_sb { struct dmz_metadata { struct dmz_dev *dev; + char dmz_label[BDEVNAME_SIZE]; + uuid_t dmz_uuid; + uuid_t dev_uuid; + sector_t zone_bitmap_size; unsigned int zone_nr_bitmap_blocks; unsigned int zone_bits_per_mblk; @@ -659,7 +673,14 @@ static int dmz_write_sb(struct dmz_metadata *zmd, unsigned int set) int ret; sb->magic = cpu_to_le32(DMZ_MAGIC); - sb->version = cpu_to_le32(DMZ_META_VER); + + if (!uuid_is_null(&zmd->dmz_uuid)) { + sb->version = cpu_to_le32(DMZ_META_VER); + uuid_copy((uuid_t *)sb->dmz_uuid, &zmd->dmz_uuid); + memcpy(sb->dmz_label, zmd->dmz_label, BDEVNAME_SIZE); + uuid_copy((uuid_t *)sb->dev_uuid, &zmd->dev_uuid); + } else + sb->version = cpu_to_le32(DMZ_META_COMPAT_VER); sb->gen = cpu_to_le64(sb_gen); @@ -848,28 +869,29 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_super *sb) { unsigned int nr_meta_zones, nr_data_zones; struct dmz_dev *dev = zmd->dev; - u32 crc, stored_crc; + u32 crc, stored_crc, dmz_version; u64 gen; - gen = le64_to_cpu(sb->gen); - stored_crc = le32_to_cpu(sb->crc); - sb->crc = 0; - crc = crc32_le(gen, (unsigned char *)sb, DMZ_BLOCK_SIZE); - if (crc != stored_crc) { - dmz_dev_err(dev, "Invalid checksum (needed 0x%08x, got 0x%08x)", - crc, stored_crc); - return -ENXIO; - } - if (le32_to_cpu(sb->magic) != DMZ_MAGIC) { dmz_dev_err(dev, "Invalid meta magic (needed 0x%08x, got 0x%08x)", DMZ_MAGIC, le32_to_cpu(sb->magic)); return -ENXIO; } - if (le32_to_cpu(sb->version) != DMZ_META_VER) { + dmz_version = le32_to_cpu(sb->version); + if (dmz_version > DMZ_META_VER) { dmz_dev_err(dev, "Invalid meta version (needed %d, got %d)", - DMZ_META_VER, le32_to_cpu(sb->version)); + DMZ_META_VER, dmz_version); + return -ENXIO; + } + + gen = le64_to_cpu(sb->gen); + stored_crc = le32_to_cpu(sb->crc); + sb->crc = 0; + crc = crc32_le(gen, (unsigned char *)sb, DMZ_BLOCK_SIZE); + if (crc != stored_crc) { + dmz_dev_err(dev, "Invalid checksum (needed 0x%08x, got 0x%08x)", + crc, stored_crc); return -ENXIO; } @@ -895,6 +917,21 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_super *sb) return -ENXIO; } + if (dmz_version == DMZ_META_VER) { + if (uuid_is_null((uuid_t *)sb->dmz_uuid)) { + dmz_dev_err(dev, "NULL DM-Zoned uuid"); + return -ENXIO; + } + uuid_copy(&zmd->dmz_uuid, (uuid_t *)sb->dmz_uuid); + memcpy(zmd->dmz_label, sb->dmz_label, BDEVNAME_SIZE); + if (uuid_is_null((uuid_t *)sb->dev_uuid)) { + dmz_dev_err(dev, "NULL device uuid"); + return -ENXIO; + } + uuid_copy(&zmd->dev_uuid, (uuid_t *)sb->dev_uuid); + + } + /* OK */ zmd->nr_meta_blocks = le32_to_cpu(sb->nr_meta_blocks); zmd->nr_reserved_seq = le32_to_cpu(sb->nr_reserved_seq); @@ -2460,9 +2497,18 @@ int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **metadata) goto err; } + dmz_dev_info(dev, "DM-Zoned version %d", + uuid_is_null(&zmd->dmz_uuid) ? + DMZ_META_COMPAT_VER : DMZ_META_VER); + if (!uuid_is_null(&zmd->dmz_uuid)) + dmz_dev_info(dev, "DM UUID %pUl", &zmd->dmz_uuid); + if (strlen(zmd->dmz_label)) + dmz_dev_info(dev, "DM Label %s", zmd->dmz_label); dmz_dev_info(dev, "Host-%s zoned block device", bdev_zoned_model(dev->bdev) == BLK_ZONED_HA ? "aware" : "managed"); + if (!uuid_is_null(&zmd->dev_uuid)) + dmz_dev_info(dev, " uuid %pUl", &zmd->dev_uuid); dmz_dev_info(dev, " %llu 512-byte logical sectors", (u64)dev->capacity); dmz_dev_info(dev, " %u zones of %llu 512-byte logical sectors", diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index 44e30a7de8b9..7ec9dde24516 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -1008,7 +1008,7 @@ static int dmz_message(struct dm_target *ti, unsigned int argc, char **argv, static struct target_type dmz_type = { .name = "zoned", - .version = {1, 1, 0}, + .version = {1, 2, 0}, .features = DM_TARGET_SINGLETON | DM_TARGET_ZONED_HM, .module = THIS_MODULE, .ctr = dmz_ctr, From patchwork Fri Mar 27 07:14:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 11461823 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F217017EA for ; Fri, 27 Mar 2020 07:15:25 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA8DD20663 for ; Fri, 27 Mar 2020 07:15:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XicKDaED" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA8DD20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585293324; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FdjPns9fA2lg+6E6TS6BMHsqjkAXbm7aocb5MPziaM4=; b=XicKDaEDapwhkZ0DNnG4EEAcuD6nPiv8Bz9maZ5uxdH0rFvMD5o2JGf7pOYLzdeygdRttq zVFoGQj9LLU5VXli5BZj18XsbJidAZqidURFC/MrX42BPLDhojx5S7ogCUm5RuF4iQNOUE ce4pzv/5ScONpZuYbnofV1oOlYq/Wjw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-e_7kTLa5MC2WX96b4VIotA-1; Fri, 27 Mar 2020 03:15:22 -0400 X-MC-Unique: e_7kTLa5MC2WX96b4VIotA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C449A18C35A4; Fri, 27 Mar 2020 07:15:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C22410016DA; Fri, 27 Mar 2020 07:15:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0E9918A04B; Fri, 27 Mar 2020 07:15:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02R7FFBg027382 for ; Fri, 27 Mar 2020 03:15:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5CCD12166B2C; Fri, 27 Mar 2020 07:15:15 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 593F72166B2B for ; Fri, 27 Mar 2020 07:15:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 19F138F7853 for ; Fri, 27 Mar 2020 07:15:13 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-483-f4PlqFbENWC1hL_jKsHJWA-1; Fri, 27 Mar 2020 03:15:10 -0400 X-MC-Unique: f4PlqFbENWC1hL_jKsHJWA-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AF60DB1E3; Fri, 27 Mar 2020 07:15:08 +0000 (UTC) From: Hannes Reinecke To: Mike Snitzer Date: Fri, 27 Mar 2020 08:14:59 +0100 Message-Id: <20200327071459.67796-5-hare@suse.de> In-Reply-To: <20200327071459.67796-1-hare@suse.de> References: <20200327071459.67796-1-hare@suse.de> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02R7FFBg027382 X-loop: dm-devel@redhat.com Cc: Damien LeMoal , Bob Liu , dm-devel@redhat.com Subject: [dm-devel] [PATCH 4/4] dm-zoned: allow for device size smaller than the capacity X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com dm-zoned requires several zones for metadata and chunk bitmaps, so it cannot expose the entire capacity as the device size. Originally the code would check for the capacity being equal to the device size, which is arguably wrong. So relax this check and increase the interface version number to signal to userspace that it can set a smaller device size. Signed-off-by: Hannes Reinecke --- drivers/md/dm-zoned-target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index 7ec9dde24516..89a825d1034e 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -715,7 +715,7 @@ static int dmz_get_zoned_device(struct dm_target *ti, char *path) aligned_capacity = dev->capacity & ~((sector_t)blk_queue_zone_sectors(q) - 1); if (ti->begin || - ((ti->len != dev->capacity) && (ti->len != aligned_capacity))) { + ((ti->len > dev->capacity) && (ti->len > aligned_capacity))) { ti->error = "Partial mapping not supported"; ret = -EINVAL; goto err; @@ -1008,7 +1008,7 @@ static int dmz_message(struct dm_target *ti, unsigned int argc, char **argv, static struct target_type dmz_type = { .name = "zoned", - .version = {1, 2, 0}, + .version = {1, 3, 0}, .features = DM_TARGET_SINGLETON | DM_TARGET_ZONED_HM, .module = THIS_MODULE, .ctr = dmz_ctr,