From patchwork Mon May 1 17:53:07 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: 9706757 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 168DA602B5 for ; Mon, 1 May 2017 17:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B62227D4D for ; Mon, 1 May 2017 17:53:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F22D1208C2; Mon, 1 May 2017 17:53:50 +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=ham 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 707E3208C2 for ; Mon, 1 May 2017 17:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750722AbdEARxu (ORCPT ); Mon, 1 May 2017 13:53:50 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:9617 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdEARxs (ORCPT ); Mon, 1 May 2017 13:53:48 -0400 X-IronPort-AV: E=Sophos;i="5.37,401,1488816000"; d="scan'208";a="14484654" Received: from mail-bl2nam02lp0086.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.86]) by ob1.hgst.iphmx.com with ESMTP; 02 May 2017 01:53:48 +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=XNUYP1Y62e+EpTRSRrYObEgyc+aLntlp+OOT0QsxQ8o=; b=mF/ri+rqUqG1kyPH2gCC8MhEq+7U6wHK4VtDKqXdrr6T9mgLJ1M7J+/dEdg39pEqFtRlVUrug+mDwfW9v9CXTLUqpvA6R6NPwUpt3SJ3hos5E8kh2bgw9VqjZefZvjIYnS4+4Ekt292o1Is6RlZadzE+VBTav0vq+zSpuF56+kU= 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 BL2PR04MB1971.namprd04.prod.outlook.com (10.167.97.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Mon, 1 May 2017 17:53:42 +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 v2 03/10] dm-table: Check block devices zone model compatibility Date: Tue, 2 May 2017 02:53:07 +0900 Message-Id: <20170501175314.10922-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170501175314.10922-1-damien.lemoal@wdc.com> References: <20170501175314.10922-1-damien.lemoal@wdc.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: BN6PR1301CA0002.namprd13.prod.outlook.com (10.174.84.143) To BL2PR04MB1971.namprd04.prod.outlook.com (10.167.97.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49254ffd-9eff-4d28-4fc2-08d490bb02e6 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:BL2PR04MB1971; X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 3:RwyyBqcTyjXIDLaSttlGcPcLcesGKRhXjWlea1m8pMUNl7z5VTwjAavkqx5q3agMu/L3puhomw+EcrSGeEjhSsYSRCM7MrGbHa1BS0AqfyjBgKBluXdNMNzs5bh+kY/FStyXPwJ12e4CvEiOsX+V4E8mzyaWQnGpiDOwzR4PvONf6M2KKeXPmwukOThgVabNdv9/OHksqbgWOxowCUihKUwWB+CdyxzWjHFFVnt0+IlduSpTkmLT4tJ2PzFQK38+BBn9eM7qnvr96I8Anm87Vi0rRNUzhIgOD5uqlAMXLZH9AdxiU3B40Le/Leyf+vYoBmXJtWt/3zlVS6ft/MXXGoRlxdzEPXpDAGi7gu6Vs2c=; 25:cVLWls9Kur+8gejgTumOGvs0KwjBepbTYLYnm/GD9u7ggJcKsNtKZQCpltvdDze4tJxNP9TE1mz8qw8O9maMilr52KrENj1f0gIAOEALv3lXRMCuEjsWx8BftUopkUdCaFaI5bW8iUBSzZTSDiJ5IbHSH46Yp7g9i0Tz6Fxf9mx+QA1TlX9e6mWlRePlAMFbkoWlbB3RwoSznIvcG0Px9f0kyRd5K9uDumr3w1q5bAnnAAVJ1FPl9iCG7/YZka/J1npvoIUd8hsyeTfcogzGx2al+6SI2Ofgg4dxc8/67/CGzRkc38AJWj9BteMgRJ02+L5kwYfukcmtFH5GirJVFUHgUuabyBuKexAV4WMjpm7tbfbCJWnQhXsx7KwqONq0jsZWB3XfAKmU7SEfSskqzXY4xR4k+QwS6xmZH+BB51Y1b2/jsvDkVHlQ8CPP9g4DZVoaBCAASrRvzF7f8aunJQ== X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 31:sFPKtyzK5dOCFbmcr7/0GzznJCDpnlXluen7mflCCKprIbZoG6PYLrGoVCRWQc2sio/AIyZeThZqMwsnH5bAiWod3CLhHkdmWNogHgIop2RVNCjWlgLaRwx4tF6c5lOKECQO6U0l6rFklMesA6plKnLj2bLx+b3i5cJFCuS2PPG/1n4nDoXgZc6stRpycq2Z6uKbHVTsEnT5DvmyQVW9dD3iqw3WTn3lu8U/BKNFObRIEUDQp4xAeP402ke043PA; 20:jvrjlLzHy7GLF0EKx1K9pWDP/Pq4eakOT77qWQ50mvNQqzv+8y27ZuG3HrJPl9s9i9Vo0kUQAWdUlmPWbJvIEX9JfxsB/w2hdJ5qGvmp69gLZSLFmrs0K78U5WVlFz8tzDQE3D4h4RRSNOS4HrMh2Xw4VKzyLQnJ8SQ7MZVcNOj0Eij7lZfBIetJZw5brJp+NFsyj10Qnur/9iNmon4IYilyHc9ERVfpac1NwEvTSsRxvaqyddUVEZyBXefBbKOSItGLsbUXKvZJqjL88XUm8pTFEptpVZs4sYoY3C8KuW2Mf5JAWM5BwdTvquGTza/mkhvBFzh1m+GAJHiktioCnGjJWnCjxwa6H32QfVhBAQ22Mq3kfU2Iz94j0k2/WKJBLgAoSvJ1BFcpP2ISjvjoDMcaaVyDyWZqHn3J3AqDiB/jExr2g6/f4OV1t637BJp8X/Kjj69Q1K7XOthPyRNK1/YnkJ3IZ0HjEGUGw7wwLndI5wglfAKXAGHdpG6YFkJl 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)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123555025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(6072148); SRVR:BL2PR04MB1971; BCL:0; PCL:0; RULEID:; SRVR:BL2PR04MB1971; X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 4:OSfx0vAainMh9bY+H/Yg3mCskhtP045A7l0tYjHwuoQeWxvy0zKo02G4qoa9Up6hfLI3DQWfhNHHV3SFhc7ICWLImeZtoWLLatjESA/qhBA1nFYpchb6V8pBocb4GJBkAG9sAWd4/yLs3K0QmFWyg1Vu5ig6O7aRsy8//LapIhTN2ne6hRoF0EoDqz892b99XUaiRbWm46zLt7caRWEzd2OGV9ooyDCk86//cbza8qoT+R2fWFdFRsSoqjHwIbIoBnjEBBcOqrNiW3GPeIgk/9oBpimeP57V8YG+DsAE37MbPrk1cSAUY8u4XtlMTdU159Xp87o70TCaR0aynya6loXl0xSWI/JMFXLX+QJsiqxB3yhGMAbZfvGdAYtjMJunAfnFJZlOD6UGsXCPhL2IqPlIB8csdsP+qMM3PU0IEKpqJYehlJ+KZUaUJxmCmpIjm6aHn7BsPUpx61a+al6Qrzg3J2Qb8++s8zco4rHVTPlxIAhNHCfPFWxo6OVcE2gGpi4NIB3k66NJyXDZSVEioiaq6Ysmt23ErJ5nzZq73RC4OOrRu3Td7r5D948uN2zMwN39+YFSzQtli6ZR9ZjojdyAZUT9Mw2DR3eQqMw+3oxmze3PWg+Kr5CLpIH7oeqPvJU0xEeRNrHLoaiOAhTSu/ZiGGmJuCxSErbIkZ24M7yj4dywuhcBa3F204YwP//f+S78mrIFjSsVALG8/SCcc8WPJlOmvztzAdB9fhk24iw= X-Forefront-PRVS: 02945962BD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39450400003)(39840400002)(39860400002)(39400400002)(39410400002)(39850400002)(2950100002)(47776003)(50226002)(85782001)(25786009)(42186005)(7736002)(5660300001)(6636002)(305945005)(81166006)(6116002)(3846002)(8676002)(33646002)(54906002)(6666003)(53936002)(6486002)(9686003)(189998001)(6512007)(86362001)(575784001)(1076002)(50466002)(2906002)(38730400002)(48376002)(4326008)(36756003)(76176999)(508600001)(50986999)(85772001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR04MB1971; H:washi.fujisawa.hgst.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR04MB1971; 23:64O+n9hSaSxDJUDdwCh8mVPmrcyjpP5CpQR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LmNVbV5eafU6tWlZ4vBSJktA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1971; 7:EjWOIXk7KfAANu6H2irn0z+EtwW/KE8xdgw0jJoILHEZjcVNiWns2JDcZpf6hcdOMxG/nrDCF7QPIlQZxwhjXvIxWZG0OC26AqDi9l2G3HbRTocmALPruSeUW7VCV9i3Ta2fCl5KmMR6dWhTN5lojBvas/71FXC+uUqWTmRwjqW+PFYf4RBiDXnw4kfCRMgeof2XfAYjbgkR+au4AkdXa68FspOEG4aB2MemMZWdEzV7QSodUlgViHtb2VO51eDuJEPi3f/lvup+XioCacInWbgwVRawk3owbCkAeMQMn4qZfLYPRBeeevDAYzi/eNJyoJCv2TwrBgFrUM342KyLfg==; 20:4wogECqGU/MMU+Qwf3y0aNkVg7RIWOmdf0RQWQymvDecxYOLZmNShX6c25kYhrK33nZ8fDxkDoqXhzK/vZMYmQswzh8YVOFp+2358GEWjOUvRbbjKo4BoI+dIPeV/3aQWRAB9JIstiUHnfA/ZxMenBUSmJE9ixxBx4NM27J3THk= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2017 17:53:42.7157 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR04MB1971 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 Reviewed-by: Hannes Reinecke --- drivers/md/dm-table.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 6947f0f..cc89a78 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,94 @@ 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; + + if (!num_targets) + return 0; + + /* + * Check each entry in the table in turn. + */ + for (i = 0; i < num_targets; i++) { + + 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; + } + } + + } + + 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 +1522,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); }