From patchwork Thu Aug 15 08:27:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13764493 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 9A070224EF for ; Thu, 15 Aug 2024 08:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723710518; cv=fail; b=cdH7sMIfie+XxQ8VgSWdzMz/GYxZNuokEM/7AnLSeCjz9hgqZaz25AbqKWNN9H4MWVQMzW5JWiME1G8JWlwNkzpxGSCfGp3zmX8zWUcIxB481E24r2Kk8Lw3Fl8h7tmu4seNvG3iaKWfnrEEsbwmhOIVyY9A9XQNCvkUtAmYF9U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723710518; c=relaxed/simple; bh=KRMjbne2YUhkbzehontpkH36Bf1aJjbLpLOepUh5JbI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VnZTpCEJwx1HLcpqpeJxCOtm1nSVQDekLZ0utUPCgyn9ng65VpsL2FDva6mTjVzqubQ3QaFGfXkLTieaTxiD9L8aMzMHtmSO9x9miB/0GMKwpU4b3SwW8S6xmxjAhH4saIKU2nYA+QCEGIv3bfT6t23Buf2yguy7lHlH4JYLYYY= 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=nEKFmVn3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=mz2a6MKT; arc=fail smtp.client-ip=205.220.165.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="nEKFmVn3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="mz2a6MKT" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47F7rc5N006074; Thu, 15 Aug 2024 08:28:19 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=2UYrNRt6Hgk924NAfHO0Za0D48oObid8JGepvNSC55I=; b= nEKFmVn3xNHrkhndA5O+RxuXtLU1R6DeJ4M77yjuhKJOHCbRkM9MlphyCDOTJBzw i63mbamcJ9N5lp3CDxmZYkdlUoQMo+rmv41KB3ZT3xB0mJQZRkbSaKmULyh4+pKr IXuQGjNdge89a66coca8TvxV9DW0iF9vB8EynAokKoORIPKvc0D/Jq2gCG6Qno2H U6UY8SIHy4QtEjGotQlSgRP53hQBUedD2pPvGw/LJbU9/Q8iL+3mgHzEhv9P/5mC aDBJoHjoNkhgPhyRhS66xrIqy4S16UHnBuuEoYSPTabS7brTI6UCpC6ERqBTh2jv 9iHkQhNHcLhxBhSVE1BIjg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy4bj4gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 08:28:18 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47F7owbZ003825; Thu, 15 Aug 2024 08:28:12 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnbvxtd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 08:28:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QAfeI4hYN/urXsFGhxJbaRks44r/owanJSPmOUQecby7Poe87+rnKr6MTNWiBgqvCmn5AVgH3/QjCE2cqs9iN36qhkBmKskKuVt0QjCCdgsipa8W9yP6VhCa+lKK7rWJ1QyEccw0Ezhn2dtCa4VRPUU0TEsmIUDLPiuVwS2S6KGUClLbUXckx62TfeeBK/3jz65uIl/gSy3a8RIZ48t/WlpsljvXY3dDBHdZm3qN75TSThk/4du7aMflDbzBCoifySJEU0r4ArbcCafNxvduLUVaUCnOP+pearLAxx+7vP+0jQzMGLScb6YelAUWywoBk2UzX+DltezR5cGpMLEvXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2UYrNRt6Hgk924NAfHO0Za0D48oObid8JGepvNSC55I=; b=TEZM8ccLqDhxPEB2/bGSvynoYgL0RG6L+r5vQHMgdcmHxWKFFZNi2FCY7pJPNRL0xnzbvsiLoiRhV+rag+rQwaXjBhRNsKdiberA0NUbDY+lRqk15qXYdFK7ALc7VdRYlGx1kMDLbajO4IP838nN6Yl50DrcQs2fRObhYWEKUYAySichi2hZyuAIT6HCGsnLXOBo78zb28aZIgSy++kwqeyJYVs9o2S30OIxpB1Wl0AfY3lw2ATzNhGuox+GP7uK2TiJqpkf148rXL4Nn01es/2ch7ZI14pqIpbH54S90RmAHCtRBeTCQNLjJY8JaZnStzRCKbgQ3y5A45+FCJxAnw== 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=2UYrNRt6Hgk924NAfHO0Za0D48oObid8JGepvNSC55I=; b=mz2a6MKT2HCIpXQ83NLLb2N+p9ci2qIfwYmclaeMZ5OTnXmdBNQxZQrG/X60rDxMx/cFFsaIkBwmTN3LVHLJdjpFuACrqS4Mjbgqk+fl89Nf1M5f8md3DtuEnbx2S3zWRyyCIi18mfHGZd5vcfzd21RxZcWbQwC0K141mO/f1y8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW4PR10MB6394.namprd10.prod.outlook.com (2603:10b6:303:1eb::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.9; Thu, 15 Aug 2024 08:28:10 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Thu, 15 Aug 2024 08:28:10 +0000 From: John Garry To: axboe@kernel.dk, hch@lst.de Cc: martin.petersen@oracle.com, linux-block@vger.kernel.org, kbusch@kernel.org, John Garry Subject: [PATCH 1/2] block: Read max write zeroes once for __blkdev_issue_write_zeroes() Date: Thu, 15 Aug 2024 08:27:54 +0000 Message-Id: <20240815082755.105242-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240815082755.105242-1-john.g.garry@oracle.com> References: <20240815082755.105242-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR02CA0128.namprd02.prod.outlook.com (2603:10b6:208:35::33) 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_|MW4PR10MB6394:EE_ X-MS-Office365-Filtering-Correlation-Id: 6331b993-008c-4804-eaf3-08dcbd043269 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: qQ+Ee47pHsw4ssSCUKX8N5qklXRIk3p/fk5WWd9MhTAX2hYlAREtKLMJVdZaSQ4VhIUcgX7G8S696F4lEwb0kGCYwfKexlr+fUbCpJ1nshm6BwDo/mNUEIbYuJsAlOy6KDSQQCUZ2b/T8iQUSsaULZc76xwvAyy1mW8LTckYe19YrkErAlfhtPMt7epwsNDM6GD3Ym5QldeSlzC+vSwbDIdr7+SJbZNMmszZghRbTuolHKvOZCzV23V57vfMFnu1gWEbZozerK1QqyDZca+0XmL48m3DS8VoAYJnUXoukKLiYM80olJEFouOJbr718XDXdO6E7+imUpER6bA8NiAJj4/cUkRQUpqJMNbrLsk0YXxKigaUwSh1qrpAB4s7UphFe3HtMNgTukhogiTcsvLbXRRU7XhG6zf2l+N2FqtHXF4DVXRwNfSQsV7AeKlY0Wj+yvnwMDPdcC9H6ur6EbbFc3cnhdsfYH5d7L6S5hsB3cDAwqgJWPmFSjx4ULAazxiDBNU1Gt9BiVHdJM4iaeqvSZfGuNniUDQVwI9AOAfogvnlCsbgd8PbdQnlWQuqRnKSGm3kXsAKkXatmLV9ivL5nqYMP+1poSIZe0VWafgpAJ2vv0uAjySzdZJLONimf7sH4z/7HPTpycyPCYPpTsJJdAinKr4bLpZo0+MBr6+NtMl/3zY2uqxuckt1WBCQPnO8FybLQcwH7Vp49linPE8e1Yi5AdGwq20/w7MZE0FeRyjIJPLTPv7tuT5p5WBkn/dG8b7F++jVHsVHq+muXS++8FuEkwsAjZmzcCjri3meI/xkfMvLvW56lKhrE4ilAPW8An9kgFFzo0lhJQrHbimGvTtiKmdkcT41n/QGOCk8BMGNCzB372pn+qhMs8f5IQDh9NzRECGDwyOlIxQ+eQ32uR2Fy8z+1QsJnKUJr+6KnqvZf7V2EnNTEbUCjxaUhuyDanE1LtBOMy4s1apef7SGZz96VN6sWtUz/Wjc9o3yyOl5fhlUIG+s7tp4kEHvsaPCvdx4BsYZsT7obAz0jAKVAPHJbOYs9YiAvVB49Cce/232XEncgeOMHKlUPrE8iXGMaZWENZqnurbaTWRkM2rkTgXV/2QwtcpLeUEXqjZf35kTfKTQJHihKNizOvhhGX0W2VbcFZXyxrIEf/jYn2sXMOLzQ3wHmtbqN4PnfmLkGL32bceqGcYaFCgUj3ygimsmhuMpJyPtRA27QKfGtduepUAvNt0i2evFauesYOT9+9qB+lD2a9f+3k+y76VBbDRMecXqApxSPi/puvRrsMIUBWeUhBbUC7Iv3R3ap1LC1I= 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l6Y+tp0gvXAiqptfwFWa3SDHJMehAuqArqBXYkg9PuY4sCuMcKJ85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w+k5Pc5mOYd7Z93Bb9YU0v8ZNKDMS3bvl39jxwDrfi72595JDzs6cliMP3bRUDhd290sezUf9OTowYJOKg/vhZs81oDTqeO0g+ffWD5y+br5AXx27fW/L1CQMp5Qei+yz1WEVrPPAJbnya4DGauorKbao4REEeZfNlYvEjlhi1gRmtNao1HpwZhmXGRxoNJNZU074YeakurUYsb+Eyql5YmMkzfHm0B/C/aD/AbH9AiMjo/WQqezAM8nlA+LTmWzkWB84zOk4AisE8uVh+ENoorHeSQkZVBCDZxI2fNOYoT6Jc1m8aKxZ5RK960hUrneAdtb/yOhbbV8dk7bo5P9gJytxFMCag2EvkJbDgZSLUmnk/3AvS0HRapxhrnKRfAa2SfE1tdMKmYrLbgQcGjJBmlcwap5tpKPfEhwcTcOX2z9B/Pbkb/KxJquQW/FCEYENcq66GLDJhcTJLg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: TbPtN6Qh8TW/ZT51CcvDpRf0hmGqebVbKsCQLgz54MX/1jMz2ytkffANF+guVY+um93NIij/tsyVTX1fTm9MSH3t1ibiQuIMEmHcEz6N177I7gCxln64JgMHe877ZWHfdlvpTZkA4ofjZ05T3pEpzJ5kTasknVK7LFv80WCmUcAJ7aVXwjTIvG6XSNekJXZa1nMxpaz2gO4bwT50kw450rL+/3IfNuHpPVaUa38rIapN7OTencFPuNS4Mw2SA/SA6upBIor673TnpnKBq64QPhH+RoX4dITxGHT23xwKw/vfQhJ/9d1kewqjSE2AaSaD79Ontm3zdKo3jKySw3VZEFAsLuxcPFeQ6sJ2w+nQ3H2JKDZtWiJypsBGB0yowIGEIWVdJY6AcJMjeFmz+istyrO1QGEyLWMHRGxusejXzF9yVDOsJgirm60Y1EjBi85WXvxgHK4A0Z5tLvkXwCoxpuRUpR/SUhEJvKjmzwHK+6WrfHIq7MuyFvoG4uJ7FvgSl84ZKKvRQUrKxcbY8sVxxIs2OYLzdB+Ls1Y5k6gTmY6sWLyfk66xZ9l9oKwmqLHvg+cuQAucvYqAw7SNlPmMPMcmjCr6u0OnNDp/mmlHS14= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6331b993-008c-4804-eaf3-08dcbd043269 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 08:28:10.4395 (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: 6hNGlweJNnjUZx2/hUNzYqFU/0BUh/Ufom8YwWVD9WPN4Qk/LeeP8ZHMM6ClALus776cdbjzNeLpHkkgPH0Apw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6394 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-08-14_22,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408150060 X-Proofpoint-GUID: HFq9dSrVhxKDVSOx2MsHlhXShM4gVgoC X-Proofpoint-ORIG-GUID: HFq9dSrVhxKDVSOx2MsHlhXShM4gVgoC As reported in [0], we may get a hang when formatting a XFS FS on a RAID0 drive. Commit 73a768d5f955 ("block: factor out a blk_write_zeroes_limit helper") changed __blkdev_issue_write_zeroes() to read the max write zeroes value in the loop. This is not safe as max write zeroes may change in value. Specifically for the case of [0], the value goes to 0, and we get an infinite loop. Lift the limit reading out of the loop. [0] https://lore.kernel.org/linux-xfs/4d31268f-310b-4220-88a2-e191c3932a82@oracle.com/T/#t Fixes: 73a768d5f955 ("block: factor out a blk_write_zeroes_limit helper") Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- block/blk-lib.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 9f735efa6c94..00cee94e5d42 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -111,13 +111,17 @@ static sector_t bio_write_zeroes_limit(struct block_device *bdev) (UINT_MAX >> SECTOR_SHIFT) & ~bs_mask); } +/* + * Pass bio_write_zeroes_limit() return value in @limit, as the return + * value may change after a REQ_OP_WRITE_ZEROES is issued. + */ static void __blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, - struct bio **biop, unsigned flags) + struct bio **biop, unsigned flags, sector_t limit) { + while (nr_sects) { - unsigned int len = min_t(sector_t, nr_sects, - bio_write_zeroes_limit(bdev)); + unsigned int len = min(nr_sects, limit); struct bio *bio; if ((flags & BLKDEV_ZERO_KILLABLE) && @@ -141,12 +145,14 @@ static void __blkdev_issue_write_zeroes(struct block_device *bdev, static int blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp, unsigned flags) { + sector_t limit = bio_write_zeroes_limit(bdev); struct bio *bio = NULL; struct blk_plug plug; int ret = 0; blk_start_plug(&plug); - __blkdev_issue_write_zeroes(bdev, sector, nr_sects, gfp, &bio, flags); + __blkdev_issue_write_zeroes(bdev, sector, nr_sects, gfp, &bio, + flags, limit); if (bio) { if ((flags & BLKDEV_ZERO_KILLABLE) && fatal_signal_pending(current)) { @@ -165,7 +171,7 @@ static int blkdev_issue_write_zeroes(struct block_device *bdev, sector_t sector, * on an I/O error, in which case we'll turn any error into * "not supported" here. */ - if (ret && !bdev_write_zeroes_sectors(bdev)) + if (ret && !limit) return -EOPNOTSUPP; return ret; } @@ -265,12 +271,14 @@ int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, struct bio **biop, unsigned flags) { + sector_t limit = bio_write_zeroes_limit(bdev); + if (bdev_read_only(bdev)) return -EPERM; - if (bdev_write_zeroes_sectors(bdev)) { + if (limit) { __blkdev_issue_write_zeroes(bdev, sector, nr_sects, - gfp_mask, biop, flags); + gfp_mask, biop, flags, limit); } else { if (flags & BLKDEV_ZERO_NOFALLBACK) return -EOPNOTSUPP; From patchwork Thu Aug 15 08:27:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13764494 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 795AE13D530 for ; Thu, 15 Aug 2024 08:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723710524; cv=fail; b=eBcOZQWKZZ3n6tgk0L9OB9hXUXsZvfyEkYPqtfyQZdVEBo2MrplGLwdXvzXkvZ8jLUP5hCBRwUvXy4UrLYSgZfbDWvqb6kpoP/uQH6nw4B9l5Dm7iXmjn4HrAu8YCaQ8ftXrJgHHF4BtjE4SimHl7UICvzWFlPYMUsg8CaqoPhc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723710524; c=relaxed/simple; bh=yB6v9+e7sO2qlPskMZlrHMEdxJIhulPSPeXlDXpRcvw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HiCv7YpxlHz9jD8wOiZKImqjD/jNYehAvlA9pkRFOxyFlyIjQbvhb4I2lQjIjoNpmYFo5o5ofe9bM1N+APRXGUt443a988Wk4+ByNYthi5Qs+JpnyrI4TANGJHQQpLtXyqWFphqBDxefkChQN5xJcNv9+nfyQpgIzrdQe9Sb4IY= 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=O/OAhZDA; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=YtFnUK8W; arc=fail smtp.client-ip=205.220.165.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="O/OAhZDA"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="YtFnUK8W" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47EIXl0Z007009; Thu, 15 Aug 2024 08:28: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=RZXINorZSC/xOeoR1lgblJukeobVUKvT9ArDycW4LvQ=; b= O/OAhZDAWaLpkQdt+4Mx6deYpRIgtYENR/eTLIHOz8Tu8diSxZeKGgbfZKrxbIoW x+siXc265xflflU1NrdYzuDJJ+nFDZHvVbcgviPu0hVPPMy18xrQaNFUnP5Gf0Nv xUNhnAo2KoDeE/IOL/j91n9IIihox5k3+piAjlhtorMinon3BjmHczCp7+K9SucK OEdPkapwb6bhFordih6zEcH5p1blZkMGnP/VASpyTViw7fJRHefonGkS2tI04PKT XBOwxpahmg2CP5TKkw9Abd5aia46ajxQyowF73rPAGpHcTaJFDCJWn1p/3qiipxa UEeMFNaurWZGzCE9qUUKrA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0399vfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 08:28:16 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47F7lMc7017118; Thu, 15 Aug 2024 08:28:15 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnbwbu4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2024 08:28:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QQDLSHJ2lFvKGDcbh/BxsUAytI1p7TQeUdSIYP7v9yrCKFp+QPhRe1/ey8mp8R68HvK54ASVa2qkTu/V3rZYge9UUbx2vwub/q8UB8gJPFujOy6i7LQre/U1TlNdglP36Pl8DHzOs5SJk3zRYm6Owh4NAS2hkxZBOcOZ4JOD1cE98/2n46R3+RKfnobK/HRJPt86rbi5zvLUmel6LrQrciZAF5YzNpKumNUWDizb4yX0V0JDCTieM66lfTO4KpTCdDS6hrPljHGCfYRmIoTduAWehFwTHV9Wwp8060t6TUMcE+nFMTCXUuO2PDCirtlvkJfN2oDrYuHGtGQ8N22oOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=RZXINorZSC/xOeoR1lgblJukeobVUKvT9ArDycW4LvQ=; b=sgmyllufY8O2QOBOdZDQgypVSfWGvY4Di2Y81gHxDN5r5rq+GZRWGSeiQCS7SscQ4cXieJw6+5NdjKzuq1Or7d2U2tBE8drw7H4xnWSM7PAFxM4GK7atn08XlfuLNeoxsII1+UXKub3aTG8l9sY0D/hZDEAxcU7G25kxtK9lh7/lQD7qkETsuhd0CgWSkiIkM+A0zaGh2N1k0gDcH/Teq7gk9yjpHBJwXijNUGxceF3VNqmNd5uWfCHB0Nm9Ev/WgKbE/K5ZLIz9bXBm25OPX2v0qMlgNjqvn+2ws6lC1GoECAXZrobCccFSNZ4c7tMHZCIHGHaNUqWbB5BVx5hc8g== 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=RZXINorZSC/xOeoR1lgblJukeobVUKvT9ArDycW4LvQ=; b=YtFnUK8Wty3zyYwUJxbzUoTvqX9hR1dnssNB1M8C6lvwsIlkl45ohTzl7g5MNnlOFJ0C/mj1IYEoGxJSJO1rM6zDhtKlssj4GE1thwagJJLZsc8Spexrcnzm1rDG4HFq54gKYkXRWBRQOSlrJhecI5A2yzQSSCwG2N/Cbo+W7Go= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW4PR10MB6394.namprd10.prod.outlook.com (2603:10b6:303:1eb::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.9; Thu, 15 Aug 2024 08:28:13 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Thu, 15 Aug 2024 08:28:13 +0000 From: John Garry To: axboe@kernel.dk, hch@lst.de Cc: martin.petersen@oracle.com, linux-block@vger.kernel.org, kbusch@kernel.org, John Garry Subject: [PATCH 2/2] block: Drop NULL check in bdev_write_zeroes_sectors() Date: Thu, 15 Aug 2024 08:27:55 +0000 Message-Id: <20240815082755.105242-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240815082755.105242-1-john.g.garry@oracle.com> References: <20240815082755.105242-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0446.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a9::19) 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_|MW4PR10MB6394:EE_ X-MS-Office365-Filtering-Correlation-Id: f59605f9-b6c8-48e1-a3e1-08dcbd04342f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: ocfPG249gNG1wrXpi66DZw0b1zXcU67GpyYlbHARpXXeX7jfvISj4aksWHXZ/LR1XweCd60pwaGdDhmGTjphSUzSzPi/wzAiTSSR/2QBkDWpdIV81Sqe2pLeFm56av+6oCC7+2KlZ/QNCyvMevMnS/U4aBtvEmb/sB78fFPKIkZVSp7SXk8dHgT6QQkO7UKsoyk3VEveH8Ch81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arMjb48NoK2mpUqTFk1ez/LBFr+bAf0u+q873MJ8AF4PF+Ca82OXiQUcXmj92klSOoQ8dxA== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OxVWmIyNhYUIAC6tdOm6zdGwH35bpogp/6tWAiZKkAVKY0wTlUwed/pnKV/AkIFT58I9AjqjkGbQdWR+968MRucNPkYz2W288LUKZz9n7ksRUdGNg9tgzZeVZja2Mxi2QG59HSWlQ97a6j9nFL9Iq3DdzdC3dmtaLGiGlNtqzYnjCtXo0MmTc19bg7iuUxBorxJtjWtLySzzpVjmDppu9mMWA2jGyqufMLHRvk9ubcomuZtxT8xoBjYbjOv39ppiuBATIAD0g17NJi+8kTliL/xi5T8r4WXq5K3Gta2iGrdvTalUm16FGz9GndsuU2CNHBzndm0iwd8W4FYT5DvKjVUN6QV+8USiK65+Id1Dr30gdCJmwtuyUCNN5BxxS26uLEvrePopx2+N5+er1mwZoetznjRXgbwzmF/T0ew/4QQJjrXCM3idcmcrPpqQUwYTzwF/lYscuFHxgQvf43SUUtAApF+YS2B1RdDdGzaLIKGC3oSi0H6psqYG5fXbzmHxuuiScGIe8cJzFeQKUCw5HEWrN1pPGOvD1l4iIhqMsBSWAeZu9elqV8IN07TdNi9LFwPkCcSQFOiCZIg8rRMs8uqIJigufET8xEGcWhp2/QM6pSULLjlIW/Z6S7fb/J05fCz6UQJK9NgR/S2vQbBDmOblG1S0fMLBklCWCytxtDCMoFQbdHclQJXRpxpmkDqoOKRKCR+sNhPwtHh6/aqcPZ+oDymUGHDD/8ajckUgk7/QwalZYFJNeJM0X8QTpCI8YkzKdDa+Sa1qNPxantwHCrj0y0nwQ0WJE1NP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VpdXc8Ej6cHhgbfzTqJzZngy3gX1kBq8RRhigCJn8YrN89/hBppYbmZ1QmtuRsNCa09yscmye8Q/oRMT6jF1urIlZYH9QVr7MFiStlz20GOZWtmM5o0jH84tiwDqnhhQZJDq4FDKz847T0Gsuek3Nqal8OanWxpygn7AXVTforC2mssaLO1yitmJWagl1W+jjSo/0ymSpeMKh20SSwsu3hxq7czPAfTt1p/8i9FL40PItHcoFHmSJt9tD25undsdugc8nqAfW66Aa3QHNIbfqEPKmODIh5ptbgV3Zd2O6aUXtoG0Ro8JPdWeQC61TQgrIFigbgo0n14qkJ+FcK0BIRXZrn3+WXlumr7OxHshh7AmIFh7AqglB25goB1wXKlniWTD/lAMCCPtg/s0997E+iPjNskUcVhHA2AIhUtqGoCWGYh20uT9nGQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f59605f9-b6c8-48e1-a3e1-08dcbd04342f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2024 08:28:13.4433 (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: tXjihynZ6E1oW3XhpFctoZU0EU8tzeFnmkUEhgJno72k7206o1c7ugCwq6oRVDTPtyt+F+R4hT911bgoZt6kYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6394 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-08-14_22,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408150060 X-Proofpoint-ORIG-GUID: I-4fbODZXhzi0jEOQCVy2RbekbdKvuKL X-Proofpoint-GUID: I-4fbODZXhzi0jEOQCVy2RbekbdKvuKL Function bdev_get_queue() must not return NULL, so drop the check in bdev_write_zeroes_sectors(). Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- include/linux/blkdev.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index e85ec73a07d5..b7664d593486 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1296,12 +1296,7 @@ bdev_max_secure_erase_sectors(struct block_device *bdev) static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev) { - struct request_queue *q = bdev_get_queue(bdev); - - if (q) - return q->limits.max_write_zeroes_sectors; - - return 0; + return bdev_get_queue(bdev)->limits.max_write_zeroes_sectors; } static inline bool bdev_nonrot(struct block_device *bdev)