From patchwork Fri Apr 21 03:55:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9691751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C8276037F for ; Fri, 21 Apr 2017 03:58:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 202712848D for ; Fri, 21 Apr 2017 03:58:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1401B285E4; Fri, 21 Apr 2017 03:58:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 763062848D for ; Fri, 21 Apr 2017 03:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035043AbdDUD47 (ORCPT ); Thu, 20 Apr 2017 23:56:59 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:36240 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034984AbdDUD4Z (ORCPT ); Thu, 20 Apr 2017 23:56:25 -0400 X-IronPort-AV: E=Sophos;i="5.37,228,1488816000"; d="scan'208";a="114480064" Received: from mail-dm3nam03lp0015.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([207.46.163.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Apr 2017 11:56:23 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/0gsoskA0Xo9T7Q2fnNrw4Vy6ZgXIuilPuWYxqdHajo=; b=EwulSfH7aR6GIeL6/ZY9VBP4OQjkjaBK/bDLDgmjL/Ej8nBrg1uHqPjMiyCGrKPTm7jOr4mewAUH/GT4hIyOCcDjKnq/zM4eRtKBJtcfT/MCnvoVXU8CH7DIppQhvLixjWF7loBv+apn82FD7ceIlXuF59lTtgEjk4REHVoN8rc= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=wdc.com; Received: from washi.fujisawa.hgst.com (199.255.44.173) by SN1PR04MB1983.namprd04.prod.outlook.com (10.166.69.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Fri, 21 Apr 2017 03:56:20 +0000 From: damien.lemoal@wdc.com To: dm-devel@redhat.com, Mike Snitzer , Alasdair Kergon Cc: Hannes Reinecke , Christoph Hellwig , Bart Van Assche , linux-block@vger.kernel.org, Damien Le Moal Subject: [PATCH 03/10] dm-table: Check block devices zone model compatibility Date: Fri, 21 Apr 2017 12:55:51 +0900 Message-Id: <20170421035558.2657-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170421035558.2657-1-damien.lemoal@wdc.com> References: <20170421035558.2657-1-damien.lemoal@wdc.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: MWHPR10CA0052.namprd10.prod.outlook.com (10.169.238.14) To SN1PR04MB1983.namprd04.prod.outlook.com (10.166.69.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86fd52fd-45dc-47d1-2938-08d4886a5fcb X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SN1PR04MB1983; X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 3:yRiBvnzGoGLvc+IAOZjNZ4EOF9XsInf2TqGLLlZTN6IUP64UnmQ2tubRkowlv5pdfsBVCU8Ks7CZYUn2yC5/jmw6iLvZyJGuxpOq3zJWczBOqIvUiz6EEUqj2fo5lFoKUpWpUgXGAtjLGKwqRdcap1mn6NODFl2nSbS4ok/W/B8HsI4mwp2oanO9Dt0KwjEQnzscdM5neLU3c8GT7pUlJYv9yQq9fxba0KtrMZTgTpdY6jQLuuPedzOkdqKLGEUM5J3XQriu3LAUdMZGjRAsLp2BbN828FnHPm4JciCzhzyA9f8q/7U9GfTkwfJoUkoutFn1bjxVbn5rsgmfcle5P8LHIvgOsggcJ3HP86eofNs=; 25:eupYIJdgm0F5LElptXCf8iIcorv30KYNl1YCmGWshhzRAUALJkOrlAwhRHkVRuCKWXSXWzmAehZhX/VHgMa5IEHJzfW/tbtzAxRfwZ/UlXVz4jg4HOegI+tn9YatJP2TCDo5BTWxFUU3vw/1T264f2lY/U1iEcVSDQoqb0wmUHT7G5kdkhUAjJF3md7rT+eMg7MaxNBXP1hCHiafnDFjrOBWcMNopvEA8u25vXN/ZJh83beahkdxJAFq59oGtl/hx3XEkuaL71qEh7j/vF85ElMSOhZQjw03NLigpXaRM5QVeQuHLQ1rCLKTrF7X6dNRTDWKO3qxiGlejabBYQloMQQ58HJ8YPUTzpcV3bHc7MsuFeiMRXQ2QANSfMxyHWMKgKeq1RXtF8LAY0CV9M79+WfuxnbEAZo7imxf7FJ08Ozl4J/Oxdad8Z67Iw0XA5Igc69rfgE3nLxEMFRGTRBS2A== X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 31:0S2+RWSvbCb9cpTVVKYiTYEV3wf9AAbhhvwH6423C2OjpolxojYRpVo/XQOJe+fNkO2q+pvLr1AXlXBCoNSnAwllEOf5GhzkU/YprXwAC+6qd/k96QWes+lCJu/UEOecJSwZVFALV9gWcWkc7bzHyi6JkWdk3Abm61QkcjINWtEfTAm8H8K+tiSc6VsMN8E0bSrMqyEQGTVdusRPUkSW84NJSUKAu2VSt+xjM9i7IvXd/u9DOTdOWe8w2D4QzjHg; 20:6A/QDQQeG+jSunj0LeOECZ1aDUDqtXYyaFpLmsBx+LbAgBR1NSX1xQ4VAZL1ExAaFcPWtDTg/1EUmitm6UmDVroiNis4mFAyTfcicqQUjrCbAuNi/DIq4A1D3CkMiJuGpu4u/qXLra2LGaa8r0KEA2U0lLeHOY2nb9ItsqpeCy7Iy9Q+fgDmlGi0d7lhXxj1z8xYAS6utdyDNhL8XH7zySP2LhwnuEGHPf4NGGktIxZ6MAj8q45Dw6SLRCUB/6YIs2Zniv3vfpEK2HJ4945o0hNKoGR1DzMFDwHkFdSVxmLv4zZhob+V8Xxy5xC8LbMeE1P63P8V01KYOgwUgYsnfrLUUNYwe3hltoOe4ErTO7vu7oeHIypciJnIAC2/k4awJ35DxmkzTZkIQ0VIOownYR8HM0JDHglzmUeh83OtX1nxBW/YaM9miHpmiSoRxxXvLTtIN2rHYxqJhuY1IKN+rK/80H+ZcVLifLjFzEtVCbiu7IH4luum/JBg4ho+RJYD WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(6072148); SRVR:SN1PR04MB1983; BCL:0; PCL:0; RULEID:; SRVR:SN1PR04MB1983; X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 4:RiWA9RjEGQlEEW7gQToiRLyDV+p4etdhspMeYwZIn0giF4uqyGTrVr7pLuFV5cxA1WaA7OcemuKQK6jjwSkjq/GnsNNh/JjJFB+2cb/JxBirOTMDYygF6z0VbludFEHq23tLEBIfsJGF/Tm7EZWI6XILVvFc28ybpaC5nLDCmdInLpfOWuUGhh/AKHOsUeo1dcsLp8pf2iW2tHY3/tJsKZTF8N9sxLJFCeiCzMlRXRvPfFMYVzh2J8buPvZI+dnumVHA9Reqr+bRbWFZPm/3hyRBNrCUdDt4kBM8n3L7K8hNZMsjQlQ+gdiPDk0/QUzZMyTWoj08bJdOKdLca8JeaAEAl4GKmzPVHcnJSSaIsrgjdPPbb2C8HUSafbHkdbGHhSjNzfpHqSL2uxrbNRm3saGisQogrW6fok6k3GAdgilALx7WaoijCBC7HpuucSWaaPqgFeVZ8ZWAmR24FrBRhFfDTRVY142soDEfN13/TsniEViVr4DB3jIZjAxGoSY+FKFom/8kwWX8uwuKPs2Jzgs3DTh7g44cA+zi+cnqMwWh/YrIArzU4M39xK9tC8fI5y7i7fbAM2H2viWpNcesff5Ks6G1V3Kxt2atjPKDQhTbziC8yxphk2rikWFF9gwqKrLvZ44x5ELjNhDm/MvIeCk78gRooev9mDSoxlt+I0a0sHfiFRXvAX+lJn17qA5+vmYbxD4CbwRBUAThMBXJBvFRA/MvAuLvGFTIPO3u+wY= X-Forefront-PRVS: 02843AA9E0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39400400002)(39850400002)(39450400003)(39840400002)(39860400002)(39410400002)(8676002)(5003940100001)(50466002)(48376002)(3846002)(2906002)(38730400002)(6116002)(36756003)(86362001)(4326008)(575784001)(50226002)(1076002)(6636002)(2950100002)(6666003)(6486002)(305945005)(6512007)(53936002)(47776003)(66066001)(50986999)(54906002)(189998001)(5660300001)(76176999)(85782001)(7736002)(9686003)(33646002)(25786009)(42186005)(85772001); DIR:OUT; SFP:1102; SCL:1; SRVR:SN1PR04MB1983; H:washi.fujisawa.hgst.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR04MB1983; 23:WjStntMnLsM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QG89+6zXsGp4QwQwPa6g+Mu5j2XHofTh6SQ/347/5SPFUGdKsCnOYqnk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR04MB1983; 7:adeVoh+VWtys4eWH9d1xbZCVH1ARiQnp3+rrimxt13+Cig7t2CnDYsFISB+Cxgw9IP8WGvCRkdCC325rd1ZoS68fXEdkKXQnchCLoAdQb6GE+OxfEU9emAa18MQn1oBQURpweYoIDwZFhCOVUqqRVojRGbx/FnsYN4Bei6/CXfy/ZFi7L2H16fZIE+Zq3583Akq1M5HaUXVXPMaOAWmjNqPTID7+yh6b8OvCdf0aWZ3Br0Vto5UADsV1C95mOgitHGEuqcz+AgtV/u74rLN+AgY2GQ21JSNVxqR+ij7MhHlTjOtNzaDTr7HJwtEefSHL4eWg4yadpQFpzRlCZgq+Rw==; 20:PYKtsiP/IZZU/i27XnE+AJDljKqFMbG2os+kQNzeIkrfntcmPW8aC/PIUS/SuXwwqMfFw8bo0GwYnoiQB443eK2HMh6CG3bIEKj+q3yrIp/7rYcXm3udE/ZDNS3EPfmHgxIHCDmwrAvfVSOq4unsuhd/jEuBy8kB2lR6lAkQBm8= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2017 03:56:20.1457 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR04MB1983 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Damien Le Moal When setting the dm device queue limits, several possibilities exists for zoned block devices: 1) The dm target driver may want to expose a different zone model (e.g. host-managed device emulation or regular block device on top of host-managed zoned block devices) 2) Expose the underlying zone model of the devices as is To allow both cases, the underlying block device zone model must be set in the target limits in dm_set_device_limits() and the compatibility of all devices checked similarly to the logical block size alignment. For this last check, introduce the function validate_hardware_zone_model() to check that all targets of a table have the same zone model and that the zone size of the target devices are equal. Signed-off-by: Damien Le Moal --- drivers/md/dm-table.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 6947f0f..4683cb6 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -505,6 +505,8 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev, q->limits.alignment_offset, (unsigned long long) start << SECTOR_SHIFT); + limits->zoned = bdev_zoned_model(bdev); + return 0; } @@ -720,6 +722,96 @@ static int validate_hardware_logical_block_alignment(struct dm_table *table, return 0; } +/* + * Check a devices's table for compatibility between zoned devices used by + * the table targets. The zone model may come directly from a target block + * device or may have been set by the target using the io_hints method. + * Overall, if any of the table device targets is advertized as a zoned + * block device, then all targets devices should also be advertized as + * using the same model and the devices zone size all equal. + */ +static int validate_hardware_zone_model(struct dm_table *table, + struct queue_limits *limits) +{ + struct dm_target *ti; + struct queue_limits ti_limits; + unsigned int zone_sectors = limits->chunk_sectors; + unsigned int num_targets = dm_table_get_num_targets(table); + int zone_model = -1; + unsigned int i = 0; + + if (!num_targets) + return 0; + + /* + * Check each entry in the table in turn. + */ + while (i < num_targets) { + + ti = dm_table_get_target(table, i); + + /* Get the target device limits */ + blk_set_stacking_limits(&ti_limits); + if (ti->type->iterate_devices) + ti->type->iterate_devices(ti, dm_set_device_limits, + &ti_limits); + + /* + * Let the target driver change the hardware limits, and + * in particular the zone model if needed. + */ + if (ti->type->io_hints) + ti->type->io_hints(ti, &ti_limits); + + /* Check zone model compatibility */ + if (zone_model == -1) + zone_model = ti_limits.zoned; + if (ti_limits.zoned != zone_model) { + zone_model = -1; + break; + } + + if (zone_model != BLK_ZONED_NONE) { + /* Check zone size validity and compatibility */ + if (!zone_sectors || + !is_power_of_2(zone_sectors)) + break; + if (ti_limits.chunk_sectors != zone_sectors) { + zone_sectors = ti_limits.chunk_sectors; + break; + } + } + + i++; + + } + + if (i < num_targets) { + if (zone_model == -1) + DMWARN("%s: table line %u (start sect %llu len %llu) " + "has an incompatible zone model", + dm_device_name(table->md), i, + (unsigned long long) ti->begin, + (unsigned long long) ti->len); + else + DMWARN("%s: table line %u (start sect %llu len %llu) " + "has an incompatible zone size %u", + dm_device_name(table->md), i, + (unsigned long long) ti->begin, + (unsigned long long) ti->len, + zone_sectors); + return -EINVAL; + } + + if (zone_model == BLK_ZONED_HA || + zone_model == BLK_ZONED_HM) { + limits->zoned = zone_model; + limits->chunk_sectors = zone_sectors; + } + + return 0; +} + int dm_table_add_target(struct dm_table *t, const char *type, sector_t start, sector_t len, char *params) { @@ -1432,6 +1524,9 @@ int dm_calculate_queue_limits(struct dm_table *table, (unsigned long long) ti->len); } + if (validate_hardware_zone_model(table, limits)) + return -EINVAL; + return validate_hardware_logical_block_alignment(table, limits); }