From patchwork Mon Jul 8 09:16:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13726307 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C596D7318A; Mon, 8 Jul 2024 09:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430244; cv=fail; b=mUvFvcm2yUkHM/N+6PuFzJUJbESm/r5AyWr2N4ufeQWjU2VTnOLtOYvE1qu4xx5RduXccX32tHMaDqiZ5YhuTI3aFsGQb0DXiUmmrEeHhY1BKLfLRVZc4dBNvPIUB2T+7fjpH1u7/hlApKqOXhHOXVBTPov93t3eVsM2SCljExQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430244; c=relaxed/simple; bh=N8Fdwd/uZcf1fpS7HVApvXC0RRgMRwjmopzGOinvZTI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SfqkG2N+UtRgl4acWy9Kmvf/BR5TWRHfkGWHy2d5TL4deqlEPr1bbCsasPARsCD6/rHBGPKzjCiRo1S7GctY95T3YohI1dvnCCi4ClkCybn0ULnCLhn7csIY9L/9+tQket3a09/t07kqhwW903zPVOyz7K0HvBrUk7lpe4HbY/M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=MM/QWcEi; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BcDdy6iS; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MM/QWcEi"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BcDdy6iS" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4687ffJV011980; Mon, 8 Jul 2024 09:17:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=tr7FY/2db9YsQPfXlk3ssa7WIQSMOzgNKUP9pLpTgRk=; b= MM/QWcEiM1KPjRRtp3376kE+jJpciPIuh3NHes1yA4SA1RBe7Z3jI1ouKo88GrUd 5gnx6dcBwRTvOMGDIisdyON3E1l7OSN5DTJqaqTvaiG9jzv3LyUuoJA8vUlyYuny vvEHQ181vXxpJOFsRpZu9WVSzIQIlgbi8G3yE8taKSJjWhKq+s9nEdavLkAqlRay GgDAoD4QJu/AEbQkIljkGoz9VD9HdemIiS72bLCWCYJwC9mQRQU54GM8AxUcq61b R3pv/MRVLsHU13H2QJV1B3zGZGZaX9DWpEiblSxqNQZk3Pe5PlR6yd5dDMWwC7ny kSpdwNAWcqQ2bPvlpCMgWA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 406wybj6r6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:03 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4687FHQb005608; Mon, 8 Jul 2024 09:17:03 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 407tx0vxf5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NCTYsB0/O6n0ZNupuTbWqfuSu9JYKLr/QHpY+c7HHLRoyAy1kXzkyebvQzhdr45JaaWwfi/cqlthWieFZu6t+GAuwllAs014GaOOImY03d2n6edOvwOOuq730QqnlkX5XE8SVTVAJIiDuA9ZBidSUfFA/AKlIyUJxJsia0P5J0RY4N5cx7O5sVhkFlFpgC0Mr0my5DNuUfr4L4sou0GSbvejXBpsB+jiuBH8kTNpya8hg0H+sWCuT5MTJhByMhVfFPt7v0zHW4VaVScOo41Ai6+ikxS2FqWJKWLdYUtznWDcwLkXC1QaD92Yyayux5btrtXf4/FVguaFG18kov+KgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tr7FY/2db9YsQPfXlk3ssa7WIQSMOzgNKUP9pLpTgRk=; b=Na9C1gOZZIJubsV6eLfUzQ+A7kUtmYOvyYV/9fna8+/JoVWu+cLOp7JLcXy4XlleDGTHx144sJZQUbMCtCKvSO9VicV+zW3GlD2cTzIEA+DnD8MWGNnEMCvtdJ0Vrki75F04dZcFZgq9dO5qudSAnHmRFvl4sXrSGKyEi5LbxHZk/SojMKoHxxu843OsT8djug0w6KYF+ZPTIheLceqZR/XXf+R9+JvV8EcYqSX7BBTRpI6/ksGu1Mlvx63lYSYST6h2oggbeVd4X8zfE11t+tvTV/i6A54/tmMjstSPt+xRX75zPka6tWh8qmzf67wWWGR56UOiKa7cjqCmU2Aftg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tr7FY/2db9YsQPfXlk3ssa7WIQSMOzgNKUP9pLpTgRk=; b=BcDdy6iShX3u0FZK34GIZPF/oRA6SGW/IgBWRMvVeHZ1WCyrfRA46xe1PKKJJjY6CtKD2/wIBFwt8SxwOhUXLQ4+HYFcZ/ZWLWv5E+8ziH2wh2CkNvmfHk/R6tc/7Czh+d7LaxPRaTBpoG7r5wHL/1yAoHqQZYt4MFDqnmryCAI= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6799.namprd10.prod.outlook.com (2603:10b6:8:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 09:17:00 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 09:17:00 +0000 From: John Garry To: axboe@kernel.dk, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, hare@suse.de, kbusch@kernel.org, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, John Garry Subject: [PATCH v2 1/5] virtio_blk: Fix default logical block size fallback Date: Mon, 8 Jul 2024 09:16:47 +0000 Message-Id: <20240708091651.177447-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240708091651.177447-1-john.g.garry@oracle.com> References: <20240708091651.177447-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR13CA0021.namprd13.prod.outlook.com (2603:10b6:208:160::34) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6799:EE_ X-MS-Office365-Filtering-Correlation-Id: bfeb0657-6cb7-47b9-a823-08dc9f2eb8f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|921020; X-Microsoft-Antispam-Message-Info: 7fwXHlBDApuM5eOll/+veY+U37L35g7pGsR0/lpxjj4JswuCdU2rlQCchAe9JOFeIPFbEqLT+BABcGHoUwlt9diJaBUGRT5Qt89x5qJZzwSMnb6oerkYYG7UJcy0Gqw2c8GpaRVtHsJnH+V9q7qpqa0NQNh+nLfzHOtMdvdZYEXes12i8DwgnLqxPsKgLiOsDu/+DAhavJHZm7Nr/Dv/IX2F9q6aboyemEP94ZGovwbZpqeTXiSKEzduEX4tafhQeMkj0vgOZPQ5EsR1V9e3VxNA0KesCdalwJg2Ddj7/Oy9F2mpeMVWgern0txnbWRhulD3VjwCYr8mhoBCMox6voUvIGaokGyoVMO6xT73ncJWdfDUwQ3Bc/JkCxpqTM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;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c1QCwW1WXkqH7HCIFSrgME86IFPjrb9i6efOauUcEDLOov2EeU1eltyUYTzeiA/aOBpYsYi8dRF9LLfghmExGxm132K2ooQBWSYE5Q3PNNKH7tMVQiffcKDx/G6pPg9WfzMFwY7bimr1afsPz7w2Y9RjWn1r+m8tG/RhzMXga3T8EG8U728GoGA0OjZlKNQNTEsMXUI3IsA/31XuAvpz1skKyDVjw6RD0XDckaDTyEw6TejJHlAdtJbUZYqu8qEAI6fPXnU+ti3B/11zFH2PuK2YG8rZOkQLckRmOuTCNxo6ZscZc7eoG5ZorQFKoqPK+xqaaV+WDCrkS0jA37/Mm36LDtBlXjorzGmsC+z73MqJNPZei1UuJjvgBq9xfeHhn+72yUoHQEzI8bvyPKVe5U+gOYZbVkFp8sQhOVXvCgbEqeGgZn6xmoXlTGuVGkbN/NCjMenaYuu/yDN4xP/StIeJ8zk5gCM7sqeoZH3HKLvwvzoZVfSiiZwJDSlIZTMJ/UM5Q+klMi362SRq4GSLhKPAWwo+HHgfunq9LRrXj9PBfyNLO7MbzALpuPJPeM5Uovd0qOXHHMTEJ8tOFy74sgVCByfrT0Dh5BEyHvg0ZmywTjjxqJ5y7h1k+fhwO3O2NmIe6gwzNSfNPI27Xlio0EKMaHnvpgBUJroTTBU3qJm25jma8A9FjHJN/9S7X5yW95fNHvuDIF/fO0RMlAd7MLI0CjtN8q+wySZUksRf10rF5t1HTUbWQKbQ320aPAZi+vOrJFSlTJpAr0aiEb3Wa2jxS5WLsWuGue05i4bkj3PNijP/rwAa/9RMRQwhuIXqeujAnFTsendF3ZcxifNgQJW7AiipTXCHYNQ3NiN26GPRFgd13TApCzA+PMwjmM//M0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edAGEMNPKGJydS3bX0FvRUDrlwkT+dJqoyGs7K+z0yAsWyzlEiaV92NhLQt+ns64yXS/T6dQg/WsQhX4Qznbgp746j+GHIresANN32+02YYFBB0uMndW3nEkwMC438yQsLqjZjGk4uXzyyUm/oIDHI5vSljifC7On4qJokFhPxy1RXfad1QjnigypmiW7Ymx1Yz3tsLrJwytHTkUWZ9muU1CtoFvo/QwJrrfhpPOyGLQ9xBQj8x7vVz9Njzh0o0mkQXvv8+KRXjuDSufn2gevhhj/kmCwSVGGQexaf6WhkOTYsgcoNtFL2rlHsz8FiCE+6uaLOUNSxSTZctmJIoijZzGmhKK5SLCG4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfeb0657-6cb7-47b9-a823-08dc9f2eb8f5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 09:17:00.1120 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vD7c4Lg/iNCzI7gBBGU6ZSVT1XTaWDH8n8KdPczyd6paamhx/W8l3bKOosQhaCC1DiXyLUZK8dTUsj1NwbpgTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6799 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-08_04,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407080071 X-Proofpoint-GUID: cotluPGEYHfrfq6TGqhtpcXqohOqVo7y X-Proofpoint-ORIG-GUID: cotluPGEYHfrfq6TGqhtpcXqohOqVo7y If we fail to read a logical block size in virtblk_read_limits() -> virtio_cread_feature(), then we default to what is in lim->logical_block_size, but that would be 0. We can deal with lim->logical_block_size = 0 later in the blk_mq_alloc_disk(), but the code in virtblk_read_limits() needs a proper default, so give a default of SECTOR_SIZE. Fixes: 27e32cd23fed ("block: pass a queue_limits argument to blk_mq_alloc_disk") Reviewed-by: Christoph Hellwig Acked-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: John Garry --- drivers/block/virtio_blk.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 84c3efd0c611..f11b0c3b2625 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1250,7 +1250,7 @@ static int virtblk_read_limits(struct virtio_blk *vblk, struct queue_limits *lim) { struct virtio_device *vdev = vblk->vdev; - u32 v, blk_size, max_size, sg_elems, opt_io_size; + u32 v, max_size, sg_elems, opt_io_size; u32 max_discard_segs = 0; u32 discard_granularity = 0; u16 min_io_size; @@ -1291,44 +1291,43 @@ static int virtblk_read_limits(struct virtio_blk *vblk, /* Host can optionally specify the block size of the device */ err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE, struct virtio_blk_config, blk_size, - &blk_size); + &lim->logical_block_size); if (!err) { - err = blk_validate_block_size(blk_size); + err = blk_validate_block_size(lim->logical_block_size); if (err) { dev_err(&vdev->dev, "virtio_blk: invalid block size: 0x%x\n", - blk_size); + lim->logical_block_size); return err; } - - lim->logical_block_size = blk_size; - } else - blk_size = lim->logical_block_size; + } /* Use topology information if available */ err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY, struct virtio_blk_config, physical_block_exp, &physical_block_exp); if (!err && physical_block_exp) - lim->physical_block_size = blk_size * (1 << physical_block_exp); + lim->physical_block_size = + lim->logical_block_size * (1 << physical_block_exp); err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY, struct virtio_blk_config, alignment_offset, &alignment_offset); if (!err && alignment_offset) - lim->alignment_offset = blk_size * alignment_offset; + lim->alignment_offset = + lim->logical_block_size * alignment_offset; err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY, struct virtio_blk_config, min_io_size, &min_io_size); if (!err && min_io_size) - lim->io_min = blk_size * min_io_size; + lim->io_min = lim->logical_block_size * min_io_size; err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY, struct virtio_blk_config, opt_io_size, &opt_io_size); if (!err && opt_io_size) - lim->io_opt = blk_size * opt_io_size; + lim->io_opt = lim->logical_block_size * opt_io_size; if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) { virtio_cread(vdev, struct virtio_blk_config, @@ -1422,7 +1421,7 @@ static int virtblk_read_limits(struct virtio_blk *vblk, lim->discard_granularity = discard_granularity << SECTOR_SHIFT; else - lim->discard_granularity = blk_size; + lim->discard_granularity = lim->logical_block_size; } if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) { @@ -1453,6 +1452,7 @@ static int virtblk_probe(struct virtio_device *vdev) struct virtio_blk *vblk; struct queue_limits lim = { .features = BLK_FEAT_ROTATIONAL, + .logical_block_size = SECTOR_SIZE, }; int err, index; unsigned int queue_depth; From patchwork Mon Jul 8 09:16:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13726306 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C599F73459; Mon, 8 Jul 2024 09:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430244; cv=fail; b=tQ8goQROtG8VVkZqYYe7/aPzkkk8wLsJo7n4GGXxA+6g6rxrp8UOqQcF9kY8iDbZ3Em3r9+W1FiCC3clPQOUxjOTELfazjvrh+w0zjvzSXLHj6OhQ2AyEEBA3OosPWvuITYkTm44CXAhcnXTOtkk46Mqz189LetO5jYYdK9glWs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430244; c=relaxed/simple; bh=MIDlf5qR41P2BYlbuUuNHrlqFaUR7cS9PsnOwU1HzEE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nVWPVlKc7TqbplTb7HrNriINXn0oCYGt//UskQA6qg2Z4kqB3LoIDjkHMoBSds5zsV6kDfFStbl+vwZPPZwr0IYWK6QQ36PDlBy8tIKtRl9fxhCenqM7Sz3xDecwnJ0hZ6eN1Ey9W5+gCSH4Y8sVKhCWvfp5VHoUqwNNUa3v1kE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=ENefULNa; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=AQddPor1; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ENefULNa"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="AQddPor1" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4687fTCe000623; Mon, 8 Jul 2024 09:17:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=FPL3ZZX9u3o4sooyi7LvwApX0K74xlsWOHiXFDJ7rpk=; b= ENefULNahB/BL2V+Jh3Wt7ht3ul9JnnMLaqZJ/NEeNItaCE2j1dV0jWd/fiDoHgu cmJ8r0/F/ZaTUrH4QNRq7wdS/uj95Tm1jTAgvL5W6vPkS7Yh0jOFOe4nYF9tUHgT xVk1GO9cq83vh8swouktlWAk05p0nyFIg4usWwmE3PcW40cu5UhzbGhYIek/kTUF pC2n0ZEQzveLkAcM75ftRktOlPk/hZXoafqufNZD5M5T9msKj07Wu0+xKQaYNUsx PbSxkpsFoYMR4icf6WYYERSumSpXWT5Cai+Ub7Kf0VvzOTIelhUaER2Lp7thS05z rf1uPE8hpRF6pSNC1InjSQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 406wkca61s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:04 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4687FHQc005608; Mon, 8 Jul 2024 09:17:03 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 407tx0vxf5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JWyDDZAOfLd56C12leBNzNkFqlszmw0MeDtrowgx4h7r3OWLGry/Bj+s+GMqJzYAIf2FqSsaPNeXeh9y2mepqdDZzmvbUTSmJD10X8oqXJDcoaEFTHX9h2C/7AzmqGJaakVyEmg0YD0lEM8dnu5wRXnOETiPoNZ1tKji1El3afGaPdCecSI4S0TcH0Sk9cRhtRBZCIpdBUzom49C3PUd0Q3xnNVYV+bOuz3jpEexyzBy86oNoIfZBkMCZFuQquf913HMlsdMus1IdtKsPo0ZJDs7xZ41l1FIJRPuXH4fEvvq/lpElKiOPGF/tWOqvJKm2bd4LuPFlOLFNJ+2yQIO0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FPL3ZZX9u3o4sooyi7LvwApX0K74xlsWOHiXFDJ7rpk=; b=JiCJnnJXMaZ09CXxeESdQzUgCHEvNr5QzZOZgB1Mjm4ngPCcWmi9xpgSjOpjmmfm7AHJ/lmHKx4V9ft/sP9mlB04J7MW78He/61aKtNaKNnz1Vwo9vcq+s4TPs7MY9ZemYzT2RnLTvk2k9Sii/UFHHyaz5vkSlmvGgZC9ocY8S+2RIBPQAIAyGLRYfvIyTHVBj31zpj01QSarb3tqukBjKqq06dguaSxVpGLhgzctPVpeA/wl1cTv5PbuEWzJwh80kku5oUhHP8EuRh3k8eLfs5q3PuAqXqEJDJFWZVV6Y20o191Nug/Rf8hWndxt1EvjCPSyEbdMP5KLaIzHa6Kgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FPL3ZZX9u3o4sooyi7LvwApX0K74xlsWOHiXFDJ7rpk=; b=AQddPor1vPfZiP9wJFT7DkJjeob0VbdtHdmXFhgljCVbjxsNNzUR+R6GDuD/w61rGI/KPaAz5Kz3/UoD2G6zLfFowTEtXJZxp96ku000Wd1fEP8i59HhzvPKoRkppmo4N7FWoS+U9wVbcwdYgblqPHuZTIse+wVhP48TCDp9AIg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6799.namprd10.prod.outlook.com (2603:10b6:8:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 09:17:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 09:17:01 +0000 From: John Garry To: axboe@kernel.dk, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, hare@suse.de, kbusch@kernel.org, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, John Garry Subject: [PATCH v2 2/5] block: Validate logical block size in blk_validate_limits() Date: Mon, 8 Jul 2024 09:16:48 +0000 Message-Id: <20240708091651.177447-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240708091651.177447-1-john.g.garry@oracle.com> References: <20240708091651.177447-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR13CA0005.namprd13.prod.outlook.com (2603:10b6:208:160::18) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6799:EE_ X-MS-Office365-Filtering-Correlation-Id: 80e6f45f-a165-4275-437b-08dc9f2eb9f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|921020; X-Microsoft-Antispam-Message-Info: uj7Bp1d2YUbL8CQjF+VoG+3JA70RHw6Rk8QySalGxCp/rqvdzA3+fNl+uA03d90mgztVddd8qLcNdFosBJN9rXA749biY4aXInMCvxhr5qZEXLoAvKIeciEXOlNmxzh8YjgPSOg8TSQtTzyX8Pw4IZE/2dtKb+uONIplBD1jzDp1pFPKTk4ejh41qIJrnLaT1j0ftsYJFGrO7qQBlnZraXxd7NOKsnqT4PXknTOmEYbNQozamYJd8lEfNCzdE/pRoXBHqekWy7VGxqifSEC0R/1t3FFFlkOAWj+wfR6xIE5q3Axpx/yjWfdAC/FSShnstXdrsvMNhMz126mlpm21G3Az9eRUc1LKd7dpp57MsH6P2H4S6za54XzFTwFmIuxAJLq0QyqdX9Wy6dG+IuPVTL/NH4d7BySQB4p9Ds809W8iUyDVylcXprMRKYcszSD+XFSn074jvKpBkO+O5ek+qzZkiAN79UuWTllilFs4yOLdE3InY3YG7ZIX5hyvcHTOshprNUPzEZ10eqe55tkLRxkJ+pol6fzoCFcEIFsTzxNthd5hlcZyaT1cRjRXsrUiJtpfl7lxxegskjb76GBqZBi447swTTu9WjKQgY/BxCO0zETLqdWzfPV3J8+AscnKK5NmTPkzMrWI1SS+pc3s20Iv3Nsr9ZsSzZABAkIWF5VfEIZrRJgvmb+VbmqfSMEhWTDd60LCjhmnPqeMRptWGSZ1FpmVNOdwGdYIcQXnLcnSHfnhj3wj+rVUrXSodARCP2I6NBUvchyKSjULbZfXkYLrTC7iAMPofpMZ4gPo8guzFO7BlcifyQ/iN/2Jt0fdv4usE882LBRbKM1obwveSaQsiHo492cWs3HnLpwOfCGGQ/9RPDEeduUldQ4F9jBJj6uhe0g23J/iDL3coDMqRsaIl2QaFZwIuEcSWsZOnYk5l28N+76/o86NxGBZIBYXNCJLAHMsGWbdkZEvntPPUBGjHruFmhcNDH+ACgF97yK421KHX48uHLjYJPdO7KoGg8av0L1SM17hYd4VDZ7sL7/xcnipV4Chb0yLiqJYWz/FCkApNUQYUsDkz9IPF+QV/Q9yFgN/FWGd7Z7MtaoZr1rHwie2w/hehYkM9OP/Oxpzg+u+K36LTZBByiL2E2Ue8EIIQijZcM9z4UNkndzN+gTRWUqxm9CYAbj8Q7bnFYomXxHeAI+3Oy3IAgy9i0juiDGN+XxsaDaZJr5bVuavEwTzahoPHxupDlVsDCghAJxuqN5w7cAGFA8HX9QpWN84hWl7cu5X6aviWQFoPiElE3Bq2u8TnkAU6jnMnVF/0O7dmAg6fkO4D1dzf4Tbs0jArrNwynze91YJD91P2gEAGnKPh0fY/VC8Od5sE/mRmKVWGmAk/eGJ1xvteLULykml X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RguL3MyQqVPJdgbzeClFT12YGlTsESDC95ChlD0pKGSsV/XnTstPBO+ZU8WT9RwyapBRol4MInjYevAc+l2obq09ERv6U+B2nHoKy9nakQFQ0QIGc4PjZbqd6cGcK/2sWMMOB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FQVlIT+dABwT3umYwLtK0CC5gUyCBFoNSCyw4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80e6f45f-a165-4275-437b-08dc9f2eb9f1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 09:17:01.7609 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7k1ISspTk7rIWkW3IiY44kTA42AEQYSXwbl5geAK2XpLD0H2QcqSBpEFAL2AFtaZTTafhvh3mdaHN2J4AqKRWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6799 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-08_04,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407080071 X-Proofpoint-ORIG-GUID: wXWeIqH5ZFXYNJKkUF9tLn6bSSlgWELc X-Proofpoint-GUID: wXWeIqH5ZFXYNJKkUF9tLn6bSSlgWELc Some drivers validate that their own logical block size. It is no harm to always do this, so validate in blk_validate_limits(). This allows us to remove the validation in most of those drivers. Add a comment to blk_validate_block_size() to inform users that self- validation of LBS is usually unnecessary. Signed-off-by: John Garry Reviewed-by: Damien Le Moal --- block/blk-settings.c | 4 ++++ include/linux/blkdev.h | 1 + 2 files changed, 5 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index 9fa4eed4df06..cd8a8eabc9a5 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -235,6 +235,10 @@ static int blk_validate_limits(struct queue_limits *lim) */ if (!lim->logical_block_size) lim->logical_block_size = SECTOR_SIZE; + else if (blk_validate_block_size(lim->logical_block_size)) { + pr_warn("Invalid logical block size (%d)\n", lim->logical_block_size); + return -EINVAL; + } if (lim->physical_block_size < lim->logical_block_size) lim->physical_block_size = lim->logical_block_size; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 02e04df27282..dce4a6bf7307 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -268,6 +268,7 @@ static inline dev_t disk_devt(struct gendisk *disk) return MKDEV(disk->major, disk->first_minor); } +/* blk_validate_limits() validates bsize, so drivers don't usually need to */ static inline int blk_validate_block_size(unsigned long bsize) { if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) From patchwork Mon Jul 8 09:16:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13726309 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 684DA770FD; Mon, 8 Jul 2024 09:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430251; cv=fail; b=lZ2RFp25lTgx+JgJlDbvA8ERAFoCXmlJL0Pyx1McqsCb9TpRZpTpQ+loJ34qKgqFd2N+nqXk11HZKhFUZqgyiZ8sUJdyeZ6IMTzWJYdHT+qyRgVHrNqrFzdf4fLTQuMShEEBAvwVnD++xpWZoQW9IMysA1+PNNIuQC2OC+U+fdw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430251; c=relaxed/simple; bh=J9r8Ou/DeHdGHOioz4TUaQs9tc1WB59AHu31HTXLKIs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SGw8QqbcfMXSHmBBDD4MbjPhb1ogAm7ihfJkKbX7PNjFBirpYfeDcr4cryQrgt8QdEFnxuHegimOKoK9dLsAvBAD4IiN8mBXMmP96kBfBcR4UsatNdcX0XKdomsZ9CzYJXvzrRUrXP2L9mRrFLmO2PFR0vsGleaVSq2BEqFokGc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Jhna2FST; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=wYQh8o9w; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Jhna2FST"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="wYQh8o9w" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4687fSf8011862; Mon, 8 Jul 2024 09:17:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=Vb5qjclebzn+tF5W/Rv96U7VkTNPdXqTIYpfsV5PBpY=; b= Jhna2FSTyeE0pk89nC2AS52ErwqXF+rj9uhAXBcw9HWyjYQnN9jQJJ2v6PB6+NBW fDJ0hegI9tdIXZDj+UkcTF4tRQIJJPiffsNlT6lqtYJ9XkJkgQXfPD0W+FSeYWs1 0bzhcl7cS+mN7biKvqapSl1Mr28szBv6lPoqqExbl1IPl2tZCevzLRGQIproB3zh tFw9dnBNVLy9CYkuKykCTUaxDY3I+Q4MT8txLusEZrQqCSfseONhfcUCF9NeD5+K pHCbGZdu9b+m5crbNKPasa2vlLNZnKCxcTorNstUQ8sXRG43W+d2qG1n3asVYUPv WvTjcO+FpHlK+JDLDfsfgA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 406wybj6rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:14 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46876pfb013662; Mon, 8 Jul 2024 09:17:13 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 407txf4x2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8Eg2Dsx8a0mtx69vl0En2w7BTiukeIwWOgME65yhpkQpGSo8HbSPWaZElxx89rgiW5B77M28RXfxoolwZaEcnQ6YGzva7HjxR/WBl9jsVrP0cW2Py63iXfyXiz9keXWhsWpbLJuEmDmW1ot4my4MRaaSVMlSqFb6jzBPDhgCyQX+NGM8jNPicxysy9CLQB8qQpHB2wisJLqKw/RVBzHitO44EyMWEePjhnzyWQAb189t5Mwx01iNYTYPgJsePicQV1q8P6VjFAS1c5xoK5XPXIhQgB9sGLqHr0si6D+gfMlF69/M5vllBTsBJirSs676hfWEDpbJa9vCS5Ww2KW4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Vb5qjclebzn+tF5W/Rv96U7VkTNPdXqTIYpfsV5PBpY=; b=K7Laoyv75XIJEkSY/WnAKiNlGCThbow9YSWr0Nl4uTwBRA7mwip2uZPFFZaw6dECl6w3uWgbW8LySfeVS95qBkpldqB/Yf70hEfN6y+3U/cqJJCsd8+iK8KdI0EkZpW3heRak+kCvfSbx7Ug/mJzptQl/YtSTcM4DLy2IzDPOuydH/Iw5P0aFwaI79JPDzXb2CnU8RnF8Demz/Ku5ZJY6QMT+1+bohBu/AaBUTvaK7nYcpR8Awv9HrHOPcV9C8I0zvXby4gG57oNjFt0/VaMOxTPpq2ld+Q4qIYPhSIV8cw/+dZHCyFhgEQRFWlRVo1yT/c8cDEsUv9l4yIS1ZUphQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vb5qjclebzn+tF5W/Rv96U7VkTNPdXqTIYpfsV5PBpY=; b=wYQh8o9wqZO/GiBt4IwQ3o6B0BWu5NZ5pTGGhPsOI5Qq9fTZIDTxONdSRMN/G8ezh52ZY7xQaYq6txofstFlh989Z/U2zNgryyUYhBwRUJVEuGuGRy4VfeVeY2bSRcc2mU1u4Yt+ChNIXTBUAzOsliRPRSu8x44ZRm0sGyWWOHE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6799.namprd10.prod.outlook.com (2603:10b6:8:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 09:17:03 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 09:17:03 +0000 From: John Garry To: axboe@kernel.dk, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, hare@suse.de, kbusch@kernel.org, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, John Garry Subject: [PATCH v2 3/5] null_blk: Don't bother validating blocksize Date: Mon, 8 Jul 2024 09:16:49 +0000 Message-Id: <20240708091651.177447-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240708091651.177447-1-john.g.garry@oracle.com> References: <20240708091651.177447-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR15CA0034.namprd15.prod.outlook.com (2603:10b6:208:1b4::47) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6799:EE_ X-MS-Office365-Filtering-Correlation-Id: b6a09e22-1b6a-40cf-3974-08dc9f2ebae6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|921020; X-Microsoft-Antispam-Message-Info: brFcPagraufWnIEZMzx7Gi7CZW0cpa9/uSxEVVm3InRMlU3bgPk3OuwWQ0kemdHfgzm2ap8Z4O07I3pRfm92dnhUVWq2zWidYhe0b3W+R/TfruBUzY9tAUPTwV0yTbPR1r7RlV7U0/IJ52WmQVpXr9xOtNZWYn6LIiC3MZTaZYV/Wjt4p4UDetzKxnip5q3SjG6DCCxkoqHpu99yGpFkue5gkJLQDl6+EgjYbNvHnJTfum/27W8Fi5hoCGoIbQhnCe0VmUWXIOXRyh8NLVrzdncmHMRKKm2s/vSNjN/o0HtoXuDzFalEHPXFqi3k4yNr+++poW+KH9Fbhuohbn+1mop+VlBmWlYRY2n8+ikbr4bHLsY1R+DE2vzffq4eN2uIFamGJmdlIUtS9zglLoq0mif89k8ZzWfzbx/4E86MkyzPq5U1i88T3JCb6DhUrlGPCp5CTZMy0+8m3cpDIPsNEowWjZN+KwODT/yeixWOHTb8UJdv3QwrffPDxN5cpvUKWZpTYfTl1UOEzND5L3s91Y11xdWFefoUp56RrWi/GQb2WDYJlpW9C+COm2uX0rMD+VFEegaPRSS52l8vLXuWAL39/GT7p7NtT5g94w81UUNEYX7ByVpU/LQdXqWk1x8ubhX0ALPJhUqTq/HI3MvGXuDBo2mbczFS0M6NKQzJ6/z+6phxyoQAI6hDEpBcjf9qB6y7n8rFP6m1KNpG1EIwCCRf2iyKBx/T+jlelHI9cfkUuLsT4/Rrrgkvo0QoxqOWEk8l19iodNhyQuwdfH4S9Tr9MaUU5eim9xYVNDVJATk3FQySesZj49uMs7oU4jCfYvhNBFopvGE1el1UlK7OBNnc4pnHQTmNTao291gZcBoJC4RBp9+eFc4NewQSjQSxn+PAc0M3/oZfGMytEmk7LPJ6nmFjridqxSjaWlndWI/2iG8mhMU+uceXABnVmHtphZXy34iEVPaGtJ5+BpOL8zoBtAwpvTN920daUlpB/5hmf4ERoiJtD00ur9WJt9r0jIkKtx+KHvJo3Exi/NbS07xCITcAblxGpJ3pg3xM94f+SmN1oHS0F/7W2oN6oFH+1y17qTRsvU9r2pYfOzOScwZspxSZ4N2fngxUHJNjHGWB5quY+rz6vRWCMkm5jNgnoqhyhXZHT4iE8xL7E3skWZbIFlyGHW0yG1s1JwkeO1sowL7hI6Xtc7xC8kGXC7MNpP5pLv9IKURsNr4RDHq6H2ytQ4dRoPd1px/cGmHWuoxcxe+qVLNKJejs1VvTbSun3AizxZmCuh1PRuDqpSatjykOnBnFdoWyu/HsT0xr3nTxDdLl1jys1ACLYsEajF6qlGmtkgzE1T0dG5IyVaVPBAMRvSS29U78yPNn1pF51Ays/HoYs7zuVcccYBEIXcCP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sEkETdJYmkjYAHT3Pxyl/bvhPSVcICCH0gHDmYm5TxOOVC07vDWE7CLtff7cxe+gXUpuU4A3wWSbKDK5+Lwvqotem6nw6D78cgrQ7TvWcCBJeDaU2QJA5tlWWF6GXszxOoQDdz3eb6dWHUtSkotyQ9M+Gztr6rOiKPm0s2dW/wNDUHKeMpKhKdUvdvh65RX7t8ScnBlsaOpserKP/2rOejY2dZTZlI5ob1WR5LOem6DWXlF8CFHG3Baua0nGYlFXO3YcmVKQlIV5TdNuQgIAsdrHUAnS5XfcAXckZSmTqjitSyQOV6Jnm7IIbZmrskA4KmNMbo78hw08yqWepakcK1Fe+e65sXXHnC4ECGcOJTDxX3rYZdbPXt/FZb9OIr/Y72ritvLyo7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QiBWBWFk692SJiooNQC2bDpedM/SfTu3vHPfiwCN0y2u6onKwYrw0huijkpLfPjoVrcaXCCNNAKpbUXMWsToBUvN9tTL13tzqaccrfo2/I4tAad01WZrTW4gOzlZpS41VFH7JKa9A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bKyJezdg1F8bxCLO9owbFQ/LczkBlrmKHcoXhxf7huy7AYBu46u7r729SdU4QY76Wq2F0r8K6+TU9i+jyiETsMeOvp+9lEUb6YKPaHl1fRIutb0Ux1fGL5gstMghvrrP+CcpNJWjgEwfHReItTcZopkMBRgLTz5AKh1DCyU8atfzeu+ZUz3TRHo7+BP8CAbDgJfdGnekvkR16yd7+lkfMI144MGsBLSU0dgHzzeQwPddPsXoQme/5VNofpvo+XbSUn7j5OOJiJ2ZN+Pin9uJ0JZ66MZnDGIBAtU17yX8wrY+MjyqoSiZj/teWpAZ5Vq/8Ps8miOrsi4MZ04zo/h5asa1c6K5CD1zwtk96yZNvuAUQUNMj4Se69LRnXML9RyMLVQy0Jc/gXwXopXgfM/UcT0E5FI3ztN9rf8/8A+zqf2iEb9+1aChYwuppeyrUAbyQHKUQ8jOmumrqebpnOb3wb+98ip4sH/K0861p+JMYC6e3k+JTiq06wvPlou5u3z/nIRjXs3pdP/jP0mTAFvJyzEsWRM9Imh2sBkXJvVIjsesX0bIyXUrz/OISBshTEGG/GjuQEos5C7ie1IcNg7d5zvTjRMvZmg3+yksUs5+DCY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6a09e22-1b6a-40cf-3974-08dc9f2ebae6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 09:17:03.3991 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o20zpAX9TYWt7Y+NxyE0JQ796po4j8WhNbiy7DB1tsFr59KlMozUrrw2erQFp3KO4c8Cbypp7GT/qT8XOy9v0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6799 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-08_04,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407080071 X-Proofpoint-GUID: tA4wGEum9791IHhFCJp1JaYc-ZORnC6r X-Proofpoint-ORIG-GUID: tA4wGEum9791IHhFCJp1JaYc-ZORnC6r The block queue limits validation does this for us now. Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Reviewed-by: Zhu Yanjun Reviewed-by: Damien Le Moal --- drivers/block/null_blk/main.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 9d0f6da77601..2f0431e42c49 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1831,9 +1831,6 @@ static int null_validate_conf(struct nullb_device *dev) dev->queue_mode = NULL_Q_MQ; } - if (blk_validate_block_size(dev->blocksize)) - return -EINVAL; - if (dev->use_per_node_hctx) { if (dev->submit_queues != nr_online_nodes) dev->submit_queues = nr_online_nodes; From patchwork Mon Jul 8 09:16:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13726310 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5237377101; Mon, 8 Jul 2024 09:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430252; cv=fail; b=etdhvdnX4UxpwauBfO2KDwj7ihqKQ4aR9WEeUdUfV6s4e3UcLj/Ieg30yaO25uAnpDNF41Al3mN6WKcUaQkWiiTKi1jLUhvNB7YN2ZVBinRYlQLnwEE2w9roOITqNSbWPmnDaM8XqhBry/z+Dewl0ZYjYzJ8jLElOzgMKb7eLSc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430252; c=relaxed/simple; bh=Uq/bJLtSOBjRXl5cGeMNU1JHzTDkWCZFS4o3Q1Nlf08=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fBmt+CCzf+JDW0rXBv2AMbQHhL3vB5MGxftG+LdfRSKYBZsjLcLTMKKREYSB9fxH3+wCPd9YXpAWejSRsnPTTjOrB0UwQeHjmqJK2HqVaNjYZUBPJBa0duJ3/IKw919aJ0at+dfDqaEu8tjNo2bwCOCaAf63zlP2uO3eta49gAQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=QIJgqZda; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=GAp/O0/K; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QIJgqZda"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="GAp/O0/K" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4687fSga000593; Mon, 8 Jul 2024 09:17:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=RuZnVWj9aHY6FuajPxHNvSf5ZvdhJmMHCOONsdJ7Rgc=; b= QIJgqZdaJBjd0OfW4r/5EmT3HlkU5JLrAGecVjQJufPfreIyqUhjHRMBbeEogSRL doQf4v0Ti99Yr/k9RdRUiDErsyH6ND5D/Qn3EZr5Gg0QdmzXrcx/Tl3ETxV+nu76 YGnrhAwkdbL3753dG87yG67/1TWFIG9PNmquvITu0GbAgiO4cK+Jkg//Pe6H3VQ1 WzF8eyC9iRHPq66ed1OqPHQO9lCZcI9vMVEJgUaSa/mPhqu942+9xOCFKsfwe0fh gIKsNU+Xgz2dan68ShRpxBm6jUtQIVJU+dyd+j7zsu8KUM7lDlf6OQ1JsAxlha+9 JWFNyOolq9c5TkwynXRpoA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 406wkca62a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:16 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46876pfh013662; Mon, 8 Jul 2024 09:17:15 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 407txf4x2t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RMtfstz+VuUK0Rzirulmduc+4k024j3kuG6OiywZCKcG6kHLqjA8zZ5J5keGMG0VrRb6mMqda9F8mjYM1gIvPq7RrmQUTfFkNbecuuqi+LrY5ZVQtCI7+mNAgOla16bl0dOAsT6xmoRiK8y+I5zxGIRy+DIeNcuWDv7wGWvXqqwuKmrd5pJloG8dQbW4JzM33CfPcrTtZczN62PaILuFvzEqMYRbfZ4fAOGVwHQdHuZ1ekusGtSsxqvAll3kl2Are/tbamZjxZab5dLYKWKkOrmgQXctT00LXlrHMnpc89PNC2uJMGI9Z617wNFKSafEa9tRtiId6iJLNNRcOUaOiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RuZnVWj9aHY6FuajPxHNvSf5ZvdhJmMHCOONsdJ7Rgc=; b=dkHkV27+b7LZTJ5B72GjF7DmKaA+kl5i9GXmfK/OA62lHpcWXFuNOpd+n34MGI3lHG9a7C9MM8H3RNtxJ7o0g4XkrQ3xAXRvnd2Oibm+PW/YLYAet5ZorhicymtBlUeEyjVPLkVgEVPNrCeLvkNPp+H4HFHmeSIY4ybRzhMZEmKmKBYUe3nGMdlV7D+SYOiQqdek9osM5haIwHcerfAmKBiegFNeTxj9AF7tMKzHqVvaAHorCmj6khVJaqnrHN8Dm+RlLnc0VK0YYjS0ZKcMRTymtB+Du1LfyITCjg77FKhH5Unr5f8lA38nnOh0y8ppzO+jyCF0H736UtZjMqQ63w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RuZnVWj9aHY6FuajPxHNvSf5ZvdhJmMHCOONsdJ7Rgc=; b=GAp/O0/KieNWNWyeNt+yz6Zm2BHE0NqCO+b9FhhGXBuT+lZ3H3R7paqyegB85GCI55ZDkmsA/V3Txyy0PhAWvtC80gSeEd4E0YK/laazZjP8aLe6V6as6uxlgknA2pY5Sg7vqmcLSI94i4uni3tmTA6lLCqHaFLx0AZ/2NFUqGE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6799.namprd10.prod.outlook.com (2603:10b6:8:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 09:17:05 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 09:17:05 +0000 From: John Garry To: axboe@kernel.dk, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, hare@suse.de, kbusch@kernel.org, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, John Garry Subject: [PATCH v2 4/5] virtio_blk: Don't bother validating blocksize Date: Mon, 8 Jul 2024 09:16:50 +0000 Message-Id: <20240708091651.177447-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240708091651.177447-1-john.g.garry@oracle.com> References: <20240708091651.177447-1-john.g.garry@oracle.com> X-ClientProxiedBy: BLAP220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6799:EE_ X-MS-Office365-Filtering-Correlation-Id: dbcf7d7c-4a24-49f0-1bbf-08dc9f2ebbfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|921020; X-Microsoft-Antispam-Message-Info: VzbYAug3q5T3qpKKbPZ/uGpjLpjb5AsySozDtEFhi3gC6DSyJPthQnXpCWVDv9GNLPE+AYT02NubF32gViLqoeW5dqtenNuNOnT3KUYrru66BpxSTrzBytLYEaSFXXDsesXx2tOfekns5jKKrhBe1nE7u1x0FkGHvn2kEIdTlZ9p6rfo7RDwJccLEurtXKH8oxX1+va7qsqA8toje2h8Y43sgIfCMMkYd9jmjyxcRtHAYZuC4iA4mzR3pbD9gZRYD4tM4pKEYk+oxza2iI7zLdGIQVqupWWUe2AXNj0xhfDHPTDRe6IAYTMhUFtlY2JYD3Dxk837FFMwQZ/vNbTs/gajGYTZFPuJ0icHdoOrXD6HapdcLcX7AmfDoFvalJ6c2O32cHvG3Ry/hNDV1WcZ6+YaxO4XI7LVpguAWLRsGG8LzMxCfrHwG2ZMMv6McyKYQRMQwjqei4Moevx4588lxApma6TheVzd5xAGnHNCYy8TsELKO+nN82hf3MLnqPnlxFZsNkgczg7DsSPtfN7Wxn6ECAwkV2V8nrj/tjsRDsDgK4RsMAzdXYZnrGckr/Wgywx16XfnPb6sNOaDIFA+NZd8A5PafVUzvK/DIiaiLHmYHUi+gJV7GWDhyYmJBK0FwF2Hs3sa+EduZ1kIEuxm2IVSkXnyzpvlG/5MyuvI5NY571pRXErmXWqkHDaJTtMyQwdGzQXx5jFMJxInPuDEfheoqL1HtfR3CM9muTJqjQ/y2zsFHOdEeBzaTKZK4Hcklwwqy6CxqUDVsyqKSrsl4oceppR371EkvZuU2lk3/RfU5DE/mH94sViO9dukWsvukJgbHraO+OnYiwPy72sjA/ro+ce1zc8ukzqfq77754GhUyMEug2BAJ7Qh8CuoMIdOCMzNHP8dpd48tiaPME0yUd8a3TUeCcoEZaKAnh/yv7GKmtVoKcjtDCdI3b2PqTc6ZxrWfb0Ajwb9vvGwHwQ2zGwIEAVEjPhx/cPyN9l1sLwOLprXSuaPuWGSnfnx91jZZggKtu+OzgePjKL4v9iD2dvf4dKOD7BveKAE6ZqC9FqTqb4Oc0pp90zbEX5DS0sMHHfHdSLPAh15QJsphwTW1kJunM/Xuf9LTrfS6UtNChPN8b468evtBailCTYxBfxUVO8SPal8x5X8+6dCL01gzHU+rGw0S/Kf1qCFmquhQx6Rlb+if4m52DdORFbDqknmBGD3Bfdb00BJyqNc5o2ytvwzGEWD6qZPpmJo205lm8GX2rSlz6Hjq9E2Z9FMlFYfChL+oPjre+wzZ04qjWvmchasvXyYErhKPjukBV6GmhzW7VoajoOiM7w6001l0nE0butlm+3MsQykJl3LfnbAFRP1dSDSVxWqHSSNLPK9qsTxuRsM00nIKzJJyVacsX8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016)(921020);DIR:OUT;SFP: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Eo6cCWxdOghV9hk8leyAvC10qeOs/0xT4KagXNodJ8lL7m6EGDV/PncEZq0WuM9MsXaS17YlsDVBSMXGZDMVc5JXiNQPmLlqn4PpDQaCoY3fgoqQbspiGEQeVMh3Ewamnyp9Mlq7KwDEcIFZB7up1AHS0ofeR35pw8zzRvc6065T1s4lH+k8BBOEa03nPIkSnAJ6yyScakaE2bo0zNArmQS64k491neXVNW3w/HAbTgPP/aLSCk7FqnMutYwVGOoC0/v7GCdCZ2bFlCmwsb50rijnFO2kerSLbu37AmFk0iDTsbXXnKmUy00N+2IwP3Gad26u1yksdoogXM4yq9cySlnR6xjVbGiHhub3uAeYYn4SqirvTQ5uOsDnVdDYvYQzxIS9Y8kiZ2KA4Emzbho3XO4nbn6SXzIMzNfOs06sbp6iGBA9J5xnVCpcje/J1G8FcE9m6CDdmxqU4exJapWSDqri9c7luzBfsXIOsPUt6Ns1HY8yH8mkpfNUdeE9pTnfbwLo1iJ1/38QNDoi5jcRHKadqpMZSn7+AADHLVUZFJ+eqOwg9hOma11RZuagi6Qj5+xcSqCY6FvqEmaTuHOiJXyM0VBpL/Og== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VOLwY+ZaN1/y5zrv6Inlsov5LOcx418mznCjD3pfW4kDFR6r4QrPwnD3av86DqQojQRqKgwVPgySvXTQJLBSJn/59XXpSSOYJpTx4nUBKBteitvL50Q9squzjfSXMEO9UphMb0q6x7qPEnX0pKGJv2GMqHKcFa9neVpYSLMnkYxcPHRCB7F8O3fYa/wLSXxEVuatpIeaOaCIo2v5oHMO+U4p7O7cVcefprUuSS04YQSvyqiWDQzvLfauri+gsDXJI6IUSb7m68rCDVPoW5e4//wKmjqHQeV4WVZEqdD8DnfWNqDHb7A23FvcgwmWcZNquJEkpWbB4E9iOc/8duV2LClWzy/NLB/vFrYs5wScurigJuj9Mfb1+zyiwPKdf2f2GqnY7l/3ugqCQ0/1ore9wVJdbuYA856UGI/9DoNEC0TaRDcU4YtPJllWzHAClMPgX6CeGH8wWcrhas3c/hMUz8DSOPfVnK/X1c9Nb7PRaE8TSoKzFNvkRPRvCcEJtyHXC5sjPIWGnZDNxxNJho5+wx8a3+TlOUCMBG44671fI3pgcoottmBXXRW5uZ7TT+adeZ2uZ4Y+0hFFkqOzUCkzz1AGudUaY8eaO8DbrAboJUo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbcf7d7c-4a24-49f0-1bbf-08dc9f2ebbfb X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 09:17:05.1903 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4kuv+qI4lMvC2KUrXyF/jzH14lWyKjeLowYjNOveaTY0hmY8gnoG5USh8Uu5IFSNszCR7h88re47fzPVMU/DJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6799 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-08_04,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407080071 X-Proofpoint-ORIG-GUID: ZYjOm_9BiKcZafr3nbFwl2zb0flBZ5Ek X-Proofpoint-GUID: ZYjOm_9BiKcZafr3nbFwl2zb0flBZ5Ek The block queue limits validation does this for us now. Reviewed-by: Christoph Hellwig Acked-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: John Garry Reviewed-by: Damien Le Moal --- drivers/block/virtio_blk.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index f11b0c3b2625..e3147a611151 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1289,18 +1289,9 @@ static int virtblk_read_limits(struct virtio_blk *vblk, lim->max_segment_size = max_size; /* Host can optionally specify the block size of the device */ - err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE, + virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE, struct virtio_blk_config, blk_size, &lim->logical_block_size); - if (!err) { - err = blk_validate_block_size(lim->logical_block_size); - if (err) { - dev_err(&vdev->dev, - "virtio_blk: invalid block size: 0x%x\n", - lim->logical_block_size); - return err; - } - } /* Use topology information if available */ err = virtio_cread_feature(vdev, VIRTIO_BLK_F_TOPOLOGY, From patchwork Mon Jul 8 09:16:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13726311 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C19807710F; Mon, 8 Jul 2024 09:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430253; cv=fail; b=c3B/0o8Erqj5bqqzwkiCFXC+ewlGkiqrFz4K3HQyjVkEJdnz4/0mtRstQ/82sKpw0bdx0eGr/zFbyqhXmDxyf3Lp3y0cRT30+NeK3zQPawMIkJPOfCreIWeWdF0BNMUBoKWRsvvySuv2QDakCqbpY06qVswz3gJ9qohJF8VuYCc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720430253; c=relaxed/simple; bh=3tflWZQLtRGG6xTnvfYoPxw/rXV5vbtF/V9aonOj6SU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DhkpCWRAbTlTwuObw3lRSVc3mQEERp8sqtNwZLpitHvYGZvJAHb+DZBtWyJk4Ymqv6+eEG9U9ss91+kNVYFBzqjHuAOBi/8vQQDqs6kpDDoR9AjgOeNtsIJ6QiC3nw1BDzMjfpVYOouiqxhFNkTJkFNdPqfzDMFOnW2nY0v0KPs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=J2tcbxRs; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=f8uBIf0H; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="J2tcbxRs"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="f8uBIf0H" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4687fSPa011849; Mon, 8 Jul 2024 09:17:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=slIpfovpSQvVVayB1+m7u49dtx9OSvLetXSGxDcaX8Q=; b= J2tcbxRsPZdNluEZQcpPU7Zgf3tnKmOXcRQB5NcbHeFuzvTBYqTfeIC0VxRs9toE j0WZIDrPSmkzuDlEEBeZMbZLryOBU73UwxtW8ywDVVLQXsxUWWd6SiCE5iy5paLD La2pYlDMI0ZLyz7n8G0TARZkQ25Oaiu22sOYRqfR4BF4U4Eh0MXUWOCrmtjRZUyS hNWfS+BqUlPmqhD0mr/4TTlaNYegI0L30RKOgAPt+S5no0VjHYEpfekHpsPTdZoN pu0airDVfUo8lHNIfqfgk+ZHsPQpCY4jHuRxENu8mxJoN2hjUfRFsMJjCTrw91NJ ZzRMZV6xL9AMG/DQ5NRHJQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 406wybj6rr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:16 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 46876pfi013662; Mon, 8 Jul 2024 09:17:15 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 407txf4x2t-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 08 Jul 2024 09:17:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MFbDiaZffyk/B72IOoB3cdz41/D48vvKLqCUCCuxO/WAjT3RPTMt59rCgvyPQnMwywoQLd8L0lw5u2RY0Bo/b6Tkgjp1n9m9lKU6m14oFpJo0bNv6YEXKttwHWEzx5sJ1CG34TzEMlqb9zmrla4OM1mzwJ2isO61A6VifDpyT4eZOnDPOTaaQkXq0helBa/Av5Mqdet8STeZocMJ7ZL7v1fXd5wO6MHGuZPvK5akf1pZGl9S9AW/HqlnykJWgo2PwE9a9ptdL9oXwhSKBucKudCGxeVzxEGbf5SyUT9YnVoE474JqNIWO9gmDw5yfXK7R5TkRyjRF6LxmXtOPKL4WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=slIpfovpSQvVVayB1+m7u49dtx9OSvLetXSGxDcaX8Q=; b=NjEPYlaI1mwGOiuGVetLpTCHMVVik8Ww4PgYBGoO2L72J3OoWAtFkGaaWKFCPdBRUiYK3NLPni4SVlvQ9PItvpdFSNo4M69FcSJmXJsvo/OT0jbh2p12H3rOS7JP/YQozhn/1LPxdMjTzjhxsi49AKpGr7FQUQ9lMZxmL4qshVVBiVUfrE5dMhbVfIIvS9AgesDoNUSy80LZ3n4U8LoswVEC1L0qzf0M75IUBlfkH84GxQkvw4Pi8ldLvVHMh1QpDnY8at1QwIaXaF0VBT2rNOYSPcDV6GZGx2WDBJOLmjlsyOO7irj5czHWhK/3xe2Hp6ZVLtAkx8Mn3tGdxo+pnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=slIpfovpSQvVVayB1+m7u49dtx9OSvLetXSGxDcaX8Q=; b=f8uBIf0HSQXgh43aZuGR0dwZwU1sS9PuT9ueJj2OqemHKbCf6B1s8yzVzP1x/2XCjMHkWQ0eQUuUtHQfGS6VXQ/r40EEQGuP8KfPRKkVNGVhburPABsK016ziKjQKB1ewppFRJnVntnFSrz72FLflZBu8APFx8tb0Zh3tmU1KJI= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6799.namprd10.prod.outlook.com (2603:10b6:8:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 09:17:06 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 09:17:07 +0000 From: John Garry To: axboe@kernel.dk, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, hare@suse.de, kbusch@kernel.org, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, John Garry Subject: [PATCH v2 5/5] loop: Don't bother validating blocksize Date: Mon, 8 Jul 2024 09:16:51 +0000 Message-Id: <20240708091651.177447-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240708091651.177447-1-john.g.garry@oracle.com> References: <20240708091651.177447-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR13CA0033.namprd13.prod.outlook.com (2603:10b6:208:160::46) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6799:EE_ X-MS-Office365-Filtering-Correlation-Id: d5ee9666-6c38-407f-75ac-08dc9f2ebd0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|921020; X-Microsoft-Antispam-Message-Info: YoNlw8zXNh/3x3jvlSt7nD/1niMSD+cY+FUovfWmHZ3Xb4Rrj/hHDkvptlIGZGugOZluXbXtQuhAkStdQ7P6SGLF+fy4/zCE+Q/VCEmtJ8mop2zEWBuwdD+DS09lu0pSSZffu0xUdsOEeQ/w+b8gXqXjN0FwpmEUWKQjc72Gnegdfs0Po5QaQkodvy3ica4gAPaDtL2P/0g1AJ/j6RpKA7lMg+3vZCnWq6FedXaodIokmwjGZEnyXT6CMHytgdC8kc7wu/BmipQvZ3WRrhRKpfQkhcA61uyqwv9AzYKSdh8Gx/rXEvvD/QGT2yvK14VupkStooulUkNynJRSG1YW6n0j1QrMFJFV4g73096s0f6geyEJE78myd1ZjbkKMcnqUDK4trNB1hXl/j4rMEmn7rOTUbLLOhKpD+y17xDI+ZNPMuom/tNseSb4abwXbgvJX3fDg/vSEde/NRUyHlehT0hww9AC6eFHs1CTpSBL9RGH8JG+Ez8sw/DYMTJJ03Dx+v7ZmJ5HBEA5bMo36xBnhUbnSQnKaZAyY27GkfJ9rO0CN63YHFCVeaSBO2+EMfdPErzlIa1Zp0XYOXsV41cQAlcUkxtE9Wh4ekYUKo5ccJYk953tVA74B+08ZENHggjZcKkq3bt1f537/bSoapbXxKdjIC8d4rSfRDTm47zaSOdPctUOalOOqYmDqX3Er/eLD+vuGTELye0uUSGpr+40P2aJAmlww2Wh9QR6WUBuu12mB7Pnj0ZgadkFY3ccttHygQKawxF8aSAOTdA8MHEFNk+pKdLECKMAk+eDixs/tYYPU2HSPm9ZwdK3porIWEfkKulfFcHdxOxpAnDdjgHKHybvnS0v5vgqU+6kXcsVOm79ez9yCIvLKhIM9D9aNbS5Ku1Fm5f0fZRbbcD8eLzHeMKiH3ZEbq+Tf9J2rbwCbJOTkP/CcTAWoWYTKs2Sr8FpayxrSPOTB3WGUAgCrxUN/OBr/gFsDR2ibjoprOZtnnnyDZ/jmO3XwoBc6HeWODYfvtpT8JO5jO3lm9CHcPsBndVqhyYCiJmIoShOc+zmV5Fq1a8+7sUbYEarA4Ww8EHmiNW7XEfA21GpcC38KY9TFk2M0c6tGgO4GuVgV5KCLpXCCTy3vHDjUDmX+gxlhqBrjEX0oN4rI2OT3BParQHMYxR1/JwGdQ0YGQ3yxmGFj7bixADuDXZa4/X9GbvfgVwspRD+0+tyZB8dj9OfBFlKYLVFaAF6JvgXYbnM3otOP1p6c03sHFM/UEforWDbPr8eaM/QYx/mifix968BnDDtAhQ0TVW8ql5OJRGNh5ZeWFB8fnOkqKXTqS9xbEG06lQU1Z6yxJxpxfOYSqBorgsDJJQMAzHuXFAhOoGyyDOebKG4ckK6VlbDxQXEEH6t0MtO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LjgmDzPHhTOWqqPHbYqENYjkMZmMpT+Ri6jMsdjdoUgejVy6KkIJ5w5gL8dzOOx0sxGcY/ruVVBiHFlTgBka8rrhLTDJ86Be4UG05HEOpg2BD61PlEj7qa2+GYO0UtlDF7GfwRxUodBAgY9SPLmc/xd5XyawoBDhZmqtbRaX0Y5W34/d55O6tByyNgr2EjggynNG+OQu4PBlbOFt96m27/WcZJUeZQyZX7lj3BffXzDToWaxGXT8EAbkWG9j1hviqaVRiZ7bv5NJ4K5GcXOjDRPTtv/ZQMUFboYP1nwyi716CyzgGU7KnZf0ZlY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J7a5wrbT3pqyXpzv4qr+Sai+bjXJtilB3yVbGXVLJRfqd6zVCS5OvE+Ro71JPpwJAUc9ed2ppZNfe+cfkCul5ARhDbDSmiOJStJJuMYJY41DuAMskCQhNRkOybC7+FkhDXfsJiJZcRTn5G67To8XaOe9C0J6zopqJpk5lwCPKGxw2OoE1lbgaUK0fdKjHugb8HFjXkZUqqARuE0hAiEdSTPPnGZEYBxGuwBNkwQ94A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VaQ+Py/cS40arRWjTnbRHaiuMV9ycH8axbP62oYGmaAGKMunARb5kZpLmLwK5nH+CcLnhhZuNh2okPOSyMtyWAhgbsmJ48g1RjNywPtz9WMYwHEhs8leuoI3VoTtTmQeWo0TLcIW/4bRwo+RJp/wMrDQ+6v4h18sa+ig/5+WVazs7XRnYvNGQdcA+SyeYa+NDujSbLBsTawHSBxD+B77acyi1j9Gge+UStr7IeRGHyw/0rfJ300YG1218EPtkdq2xny6jRpbvEc5Zt40dAlfpNBm4AwbRw/1kDi/Ca83srlW3o0BmZj9t3FKc80gA6WyLUpHwsLCoZkgNah/cGuEXWWtR2/bR88JZCLI0iIRgxS4/q26oKKaQJI/hLHBO3JccNdrn7EUdgkeDnYlx5jhc4sPxn32i3YhKgWDGMzJv0xrFqfYAuPLYrgoG3YfKKRHLAzJRjwiQOujLIH1/CkOl4xCRYMf7IzbxnD9iLKJdoGokvTHpkXusus0IYlhQB3H1IVYwIiX7HU8cwRNy6kXZnlZELXMPxoyKFxkvAsxfl4ROH5TCU9TQI+Ovw/1GmKLtTw65S2T51wYEtO2OaB568qj343jAZDHK9kghEm77Nw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5ee9666-6c38-407f-75ac-08dc9f2ebd0c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 09:17:06.9886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HwGrp619uCp+BvwxJQnpwFXE4PapcsoPyX7ql3k7Hi3VPlNx1QYJf6zw7bCHBZ7hjeNkK3ac/1thzRRcDlEpOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6799 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-08_04,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407080071 X-Proofpoint-GUID: FXI_4t_ox04WqlG_kQfEdIChC7njUc19 X-Proofpoint-ORIG-GUID: FXI_4t_ox04WqlG_kQfEdIChC7njUc19 The block queue limits validation does this for us now. The loop_configure() -> WARN_ON_ONCE() call is dropped, as an invalid block size would trigger this now. We don't want userspace to be able to directly trigger WARNs. Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Reviewed-by: Damien Le Moal --- drivers/block/loop.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 1580327dbc1e..736467dc3ca7 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1061,12 +1061,6 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, goto out_unlock; } - if (config->block_size) { - error = blk_validate_block_size(config->block_size); - if (error) - goto out_unlock; - } - error = loop_set_status_from_info(lo, &config->info); if (error) goto out_unlock; @@ -1098,7 +1092,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); error = loop_reconfigure_limits(lo, config->block_size); - if (WARN_ON_ONCE(error)) + if (error) goto out_unlock; loop_update_dio(lo); @@ -1470,10 +1464,6 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg) if (lo->lo_state != Lo_bound) return -ENXIO; - err = blk_validate_block_size(arg); - if (err) - return err; - if (lo->lo_queue->limits.logical_block_size == arg) return 0;