Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp115160iog; Thu, 16 Jun 2022 23:34:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2rw2ePYDQhUtmSeUrjnshfxKqXu1AmKfkX0h3T44o+fTI5gjZF2UpItPA3jhvXPl3JeG7 X-Received: by 2002:a17:90a:7acd:b0:1ea:d721:eb5e with SMTP id b13-20020a17090a7acd00b001ead721eb5emr13039705pjl.238.1655447652549; Thu, 16 Jun 2022 23:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655447652; cv=none; d=google.com; s=arc-20160816; b=pdxvtod91lYL7H1sq1g1okQ9rSe2DNgN46TUKDBPRo4ovJYYuwWnw2v/AvNy+ChU4h n4LhACwFja0QwU5xxr6DanTIr3Ww0nW54ZFiNYHwVbIlJ+teWhLWcNfF+wQqDoemLgov /zk7ENYrZLZtt7qZOzYYYtHBPbF4iIz6elpMFJsWa4Y9kwtXHWQVAasjoMfW7BjkvfOQ 4hFW7+Kh3S1e2akoTA75bMn8mnpAuigQEn2zVwl8LIXA647CZqwmT82IViZOaop5bnoT rdY/dBzZJXHQ4sgZR0OvVk0IASUQc01+DLU/wcspyeneWqDVL7suzD5l9f/JEv8XA9OS h6xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=oOmLTXxHtiKWvXXbSnbMtWVTLgRX+hcxKS6om3t8zyU=; b=EupNa8IHEjQ6DfbVLXtK1+0uFaVMLqa5+ePCesnsE8IOnB7J7b6OVn0sqy5IeCmIbP ERx7W/9s7MDsNYQHQOeyCrzqM3+qtGKD4/jOFUiwvrofrPhw1rGwcBhziWEzWySzuKp8 5bxpFxPmPGp53+Eqj1UKbvkjRBZ6BCYkW8Q3LYC8gcI8S/H5txnXpXlzvQIfkQgZVsuS qgYUE33ujZIdzAptMKKyV0yHjX//u+sUf/nG6hEtdIKqupQ/pgIrnTnyI485DHvxkK3C j5/hK73h5CW+uorpsbzW8F665ssvkxCUUNKJmV0SPuQQe0zf0ybgbadlgRjeHM42QU1P ge7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lVl4PN3M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a63160c000000b003fe25580540si5048330pgl.476.2022.06.16.23.33.59; Thu, 16 Jun 2022 23:34:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lVl4PN3M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379673AbiFQFqR (ORCPT + 99 others); Fri, 17 Jun 2022 01:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiFQFqP (ORCPT ); Fri, 17 Jun 2022 01:46:15 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744C666C9C for ; Thu, 16 Jun 2022 22:46:12 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220617054607euoutp02fbeaa799babe8f098477938ee62d8252~5Uj7V0gXC0254802548euoutp02i for ; Fri, 17 Jun 2022 05:46:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220617054607euoutp02fbeaa799babe8f098477938ee62d8252~5Uj7V0gXC0254802548euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1655444767; bh=oOmLTXxHtiKWvXXbSnbMtWVTLgRX+hcxKS6om3t8zyU=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=lVl4PN3Mn1GdpPDIkosdavwam+7MLmo+8zlgSP8rg0EkiBbWWFjXYLXVXjeT7bu6J z+gaTi/522Lqd2Cmr5wtlnLiQQrZ24w2MlBUA/WT5jNTN6h96sTQHU04IL+8L8xEVE RGhZQFQjk49DUZkjFLuy79YhGDak1JbM9/YOBbyg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220617054607eucas1p12bf3b149c16d5992795ed6722d414b2f~5Uj65en871628816288eucas1p1F; Fri, 17 Jun 2022 05:46:07 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 01.89.09664.F151CA26; Fri, 17 Jun 2022 06:46:07 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220617054606eucas1p23fd49b57f6c12cbb82cf3f700f29ac53~5Uj6djwtL0948609486eucas1p2U; Fri, 17 Jun 2022 05:46:06 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220617054606eusmtrp1cd5853c6742faf923e59de41ea4d2950~5Uj6b1vD82642226422eusmtrp1x; Fri, 17 Jun 2022 05:46:06 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-92-62ac151f2e12 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 04.19.09095.E151CA26; Fri, 17 Jun 2022 06:46:06 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220617054606eusmtip17a9761ccee9559d7967ca923bccd96ba~5Uj6N0ubu0452004520eusmtip1i; Fri, 17 Jun 2022 05:46:06 +0000 (GMT) Received: from [192.168.1.12] (106.210.248.244) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Jun 2022 06:46:00 +0100 Message-ID: <4746a000-2220-211e-1bd6-79c15c18a85c@samsung.com> Date: Fri, 17 Jun 2022 07:45:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v7 13/13] dm: add non power of 2 zoned target Content-Language: en-US To: Damien Le Moal , , , CC: , , , , , , , , , , , , , Damien Le Moal From: Pankaj Raghav In-Reply-To: <0c4f30f2-c206-0201-31e3-fbb9edbdf666@opensource.wdc.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [106.210.248.244] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKKsWRmVeSWpSXmKPExsWy7djP87ryomuSDC5uF7RYfbefzWLah5/M Fr/Pnme2aG3/xmSx991sVosLPxqZLPYsmsRksXL1USaLJ+tnMVv0HPjAYvG36x5QrOUhs8Xe W9oWl3fNYbOYv+wpu8Wam09ZLNo2fmV0EPS4fMXb49+JNWweO2fdZfe4fLbUY9OqTjaPhQ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ipoq3Grub37zI3z7lx6Hvt6Z9zpd4m +mqUVPVMqhV785dlmlZUbn6eqEMSCwubrhJLcUaioRZzUXEiALC8MQi+AwAA X-CMS-MailID: 20220617054606eucas1p23fd49b57f6c12cbb82cf3f700f29ac53 X-Msg-Generator: CA X-RootMTR: 20220615102011eucas1p220368db4a186181b1927dea50a79e5d4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615102011eucas1p220368db4a186181b1927dea50a79e5d4 References: <20220615101920.329421-1-p.raghav@samsung.com> <20220615101920.329421-14-p.raghav@samsung.com> <63b0cfb6-eb24-f058-e502-2637039c5a98@opensource.wdc.com> <0b819562-8b16-37b6-9220-28bf1960bccb@samsung.com> <0c4f30f2-c206-0201-31e3-fbb9edbdf666@opensource.wdc.com> X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-06-17 01:49, Damien Le Moal wrote: >>> Why do you need to change dm_set_zones_restrictions() at all ? >>> >> When the device mapper is created, the q->limits gets inherited from the >> underlying device. The chunk sectors of the target and the device will >> be the same but we want the chunk sector of the target to be different >> (rounded to po2) compared to the underlying device's chunk sector. This >> needs to be done only for the dm-po2z target and not for other targets >> that uses npo2 zoned devices (like dm-linear). So to perform this >> operation in a target independent way in dm-zone.c, I chose to always >> revalidate npo2 zoned device and update the chunk sector and nr_zones in >> dm_zone_revalidate_cb based on the zone information from the target. >> This allows to set the limits correctly for dm-po2z target. > > But DM revalidate will be called for the target AFTER it is setup (after > its gendisk is added). So how can DM revalidate see the incorrect zone > size ? If that is the case, then the target constructor is broken or > missing something. DM revalidate zone is generic and only allocates the > zone bitmaps for the target device. There should be not need at all to > touch that function. > I think this is a cleaner approach using features flag and io_hints instead of messing with the revalidate zone function: diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 135c0cc190fb..c97a71e0473f 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1618,6 +1618,9 @@ static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev * if (!blk_queue_is_zoned(q)) return 0; + if(dm_target_supports_emulated_zone_size(ti->type)) + return 0; + return blk_queue_zone_sectors(q) != *zone_sectors; } diff --git a/drivers/md/dm-zoned-npo2-target.c b/drivers/md/dm-zoned-npo2-target.c index dad135964e09..b203be808f09 100644 --- a/drivers/md/dm-zoned-npo2-target.c +++ b/drivers/md/dm-zoned-npo2-target.c @@ -187,6 +187,12 @@ static int dmz_npo2_end_io(struct dm_target *ti, struct bio *bio, return DM_ENDIO_DONE; } +static void dmz_npo2_io_hints(struct dm_target *ti, struct queue_limits *limits) +{ + struct dmz_npo2_target *dmh = ti->private; + limits->chunk_sectors = dmh->zsze_po2; +} + static int dmz_npo2_map(struct dm_target *ti, struct bio *bio) { struct dmz_npo2_target *dmh = ti->private; @@ -233,12 +239,13 @@ static int dmz_npo2_iterate_devices(struct dm_target *ti, static struct target_type dmz_npo2_target = { .name = "zoned-npo2", .version = { 1, 0, 0 }, - .features = DM_TARGET_ZONED_HM, + .features = DM_TARGET_ZONED_HM | DM_TARGET_EMULATED_ZONE_SIZE, .map = dmz_npo2_map, .end_io = dmz_npo2_end_io, .report_zones = dmz_npo2_report_zones, .iterate_devices = dmz_npo2_iterate_devices, .module = THIS_MODULE, + .io_hints = dmz_npo2_io_hints, .ctr = dmz_npo2_ctr, }; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index c2a3758c4aaa..9f3a4d98a22a 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -283,6 +283,15 @@ struct target_type { #define dm_target_supports_mixed_zoned_model(type) (false) #endif +#ifdef CONFIG_BLK_DEV_ZONED +#define DM_TARGET_EMULATED_ZONE_SIZE 0x00000400 +#define dm_target_supports_emulated_zone_size(type) \ + ((type)->features & DM_TARGET_EMULATED_ZONE_SIZE) +#else +#define DM_TARGET_EMULATED_ZONE_SIZE 0x00000000 +#define dm_target_supports_emulated_zone_size(type) (false) +#endif + struct dm_target { struct dm_table *table; struct target_type *type;