From patchwork Wed Nov 9 03:11:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 623619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D982C4321E for ; Wed, 9 Nov 2022 03:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbiKIDLe (ORCPT ); Tue, 8 Nov 2022 22:11:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbiKIDLb (ORCPT ); Tue, 8 Nov 2022 22:11:31 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB74D1B9CF; Tue, 8 Nov 2022 19:11:29 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A939ahN020967; Wed, 9 Nov 2022 03:11:13 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-2022-7-12; bh=4wZinNb7GU4J8atxTweXVJf6JAdF7VYCnK0Biq0fjc4=; b=TlLYUz+Oh/ajkgKwuzlLXJllD/phQhX/VdGwlW/hU3TAaV42SKaxiMbSO3OhE4OKavi2 iQg2n80rvjWEydF1ouu9iQqbzHxGAVobG37u4bmMkrTvtkGJz+i5vRog3ij4KdpSU/Z7 80OP4WvcygNMVRWWepVJxuKbSW09E3Sw030WKVJS0qJ4k1Ni+w9Zm9pN0T63ENjdM3Ef jkZkcYPa4hBTOgaRKjVVOWhFZY3lmG+b3Q0vb164nsEl67u2rD3lsbvyRrZvYuIQK40s h1Wsy0b1De6x3QGVtFoZyLfVo4F/zzSZkpxioYQZackojJe8LG+QHCLRRA9xDK8RjkAy Lw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kr4168044-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 03:11:12 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A92huOe036292; Wed, 9 Nov 2022 03:11:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kpcypndxu-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 03:11:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KyWpkJn24q3LHFbH+kVJ1tEU/hPUPSUjJfNCzQTOsOXVfLM0AmqJucbDCD1HMxvAorTERv+PC4TWnxLj36Xg4nH66ft069RkDS4VnY6cOMf2JsEtRw+FUE9BJCFD3pgKDxHMqNUAnfQNGHARBXXbEDhwV2kKGig6bN6AFYj4u29RmpOhmFr1+H3JLohzAjPGVsRgNFX/EM9T1EhlYmtYwQOxWl2qBHFZZB28GlRyvzU0XxmSaEdepjHsD4Q6WpRK5QVxRSy8MYI0NC6J6SutQYXUsowqez7c6Ae6wivRBJtefBo9XYJ4dWJD+Rn1veKhWMb0DWcBTd4C/g+jDeeKdA== 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=4wZinNb7GU4J8atxTweXVJf6JAdF7VYCnK0Biq0fjc4=; b=Wv1m1y4U9wpzAk94rnSe1VT1hoFMfb9VkSVMuA6IslHywnF3DzbPl11q3QESstzsM7SOLCifPBgKuIXYlQcUETnxJcjT/B+nbtWA+WlxHG8CQaO4BLRQmpwOH5m5WLSleyvbgr+UwuBXxQA8CCke3m9xKbl4mRZ3GPT9h4410YyUKDbUQCGFwS5sv+8IAkUl3NBZSAvNU0Udd0MJ//bMCv5FHoomltj/KOLawA3x48iHvTYFxVd99WHChl7+3D1qOsyOV9VweT3byQfE/9nrWyHfYLBnYhPnzTAYDLjNLQJXp5Fe1bkgNuxkbqO18IOZO8if7R4g02fdJ6B1h9ND+A== 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=4wZinNb7GU4J8atxTweXVJf6JAdF7VYCnK0Biq0fjc4=; b=wgvMJdxEE++IEnluYhzmqmxAKj78fBDeld0wum9kuprYehC4aSlDab5TsXfZfWRpF4YZls07eirM/rufc4EGxtYLKlrRobVr+obnR0JEZGraLLeWNWqBh8x45QysJ3vXjJGAM2S0c9DlTd5QivDvDGXIuOmbPuOtb/SgGNLP9Do= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH7PR10MB6033.namprd10.prod.outlook.com (2603:10b6:510:1ff::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 03:11:10 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::19f7:e081:85b4:c5df]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::19f7:e081:85b4:c5df%7]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 03:11:10 +0000 From: Mike Christie To: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Mike Christie Subject: [PATCH 1/3] block: Add error codes for common PR failures Date: Tue, 8 Nov 2022 21:11:04 -0600 Message-Id: <20221109031106.201324-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109031106.201324-1-michael.christie@oracle.com> References: <20221109031106.201324-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0034.namprd03.prod.outlook.com (2603:10b6:610:b3::9) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH7PR10MB6033:EE_ X-MS-Office365-Filtering-Correlation-Id: 6785ce9f-5859-4ab6-2118-08dac2000d2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LmGnI9Wer5ytBu1wlGF7McagbS8/rw5qMXhCKyT0PvjwM1DMpFYnQe4M/XoLU2OYDl6fIXuR4Ft090HL8rCL8haIOlRZfOgO2BH8vxuGehq5AxHlB/P7Bc7nhowYY44zw9q3uozc0EfL7+FVrjM9j6z06FoXAPOvGQ+uZjcKmnmIqZ3rqXH0M/A7B47rm1Ejnb9AKSSdL+TT27I3qMrpJSLRcNBVtHfF1VrmxFir5E9dfB3XI50uJMudOlYbHmM7TcEmMQLb3GN9InMdlJSN0+DaaINkSggfKSMLyxlgpVTrm7CBKB5p8uryHNVENQtnFUN/OEcNCYZ09S2WdR79drlAY7iJ9QruRjgMh85Ypbpvj/um0poYpHFrvlCifppxqekN4DCGJXD3qxne52CI/F4ST2h21tTpV+0gkdweXIf8N0LnI8N6JJU7Q6yFOSksZfvqUUd5eJ6er73scERTUo+JNrzimjbI9TwMtOG8JZsLWtwj40AK/96GVbpZ1Xl5QAxTWhNdSJ1o0HJBu4ona05+Xv2It8R8wBh5tC+xhtGk4vJR8H0aCg7/gaBUGEqOK2Nmpak6B2EM4uhxmnsuxC211SVsdi3l0QM/kzUh7CY3qDLxLnkR5c9Uzts6pEeKhF5Oz1qDsohsCrFeIAZIN4ha9hBEnQl7Kyib3KDO8xZcvqTDXoxVVGD6aVe8DLVh0T5cuaROqkg3AkOjgpUICg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(136003)(396003)(346002)(366004)(376002)(451199015)(5660300002)(66476007)(66946007)(8936002)(66556008)(478600001)(41300700001)(36756003)(6486002)(86362001)(2906002)(83380400001)(186003)(6666004)(6512007)(26005)(107886003)(6506007)(2616005)(1076003)(316002)(4326008)(8676002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mZu93fewMcQzcZL5evAbXhgGoi4POgZwmWhxVOvzVvisw7dL5J9udPOzVSLsK7kO/cHqtjjQfHla3ljNH72Wv7Ix7iQPEoGVmBZS8DwDU2UnFdLYAfHadhIasw5IhanY6nEfdi19UFWRXiFWWALF9MWRMM4jWuPH5O85dJTdViU4HM9F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wkLWKihbxE/WaYHtPZDStE3A9J2b53h6Nds+5KG9bClY7okkWdgBivB5MRZkd7QqxFKfA1WfnPHJdWi5rb6uNYz2OFjEazki0dPkFuDALoqaDs9yP52hn3lKXHh9Y2053xMEjg7wi6/5w17OcrWk4pIy+djkpt1rEUmSXimGM4EBigL8vp2+N1n7/bR1gSBxAngh/INcFZFvAiJcNZC+zpJzVhmYC5kI4cYvRe5o4hFvXduKkGmwGMzb8qIzISW6ejGGGR5sV/SkSzghGj4lfeHEwH35a1h1jGAjXaehlVkQVj8UYA93YpohFStjRb3Ot7XjWheRJRTEoSxkaqScdHVbV5cdGU7lgOcRCLdcz2GSj85joOdVx53w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6785ce9f-5859-4ab6-2118-08dac2000d2b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 03:11:10.4315 (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: Abe+ppf1VSBykvLruBlfCb6sIaQEUW8LTqmMKP1aKIcXNKo+K0ZS+UqbCdBaQTABylPytk9ETT1wyvxhMSiYAhJU8D97l0xik5fyrEB0t7s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6033 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090021 X-Proofpoint-ORIG-GUID: 3DdFNvgqsTblZbrUP5zmh7Oglm9DpuG4 X-Proofpoint-GUID: 3DdFNvgqsTblZbrUP5zmh7Oglm9DpuG4 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If a PR operation fails we can return a device specific error which is impossible to handle in some cases because we could have a mix of devices when DM is used, or future users like lio only know it's interacting with a block device so it doesn't know the type. This patch adds a new pr_status enum so drivers can convert errors to a common type which can be handled by the caller. Signed-off-by: Mike Christie --- include/uapi/linux/pr.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/uapi/linux/pr.h b/include/uapi/linux/pr.h index ccc78cbf1221..16b856fb8053 100644 --- a/include/uapi/linux/pr.h +++ b/include/uapi/linux/pr.h @@ -4,6 +4,30 @@ #include +enum pr_status { + PR_STS_SUCCESS = 0x0, + /* + * These error codes have no mappings to existing SCSI errors. + */ + /* The request is not supported. */ + PR_STS_OP_NOT_SUPP = 0x7fffffff, + /* The request is invalid/illegal. */ + PR_STS_OP_INVALID = 0x7ffffffe, + /* + * The following error codes are based on SCSI, because the interface + * was originally created for it and has existing users. + */ + /* Generic device failure. */ + PR_STS_IOERR = 0x2, + PR_STS_RESERVATION_CONFLICT = 0x18, + /* Temporary path failure that can be retried. */ + PR_STS_RETRY_PATH_FAILURE = 0xe0000, + /* The request was failed due to a fast failure timer. */ + PR_STS_PATH_FAST_FAILED = 0xf0000, + /* The path cannot be reached and has been marked as failed. */ + PR_STS_PATH_FAILED = 0x10000, +}; + enum pr_type { PR_WRITE_EXCLUSIVE = 1, PR_EXCLUSIVE_ACCESS = 2, From patchwork Wed Nov 9 03:11:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 623290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62D0CC433FE for ; Wed, 9 Nov 2022 03:13:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiKIDNi (ORCPT ); Tue, 8 Nov 2022 22:13:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiKIDNh (ORCPT ); Tue, 8 Nov 2022 22:13:37 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA6BBC3A; Tue, 8 Nov 2022 19:13:36 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A939TG4020837; Wed, 9 Nov 2022 03:11:17 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-2022-7-12; bh=hzxcAPouRFC81x8A9V1Lp6b2S4LrgVJFFaYGB+DTr/4=; b=lZFlWshGiPmI6QCHJ8jWS+aCA0i147OH1QGUEAHBH/m88Vrgmeb2ECoFx3QktxIArThO L/ko6UbSnKezbTN54lbDvv6TZvykI1i1P8ULj/5wngRT5YKTYn8+qdlOsI4/fEMPuYhA CJ6SfIsMPdrwNn50KHP4P/5ChC334FnLQS817vrt1puDwC+rjFwOr65K5re5IAcKYqL5 cYCq4CaZFIUoWNhDtOybv4R1KcsvoXM+lnt+v4nQoE+ZldK8+Q8jSXLGPg6FwkZy5wPc DLVnKAimGeJChHc1De3Ud1xIpY1eXdRRhlw3k+JekmhyMTv/0FlnHesr9ryvtTw8mqvQ yg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kr416804e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 03:11:16 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A930NvU039953; Wed, 9 Nov 2022 03:11:16 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kpcqgv3qy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 03:11:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwuJ1xZ7LW+ZXY1VdakcNNSptK/iYLbzBFnY7qGMP/2pf6W1SDr1twgE6elRfL+4gpC4nWFOST4DoAdsTxzyfpK4RTra59ef/e2lXf+AW2z+rqjTfvT2BOYLR6WeUlaqraBo0qza+/HSfdLmeru8k07bUr+BT+nvtmoUKbFp76GE3dTSVwMRv8EBXX1Hv+AKHOodilczbM/9J4vYzdHbY2oR/0B8E81NqQhCi7aWglNhfCoEVwFWWoHsjIyEHscyqS2w+FjHbBxVdfA/1nCNS0HptyYKEx4sASvZm7SctRX8g0f5doe5vWUJr14+qsHoKtwVPIrC35f636Mt+48ZjQ== 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=hzxcAPouRFC81x8A9V1Lp6b2S4LrgVJFFaYGB+DTr/4=; b=H+XM4rGWIqCRCO/UQtLt51V7IR2yxNwtbDF8O4VZ97iFkuahyy8jaVGSNNquCV185qL/yNTIHldDbTRp4lfz9EfJ+8HmcinO0kN59VV6QFJImEMAiqYF9NVkdxibOQNBZtR/gJnzozxuC0M3wFceniYcYHavBUl0T63J1K7vWn/Ie0ALR15f2iGQHmA55nOHLY3uoor0uUQ3nMxTkfu7Gk0x+VcWQvEI/0AH57krZC0q3nqOpH/yrj1DyRk33QkfylXAY/RNPrEu5cOVmEwM4KQB/AmIqu+OtidVgpWCrAxIfH93YZux7wFCyqdtFzcn6Rprm+MjMYgwu9E0aNAsHg== 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=hzxcAPouRFC81x8A9V1Lp6b2S4LrgVJFFaYGB+DTr/4=; b=XsIl5k955166wxrly3G/wc9HaIlInbFTZKJMIocCDRgdDdMAFIpQ8eMgtKnL6vkdlJ6QUBx5gtCSAypjz7xxNL0+yXnw8HxeAeHXpbpohBkj3+wdLEyTsGiJGStBwMRYwl3gK1GGiY5tqsdgk2zr6mSfXdBzXQdyCubZ3FUwTw4= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH7PR10MB6033.namprd10.prod.outlook.com (2603:10b6:510:1ff::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 03:11:11 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::19f7:e081:85b4:c5df]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::19f7:e081:85b4:c5df%7]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 03:11:11 +0000 From: Mike Christie To: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Mike Christie Subject: [PATCH 2/3] scsi: Convert SCSI errors to PR_STS errors Date: Tue, 8 Nov 2022 21:11:05 -0600 Message-Id: <20221109031106.201324-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109031106.201324-1-michael.christie@oracle.com> References: <20221109031106.201324-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0045.namprd03.prod.outlook.com (2603:10b6:610:b3::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH7PR10MB6033:EE_ X-MS-Office365-Filtering-Correlation-Id: 44f41500-35b1-4707-74de-08dac2000e06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TjWGYDyqBehHJVrCV8g7KXA0RmOvedAMOkEI8xTcfZRNPlGZHtZqF3yRhpmZKxw+LfFXQiRt7lSoegodlbhka9VrTD3cmWdUBM5oLsEZbUioK4x4kkFfgWk88PRdejPIqUB/bD37B1Wx3X54OoRAHBgOFzVAmOGeKSLUVECPm68aAc3V4haFoq3rqme7tcuzgPtIm1FUj11Z/c1EzoTvY5UZYqHVzva46QbZh9Tx0c7rP5C5pMYV+sbSHzqEdIMdzXz/GA2nCcwoK072Q0EEi6i8nYuH2mY1qbYCXW7jb/t/9MDf10fqt9olpijVZvHLxegCRbQvFkTXpMfJOtgNCCA2jxKMSVs5zpqoEr93s7boGeFdy+pmm7agYp/+DHmdIX+xigNXCQoaxasIAqBkExOFkWQCcaRJrDyegvtI2AWKUh9CpK1iet/4gFSYraqPMYPZ2+6WaE28ijxQsTvMgRgoE7RGvpQsVhwpUgGkfafgfMzpps2gUdjNz9p+dPuijcmtRI1KutpAhuqVosTGma3wAi1sdlriArUPNoFZmhx8itNmMeM53u5ijGPxQJFMY3nISU2bEPIDv/171KweWTbO7ZTqj6MyzKFvOxbpUukAv1SQGvsc9g/ij7abMNmNsuv2YInq9RNSYE1u4Q7yl5iDLtechu51EEGmjpQtTQqnt1YloBXAQNLmV0j4ooeJxdaxlqJaVcU/gHexnDaC3w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(136003)(396003)(346002)(366004)(376002)(451199015)(5660300002)(66476007)(66946007)(8936002)(66556008)(478600001)(41300700001)(36756003)(6486002)(86362001)(2906002)(83380400001)(186003)(6666004)(6512007)(26005)(107886003)(6506007)(2616005)(1076003)(316002)(4326008)(8676002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZRrrePaxYbxUdpmQSkdC7REvkrJFEvjj8hAT1MTidN2RbJdu9f6iucv7as1yug/MSsWH4Pjh4vUPnfcfHWMsD4Z2G26MN8SfDNOHMFpQKUSxuxM1PF4tl5pK2cvfzvUKcHYhTIjrf2idKqByhlPYSif5AmAdcpiC+/Co9aFkOWx/SpLau+pVefXv4m0Y+oiX1dz4LquCYFWMnXekb7Wl0VYoj8pAl5bNuUt6graJ5dI1ZKk9RCZqkbMHd0PHlfzMUSxgsPGyIJaY4EdexylZHeF9ql5xlkmyUT5V79CIhq9XprCMBJZRHJR2Ux3hjl2C1rAa1Ai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I0WU/kKJgrfKGNL3jtlFeQ7WNnuxuP8lvVX5myFll0HWI5Yc/Jm7GX4bFXc9hDBXXb/XVr3RUQu+ss8ZiV6FLjdmL7NuFhdzW78AGhsyxEKclwgxMjXBpi5Tk+tDyK8fuyPWtwKzmgHO0q3MzvjrgRaAqkTCHpwV1HVdWwzhYvihX7xDYV+wtOWsyNdh+rhPq4pCPfX0JfeVWh50d7idVxpw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44f41500-35b1-4707-74de-08dac2000e06 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 03:11:11.8689 (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: 9RkNtnLME95uBuJjrKPLz0OSYbP0CB1ZeV93aULxLuUPIOQmfQfsrz9D/vlKHIKlpel+IF4s5SLBDvx+aRiDKfVO0vTT1xbqRfUCP1OvpCE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6033 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090021 X-Proofpoint-ORIG-GUID: O6hUZpcLG-9UDCPlksCEid2lhEIWtn3b X-Proofpoint-GUID: O6hUZpcLG-9UDCPlksCEid2lhEIWtn3b Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This converts the SCSI errors we commonly see during PR handling to PT_STS errors, so pr_ops callers can handle scsi and nvme errors without knowing the device types. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index eb76ba055021..667477d1e4b7 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1701,6 +1701,44 @@ static char sd_pr_type(enum pr_type type) } }; +static enum pr_status sd_scsi_to_block_pr_err(struct scsi_sense_hdr *sshdr, + int result) +{ + enum pr_status sts = PR_STS_IOERR; + + switch host_byte(result) { + case DID_TRANSPORT_MARGINAL: + case DID_TRANSPORT_DISRUPTED: + case DID_BUS_BUSY: + sts = PR_STS_RETRY_PATH_FAILURE; + goto done; + case DID_NO_CONNECT: + sts = PR_STS_PATH_FAILED; + goto done; + case DID_TRANSPORT_FAILFAST: + sts = PR_STS_PATH_FAST_FAILED; + goto done; + } + + switch (__get_status_byte(result)) { + case SAM_STAT_RESERVATION_CONFLICT: + sts = PR_STS_RESERVATION_CONFLICT; + goto done; + case SAM_STAT_CHECK_CONDITION: + if (!scsi_sense_valid(sshdr)) + goto done; + + if (sshdr->sense_key == ILLEGAL_REQUEST && + (sshdr->asc == 0x26 || sshdr->asc == 0x24)) { + sts = PR_STS_OP_INVALID; + goto done; + } + } + +done: + return sts; +} + static int sd_pr_command(struct block_device *bdev, u8 sa, u64 key, u64 sa_key, u8 type, u8 flags) { @@ -1729,7 +1767,10 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, scsi_print_sense_hdr(sdev, NULL, &sshdr); } - return result; + if (result <= 0) + return result; + + return sd_scsi_to_block_pr_err(&sshdr, result); } static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, From patchwork Wed Nov 9 03:11:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 623291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14539C433FE for ; Wed, 9 Nov 2022 03:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbiKIDLg (ORCPT ); Tue, 8 Nov 2022 22:11:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbiKIDLc (ORCPT ); Tue, 8 Nov 2022 22:11:32 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14BE81B9D5; Tue, 8 Nov 2022 19:11:31 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A936fms020815; Wed, 9 Nov 2022 03:11:17 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-2022-7-12; bh=eZV/7FULtFczOF/nMv7jijDaDxZDD/i9fqv0Sq+HhI4=; b=MNrXHKbz40dnIkcq0yeBQORxSB7lpfAYW7OKsKgFrXDtbGl/pQAwC9R+yAHkq290xEfW F+ZoicbDMGqhdqlysfZGznO8mFaICGWYsZ8bNdlolfSII9EGD125wHv6Oz+MPPO5hy2v /m/5aiGcRXi7Y8dY6P05zN+vvDi5QCgr/2kQz7SXlFixYZVtHKmVozGutka+gdJ05IVS zmBebr6tek4ZEelR7vRNM8CQCode9TDJHn5cvJGog5UNgf/UdahQmHdmNHEJBw/slnVI HaGUA2dspfaaHhwpD13tm5CPRePRmeetFgdBemYzdItboqblX/1/W9SA6I6bP3qd92mO Bw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kr4000058-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 03:11:17 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A930NvV039953; Wed, 9 Nov 2022 03:11:16 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kpcqgv3qy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Nov 2022 03:11:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VusipMjldN61ei54lQ8sez8Ucxk3kAXW/XfcuZrxDSOT/R0wGCB+bu+HCjaPIpXTpua+KKe1L7da+CnNf+22viaYHv+tRMmRvXSEjLt8oV4llj+yIsvQnimEO/qBfCyJJHmFgR2qpe67xc91UHE6sBwF3QPCYcS/8CV4BM0RKkqVWfFmmZoyKMp6vMGINzFPVxvOyJUE9tyt/mr98MNl7IVsSkIy+bA2gTqKUqskolTO2ooxI7LGc45LNcvqVPdQTsX32rpwcVfAW5R5g7ZofN/b/cj8SKmc1PZ6UmJPD2284iWfcjjHfTNtM/gAxJixyPU9PMEEGf0Ko3bUuvvQ/Q== 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=eZV/7FULtFczOF/nMv7jijDaDxZDD/i9fqv0Sq+HhI4=; b=lko+pktXM8pBGE/Ui8e/ZRWUwdQaeAnRH/0PvTiXliibC6CqErGbTzyeMduoOFjgbFVWzL8l3h28I+1JiYkNE/d0Fj2imPKg+VmpAyM9F5pBvfOc2u3bcws0eT33VzDJdJ0lrafXvs9vdFUDXXEt7+bINdPZCVN7h5gWx+kej6kVYGYeERRW2SkRldh0dIyJnvp6VDm0vJAsYJ2B/G049+9E9vBzXUvaD8rMtCU1UIWWeGHn3etTCklq4fikfbmsyn7/X5OZY7f85RJiN02OvfvNJZNlSG0nrBY0CcTqkCi31ZLtaO5bYLhm0HqmX09xY1gjWI0GetmubD8gJwFYIA== 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=eZV/7FULtFczOF/nMv7jijDaDxZDD/i9fqv0Sq+HhI4=; b=h2HNFIHvpdoUU7INDLasjst+IKlYWz+OF3WVMF+ixAQnZHKpM8GDjd5gUxYolMDZUOjczJ+UL+Wa7uxbG2ACJPar1lY2wbh2kRMT2mW4r0FbSma00aNYl9WiC8UpNsrU1H9peTvsiAwenwvv9UkLrW391ZOR0dNR8RM0lOMeQDY= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH7PR10MB6033.namprd10.prod.outlook.com (2603:10b6:510:1ff::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 03:11:14 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::19f7:e081:85b4:c5df]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::19f7:e081:85b4:c5df%7]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 03:11:14 +0000 From: Mike Christie To: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Mike Christie Subject: [PATCH 3/3] nvme: Convert NVMe errors to PT_STS errors Date: Tue, 8 Nov 2022 21:11:06 -0600 Message-Id: <20221109031106.201324-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221109031106.201324-1-michael.christie@oracle.com> References: <20221109031106.201324-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0046.namprd03.prod.outlook.com (2603:10b6:610:b3::21) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH7PR10MB6033:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ad6bb1c-7b3f-4838-53e7-08dac2000ecc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t+nrxTJ6FVJEWRzYck1+Ho5DIQnfPolTc9CPPlciz8NQkmgviuyvWm7aBw/x2i4xW3+6bdvu1GgvxyB53sBSpMY3qQtOX59AIaFbu3/FZEn+onnTlTC2MT17IqFkatJIM0LkzDS5iCICFhcJX6moArOFR8GqzP7uKxChQUVIrEhEEVfYlA5UXF3qLYETIUJHqzMwVRI7oIZ39PsjQ2UtdeHz0qQWYOE/hrwC3FKKuUVnWCv7oirYoYtAO4X9qEvD9DDustkIfqAZJox0gDuELCrOUbFGZmbeXU7XfxORVteObXlsSSQ+i0pgMeWGJ28QRTsdxCdZbrdXOXJOg1yQ+O61V/k6iBKvh7akyTWhf6tPFMaGiElYq5/uj+XVl3hKRLY9oJR19XReAv+ygj/E/KNTXqRMejkUTkUOdB5JNxNrB8/S25sVtMLxXQNJVeefsYAwG534j/HuVoyjMCnZPAhRPXmpHpyufw24Hc4sKY3bb6JDuM/mv/Wb7bCSGZt1Cmb7kE8nYD2bh04e/BHmUbI3WU45XC+e1PFWf6wMTND9vAOdnekhsijcYPsziQz9o1vSWBJeM4aPArVPayOVx2gphAH1ylhYs4FuW/cymMW27+jjOPyllRw5jjZOLuIiWRyrwFklnNLNW4l4AfLsa0ZHN/dPXUbNANvKNkbOxHANwmwOaeiK72Z3iGQyn/3EcOTc3sGB2FAL3PXu42Lvhg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39860400002)(136003)(396003)(346002)(366004)(376002)(451199015)(5660300002)(66476007)(66946007)(8936002)(66556008)(478600001)(41300700001)(36756003)(6486002)(86362001)(2906002)(83380400001)(186003)(6666004)(6512007)(26005)(107886003)(6506007)(2616005)(1076003)(316002)(4326008)(8676002)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HgkI3X5DEK4PyHdfvaOAgCrGZ9HdRtOB9tf5uc/U3Y11vesH8jLRTeOGYPTgycvY7zWgzqUJyWyxGWLP1orBKGfbPxOHlDY+9b91DraYZnR3Erqu1VV/zATBMmUDE/339zcU+7NnvN5HYy1Hi3krkA7+pAUCWPICl3ua3PCZXMldmyM7AqASSXYKntnvIL/tq0lCaO4SKSmPSVr8M33D3Xddv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kfvZFOrD7SSL5n5mjgtLbw94gub/X3y8/UnTJfBEckZZSoQmr2a+XMAt1BTZbBPTOTbT9l/lYnJXNwonUT0fBHz33DfZIGFwOm02X8benBgxPYVAtr/Cyt1Z5qMPALaUSlQClnswYsBpSYbpCbS0DYxfmkG0PhnkM5r529ic3L8JJ9jOn9Nk4GUssl1if2aAcN3T8dyak/Sq6DpNq7M1zj8Ur9vwNUk1rsWOc8/Kezd8jEvfEa5x2Et3Bbhylai5BCvLlUsc4D+c8cB3T8/BLI06/PQgFB0sUk/n9bUDTzmv7aPcTuZmToo+WHNtSKck6uEpUfx9g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ad6bb1c-7b3f-4838-53e7-08dac2000ecc X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 03:11:13.1813 (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: HnJlmcsIOYKD/3IVTJp0yEe9ZTpDTNkc6vrEz2mIaoNSUwo3TsUNheGYSc0SFf/Aaxy9cCY7HVSmXyrnZkMh57EDimTCuZFfmjkU0OrSwD8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6033 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090021 X-Proofpoint-GUID: UXGBI9r19G-gXfKIvk0DxVJ_aWMonquj X-Proofpoint-ORIG-GUID: UXGBI9r19G-gXfKIvk0DxVJ_aWMonquj Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This converts the NVMe errors we could see during PR handling to PT_STS errors, so pr_ops callers can handle scsi and nvme errors without knowing the device types. Signed-off-by: Mike Christie --- drivers/nvme/host/core.c | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index dc4220600585..8f0177045a2f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2104,11 +2104,43 @@ static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c, return nvme_submit_sync_cmd(ns->queue, c, data, 16); } +static enum pr_status nvme_sc_to_pr_status(int nvme_sc) +{ + enum pr_status sts; + + switch (nvme_sc) { + case NVME_SC_SUCCESS: + sts = PR_STS_SUCCESS; + break; + case NVME_SC_RESERVATION_CONFLICT: + sts = PR_STS_RESERVATION_CONFLICT; + break; + case NVME_SC_HOST_PATH_ERROR: + sts = PR_STS_PATH_FAILED; + break; + case NVME_SC_ONCS_NOT_SUPPORTED: + sts = PR_STS_OP_NOT_SUPP; + break; + case NVME_SC_BAD_ATTRIBUTES: + case NVME_SC_INVALID_OPCODE: + case NVME_SC_INVALID_FIELD: + case NVME_SC_INVALID_NS: + sts = PR_STS_OP_INVALID; + break; + default: + sts = PR_STS_IOERR; + break; + } + + return sts; +} + static int nvme_pr_command(struct block_device *bdev, u32 cdw10, u64 key, u64 sa_key, u8 op) { struct nvme_command c = { }; u8 data[16] = { 0, }; + int ret; put_unaligned_le64(key, &data[0]); put_unaligned_le64(sa_key, &data[8]); @@ -2118,8 +2150,14 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10, if (IS_ENABLED(CONFIG_NVME_MULTIPATH) && bdev->bd_disk->fops == &nvme_ns_head_ops) - return nvme_send_ns_head_pr_command(bdev, &c, data); - return nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, data); + ret = nvme_send_ns_head_pr_command(bdev, &c, data); + else + ret = nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c, + data); + if (ret < 0) + return ret; + + return nvme_sc_to_pr_status(ret); } static int nvme_pr_register(struct block_device *bdev, u64 old,