From patchwork Tue Nov 15 21:28:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13044204 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 56B4CC43217 for ; Tue, 15 Nov 2022 21:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230338AbiKOV2s (ORCPT ); Tue, 15 Nov 2022 16:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbiKOV2r (ORCPT ); Tue, 15 Nov 2022 16:28:47 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 402F0C0C; Tue, 15 Nov 2022 13:28:46 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AFKcAZ6023866; Tue, 15 Nov 2022 21:28:32 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=3U1Z+Wf1A7Rg2/sr2QAOlhV2Xn4XQzweQrXl89XIfnU=; b=DaYuW01KwFnCCdkMPp94DsPzmqI/oli5S9weeDR4Xv55i34AqA38GyjczjWIR6pmINqc PDhXj62qaxhhc+1ihyotp9PFh+xwvIWqsNi+cqcpOWXKHrR3p/RwwzyqZZtzekaBTl1a AEkmex94B65lXpvADBLHanYOfg9R5PYuACBDIdOsIwvJB5Rx/zNrH5S74gwT5v8Dro/5 Pv+Yw6yAq06l21Rj5JSMGEoiNlDych+Eb7ft6QUda8BBOki1ZOFlKr8TiwzL6nGOK0lS NYYcU1/iZjGHm9hnFVWjbuBGiHKUdGZk6u4AaoEaTMjeDj7hQssdUQMUy7kv6OOrIQid pg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3hdtspc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:32 +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 2AFKDURd031804; Tue, 15 Nov 2022 21:28:31 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1xcg3dg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J0ip0HkGU8bJwzshYniR1iVfocrp7uID/Jfd8ExHmIwpDXCqIuvXOvjDbPYYQK7e8M3wpI9F72QHOrEq3HdNm6Vlyom1FfuI9YyB9m2mp+fk0RfXw5ANAn77jG1Q+a0bfXNvRNXtiKEA2aIOwo4L1Qj/80DEZiH8D9OcIZVa9jlbXnl+Ag7BrjkdhEK2rvigi+gNX6j8yXsKG1ww98gyMVbUTSRxhwnsgjL4uWzO2JhjHA0esjipFvc5hVwjUyKnrKx7FyMSys5O6aG+i4WxHu1VnyHt6PNn8XGaLDpcURl+YxC9W7MbV8ss2PxzEl5cfwsYFS9h/GrDAN5vw7daPg== 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=3U1Z+Wf1A7Rg2/sr2QAOlhV2Xn4XQzweQrXl89XIfnU=; b=WyG1W4VfcRZ+YNTOVm8x2GdxVZkZ6zxo2JXXb0VzOCoIN4WcBky8apHaChPhXHCDrryH0VkphpB5irDN0/wr0gh2GACyS3oHlvMpvIjCrXm3Jm97ScxIuA7WT0mdz4UAO2u7lLAlHwnnhDZ8RUEiAG4byAHOB1jSpwsxmkQ9iMXV7ABkWwTCRQERGktCg3Oc9W2PQNapzxOUs1tW9ZPcupYfVDOkL3uUuXCHyF+WyqyayF/4QE2CNE5aLcgHJSf40YFT/mEcwxOm3qlAeGK5N3ynRPq92alcyUBB2B1UadVZPxX+41hF+ANY5GkrmG97yYs3v0Pst3LmfCuWW8EQNA== 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=3U1Z+Wf1A7Rg2/sr2QAOlhV2Xn4XQzweQrXl89XIfnU=; b=tqbdOOJtpA54sf1oEiKJ2p2swif+aHbXWCIvVLDb0dMO5YoG0B/VrTd+tfuak5YqeQdVE5S3jQnZWrUPZeTg7n5bljjFiLPr1xPhvqFfm96sExrmWyGv8MSXrtQBhgzrfnbyEZ7iS6AEc4+COHW59igeFn/aaMKREK8/xDV8pMw= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5368.namprd10.prod.outlook.com (2603:10b6:408:12f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Tue, 15 Nov 2022 21:28:29 +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.5813.017; Tue, 15 Nov 2022 21:28:29 +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 v2 1/4] block: Add error codes for common PR failures Date: Tue, 15 Nov 2022 15:28:22 -0600 Message-Id: <20221115212825.7945-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115212825.7945-1-michael.christie@oracle.com> References: <20221115212825.7945-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR19CA0008.namprd19.prod.outlook.com (2603:10b6:610:4d::18) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5368:EE_ X-MS-Office365-Filtering-Correlation-Id: c7903ba2-82ad-4c46-64b6-08dac75056bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XUYQE1lzB3vbEn7w9oD1/NtL250nrMZU8kkLRPcSslej3r9+aPbJRsSGWtU/kRuqiazEjcNChzdJARv5gH/cXQV1uQJX/HfY5vJ26qJZTXnBTHBnKqscwAbHeTs8zVvn1TFC8RcauOpXxCTN/maLAIq6PlaAKotjISqr0no9veAYqP0ggSZQW/LmOaAv+9kiQPcf5VnCDYgHZzrXHq3Vf1UtVK1BvvXKtPlSNEbYKkrTsdyDK1oEntrPmD7XJ+vjlEoYGjeGCimtXk7BFvZ6gtbhwCouADsb//aGJVgPfpaze9QuPZHS4IezBXjAt1lj6ao3yxQMp9+zH4JywiaNGLHpUQSaYuPhDXD++gA/83DsgcuPCJDd4cj8BVQkC0lPuY8IMYAD2DyBa2luDmSRtk+QwRmzhtUNwCpT/NxviF5190qYJmm7wDWi7Xd9K3rlihAcYUkbVOtsTq6e2M2uh9sRAcEjmkzHdHzKyGcntucTzEbDRfcu66Oi0EoqkEumlm3MR/tDBQU+RMqfovb6KfzF3ogKSr+c1pKIlZCPsGeykytuaVYwdsP/bUYd14+I3UwUbi8uzIsE/j4vTXnzLCg5j+w065SeTpJOxNdxuOG+ix61JtKg7DGpBlA74erTsVG+bLCJx8zAmSyKmeZ2mj4+szEZ4A98RLW4n3X0Fa2GI6GXrQ2JG+I/AYXSr4YMtWzeRFAoXZ0oo6OBhpe+nQ== 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)(346002)(376002)(136003)(39860400002)(396003)(366004)(451199015)(1076003)(36756003)(83380400001)(6486002)(478600001)(6512007)(6666004)(2616005)(107886003)(6506007)(86362001)(26005)(186003)(38100700002)(8936002)(41300700001)(2906002)(5660300002)(316002)(4326008)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KQGV0TUxYwSjc/EdQMpcXIoqcJq7QNHHeH06M7h7t4hX9IapzGzrbk22QlreNHBshTyzUb4SLWgkDsS9ghK2SPX8sIXyL7wt//DR5UCI+it1B33sGHSxN8YFZQFe2x2qA01vHDFx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Z02gmJnh1KN4Rt7soCU4rf28TIHhI+mOOIWXsdRE6vTyzzgV5xv0xe39pLIdsW6QyF2la4Q1uixNggCf3Ala0wgH2uzJNKEWkQwka0s8G4S3LAmWxc7t30Tm6AE68d4XSxyR+2z34LA0Sj9RI2Pfx3GTksm1LKVIyIyGOsAGkD7P36I3CL6BGUsXCFL00XNX5T4XntEW4rMJs0ooX4EUd/FQqDBG8+h1hbX5dMvXgwwrWFi4DtXBgkK8l07O3u398vX0PRMxX1t8/UHZJJv6UkfHtW4IoPZTQ/mwz+zBcKt4+LvSEu3ZHKLut6/4aSUDzvAdfkmv1XhMkN5gEAM68GpHJG5t5JlDMQE9MWHZsgdQmzxLVrDLGQAaaZje42cU4eYFyzHFaqbV6e1h3uDbOCgPKP2Uzkjg9ey2BkZdim3vSNM2NMKR32YJEd0A X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7903ba2-82ad-4c46-64b6-08dac75056bc X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 21:28:29.4250 (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: 7ajj4q/sX2XXMAovfBimxB4zFHn2QJDfOjzCt50mImtaJ0LgiKP8WHy1rg8lw/5rEr6v5LaUnk33/SZ1575VVQ4xljYefMnpp5Ko3WoVAq0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5368 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-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211150147 X-Proofpoint-ORIG-GUID: XImu34Qe1pFnrj3PqBcgZxJuapgxlXhb X-Proofpoint-GUID: XImu34Qe1pFnrj3PqBcgZxJuapgxlXhb Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- include/uapi/linux/pr.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/uapi/linux/pr.h b/include/uapi/linux/pr.h index ccc78cbf1221..d8126415966f 100644 --- a/include/uapi/linux/pr.h +++ b/include/uapi/linux/pr.h @@ -4,6 +4,23 @@ #include +enum pr_status { + PR_STS_SUCCESS = 0x0, + /* + * 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 Tue Nov 15 21:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13044205 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 9F4C1C4332F for ; Tue, 15 Nov 2022 21:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbiKOV2t (ORCPT ); Tue, 15 Nov 2022 16:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbiKOV2s (ORCPT ); Tue, 15 Nov 2022 16:28:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D123B117F; Tue, 15 Nov 2022 13:28:47 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AFJJqke003865; Tue, 15 Nov 2022 21:28:34 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=7Hg/yN+X096aDjv8xdndTj3B+mW/nmVz9Eo+hoRBoUE=; b=XEVol5umqV6NudEmHH2UOfIc7sw/Msga95Ya8E6n/neCw1ANdysxVz7mJa48efeVb8ud Lrx68mYACOqaCpOtWPEoPP3RAi8vOi3quo3R38QQ8QHeqKAhWkVEst/0tio5kiNiDl5B DGPHlFpnCs/l1ae68Pi13Jw+4KMw3iwgzdYy2kezoPG+VEyH2Rl6Ux2rAet3ROWcmzSA o5joQ0BsSXzHp4XKOKu6duZlMR99S3oLwpJdxlTfVIULSu/9INnvfjLN+2D9OtSv3Xta WpcfpngQ7gSFM04f1+IM0FdjI1ZV1qCjPjGzFjx74MNIYQozz/AtN30f7oXJ7vxxHUwr fQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3n132gb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:34 +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 2AFK5VVx004724; Tue, 15 Nov 2022 21:28:33 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ku3k78736-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZnKDxNKJpRQO4zKMN7yu8UYoSPZO/CEG2uzC3NHvvEzskQPB3EoreC2X2Oqgir8IHjlLI4w8ARn3OsG5/JAe7cSyLGBXEzimRQHUpwm/tpGLpvZGB6uIgw+GSfc26Ey2RzyjlZc1ddV5U6oeVtphBaoezV4Q+hEOCrMIQwNXiK/ZnZKOdPZRJ7mDCZNmJtY1k6KtDKZyMB+BQkRvL8inx8WYyrciMKEVI1hXfF9MA72Wt7GEbehpxHl8vCAFUnh4JiL+Zg4ubMdeYSgUp8ciJqljjCfQC7YeWEds1zsPYQjmz0mGR8vf9bmpXGKBCor7uyqPxWnDvA2JzzHykPM/ng== 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=7Hg/yN+X096aDjv8xdndTj3B+mW/nmVz9Eo+hoRBoUE=; b=TFCTHv60PHxkckOwcK32XmaeB4jSjYao8uKPRs/sP+L176oiSVVynIrMFacJul+EhaBJBv16Seg9UgzJ+/eOr3XD5Deq6GKCygSb+rDBI98BowWiREypvqQsOCupblzeEArfu6qf2qD6xOPat7/bIs2QSgqg1OV863qHj4eZL4e05y9NANzCxjsFTN5ObdCxb/lu/yNQfc2n8IJJ8Pqrgk5TmwGGWs8lebAXnI38kMKSkXWQI1Wf5eb7nd47r8NUgVcOVxPVJXl1wMEYWzsVwRZ0POo2XzNTVgai2lut5cfhsfRLkKMVlKHIA/ZL/kV+PPJW3wqyHgcvaaAxB4W51Q== 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=7Hg/yN+X096aDjv8xdndTj3B+mW/nmVz9Eo+hoRBoUE=; b=rQ2dT8IbQmNb9z+RLfU/CwU1moahiLTzCD/kgC9gjy7MBm9pArIsB5eTv/w828Vh/IpLOvcPID5I+5hr9b3sPLnRQXIkpL1YC1PF+zgVA44vPk8cptDrCuabJ4wuo+r85eivVnB5KrBOROmFYCOmLBYCMJXElz+PZ9DlS8syWWw= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5368.namprd10.prod.outlook.com (2603:10b6:408:12f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Tue, 15 Nov 2022 21:28:31 +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.5813.017; Tue, 15 Nov 2022 21:28:31 +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 v2 2/4] scsi: Rename status_byte to sg_status_byte Date: Tue, 15 Nov 2022 15:28:23 -0600 Message-Id: <20221115212825.7945-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115212825.7945-1-michael.christie@oracle.com> References: <20221115212825.7945-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0011.namprd03.prod.outlook.com (2603:10b6:610:59::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_|BN0PR10MB5368:EE_ X-MS-Office365-Filtering-Correlation-Id: b5478438-8dac-4ced-418b-08dac75057a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zA2qkpC1cqt6z7avdKiqAeEcCQ2j01q4GdecGYGqTkeXPBiPSkGmXzLnXuZupRRsA0Ijp0jL35ofe95jldD+ID1B/nsUOkN706TY3bHgg0K2eNfRB0hi2Obi0ksLRjxgWuSJm9Yfn9eIXkcUrSRMbpkVIr/T3eXTxyrya+R4yXLiS2QmxAGKW6c0hfxIgjNpPEIQqPdc7uEGuOAoMTfP80Bql1TgPZu8vKzZ72CJm5zJ1QhCWQBxNRYOSlZr7yeuGEw/n+0sc2tAO4gsiEKQfatf34OlQG+KpG3GYidjgSNuOdXmvMZaYRu6TPitdoFu4i8/ndQaaITneqU6G7YJ6wYjKaLVy3uaxKpWCeZhht0LcH/C+xC7pdF5ev174O7Gx4v24sncVZPYjxoSYNbPbblQl0IgOy1vCBqJvEhlBvVPOSO9CXppQK4f4tBFgr61Oin0K+aurrY1Z5A587UiBXst67xBdbu9BFP3Nmjc0juPtg5UpV3qwuADa9tx43v4VFB50tfqE+0AHZTgqXALa1DfXTNJZyql5Kalg7WzhHE54ZzrIHC1RjUyrMNVJLEPZmCzf5tkrZ6vLlUzR16apRW3fyBnhppgKnKG3GDtCKB8fR24E9iQxHZck9qc7aXedVkVVHZSMQithg0Epm9eQeOZ7NVAEdAaEwCsBB5vb7his6+r7H8/eQSUfXsygnMxLfbXtF04XcfBLpjlTdkReQ== 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)(346002)(376002)(136003)(39860400002)(396003)(366004)(451199015)(1076003)(36756003)(83380400001)(6486002)(478600001)(6512007)(6666004)(2616005)(107886003)(6506007)(86362001)(26005)(186003)(38100700002)(8936002)(41300700001)(2906002)(5660300002)(316002)(4326008)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vUpUvchc5QEbYMhC1p3at4DFjaYaDJ99VwgmDWeA84YxzVyCTzVzNHckTl5LSYPDk1Xtr30LD0D7dx9u5MFIt4hvcz0FP/jo6JnrMLo2F7wCV4J4Y/hashi7opGYitz5cAQIvGSRxOxj84O6Q8RChWkE6c9Mhj4qEwX5kSnqu3lxGJBs6c8Rg+ZP5cg/eCecfEQVfkajeKwJDTIIyn6Oo7xHT5tLrJf9vifjXPMn/ULvnThapf3d1zbim2R1rZ8zF5ReyE/wdUyZueJlPJwCqI8c7VptRfoQO1hBHUBAf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ODu9Rp4tkOR6mW4YbbMUk7d8ijRizCyqb/yaUUY7a4X5jrGDLDyIzfwXAt5cSuJ63GPqbUjMnMI3oBF7Q3Cgu3TtPe6faubLqXpRex6Y1xW1GX9xlEKy63cfObE2621uAf2WcgEi1w2kcI6vLKkE3OGeNCfdriyicQJQmPwgySlGnGP3z5RpI6L7MhSTboxG143JXsD3ptuszY/jEkZSslpDcvyyQCLvEE3y3Bcdic15FXClUfnZYpFohpO+3bRe0kQfSK5Pp0RnqurSd7MGVKqc2aefhgfr9SXMlQC50Flc4RMwA3kT6lWPQ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5478438-8dac-4ced-418b-08dac75057a1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 21:28:30.9093 (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: Gf8t4TEGU9gUmwDpTh71C9AMxD0j+gnPJ4aCxf8/Wz2wR6yt61A7/7YiQ/zOeKcAtU/IysrXMAR3K2LBO/dghn5sKoNvaoRg8I7Ppkz2WLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5368 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-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211150146 X-Proofpoint-GUID: hjMKoH44cwai2nW40re-UU50g2dOxsH5 X-Proofpoint-ORIG-GUID: hjMKoH44cwai2nW40re-UU50g2dOxsH5 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The next patch adds a helper status_byte function that works like host_byte, so this patch renames the old status_byte to sg_status_byte since it's only used for SG IO. Signed-off-by: Mike Christie Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_ioctl.c | 2 +- drivers/scsi/sg.c | 2 +- include/scsi/sg.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 2d20da55fb64..8baff7edf7c3 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -376,7 +376,7 @@ static int scsi_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, * fill in all the output members */ hdr->status = scmd->result & 0xff; - hdr->masked_status = status_byte(scmd->result); + hdr->masked_status = sg_status_byte(scmd->result); hdr->msg_status = COMMAND_COMPLETE; hdr->host_status = host_byte(scmd->result); hdr->driver_status = 0; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index ce34a8ad53b4..d61d8d0d1658 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1349,7 +1349,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status) struct scsi_sense_hdr sshdr; srp->header.status = 0xff & result; - srp->header.masked_status = status_byte(result); + srp->header.masked_status = sg_status_byte(result); srp->header.msg_status = COMMAND_COMPLETE; srp->header.host_status = host_byte(result); srp->header.driver_status = driver_byte(result); diff --git a/include/scsi/sg.h b/include/scsi/sg.h index 068e35d36557..af31cecd9012 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h @@ -159,7 +159,7 @@ struct compat_sg_io_hdr { #define TASK_ABORTED 0x20 /* Obsolete status_byte() declaration */ -#define status_byte(result) (((result) >> 1) & 0x7f) +#define sg_status_byte(result) (((result) >> 1) & 0x7f) typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */ int host_no; /* as in "scsi" where 'n' is one of 0, 1, 2 etc */ From patchwork Tue Nov 15 21:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13044207 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 3B839C43219 for ; Tue, 15 Nov 2022 21:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbiKOV27 (ORCPT ); Tue, 15 Nov 2022 16:28:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbiKOV2u (ORCPT ); Tue, 15 Nov 2022 16:28:50 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8195B261C; Tue, 15 Nov 2022 13:28:49 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AFJMuBg003946; Tue, 15 Nov 2022 21:28:34 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=g0kR0Ufgfs4eSOdzlHFJFSMREOuMal8PMZZc412X9RE=; b=UJkyfzcSNY0+vI7NZaX9n75V/ecv+tC/xi8M1zvtbZalV55g89Ly/JIiYp+2TuuTtvhQ kXqC3Ym6qjQyOMJD1B6JjcCthnUqFbipldz1m0wncxh4HykQ0Pu6WOM7uWJO0E2YxAG0 IVm1tvzhshUI1PJ4uSEztGECQTGi5gP0oEruX9vPY8LCI51DF04Y2GHUwxdsON5hIMun GaHaIoJRC/niLrO/unAGigT/MKhH5b9Zda9+5VT7BoX+EYvsb11g2e8H4Y3Bj1cAjCYo fXqfJOY7DCxWwQJv3Pya5aXCxqNVfye63FS5NRGX4NJ3I+XpxqqR0V1aSgU+xjveJG/f ug== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3n132gc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:34 +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 2AFK5VW0004724; Tue, 15 Nov 2022 21:28:34 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ku3k78736-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpMYSoBkbdPI0sZ+PLVmtwKDAfdOgPqtLmkAUc2W1A1Z04Oh7Yx9IrxRWtZtY4+siPri9QQ+1adGV7mle7tO0lqof09/BzKjpdHCbNYk89bNpjnZKcn4I5slGGQHZbHgP6ZAfoLiO96BrRke92PYax7qLxYLRUSaruY+LCRp7UUw9CcesD7W/jX1+iJjF7ZdHe8/sOg3OGdcKorg/u3Qq1Il8/0Zdd2Y6imd3FCSLxvW3DH8+80mAQq1GLHAO58eNNbt9YonfUH3g1UpZJmCvXhsDMXq5qsgbOCpB1PRs2Nn4dSo5PykpNfk6jbfteVibqWbEwSro95Sg0QJw1fEbQ== 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=g0kR0Ufgfs4eSOdzlHFJFSMREOuMal8PMZZc412X9RE=; b=QXnE5WxPF64p7ZtZOCte5vTFYn5ZWiLq7Cu0+2aUt89QUfuz2gM1Ub8d5iZose88bRq/OrfcV5CQ3tW9UJufGBRSTwIwyZA1kTugpQivdt44ofAn5of09qUtP9TyouvjC8fqRLt6XYRg6qy/Mn2eJKWSYzXIKWuME6pRICLlxJtLCVbcB351ilU6Vy/NX5XnM/urD5zsHcNMqcmAR5tvfkg7vxSPDWzzza0sgLLLPxdvb25Pi6+i7/+Cxei6r1ZuOzeVtH1Fi5RBvN+9XYSjx4wZAExlYyBiZ6LfcfusbhRQtjyNRifeNE/gahp7OiaNQYUlZNeAEBLdkcwq9zyGeg== 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=g0kR0Ufgfs4eSOdzlHFJFSMREOuMal8PMZZc412X9RE=; b=OpOUDcwf7AReBPJNng5DU/WTGTK7HiqFJNYFc6p6BRq5e52bPqQK06m7nvzY6Ba449LmRkKmNwsSz8TpHquwsumskgVDy+SDyxENYzA+DxTqj9NW9Eb612/ImbJh8yM8+UYvmH+TmNuPl3amWITtreKsUPt9vxYldzmLqQsfmmc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5368.namprd10.prod.outlook.com (2603:10b6:408:12f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Tue, 15 Nov 2022 21:28:32 +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.5813.017; Tue, 15 Nov 2022 21:28:32 +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 v2 3/4] scsi: Convert SCSI errors to PR errors Date: Tue, 15 Nov 2022 15:28:24 -0600 Message-Id: <20221115212825.7945-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115212825.7945-1-michael.christie@oracle.com> References: <20221115212825.7945-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR12CA0029.namprd12.prod.outlook.com (2603:10b6:610:57::39) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5368:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c3cba00-6886-4e61-abc8-08dac7505851 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D9Vyu1DHNb5bvIIcJP7jjzlI9AqfBIa3BR1vs8Lwa5O+6zqEs5Ou3lEG818EqwS5FW82pjLjhxG9aayVWNfgdkAZJCfok//18htP2twTQB9RPLlzSeBNQeKlwoxaJL8eVS4HbSP6/35MgDD3TMQQq/PYl3aXu/CvqQTvqB2z6iiRzE8Nt2ecJqz8sfvW9Aif3hLN01Hbc4NxSrk4nSnRqDg7nZ/UAbi5kot+fCYVF1q9bDqmlBchEPlNZ3IPnL3xiIn/Iuoia5FWxS9NGSUSB2tendt//s87Vy/P2eBrgpFeYF94k69SRECkJHUhNUu6fhXKhSXauN93mD8xqvFtKYyt50Dajv7ydQRutUPlF6+i64hLU/LhnMwOuXpsUqSE4I/VoUeKastoFYVHA7+QvuigwDoSfcI6P2rjd0pPRjcypKGMQ1VA9vgQ2fljfzOnY1EECLeB5vY3rpX7nDaMAGwfyh/t4Y97DaN+FarzX300R7NNCkZ5szZQ+xHrJ1TaTi3u1w5wf2ys/jksmbrmPayY9F+dmqiO01fUf+LLEBbizFVubZCNakpZhud2hw9q1uvcjugExWMt/bPdJVACVvxOTcJ9tWwfOHCYit7vMcGhcyXh1NQM8U6lwFAg2X2akbShFScj9YCcCi+OkjLlCEmCX9eVBGuVDTKPmDw+6SlDD7NIB6qQKdeKydbpriR7kAyJT4h0MqqvxvdajF3S3w== 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)(346002)(376002)(136003)(39860400002)(396003)(366004)(451199015)(1076003)(36756003)(83380400001)(6486002)(478600001)(6512007)(6666004)(2616005)(107886003)(6506007)(86362001)(26005)(186003)(38100700002)(8936002)(41300700001)(2906002)(5660300002)(316002)(4326008)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ORkozTjY4oyGrmQSSC2EVEUm6JejVYvhaZ74u/TBLnqUzDMyj9Hl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oYCOcBmFUA8iQGcOxsYv6UPg+88+kgICzR1mg0c3ps2wfh13mPMFsu8Otw8dHkDsVzxh49umgkNquxw8qNOtOqvVJ4eUF/bsGA1SyJmjV7eBRbtkKjQISdtQ2JiE+4/C27esgL8G1lQTxh16UftPJ+oUraiHRwxQ3PmxiXNHkLDil64Tgi85GGf6XsulUOqQWOqu2LYnccwV5k4+QCM/3f9ldxbfrOLrPYvXoA7PQQSa1XlCe4kUtRGL9D83KNd0+wNj+szCm78XbaMhLVuK2umSC280oE0/aUJJmBpxFET2JOldjgNbHuuZM/xXTCGAVrhdTKEzvhBCNH/hbnD093WOnmf0bFet9y+7DTyS7ItPyZqAa+meu9UwhldGv38wxIRAug4Ua3JiDDD3CS4T6I0zU6parwzZw30rgY1TaXyARRMFa4J4ZR0KvmeD+51G8K1cN179lC8jOyxulH4NYOtvzHzpG6PE341Pc1tNxfrcHN/IUT4y4e1gD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c3cba00-6886-4e61-abc8-08dac7505851 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 21:28:32.1123 (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: /8yAhq5wyDQ2lbgkuOc0zto9ztAI+5Vg7Oefg7bjFVOW8hlXaiRKaR3TleAtdc/qCrlTtdRrzlcdAQlaURNODl67EpmxRkIsFx+AHBgkRUA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5368 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-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211150146 X-Proofpoint-GUID: pnUl4Dz09b955ulfrHdYM289aH_pSYtN X-Proofpoint-ORIG-GUID: pnUl4Dz09b955ulfrHdYM289aH_pSYtN Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This converts the SCSI errors we commonly see during PR handling to PR_STS errors or -Exyz errors. pr_ops callers can then handle scsi and nvme errors without knowing the device types. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni --- drivers/scsi/sd.c | 42 +++++++++++++++++++++++++++++++++++++++++- include/scsi/scsi.h | 1 + 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index eb76ba055021..00cc17fe769b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1701,6 +1701,43 @@ static char sd_pr_type(enum pr_type type) } }; +static int sd_scsi_to_pr_err(struct scsi_sense_hdr *sshdr, int result) +{ + int err = PR_STS_IOERR; + + switch host_byte(result) { + case DID_TRANSPORT_MARGINAL: + case DID_TRANSPORT_DISRUPTED: + case DID_BUS_BUSY: + err = PR_STS_RETRY_PATH_FAILURE; + goto done; + case DID_NO_CONNECT: + err = PR_STS_PATH_FAILED; + goto done; + case DID_TRANSPORT_FAILFAST: + err = PR_STS_PATH_FAST_FAILED; + goto done; + } + + switch (status_byte(result)) { + case SAM_STAT_RESERVATION_CONFLICT: + err = 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)) { + err = -EINVAL; + goto done; + } + } + +done: + return err; +} + static int sd_pr_command(struct block_device *bdev, u8 sa, u64 key, u64 sa_key, u8 type, u8 flags) { @@ -1729,7 +1766,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_pr_err(&sshdr, result); } static int sd_pr_register(struct block_device *bdev, u64 old_key, u64 new_key, diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 3e46859774c8..ec093594ba53 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -121,6 +121,7 @@ enum scsi_disposition { * msg_byte (unused) * host_byte = set by low-level driver to indicate status. */ +#define status_byte(result) (result & 0xff) #define host_byte(result) (((result) >> 16) & 0xff) #define sense_class(sense) (((sense) >> 4) & 0x7) From patchwork Tue Nov 15 21:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13044206 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 8014CC4167B for ; Tue, 15 Nov 2022 21:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232250AbiKOV3B (ORCPT ); Tue, 15 Nov 2022 16:29:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbiKOV2u (ORCPT ); Tue, 15 Nov 2022 16:28:50 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFF9E2639; Tue, 15 Nov 2022 13:28:49 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AFJXSad016551; Tue, 15 Nov 2022 21:28:36 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=W6a7W2LymHPQff1DnOb+5dhR9PDMiXFpoN0Q8trv1o4=; b=jbbPxIgxyUSDpOsxPXcfDIb1uLl29A7ZJqhb2Q3puhX5MM7zJBKar8R+Ov78RKISeAL7 oQlou40PGFxjGi6oD8VdAmH5358ZyjAgRoXvquAQQCUKgxkNeaovn1ndhzVXRDJ7tyKl ZfBLp8JzWkeQ1D6E9cMVAVPr8ew86vtthnJ/AyEsLqjTyRQ+cC7+VdK64iutR+QD79Ir /IAQ7AXoCdDl4vEzwAK2BeZn29Tp5tJDJzi9+lq9lxCa4Fw1NjWGL8bE+Xij1VHN+XP/ IF4G8KW6R2vp3/oUrcjwv5nWT9u5ds/+iwArWbd7WRYI8916wTTI3LPTVH7EhRnnc6Gc Pg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv8ykj99h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:36 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AFL04XZ034817; Tue, 15 Nov 2022 21:28:35 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1x6e5ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:28:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N77XTPICrR/YLBWPONisnDSNzu9PhBFkd5/mcvd2l888EUmraOt2/6EItq1xiYV1YuV3LAayzcNdypdobzFqqmLChaGIqOfLQ2xdrIEmzgksiPnjZCp5RYM4SyCR1b/e46QXC8a8IcjoTdsZaIee1ZJDu9qx5KPE3h8+1AYNCWO1zFec+PzfvI0/1mgMWis8MG7LKfUq/1I1LWKkDUt7Hd2UZP88eXaZwoULBj0/3ZGVGxZiwa12z8TC3BbWLf3YtEEGtvPIWlOORRNO981Nu7ZfduNSQtkK+GKUyKkZWiUr1kixlrR30cJxGYpSJ40kVhg0wy4kM4o8s2K/xg5w1w== 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=W6a7W2LymHPQff1DnOb+5dhR9PDMiXFpoN0Q8trv1o4=; b=eYk54DIOwaQpl7jtqlmunsYmc+u1/fFE2iCxSNHECKrK5MehKPstW1yrZPyv11uocqlAkD7e/Srh8gyZ4gzxtN/CF5P2qsE0pmEGbNiT1cNTl+wfo3kK8e404GfJq244iN1mpJUVN80bp2fTFemOnyGgl+DCCtztAsuV7PAoLYnYJAPXl/ApmZiOYGb8anDB5nGly1g5RmQ6g/8S0GjVpIOq9vDcKSzf80ulLgzMzLQwfg6MesNDrHXd5xbjwjfnq5kX92ii4fm3pPgVPRVWyKIFW81AO89gz3xdSNUl7dJmCQt1J6peEXC7Yi95rMGvpthURewvZX94HDAqNIk9dg== 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=W6a7W2LymHPQff1DnOb+5dhR9PDMiXFpoN0Q8trv1o4=; b=YPiIniWcYGnxadbb2gTUqPxpctGu+w+ShA2W9R4vSe7XZmuzZvdbe+HfPUGRy+KfBg+7hITePCrYGE58bFTvHx4l3J6WZlun1xTUdz0KbvM5Bkx6AREFX/ru3s5GJNgdgngkrSHDEtc0BZrzl03drm7kOg/sdq3Y+ZYVBrGZbrg= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by BN0PR10MB5368.namprd10.prod.outlook.com (2603:10b6:408:12f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Tue, 15 Nov 2022 21:28:33 +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.5813.017; Tue, 15 Nov 2022 21:28:33 +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 v2 4/4] nvme: Convert NVMe errors to PR errors Date: Tue, 15 Nov 2022 15:28:25 -0600 Message-Id: <20221115212825.7945-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115212825.7945-1-michael.christie@oracle.com> References: <20221115212825.7945-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR12CA0005.namprd12.prod.outlook.com (2603:10b6:610:57::15) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|BN0PR10MB5368:EE_ X-MS-Office365-Filtering-Correlation-Id: 6754cb73-1547-4a0c-af8f-08dac750593d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZDsXfhxpBawDVx1WqQCBenxDDb7ll4axMm88/JcGjAG2sQT4E1l4nmy3pOILEV1xxZrOIwhDI0uHTYvfmowjMGE4cxCfvAr2lxUeC21kyLRP6q+yKoGJvu//iBEic7bSqbxLAkjKF9Tch4wOedCyzlbYSBy/5G/ohhcSKqNMF1p5gh0LS7iB96sIEECJQS47Sdb5P+Txv3wWFl7e3YMRmL71p0/C4ZXRUwa+gKcB/c07mnB6OOKdl9Yl0NCdAr0bwTB5eGJD4iM4V9tdSX3JMYRnwbpp5zaojofyou51HGNEi0B8KckYmnSx9FnQMBAxpahrmiKEgGn4DfMUDItrHoI2FUJxpWRjmTe12+OSyp4JDmVRXjZ09MtsovkMtZ+jdF/8AxKQRlJanzFHXDptvqnedztqjPgiGU3a7z48Y2WllTBMNHIfxIYVoPGqmhuwefLFAkc5LJywBpRXl5+1Bq0ErjADSwiay6S5YRho9aMesvKT43fDP7nKoODY87IhKnWtbofOteXnQArhYudNTKYOaz7WpxB4m4znOLpJzICV3djkhK1bXe+aRWfNyYe0Kj6oOu6i+yrZoSo7YK0QyWr9kGAtIfz7eZF26kNxaAP/hK4D3N97TQq9PboJqb2k7slEGR66UEJUujHTWfY2Vv0Q7oz0qz2jQcYomO15syKMJsPLCPaHMbX13C6A3McAn9hSeqdWMLoQ3RitFyOGVQ== 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)(346002)(376002)(136003)(39860400002)(396003)(366004)(451199015)(1076003)(36756003)(83380400001)(6486002)(478600001)(6512007)(6666004)(2616005)(107886003)(6506007)(86362001)(26005)(186003)(38100700002)(8936002)(41300700001)(2906002)(5660300002)(316002)(4326008)(8676002)(66556008)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Nw88YcMU79nTF21hvIbYv4dFois3j/1sFm0ibkxcRZbZUd7ROpksHUMHlrGZqKBInHcLiX13MoW5pNtfOUlkH3MX2TI3j7P5+mlOm5YCLbczNYf2EWJV+sIWOPOUKXg5V7Vvnj/HNwkwNOp/nvMCi4ylESP2W20ApcihVGgs4Y3GVHY0FPuhAtrRGWsSbDPok5qtj3Fi0gFlDYJtDFVHt1el7JedMiDNIRkStoevO+a7un2eMWbqSUBNfzClnNZmgp0Sh1YasUDrpL+6NCLxBmmFGN0KNwaUBw3hrCY7bjl/XG7Xcs4CgC2qQgSoX/kpQ2MLIcz3UT1iLno5SH7xIFxDHVQXPYujADKlwBaO2y4EcjajNiGDte8sS+9j7zr8H3MElrjOhgb9nFH1poYt1Z7NoJfNAYjMcwEHUwpY5oWA57UA/URFUX203kCA0q7+ljBDWFG9hF61Lr0XdHoCKtUCeSDAnLOx1PHVujaODXQmKHA2g0fG93H4amt4ROWbRm+eJHkGb3HRQcNesUbuCchoVbX6kx3yTD+6FCC5GGKjpmECdi/Ywzqg7i2U3BqG56ziKiQSkY1QFTiYGfOi3YQ8F/visbupknn0NPmwiX4YNhxnfOEbbSOyhkLPZBuez4EtuGMEgsb8MjLa/2WW/FS9Umr+9VCzTKj/z972UCJnovk1/uBSV5yLHseM+8EvUCCS2pjlzyCV0k2kfm0k5BdPciRncPw4tD6VTUgePR/0yVVef2L2/blJwsAVIAlnPS+ZDTsx+djQOCsk9vAp7SRc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msRVmQujlPv2vEgkFXp4T8BQg1P9KANNhxXCu3aYn+ydOEXvh3DDEyGrAferx2hPx2kUu0tKC3x756h4iwYTrK00k4k7/VEmFr7hh0ZFV6/TIRgIgbLZlh5kOr6/sKBk15fT5AaQz9xG1ptvJKnvpS/tFGnZddhcS3FPtKERP3DNBmkVQ8nYlUcIUaI0lWZbhRzAhl2tQbMVlGeABwZRed9rlwS94UQPu9DChJpIJ01lzo8QpPeRUs2tQydLS79oE7ETQ+1gOhboOHzI5CK1iXkE2Kh0mTM5p83awRCV7TE6suaBw7dUuzVtFNGJI7hXp2dIHdDSqCPCCSd8u/Ub5gtwCm8CXRDEJQj/0xkoMvnhj7BF4JP+p3Q8YMTcfNIP9A6Lk3IiRm3VcfcWdPmAcXC6f6yotZASI8crAOGPxLLfENGWlPCs2k8GAlsHFnvlXXG6j6qGI88ng5oOy+KTKxo7LxH7CxYoBvS+DiDu0JNh1C67T8rydBjWqmkMTDSpbsJ1YPVb3OwRcGwMZjiUO2gnLKOqYVhT9O97bv6ZjXDglHyEzNUg35/Pn3vHcRWSKpxwDa57tzYJQbiIVZlUCySULYRs1vmjnPNQg8MRO65b/8ARmhhArvPIwYPRmcZMCXVKejtKizeCOaBKE7eflK5K8ccrCE/QCOVss9ybIAaModZgOkLjeXSzXXtzonVf0Qjh9PYJg6Y4y2MV4uqw15k9pxP4vlnDBN/oEeUZYOu1xu5dAiIVkD84hWNayoFlZriBsGS7Ji8poxo8XEpEfSHItMx7Xk/kPAF5EtUwCej/31RfOGJzRohHk/JelIMpykmgIkYqn8o3TnG/0Q X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6754cb73-1547-4a0c-af8f-08dac750593d X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 21:28:33.6122 (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: MWIHqwEs7W5bfBoPj+Z/BDr3mjOFnuPDumFZQMvstF43GZyj4d/PvFtyPFTaXdaUHdFwWh2aBFl264COJjDXIy30IYjTFM8diXSa8PcuCec= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5368 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-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211150147 X-Proofpoint-GUID: kY-_N9V5CAxABxwAarLLNntVVVDkeZz8 X-Proofpoint-ORIG-GUID: kY-_N9V5CAxABxwAarLLNntVVVDkeZz8 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This converts the NVMe errors we commonly see during PR handling to PR_STS errors or -Exyz errors. pr_ops callers can then handle scsi and nvme errors without knowing the device types. Signed-off-by: Mike Christie Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- 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..811de141a7ee 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 int nvme_sc_to_pr_err(int nvme_sc) +{ + int err; + + if (nvme_is_path_error(nvme_sc)) + return PR_STS_PATH_FAILED; + + switch (nvme_sc) { + case NVME_SC_SUCCESS: + err = PR_STS_SUCCESS; + break; + case NVME_SC_RESERVATION_CONFLICT: + err = PR_STS_RESERVATION_CONFLICT; + break; + case NVME_SC_ONCS_NOT_SUPPORTED: + err = -EOPNOTSUPP; + break; + case NVME_SC_BAD_ATTRIBUTES: + case NVME_SC_INVALID_OPCODE: + case NVME_SC_INVALID_FIELD: + case NVME_SC_INVALID_NS: + err = -EINVAL; + break; + default: + err = PR_STS_IOERR; + break; + } + + return err; +} + 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_err(ret); } static int nvme_pr_register(struct block_device *bdev, u64 old,