From patchwork Thu Sep 19 09:22:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13807578 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 A240D19922A; Thu, 19 Sep 2024 09:23:50 +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=1726737832; cv=fail; b=lQQhN5mbZib6+gMubDH0iN4TTO25wyueTQnnzn05p5ugimLXfD4t+6hp2nMw/OR3bzt8ctAk5NX18sqBdD3M11Q8cZyocDZZcxsWJ9ckfAtY3MpANS+qSImatbY/h81XRf58VizPpsctvdsyhNlBw5aCW62cHAtcrfqjlhUGekg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726737832; c=relaxed/simple; bh=xfndRRfR2Jq+bHPzc/3VY/dAHbY9DcMESxxWT9aFZxs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Y4j/VXUDNTYXo2YP2ol9LrI6maiBcSQRfHAPtj/4qs86dlLrnJR8yjFV+T9YbZeQgwuljE9meaXNI3Ja50Wt1r/E8jlW1UdCDW0BuOIopNI/o2n26bS3XQUySSADxR3hsobVMDa2Pvurz+u8Z+UgUDZcYrh3Pi63j/591Di1kIQ= 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=ZO0rzcLy; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kNfmOLiH; 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="ZO0rzcLy"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kNfmOLiH" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48J7tWLR001460; Thu, 19 Sep 2024 09:23:46 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=ArrDeQ6Lb0PjB3tI/2f8n47f0LRAGqU99EWV9u9uwQA=; b= ZO0rzcLyHRSjVlKL/DjoCLA4BY61CIoGb/HVHoNme4fPksZ4hf0Y2BGMxDNtR+jw XbBFOr2oamdmNy2Uv163r6dLA5Sw7VlmoIdN67Qo/bOwkCgW6UKnUrHPRLHpHCi0 YtGV+M62+APzJpV0GxIdXLAPlKGoMeVOhGPtQNFM7ikY6fnIDQ2EdRY8Ve8o9jwU 4t/Upet8rqwc5RAxh6/1WbV28OPkSm8DDwnQJIRkRxQGlhZik8L3tCd9JclkP+GB qUzBpnaT5Xn1A4pqP2GW12E5OefREMpjvrvaXK/IuAUcSyRgtlqnd55Wspl6z8uF AokEyWOfe8ZeijgpgILZjg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41n3rx3g3c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2024 09:23:46 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48J7gWoi040473; Thu, 19 Sep 2024 09:23:45 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41nydxtetr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2024 09:23:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GcjqrGEhSPXJZomI5SdcnBDliyuSICUHAhbeLjvdy3ycmYwzZNA0tp0W9But9JtG/EgIsjPZ0lttCyscFn+vcfp6wop5Q5dItDr+YM7r3XX9U2LuMLb7CIM7y6iTLAuQVv0CAkygbT+EgkG3YsEwnlAYSCvE578vUXbmhC2n0YuyRVAem+sKggbp+9NjHRD5iLwbdRRmZ2HEWZ8Bijb4uwH0Ji9Qq6JRTJnYx7JSDKLbk/oL+ocKZwFC1svHRtdsHhgi8gFBzle5NGWpPVXqmciqZHkx6v1EdlIzw95YHPRu5e3sNOZfVk0pO7iFw/Oz+ePgQBH6WA9qf4hCH1oi6A== 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=ArrDeQ6Lb0PjB3tI/2f8n47f0LRAGqU99EWV9u9uwQA=; b=gwzz61+NosScRwvH3bkfc13q8+BeBLPMYlsgnegn8iF7enrH2To5MbqzMn9xVp9k4rVaqhPvJurPAEeRKKt1HZ1GkynnQjZe83y8JOSEWfiyV3Mw7QVQXMlOnDCkQhGkyj2Vu50uEDNURW7DvGdG8kF/ccfdZ4CIjowuz3flzHnvJ3lbWTp1rsqA3HD1YwzfMrzxaqG3AJrExwo1lgsHh/UoGRpXh6dby3YNor6Exy0530OypUyX3q3x1QDuxbGGw39jfQzZ0rJqH9Hw18SreiX2ljY/N+IOTIPLeBV/bbSMj9uEQ66db458b/nzpsJVzGGIcu6uNV+BICRYNzB15w== 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=ArrDeQ6Lb0PjB3tI/2f8n47f0LRAGqU99EWV9u9uwQA=; b=kNfmOLiHcoY5zZPGRsvjvhnxePyD8hQA24+r5LHmnrshh5q9HXT+s2AuHtCuTfxDrsQ0z82BCYziCuIozXHefwRrBlz/cryQpJhrwv+vTjPWLN3NV/uUkkJSKwPYPhXkJZJlshRTJjGUzQZb9eNYLXdsvcOvXvNHGHqEwyDrxe0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB7769.namprd10.prod.outlook.com (2603:10b6:408:1b7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.10; Thu, 19 Sep 2024 09:23:43 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8005.006; Thu, 19 Sep 2024 09:23:43 +0000 From: John Garry To: axboe@kernel.dk, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH RFC 1/6] block: Rework bio_split() return value Date: Thu, 19 Sep 2024 09:22:57 +0000 Message-Id: <20240919092302.3094725-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240919092302.3094725-1-john.g.garry@oracle.com> References: <20240919092302.3094725-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0469.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::6) 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_|LV3PR10MB7769:EE_ X-MS-Office365-Filtering-Correlation-Id: 9eedf12f-f997-43fd-8b37-08dcd88cc162 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: hXMq34ROVk6amKaQ6COiZ3ECIEOKgwjQxB2ZINeTX7Q2mmJxb9cCg+0tH1brVQQtmHTMN99ZPyR8txqCl4rp7QrXQO9cMss0bA4vgZc8fO9c74bSIIGprPRBMz4NBNVhPFXmRHI1DNgt2pMTRE9NshBvXenS/i99Pt2adHbzDQkKCjThxjwA7Wp1c55cWeP5R242LXkJYIei8fPdshDADr+8MypxnsMUrPIxU7QBnq/78+7uBeO06g3sRtXyDMFC3Wf0wjkmuBAFRXvozCxwfuFOt5UczzuPHZOL/6X7lVNwgQLa24Arr5clpFu91rno3x1qMu/KFho/qiq6PCMgt1aEABmE/X/pYvgEJMlOYAH558JoAnn5Z/HehO3t/8DT7BnhzoNm5AjhdsBZ/BsLiQQOxPLBjtco6E05mlIT0vFnunIxKTrt+RBFUU8sUtFrL+/XFtgme4kXX9CDCLZZ0hOL4piD8B0G4g6JsfFeKThR5fL2E0ElR/IuDx97sWpcawXFxMK8LXzQn62ZquICZSEMhFm91QDZfcF10hAe+6/tYsZKi34wwHTktwnvmJeCNrBo7/9OcMG7fR4AealjodbItBWcDZ25nMduJe7DpmhwkgKfCspiU7nXyx+vS2vGwGCOVCPk/1LF3o40jujCqMwY47VJ6IDRvH31BNceMNIZHWZSxnoIELrNbBoCs6hEPdQmYCsA5g0M1H5QX4HBuNschdjOGoKNUZLPy1mfRr3OVDMHbqQTGYyEoA1csgxoZ05kzx7qjeJvszy1ElRSpCEUWm2muU7P56P6C/4Q1gb3+sCGIQpbSuOGpenwLBdG5W/GTjQ+4ONKaYOZgxYjzEWDf/YiKMwg8KQ8pF+zH9sDBElYcDYL/HNhRzh5t1DUQleqQn6IoJ6hw51eFvJnxoalTVE6cjb7cjevCS97p1pHNFg6vBmFuFWYOAlPK/pLLpR7X/kKNHuLlMWy3siBu7mYs3vwqzMitP8+0u9ub1OXlB7tspxgU3qu3W/n6F47tZk8BNurHYnev5Mdu1i0Et5vJxLSUlkPW3H+5rx2C5xADPyaKzmLy6TyyFiuWKnxixV+cmIiEDurdN9EJvB05FXfMnkUxhKHXp4rIXOaecjFWC7Eu9d8jMkpCvNe++LozAS396GVGdr/YGA9qEcgRKh0axt6zoOa+bLavSCU2Vr90DQ88eZ9fZ1S2N5PzaWfmeIQdFUpi3a9wC7tai18KDGHrWcNwFI9JaMEFFM6P8dhSXq45OVa2fW9gFMvcE1Y1uPngatOKMOr4leoLVJvHzZRVwnkKrq+uxdK2fvHmqQHc/4a2I/YHTu4yaQJkida1QyWa/2KPM59fvx6xAwT1A== 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)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-Anti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L+cvGYK+56Q9tqkkmhK6Uw9eug4DN6uj6WgjLY3GA2fENmzWsXnAg4s4CtS9D+kuJVcKsJZGEdEr5je/CL+TvjbNV8ZJghOWV775Fqz79HeDOL8bCumKDdBFnKwYDodqaT+1mk6KcF3CVpDdFaab8SFfwD2AM3a/5kfneVfXRhh2Za3Ev3FpGot+fDpbG7fAzeL9dCCYueXZwwcCVETmK8fXuM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9eedf12f-f997-43fd-8b37-08dcd88cc162 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 09:23:43.3317 (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: W74jc+XFR7Ze0xiYVgJCXF0+V2CvOYGdOqP7UxVMzX2TYw4Fg8TufKkxczjCXDKbiYPfixryO0SP5qDmLLFXgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7769 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-19_05,2024-09-18_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409190059 X-Proofpoint-GUID: EtLUJHvjoDMwSXgssH6khVDAloNffUf8 X-Proofpoint-ORIG-GUID: EtLUJHvjoDMwSXgssH6khVDAloNffUf8 Instead of returning an inconclusive value of NULL for an error in calling bio_split(), return a ERR_PTR() always. Also remove the BUG_ON() calls, and WARN() instead. Indeed, since almost all callers don't check the return code from bio_split(), we'll crash anyway (for those failures). Signed-off-by: John Garry --- block/bio.c | 10 ++++++---- block/blk-crypto-fallback.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/block/bio.c b/block/bio.c index ac4d77c88932..784ad8d35bd0 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1728,16 +1728,18 @@ struct bio *bio_split(struct bio *bio, int sectors, { struct bio *split; - BUG_ON(sectors <= 0); - BUG_ON(sectors >= bio_sectors(bio)); + if (WARN_ON(sectors <= 0)) + return ERR_PTR(-EINVAL); + if (WARN_ON(sectors >= bio_sectors(bio))) + return ERR_PTR(-EINVAL); /* Zone append commands cannot be split */ if (WARN_ON_ONCE(bio_op(bio) == REQ_OP_ZONE_APPEND)) - return NULL; + return ERR_PTR(-EINVAL); split = bio_alloc_clone(bio->bi_bdev, bio, gfp, bs); if (!split) - return NULL; + return ERR_PTR(-ENOMEM); split->bi_iter.bi_size = sectors << 9; diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index b1e7415f8439..29a205482617 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -226,7 +226,7 @@ static bool blk_crypto_fallback_split_bio_if_needed(struct bio **bio_ptr) split_bio = bio_split(bio, num_sectors, GFP_NOIO, &crypto_bio_split); - if (!split_bio) { + if (IS_ERR(split_bio)) { bio->bi_status = BLK_STS_RESOURCE; return false; }