From patchwork Fri Jul 14 21:33:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314216 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 75839C001DE for ; Fri, 14 Jul 2023 21:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbjGNVeh (ORCPT ); Fri, 14 Jul 2023 17:34:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjGNVef (ORCPT ); Fri, 14 Jul 2023 17:34:35 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04A73585 for ; Fri, 14 Jul 2023 14:34:34 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4ciu015000; Fri, 14 Jul 2023 21:34:29 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-03-30; bh=+Xk6AFBtZb4v86xDSnKHhUr3SXxNU59+woQv9SSypJ0=; b=PUm+JrjvhMb+HMil3KQ1lrrJd5cO93iZatK6GLhrzTVwCiDwBzaWZZmKiOB3/MQH3I/U 96NGe6DvwFC+S7os+jiPfKhdrCrb9vXqgBt+P7NRA6S0YRlUK/ADGCp5DORoZ06vJau1 3DyD9OUi5DrUaJuP3MEvgWPAnERjwM6O25fO5eNJRBc+z822hHpWRIVn0amMnDkQXtaP 7PLu3bduQQQb1gFuDbRNkZCzhgOtOFiRGfV5jk+pVG5k8XzjApB0a7+e02mSVQGL8Rci fx3Bo/qyS8JWg/UsxGOYfQITtAgOmDxR5KMsHxwQG84nhrjRo0bVwV2HovHO5Xz5RuL1 Lg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:29 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EJoXZP027397; Fri, 14 Jul 2023 21:34:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvyh6fm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bk37bM7RZAyaoK83igksU1H8J3oVGGwu1k+2ZzIT+cqkWK8dD46YdOIwozSnGLd9cpaZGePXpiXKmNa4ruCu2Yyz0aCj4KYzTpnll3kYArShP5Km4B0kkizLjdkUpP5dNeOqoD8Anwtj54QM+4DqVOuTDExW1ZncoBVfGO9o4gbvYmnu805+QhgNE0GhYK6rLmQnJIn6PMYhxtc8NXQoAFIpNpjxq+9abMpPpsvDgpfomrF4AuxHAHWuO8MICo2IoZCoPJ+I/aRZ35LTP65n927XpMiDpChFKGig7YbSfjC8735cRQlGlW/ECsFdd8XdA6nc62ivjNWWxpzfmjC2Ig== 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=+Xk6AFBtZb4v86xDSnKHhUr3SXxNU59+woQv9SSypJ0=; b=ealqDNkBPrX1Wfdyi06O51zelezO0ZuxdY1MRfL9J9vycM9MgyCM249hsxOOgwDuLYr+hHCbSKYCk6QrujqWBhF+OBh+vMrp8VkTGmvITAMopS1+4k2XFbaULjF51FxkoIz3j/sqCOdFROlRf3aazNRjrMQMKfk0wsPnA8bmjwKHnjlj1Wn8uz7VL7ii3tnntzwLaydR+iXv90+H8TAXAPakrCUK5jEd8L+QmAuB/YWxnh/FZhVLK5X/Jsk2jQcFzH0Ad3ToE55VJEiUD9vgUxa8prmLSleGScXk+FPtPMflD/sODqf2oxr8KJvcZVHC0gz+SBvS7g4Xm2liWhSrNw== 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=+Xk6AFBtZb4v86xDSnKHhUr3SXxNU59+woQv9SSypJ0=; b=IUCgZjsdMGysc8r7Fwf0jUyP/Cl1mFiDe7Vkj6ObXKweBJg2+a36bIuHtYwiziwAsiAYupkLXwCqOV9SfjlkQgirrsDblPIyqO+OU4rcSwAmKdPSHDIsDhTmqdQsQOBdxW9897feH1U7mG3C2dtjz7vWBVjvySdHZf4R84X4i/A= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:24 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:24 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 01/33] scsi: Add helper to prep sense during error handling Date: Fri, 14 Jul 2023 16:33:47 -0500 Message-Id: <20230714213419.95492-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0119.namprd07.prod.outlook.com (2603:10b6:4:ae::48) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fccba15-f470-4530-160b-08db84b217ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JFZoWwDAtOQhwA3zeoDyOZFklRl/CCrBg3twRNBCQNwtyjeVYncw0EtorAEjqWfbgkbYTXc2J0DscCwO/i6MZlyTwthOoxy9Bz7AAn9hKZAeyaEssECXetXGKj52+ocsc4nzqn0NEbHOeKYuYpocWr/ATMoU8vf6CFaHFO5FEAT1dbhJ9zmxg5pED4oi79MZWNv9j5eTx9xz4+oFJ3cdkKzQTPDXf5QsfsSM0GwYwRdSZ6emoNOzi+xsZJzd6se2rxHF0NDCdyZ2NVBeuzqlaL7uI94W7gm8B4y0kTCuCrSNkHm9zugf94RobkN1iyqR3pxjXHkEKNw9YPIAyFQpz8J1s74KqbojNxgd11c5LBmk04j4K36JGbyjEHl06YBZv7G57EL8kc/WoB56BxR87wKUfFhqVsQnNpZ8xzj+XenSmDzl8brkM2yh96Id5Ot5bmNl3YRkWwxSOs04gWS/KAxBOTjcy4xc1uIn03IYnnsEMDiWSgd1cxtJUxNYjhJ+QpqhRZuDmJo1C6Z/QRPTWTVFsKehRD+IuVuzxRWLTVNs8Q+0z26qDdz8NiwLC0r9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0DS4RIk1IKaWSuYo7gn67le4uub0RsoYiwNADnjVx89THSQuNwmsFicKar83EIAEIJJCg94+mMM5mzxF8TfZ2aRnw2KekmhRwPAOGSDsfH2cCjaAuEBoVgTqINj/VMWopK7dKnpHj/7W0qN2mvXsynF4tXb6PAU1QmpXHk+Oa9sAC5q/UldzZrWRgqgcLzGR1R1IFlyuFwSF/6eR89xZe3ofT2OO1i+04v13EAeljfhJfuW3ACYGkFAwb8/in75fJpsmeFLHQH5X4IMvBYLRy2lI1Jo+mP860C/yEj/Q4sPh1FwdzjWlPR7lIE1aF/BNRwhy2OXT8r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Bmkpnc/HkyBtHsF8Vtal/IsnfQtMeFvdruGIJzgk30RV3NCMkQSM0STLAJSvoJzZEqX1Gtuqrue1v9GtS3nVxFm6DHIfro4qP4IyJ0q8+laU1hgc9hh76SNIzFU3t89CtBtB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fccba15-f470-4530-160b-08db84b217ed X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:24.4643 (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: S8pEzwpVaV8t5eqD0T8K3VzhUsHyi+XIBF7XZ57d9REZpXKlwKfi6D4/Y+zBy8Ivac7lMhvWXMUbr6DL2bx5ds+lnM3yQw5Cd+35IPDEp2w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: oO6QRcFmDZNM47QC1xPcnnSYWE2ChH8s X-Proofpoint-GUID: oO6QRcFmDZNM47QC1xPcnnSYWE2ChH8s Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This breaks out the sense prep so it can be used in helper that will be added in this patchset for passthrough commands. Signed-off-by: Mike Christie Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Martin Wilck Reviewed-by: John Garry --- drivers/scsi/scsi_error.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index c67cdcdc3ba8..7c3eccbdd39f 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -523,6 +523,23 @@ static inline void set_scsi_ml_byte(struct scsi_cmnd *cmd, u8 status) cmd->result = (cmd->result & 0xffff00ff) | (status << 8); } +static enum scsi_disposition +scsi_start_sense_processing(struct scsi_cmnd *scmd, + struct scsi_sense_hdr *sshdr) +{ + struct scsi_device *sdev = scmd->device; + + if (!scsi_command_normalize_sense(scmd, sshdr)) + return FAILED; /* no valid sense data */ + + scsi_report_sense(sdev, sshdr); + + if (scsi_sense_is_deferred(sshdr)) + return NEEDS_RETRY; + + return SUCCESS; +} + /** * scsi_check_sense - Examine scsi cmd sense * @scmd: Cmd to have sense checked. @@ -539,14 +556,11 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) struct request *req = scsi_cmd_to_rq(scmd); struct scsi_device *sdev = scmd->device; struct scsi_sense_hdr sshdr; + enum scsi_disposition ret; - if (! scsi_command_normalize_sense(scmd, &sshdr)) - return FAILED; /* no valid sense data */ - - scsi_report_sense(sdev, &sshdr); - - if (scsi_sense_is_deferred(&sshdr)) - return NEEDS_RETRY; + ret = scsi_start_sense_processing(scmd, &sshdr); + if (ret != SUCCESS) + return ret; if (sdev->handler && sdev->handler->check_sense) { enum scsi_disposition rc; From patchwork Fri Jul 14 21:33:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314226 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 D065FC0015E for ; Fri, 14 Jul 2023 21:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbjGNVhj (ORCPT ); Fri, 14 Jul 2023 17:37:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjGNVhh (ORCPT ); Fri, 14 Jul 2023 17:37:37 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 983753585 for ; Fri, 14 Jul 2023 14:37:36 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4VZ6019268; Fri, 14 Jul 2023 21:34:30 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-03-30; bh=fCb/dGujvfO9I70viXXsXnvOWK8as9iPXKsPbOA53ZE=; b=wVNsYaesn6IKUuFgEjmEcOBGi5AINqLk3mJl4YVB2o1CzEzRyhPiBTjGF6DbugjP9pHe g0xINyVsujtTXPeSTKYjgwGzPekGYddMStTjumr4o2v/3fd25Uo2guavgx1UPelVZ/h6 w17oU3ug8uoSAJy3y2AuHTUMIAwFCPc/n5e0G++CxXt9Vg73LmWDVaPwV2asqhy+5NOB NnXWy7psWxNxS9OxXypAN30CxrIlvug/6KSefMflAZQeeOVdYVFG4S3BJMVqPLmE9Epp NeCoGRxwpOl4RXqUMlCbFKbwsftW4cwry1KgX6sJiGmjRpup7veqQiWM2srf2FVgrw+m fw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpttjfga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:30 +0000 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 36EJoV99033015; Fri, 14 Jul 2023 21:34:28 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvrs496-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uf7UuJ/1wDB4TuJRVI7Yfckw9fLO7Idbbar5/IgTtsNha+HaQyxF2h2GtF9EsA491cJZ4w2bOtfwvRx/FHRuu2YFvMmtuHf1k2A9bVjWwwhBFY7CR3L9FwAKzp9wko/0wvyCHnHsUXGHCfsN45i0T7/pn9LQMM0RfrA5BdMU0f69R2o8irCMKbsaZ5dUTEdGzuB3o+ZoZVMPytRZHtO8NEtW9lH4i7tP2NaEjGnT6vdgaDY7Gf+35HoYKIBNQJ3DMQryf+cQwcbRh3cH0pYxqtUniM7ttMH8tWXO0kVi5BodepaGAn7lgZ+L7FoU1GGgjHrzQsP0bbfpYzXLpJgguA== 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=fCb/dGujvfO9I70viXXsXnvOWK8as9iPXKsPbOA53ZE=; b=S2hlf55VReegUOJmDJzGiOHhHEWyLu10VPElbuDyRsi2blT/KMwyXM9SgEcR86WTH1hzVHF9fgTjwoE1Lh187Z4RbBK8+Horex82CwgGuHMf4HT6AMFaMEDCuqI5seVb2w0jy0NnkohxzW8zR4mjdNd3F1B+3zWHZy3LFRnVVNPbUuJbsEgKuLn+0wZj35023vmPKorTWROgVLI8DNI8wkbri0cvQlOjvO62nlZ1iX1RnnvK2qnW1ETrVtTFANDwQMsw/1atkCvMIMc+/DzscaKn4kLWeCyva+EteP1UzokpdFyGFQBl7xWs+32hQgckTiiuObMkBqoxt+6oZaWuqA== 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=fCb/dGujvfO9I70viXXsXnvOWK8as9iPXKsPbOA53ZE=; b=jxY9GXg5LNkVz8ufQ5hTpbYBkIFpK6MuEK2j0Li9pRYKFngve+94KC/DYa/k+KlCt5ACK8fKUVS9+4fSaf5GzilRj/DEjFSuZlF9QvvfVWIQFpL0A6Qt2ThglK7YBh7miyj3yqZFRZsUEa8uKc/+yBCKEMVKV5Or6hxqhHYzYhc= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:25 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:25 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 02/33] scsi: Allow passthrough to override what errors to retry Date: Fri, 14 Jul 2023 16:33:48 -0500 Message-Id: <20230714213419.95492-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0064.namprd03.prod.outlook.com (2603:10b6:5:3bb::9) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d13b14a-4815-4758-1319-08db84b218a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AcWTgfaCY6V1W9XGJgAdf+HY6AE5SlZtrzxFV6PaSzUMHwDAM3T0KpaeT64L/WQhwWoU1KHdhIJqO0Ve04XEevidVDG1CnwpAngAv+LXlb004LZVhFyrP9FZ0QryLKl9OlOqnasvw6BxoUndLG6r6SFEfP/VRGT5APRjo9smkBGScUFHb3buA+irG2yfejC7Lune7FEzHxaUN6gNyNxLaIFsdY40UM7z7JQ1Jq97Y3/W8CmTrY/ldDBdu1+gduIgzzrKeA5kzrK0X7v0pzm+OJ2PwHN5ZadjQICb9jO+OlvwJGxwFk/8iv+WJUU3rOFqnmK/zGja5fzShJhnEjM+qCanf1BWqAKnr8WQ7jT49lvm5nr75Yz6jo1mZxavzp79svPiwf8Z5dOIK8bUrQaAYqta9b8Gpgh1sDkyrAdm2VoLGSMCCiTanNyqGMbFHYhy5BqYuyRzJ8ZiKIMM9rlq2oH7F0hq2rldZhqbRRttAVvS7nGS5sf7XfwjcEBXI1K6x29Xq3LOfJqs8I31Y84/9cn5tPGYxszY3BlRQJ6UkWsrSazAKckcvnTIJq5cpMI9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZB3k+2YxEeJovjwMPJrwjb8WNuvScPxDlaT6XUzuzbUhy6nO04YuBSQ3obLv7R8O749J2Ug60L1ah1vey9ivNLtkVoabufPKLbdcm3qW5fa1tFyCEsWhPeZscPKQoPy4wIApBPvHhIAH24OY9z4eU2cyuR44V2KZF0CXrtKtY4eHufOiyLzdVRRo0XOMPVYZdr3q4U38e3WOPnSyLZJoRs7LojsZ8SFksdvF5+5wJ+W1Z3IP8gTCAR4gb83haj3V5va2ptVgsRbitffc98NWAimvNa+VEoQlLSRre9cFkZPmxiIyjVJRU/ri9BOJVnG0pj5055rTllSnP+VXksJsm4jQKwsmv9eICTvpuO55yx98wEkWdGImDslDSZog0UB+CnUWw9MxyNk57r9iDFP872gH7LDxHRp+XmKOHaHR0zk3CA+NgFjRIIyEWOI9gKmgQX7yOa2ur/pDjn1QGv9NMZqMsZQx0Qy6N7ltMO7zHwI8DJyyYJo1DMuFbFBUzov63DE1tpzcMQ/ZyTrTvHlkcQ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qG0vFoQ7J9DcQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 89+8fmvdlxb4lkZwZ58ej3kfYbaaWHTd/dpwBgXBFwzk/g9q1GThvH5u+C+Cf/uBGAjyxJIsnFx8ouyeMnwv23DBLDXP0iQCniG87J1zPDMnK3LwxV7WLDgf/NNlEhf6cnhfdnzJyS3/+CnEJc2yuFb/JyH6JQJhejX9q7nGggjuaJ1enebv7snWn6e08oYt/7JWTxhNLFIE81xQW3hrNE09LGkNm14/0vpCFD9d2psGxfqhiUUcQHi3ZIZ+20n8quuYCgY2qCOMaeKTcg027VS0mM8J9Ydl7h6xL9hp1EkXh6SeN+FMzbnKZ8+0hSC4iWe9QTYqB4OgXn9nEV+9OrN9+3qQffv1z1UJs6xlnKgxRQMYTvst1fhhT88fmtMj1G7ttxlEFoj11ozmx3H4LrWu7E1Qm951NvcYlU6vprCgjp7kACsGeCHobpzDoU6S8cNrulhIzMd1auho3FAkxfgtrfGwdsYwmZnzWL6ql1XOXeP9oYEmBoFP4ElL7AITY6+UP7ZMGdYZ3Mk6gG0aXisAfF39uZ9//LYk1NdplM/cF6DhkHnW7g7NYOkpHZNI/zzmUru9dDcj3l6yVzEw755Q01xSjwOmeHrFBXfYpmkfkK8WHVwC42g44oEqQZNydHcTpGVK6AILz7WyAs84gBXuZjUU6yRdblSjweuI0TmGDbu7ws+w/sXhNLqCpJcGndEBAek07qWnyGkdAIK+T00ZaTdYGsAHVZsCoeEaYkI5POSIB4Wu6ssB8B9WQw15xKfYKxE0iHbrg6gFwEBqT28GGgsLV/NHOabqkh9n+pco+HZsyOILQzT5qma29egKzFcuMOKm84rGUCaoq5zfEPxLvWIaCcBqcdfvRgeM1GfH4MNmaQuFBGdN36tSlMQO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d13b14a-4815-4758-1319-08db84b218a7 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:25.7013 (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: kcUHLRUHUr/bSzKvxDsJ2P0CcGq6dypzHNyMd//sLrk/i2fhPgRWAWStPhHqKi4GBJEvHEXTCG/xAX82EjJfJublYsIeWocR1H/iTUcckso= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: FEIDX2-Ka3zRCcBR0XwHEhF3woa8Ml1q X-Proofpoint-GUID: FEIDX2-Ka3zRCcBR0XwHEhF3woa8Ml1q Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org For passthrough, we don't retry any error we get a check condition for. This results in a lot of callers driving their own retries for those types of errors and retrying all errors, and there has been a request to retry specific host byte errors. This adds the core code to allow passthrough users to specify what errors they want scsi-ml to retry for them. We can then convert users to drop their sense parsing and retry handling. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche --- drivers/scsi/scsi_error.c | 80 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_lib.c | 10 +++++ include/scsi/scsi_cmnd.h | 20 ++++++++++ 3 files changed, 110 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 7c3eccbdd39f..d2fb28212880 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1872,6 +1872,80 @@ bool scsi_noretry_cmd(struct scsi_cmnd *scmd) return false; } +/** + * scsi_check_passthrough - Determine if passthrough scsi_cmnd needs a retry. + * @scmd: scsi_cmnd to check. + * + * Return value: + * SCSI_RETURN_NOT_HANDLED - if the caller should examine the command + * status because the passthrough user wanted the default error processing. + * SUCCESS, FAILED or NEEDS_RETRY - if this function has determined the + * command should be completed, go through the error handler due to + * missing sense or should be retried. + */ +static enum scsi_disposition scsi_check_passthrough(struct scsi_cmnd *scmd) +{ + struct scsi_failure *failure; + struct scsi_sense_hdr sshdr; + enum scsi_disposition ret; + enum sam_status status; + + if (!scmd->failures) + return SCSI_RETURN_NOT_HANDLED; + + for (failure = scmd->failures; failure->result; failure++) { + if (failure->result == SCMD_FAILURE_RESULT_ANY) + goto maybe_retry; + + if (host_byte(scmd->result) && + host_byte(scmd->result) == host_byte(failure->result)) + goto maybe_retry; + + status = status_byte(scmd->result); + if (!status) + continue; + + if (failure->result == SCMD_FAILURE_STAT_ANY && + !scsi_status_is_good(scmd->result)) + goto maybe_retry; + + if (status != status_byte(failure->result)) + continue; + + if (status_byte(failure->result) != SAM_STAT_CHECK_CONDITION || + failure->sense == SCMD_FAILURE_SENSE_ANY) + goto maybe_retry; + + ret = scsi_start_sense_processing(scmd, &sshdr); + if (ret == NEEDS_RETRY) + goto maybe_retry; + else if (ret != SUCCESS) + return ret; + + if (failure->sense != sshdr.sense_key) + continue; + + if (failure->asc == SCMD_FAILURE_ASC_ANY) + goto maybe_retry; + + if (failure->asc != sshdr.asc) + continue; + + if (failure->ascq == SCMD_FAILURE_ASCQ_ANY || + failure->ascq == sshdr.ascq) + goto maybe_retry; + } + + return SCSI_RETURN_NOT_HANDLED; + +maybe_retry: + if (failure->allowed == SCMD_FAILURE_NO_LIMIT || + ++failure->retries <= failure->allowed) + return NEEDS_RETRY; + + return SUCCESS; +} + /** * scsi_decide_disposition - Disposition a cmd on return from LLD. * @scmd: SCSI cmd to examine. @@ -1900,6 +1974,12 @@ enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) return SUCCESS; } + if (scmd->result && blk_rq_is_passthrough(scsi_cmd_to_rq(scmd))) { + rtn = scsi_check_passthrough(scmd); + if (rtn != SCSI_RETURN_NOT_HANDLED) + return rtn; + } + /* * first check the host byte, to see if there is anything in there * that would indicate what we need to do. diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ad9afae49544..68f4bee73ff2 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -184,6 +184,15 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason) __scsi_queue_insert(cmd, reason, true); } +void scsi_reset_failures(struct scsi_failure *failures) +{ + struct scsi_failure *failure; + + for (failure = failures; failure->result; failure++) + failure->retries = 0; +} +EXPORT_SYMBOL_GPL(scsi_reset_failures); + /** * scsi_execute_cmd - insert request and wait for the result * @sdev: scsi_device @@ -1129,6 +1138,7 @@ static void scsi_initialize_rq(struct request *rq) init_rcu_head(&cmd->rcu); cmd->jiffies_at_alloc = jiffies; cmd->retries = 0; + cmd->failures = NULL; } struct request *scsi_alloc_request(struct request_queue *q, blk_opf_t opf, diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 526def14e7fb..9a3908614dc9 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -71,6 +71,23 @@ enum scsi_cmnd_submitter { SUBMITTED_BY_SCSI_RESET_IOCTL = 2, } __packed; +#define SCMD_FAILURE_RESULT_ANY 0x7fffffff +#define SCMD_FAILURE_STAT_ANY 0xff +#define SCMD_FAILURE_SENSE_ANY 0xff +#define SCMD_FAILURE_ASC_ANY 0xff +#define SCMD_FAILURE_ASCQ_ANY 0xff +#define SCMD_FAILURE_NO_LIMIT -1 + +struct scsi_failure { + int result; + u8 sense; + u8 asc; + u8 ascq; + + s8 allowed; + s8 retries; +}; + struct scsi_cmnd { struct scsi_device *device; struct list_head eh_entry; /* entry for the host eh_abort_list/eh_cmd_q */ @@ -91,6 +108,8 @@ struct scsi_cmnd { int retries; int allowed; + /* optional array of failures that passthrough users want retried */ + struct scsi_failure *failures; unsigned char prot_op; unsigned char prot_type; @@ -394,5 +413,6 @@ extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc, struct request *scsi_alloc_request(struct request_queue *q, blk_opf_t opf, blk_mq_req_flags_t flags); +void scsi_reset_failures(struct scsi_failure *failures); #endif /* _SCSI_SCSI_CMND_H */ From patchwork Fri Jul 14 21:33:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314227 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 2DF65EB64DC for ; Fri, 14 Jul 2023 21:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbjGNVhk (ORCPT ); Fri, 14 Jul 2023 17:37:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbjGNVhj (ORCPT ); Fri, 14 Jul 2023 17:37:39 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DE83585 for ; Fri, 14 Jul 2023 14:37:38 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4DeV003063; Fri, 14 Jul 2023 21:34:30 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-03-30; bh=xeO3OY03byPU6wlhOa070RJQA5Yv99PU5o3E4I7j5Lk=; b=s7tuJTgco4J0pv0grK/VxRwTfNWz/xhunmNDJbZH9BRJ+3ny/je8MjkJEDqhpF87/UfZ hCJqS+0Mf793aZleAYbxlPPh5T9VuvN4MsJ0EckduskqUjUohcPmbtv0dazS6lJNr4r1 Hq/XiHdkOHIltoO+Z8+fyvRKJluXsJcgwgEHAUo7sUuFgXooANbsCIQW+Bg5tkyCg9d+ /HpYUiEMqQSKyz+BaIjDEa9tNQ5Wt+uvP9qDsHQ8SIFsEjT0T7CmwWa14EsfgsP6NmXf K1Wnx2kInGiNPcecYXTRxOQpZs4feq/lDSAK+OUlq2yo24la8wJ72Q1L0DY+B/vS6b5v kQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:30 +0000 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 36EJoV9A033015; Fri, 14 Jul 2023 21:34:28 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvrs496-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AS4xktQNyGtSIpo24O34BPAr7iika0Wr3Ebrvv9GREpdRSJyxRa2CmersJgPPcsuv07HV20pcXdFSquvUElGVagKoiQ9qCD5+KuN+fp8r1+9EVEt3wlMai7+b/N+ndsBf6K6Z4wV1RsNKjQNyzWPMNWgx6hlH/MDkbAGPlc9iRB7C4bdS+ZaM4p0QWBPhhD+MJxXXzwAKvVB1+pounx+CLyF1wpcof7AtxVHqe4IJXMBLfY8SKkSpNS1hXmFaCgMSJvFUCk4UwASVpCYlto0MQRyklzkFD6zf3B6UXIjo8dNC8nc5L+IxGgIs2mSM9eFFdwEj0OAq7DuXGbod2nBtg== 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=xeO3OY03byPU6wlhOa070RJQA5Yv99PU5o3E4I7j5Lk=; b=giyic2fGKhULbfT2y+PVl6aI0a4+7LqFQ5sBxUs0DcC/vS0uRN9/7pfeoHycEzTG6AEBq/rL8Dnfo8WulV4sRdTr6OB9v0fQLXPd1Lx9HrQXJ/xQMi4uBehXDM5fh13QW6quzTY7OIw0J3yTVFUesK8zRft70EjJVW88NKiX82X1/BMGUgMzZCAyDPoPKfUstC8UHw2vVd9YAC4SUyx2U/PKaVdykSHc/Z214nSJ8dTDDSkcxTwgfVsmcrj9sNIuEQB7IHwwaGVY7D7wDn6HUvQEoEWVFnI5I5VT8cJwQShnrcZf6xjSa0n8/qP+km2Yt68P0lI320oWOu4kyWWs4g== 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=xeO3OY03byPU6wlhOa070RJQA5Yv99PU5o3E4I7j5Lk=; b=wMM5aHgTGkEFPFEP16WCHYSxTwSwUc3l8X1nYOtnTKb+yua/mxavY5T7CN423a8/QUMU8MrFkuiagmnwIY/DKBkXZCQwI4nqPdxpsLAJdu9DE8OpJfSGcHp95j+xuTN22I/7tPigT3+t+fDUCGSLX2ZqVEBZxVTfEVZgVy3wJN0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:27 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:27 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 03/33] scsi: Add scsi_failure field to scsi_exec_args Date: Fri, 14 Jul 2023 16:33:49 -0500 Message-Id: <20230714213419.95492-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0070.namprd03.prod.outlook.com (2603:10b6:5:100::47) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d47a29d-d831-4ca9-7225-08db84b21982 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qi8FWmjs2BAkB2ptrH2rV/gXklief2DhWbeZTE3V2nLSqCg8MAVs+YPmzgQhmob2JM8FOlR+5svy/OivE48wbcteaEqn+pDzvodu/YLtMYMma7g13FykrlnAG5OCOMMS2hp50Yae5Ef4OXyHMcl7RYd9ahJKvc0GkEI4Fs+slC39bjRsaKwyNPz/mASQFIvzJFE7LAHrUATfuCFFBEK+V4EKdlcI52+r1yV3FetDVEm5iFRdgG7lRe3VibPZDIvoJknVe5iOTqc5fkibRLE2vEES/34TPwUkiXWEaoj43iCN/oGMKaMmia9GLDwDA2fdVaqwTVqK6eUaqGJ52L77s/gO08lYtKj5c5zA/LpbpzMH8V4x9hESPP/3QFeTYKSDoc8KBgnozxGgzQkV0DbatKRBG5Ex0upfqfKZOI+rID9HmpCwk7YLEuQQw1yJryit6x7OzmcrAKTysNg3YcJTsqsW6lgawzChbiZ3OyxxBFQXFMSupTzd4aZ0Bhu/bT3TDRXKhGO9H/jMkHTyRygwzkH2VmPNXlsS6hPtJqNOT/E9UsZjLL1MeZD+FCvyc0eC X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);D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ZuAOQVzaV23LWybCGdf5lq9Nso/YXaaVJym9vkUL9QIewQf5o/6ibQuIWL4c2ZR1IJpbdnjNAmXvdyOaVF49xq/eF8mw94EN4KcEcRE5i+lH55+DbOMBryArIoMCQ0aZdu/BndnfnEMyEarQZDbJJE6uUuZlRMuWT7LP9CbECqhy91i6Elt/Bap5We2zvS4bLNDrLCzNeUI/ezgv6PDMvxxezRmUkFPYiWvbOBkkhqNowXxquaoFLPMll9z+HOMM3cYteu62YSzXtMCKA6R4EG6DTP+qs2FeGFAm4G4JPdNWV9WctNd0gOe78qCoWt2fWSjNJUWz1gRO9sEbfPDjzsXDMLrwasxIeOs74HU4fkY5cEpO8fyUZnhE7bCuAfv8A1+F5VXw6f3NDiS8vOZsxCh08V8sIz6AJm+lYSshcaToVGFpznTa2YeiZoC0qNp3S5ADUByNFCN51bgS6tUpe/GLHhzHV1ONnSqL14lVr+aquFvcIREM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d47a29d-d831-4ca9-7225-08db84b21982 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:27.1585 (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: hkYKHMAekS6nFWlGxOh9Og7zfv++RhvqBGhu9M8NCO/Nq609PQHgAO3T8yQcOx6z4TA126HyLZFLw8pIB2UJ0ywPBaZcg0gD1wV74xfPwwI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: ZyJb4ACZ_Y1CmO0hZP4CBsq8nYZe2Uhq X-Proofpoint-ORIG-GUID: ZyJb4ACZ_Y1CmO0hZP4CBsq8nYZe2Uhq Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Allow SCSI execution callers to pass in a list of failures they want retried. Signed-off-by: Mike Christie Reviewed-by: Martin Wilck Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/scsi_lib.c | 1 + include/scsi/scsi_device.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 68f4bee73ff2..0097166814a0 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -237,6 +237,7 @@ int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd, scmd->cmd_len = COMMAND_SIZE(cmd[0]); memcpy(scmd->cmnd, cmd, scmd->cmd_len); scmd->allowed = retries; + scmd->failures = args->failures; scmd->flags |= args->scmd_flags; req->timeout = timeout; req->rq_flags |= RQF_QUIET; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 75b2235b99e2..accf6c80591b 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -14,6 +14,7 @@ struct bsg_device; struct device; struct request_queue; struct scsi_cmnd; +struct scsi_failure; struct scsi_lun; struct scsi_sense_hdr; @@ -472,6 +473,7 @@ struct scsi_exec_args { blk_mq_req_flags_t req_flags; /* BLK_MQ_REQ flags */ int scmd_flags; /* SCMD flags */ int *resid; /* residual length */ + struct scsi_failure *failures; /* failures to retry */ }; int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd, From patchwork Fri Jul 14 21:33:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314217 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 72158C0015E for ; Fri, 14 Jul 2023 21:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229584AbjGNVen (ORCPT ); Fri, 14 Jul 2023 17:34:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjGNVei (ORCPT ); Fri, 14 Jul 2023 17:34:38 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8422A3585 for ; Fri, 14 Jul 2023 14:34:37 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4VFQ019212; Fri, 14 Jul 2023 21:34:31 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-03-30; bh=FeD80m4y0fRC0CIeffXenHhQXqbDKXtLAnIb4w3BvR4=; b=g1ONt+JiIpi0XBVHtAg3e4hdr1NO9JqLv/NGtSbtNkeCVZnjCoX8UifPbq/Ap+xbCqUR z34Y7EaV4KwEN5AQ4lLtYB4RbCDhC95LmX4Bx7lZjxElmXn8V+NCezUTh7atk7GHeIvI nhpqBXvzG6dOaTGde5Z/FVWLuoxPwkbPyy5m3lnf7uwdfS9UBbTVxvvCNNMT+8NRrEnV 9E625XWZ93SCnvpQ/hGHmhb/TRgxatp7cCIV3mFZQwTVHjCZA+ASWkdU01iFvncIHEax Eul1J/TueoXN8e9XYWwglJrjCRqmmOqoIDf8+QWWDK4OFRR5RF/VyQ32GLnsODBG5z2p FQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpttjfgb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:31 +0000 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 36EK49On033027; Fri, 14 Jul 2023 21:34:31 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvrs4a9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YEJtDB+AD7P/RcgRUdFD2Ud8M4FVPGtFv7vaopX6+xrGl8EQ93Pur76mi6P0FwhRQWB3HJuLuXb0tmQ/l+DXhRFMqsEOpzm53wWeu+yIgr1dsrLBz/byBjIM5p1m/R9lxd3cRX7/xl34KPCmd77YYH+q+8hl1CgJRf+1FFB6qoql2nHCbl58ZuttvIAoNj3N8vYfkLiOWOKucx0HX99OHIsrrY2/SOstBlSTst999Vfm/UlETqJ89rkdNrUnEWYY4yvTIdlGVGf+qXWSegoILZ05Jt8qnWAX+0Sq/2aaaV8sSoVyDJNtkqp87EEcM8dDnhi5ZmWiZgi5hVVDoV1Vpg== 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=FeD80m4y0fRC0CIeffXenHhQXqbDKXtLAnIb4w3BvR4=; b=K8xCLqwQcOtII9TTS0midNzNNxJQpraSLlOWNlin9QO5hqec1HHSqjADJAadwLbzMDrksTEkofTPUPxKjK4WDhtrEyA4BfsqwOtv7UVZl9u4ZwIRKxe3CNJ2C3CxuN/s1DZqJstVGaq+mYT/LQk7U5DnKMYylsSrrpQochMqJvXKptbDEHocH5e1m5jeL4BFU5XIK0RXtv07ojGXVIkg1o6vOgcYo4yV7hwr0u7auISteEW1VB1bGxK77hru1thvQoapgkRM3LO6Bv1qcK/r2wnPoXTyRAK5wxuRsW8DGZtlK9S/8u23Y58EdI8RsOLnjl4xOoXth3ixpJDlp5i26w== 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=FeD80m4y0fRC0CIeffXenHhQXqbDKXtLAnIb4w3BvR4=; b=dBLLJv0fl1Icj0p3ri3xhVREWgdcWtKcVPy8fvXv8ly+vcaYMDeaJyiyoBct2fWWS21cYacYdMS7tL7/tpyFntijd95ijb1KcStlbsY3FWmqbXusVgfiETc2EjEFOfnf2ZvhGbol/uLJSxMZQMBByXeyUzm1tb8fVudCvkiJvR8= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CY5PR10MB5962.namprd10.prod.outlook.com (2603:10b6:930:2d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:28 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:28 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 04/33] scsi: Have scsi-ml retry scsi_probe_lun errors Date: Fri, 14 Jul 2023 16:33:50 -0500 Message-Id: <20230714213419.95492-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0071.namprd03.prod.outlook.com (2603:10b6:5:100::48) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CY5PR10MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ef6e47c-6ba6-430e-46ef-08db84b21a73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tuI3z6WfhtvS0F3F9dJQUq5a6JtFi7Nq3QYICvHfq+6ebWslD5mxpb6m/+yaBKaMMIB3ab7Qqg4J/xZtXU8fd1BrmPQiftT4pqPhrkt38Fx+P8BoU/fRRHkglweLp7JsHRpZ/txQ901OL/6B6MiX5s417x3MTey6hB0vBSXwuadfTWzvQFaNWXno8OILJNfxJdiw0OvC2VvRCdXhJjHMCB73CPZr1EENuNnmif8QXBJSuE86VUgOBVz9cAMpzCNnK+OG0t5ZOyHit4y63teyS6Wz9qmeRaO3AmsvkT0zk9AEqFNrjE4a6ea02RKJsqfHLsGD7tU3P7xKHyc8eCyw5oahHEf33OhO1PUCNCIDpbVLKcbRJbEhh5tlte0DQu62uqVBBPXq/SfEmrnuAGJdLTL1ufjLadZ0uto3XCSJUIlqAKPCGamF7a930ggmpW+Jsh5wuCLgEKSsePKTQEj8/8XGQaYXeRPm/wE6+TS26LkQblSuSy0s9drxM+RkXDNqf0D2YFsbnVSIV2MlJrRopASSEKXldt9YaRkfoaltg/ZUrjTk/mmB9BNFS9bBlgrB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199021)(6512007)(36756003)(316002)(8676002)(8936002)(83380400001)(5660300002)(38100700002)(2616005)(41300700001)(66556008)(66946007)(478600001)(107886003)(4326008)(186003)(66476007)(2906002)(6666004)(86362001)(6486002)(26005)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TTrDfKEtVwcjo0kyh5p/qDfirDXCEpKMZ0eUWmJSNp3/N83i1mL+ZQvb2DNkwU0tw3IfD8o8JD2PmA40+vi6igoL17x07w6V0yStHOrt4R/RIoM8ORztFXepYLQm4WP+YeUScC8juOZq6W61zISv+aCnN2jEErezskpnCNRcZJ4B4WF1E/lha8gUvMpMppuwCKjeU3dtSIcme9RwSjgp1MTq4owj5adYQ4CLS1CoubiSpa2XBZxJpTE2RLQWk5/BgysfFdvZ9Qk/USP0GJ0/YJYuM3ejoVPEa3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4sEnb0ImReIkaadDDWpA6ieOdNRuQEMs4mQsklR+rvHzhWw+FHr9Rw3b8Gq6tr8Xh6nhFIEruPjUkWFBHHyRP6/X7CUBxvpdsgRFd1OEKt52qvfya+cVUXFEzdvrdaoWrizTfx5SqDqSxMb06XUZq255Y0vaqqDfcWL6S190TG+DBNGauG32s+76e47C3DJ6vgUDRSAs5xZb48j8ksAMuCqeflyVjk75z2wv+xIsMzCuj/DewhiOeK4CjQVA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +tLFvUpnXEM+3yX8/qx/bfDn8cYrxbXdF2Iw9yCSvAig82xicOYU9/ALZehqb9ciAdKz1HDLyENmVK0PffZIgoIvpT42K1ROOnijfzX63rFYMh2/qQT9L+SRP7wPQemsczR/blADzErg6JRUmVLUDvVm6jT9sYNAzbFH2eO+VbatHY9UkpSOAi5DQ3xIkh72T04OetcP4lQweOUYXFNYhXh7DCdzv+VhtwPsA8DGt1XTAHQlD7F56okTm57xsJSCVRGoJvGIuxwgB5xiLhzPpqqoM2ZMywiG/ikFpWslN8JCXdvd2GmTFqJn2eX9t/vehoaVbHHcL7Pal851yh5r0r0PxPH6/1iyRHp3xrJS2kuQh/bNcS2I4AcWxvE1UKs2aBrGdr7nwZTkWfm8DYUj9srRuzqnoCayVJN4y+BNrd7ck22IQaVGs6iysMLVmAZmb3InRVHQL2I3jXUUxIlp0J5fjJTIrxdvgInlY+koM0sg6WauERCYhEKVpQclSAh35zQMLbBoxfslcD1ePSg8/MODWLlHWcDPkIzAg3NjqfrwCT+bOaZyecH+1UAgJ7jsGZiJkjKE1E+3de39sTNB/UzbvhwUzg2sOm8HlkyRvtRj+STGVHTQSK+1+tIxVjb9RIugAO8iXIvfNPqEJ3SmY9MeEe5Jnqe9w7wila3BHta0CCAf9j7OUFLtf9MWn6Q0lDwTfDt5q0ry3rXCYpACR/WW87zene7oTB0Tpf074x3+nEXmLvgSHz8JGVVUdE6kcSdylCgsOeUf1pbws/56NSN0mQdD0RjNCRl0B9fZaawy4MSfEO5tgldOa2O12W7w5omhjSVzvsWkCPkQwlOl42ffU1dQE5KKkJd7BiPG+jwR3DnJTMjpOnRnhUMYBKLU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ef6e47c-6ba6-430e-46ef-08db84b21a73 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:28.7262 (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: a7r6YXENlGzn4gvapKsoFeS5d8tif3NNB2E2ctFe3RK/F3N3RMEcdMlx0/KWKfxWoTMJSWbpGSzXV0OWmH4GhyTVbaPDka0Yp7mpJ2PQz/A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5962 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: xydX1APW4U8yIBSjCBJYKGmkOB4kN2E7 X-Proofpoint-GUID: xydX1APW4U8yIBSjCBJYKGmkOB4kN2E7 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has scsi_probe_lun ask scsi-ml to retry UAs instead of driving them itself. There is one behavior change with this patch. We used to get a total of 3 retries for both UAs we were checking for. We now get 3 retries for each. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Bart Van Assche --- drivers/scsi/scsi_scan.c | 42 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index aa13feb17c62..39070d9e2d11 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -647,10 +647,29 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, int first_inquiry_len, try_inquiry_len, next_inquiry_len; int response_len = 0; int pass, count, result, resid; - struct scsi_sense_hdr sshdr; + /* + * not-ready to ready transition [asc/ascq=0x28/0x0] or power-on, + * reset [asc/ascq=0x29/0x0], continue. INQUIRY should not yield + * UNIT_ATTENTION but many buggy devices do so anyway. + */ + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = 0x28, + .allowed = 3, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = UNIT_ATTENTION, + .asc = 0x29, + .allowed = 3, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { - .sshdr = &sshdr, .resid = &resid, + .failures = failures, }; *bflags = 0; @@ -668,6 +687,8 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, pass, try_inquiry_len)); /* Each pass gets up to three chances to ignore Unit Attention */ + scsi_reset_failures(failures); + for (count = 0; count < 3; ++count) { memset(scsi_cmd, 0, 6); scsi_cmd[0] = INQUIRY; @@ -684,22 +705,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, "scsi scan: INQUIRY %s with code 0x%x\n", result ? "failed" : "successful", result)); - if (result > 0) { - /* - * not-ready to ready transition [asc/ascq=0x28/0x0] - * or power-on, reset [asc/ascq=0x29/0x0], continue. - * INQUIRY should not yield UNIT_ATTENTION - * but many buggy devices do so anyway. - */ - if (scsi_status_is_check_condition(result) && - scsi_sense_valid(&sshdr)) { - if ((sshdr.sense_key == UNIT_ATTENTION) && - ((sshdr.asc == 0x28) || - (sshdr.asc == 0x29)) && - (sshdr.ascq == 0)) - continue; - } - } else if (result == 0) { + if (result == 0) { /* * if nothing was transferred, we try * again. It's a workaround for some USB From patchwork Fri Jul 14 21:33:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314221 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 99646EB64DC for ; Fri, 14 Jul 2023 21:36:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbjGNVgp (ORCPT ); Fri, 14 Jul 2023 17:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjGNVgn (ORCPT ); Fri, 14 Jul 2023 17:36:43 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B963594 for ; Fri, 14 Jul 2023 14:36:42 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4ZFY029810; Fri, 14 Jul 2023 21:34: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-2023-03-30; bh=6h2LDGUDELlSe2nVsNyEBjYguZN4LpICUM+QUJrPeKM=; b=id+7F5/vIlgfhO2ZASpscfRglPSnUnPLZ1wkpPOdU90J3uRR8KQELCrrlt9ngjU5PE2r q5kBBiluyr1VAcmvRDk43yce4GW1GX08xD7caBRR+YzM4EjAK26esvxNf8l/Zm7SuJlv YCw8f0Xll8QhfbgDOzBcsPAmQV6DTcYX1u/70FchK0apze1Do/WX1ro59wNOkcMZSoQz UkuIxq3o0bKsd/12uSGyEzAFvJgdL4N5dM4FUoGdr8ZRjM73hQQPflQS5VLmLgwy/2xX jxveV6iGI4NCjsXtotpkrGSZp/Hyqp0D7VVOfoccfOvP7YooWhP4uRK03n4hsoPhj5PV PA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtq8atd3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:34 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EJuqFX023540; Fri, 14 Jul 2023 21:34:33 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvxsd0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AixT6eeH3PLppNk4bMAebaxfurSsDBCMsHf2svOg/xhc/VJX1MBhlHV6Ge85YcL94ERK/oZMMzFZpRsY6bMsuqAdu4ESRujX7cV/FvvfUHMle0XYM+YWcFWmzfS2pCgpZowYh1bsB+c67ZP2YKIDdIhFam7mIQxXhBL0Bmjme0ie25m9faWOHfRc0ht/qqbItUcUkrLeVDyzwgFj13lSGcqBEgldbD/6mfCyOfHYoDrBpt6w4l47KgfZ5+C4bxMl9N8kgcrN3dkvzg6YJz5Iy+9G0V7Gu0/0tadjRj8TfUR3JbeI1cYDYNNEqHjP40ey6X/pEzU1K9rm2vUMK4Y3yQ== 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=6h2LDGUDELlSe2nVsNyEBjYguZN4LpICUM+QUJrPeKM=; b=IapxYbaKlekndkM6WOJwApyXBxHsiCjoBC/IJ3P7/cNSHwRvDB6dheoTpziuIlD8dT4k3RVyRZ5rJqu4Ktge9MjCGVyw5lGcut4ECeITyp2Q3e7FVtHL8U5yPA/yKbHoZPyTnYkoqBWzCKM8rykNMT4dFNbpbvDqA0nsTzwok5idLUZg/eTzUk2c8sIPr4YSWQr5Nb7eo4of9+vSv2xPbvdmNk0eDKz9mskIGRlrR8j2fgmliP9lCw8gmmnGswqvy58Y2edSVWnZPsGhJQ7dOS1JFfSrhY514lQLGoN46BWVaVBsGSRP+EZ8W7RnbSVqcFtl7ywRrDDL4unnMc1PGQ== 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=6h2LDGUDELlSe2nVsNyEBjYguZN4LpICUM+QUJrPeKM=; b=utT6VF7hrkWkKjcZc8s2DYeYGmkFxkxeHywFXPoRoesl4cnsdPzS23UznzTV44LvqYMz6nhO1stvRDoSqk3/LcMAEtHyGobEBgHlP9l05f6KsCdt6SDAChWVUv3Uw9okHTwhRMYoNDElmLnyOsLvDTfozyx1UVCQr8xSi3Xgfek= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CY5PR10MB5962.namprd10.prod.outlook.com (2603:10b6:930:2d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:30 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:30 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 05/33] scsi: retry INQUIRY after timeout Date: Fri, 14 Jul 2023 16:33:51 -0500 Message-Id: <20230714213419.95492-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0256.namprd03.prod.outlook.com (2603:10b6:5:3b3::21) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CY5PR10MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a975477-b947-49ab-7d85-08db84b21b85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gRv+I12fHbp22WKyxVzjiCjOAewXfcU0vncSz2ZpEgRfaixOHgLsh0R5ue+bbQ9ZvTBQuBfnAWA61+juY/kJAM3KqZHS9wnIYOQ3aY+dN6Vz7CeD1ExCldSBd/AJ1492legozU2h3lDFYsw0uT4qzgK3SPjmZxFJRUePUwUojb7T7d8yYLni6jFcLG4yC/NstVslP82Cx6LcJVO8hOze9cXjjh6xxjpmhdZuBMm/py8UrOfpclg7mWbGi8AKeq9H5GocaShchwnjLSa9DGtt3Hu5f2y1TlPfAWVT9YLAXWNgx8c88HBCy3qgx8XSx7asTCbZXFDkVq1GLe1ArHpRTqUIjZhFhcvRRn2IfePd/V2GKdUqElbB0GZcqUHk4BlGrU0vAv+ZoOATzJr9Cdo/EBugYJikD7GnXIeVQNvxfpcBE2N3QtdET29TVxvQzaDIr9ZIMivtPVIAOcx4cn1EbcOhPBaD2YKJHrk+uqoMP6RofWDhiT+268EUzUbP46Bw0fRAEd91G4uxPPdxhrnVXSjb/UvZd3KgeDxL+BeOAUBe6qWA62wazJ3x58/M3Yro X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199021)(6512007)(36756003)(316002)(8676002)(8936002)(4744005)(5660300002)(38100700002)(2616005)(41300700001)(66556008)(66946007)(478600001)(107886003)(4326008)(186003)(66476007)(2906002)(6666004)(86362001)(6486002)(26005)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fjoR5zS/wtRThpga5as2I+HU1hdU4IyOVIbcI+rBuYG2Km32E89iaTaYP27vIV3AISbJ4AcoyB0csWjTbfpH6fr8nCUoWOdROkIpIj7kEiL9SFL9eCO6k7vq01qbtmhwT5POwHANUraxOEhw4oj3p4SY1md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E6V0u7U8TcK6AtIIz6DllH8/q8JOQVmoi0463UPSdqNwiJDiV37wphFKKfBpluHzho3rxzow+5dppVplSm+A8rixhPdc6tSKgjUrZrIy02LBh+CO0L828HfGkOgTj58pdAKmo3Rj7IHgyE5eAW93sj4VU7Nn2x4OzzqcPfcQ/6x85b8lRFE4AGKIwGu4KfnB7n61tOO/8+I0QJlfsolRzhSzK1pz82gm53lJAjtpqX7rb+L6yWuHzrtNHt3cZhKspf4Xj1bSzqa3Gqw X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a975477-b947-49ab-7d85-08db84b21b85 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:30.4911 (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: iDjgOFp3Otqg8U8FowPTp4DfxF18q9oE8RxJtbLrKFfUfJuoubdz3aRmi8LqeKzgxzah7WzvqEY7wQSsDGl2B4qkxWVHYJnXW/+fKpxU8KM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5962 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: J5QkAiO8thnThTg8rCJer5wm5xVeXRl9 X-Proofpoint-ORIG-GUID: J5QkAiO8thnThTg8rCJer5wm5xVeXRl9 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Description from: Martin Wilck : The SCSI mid layer doesn't retry commands after DID_TIME_OUT (see scsi_noretry_cmd()). Packet loss in the fabric can cause spurious timeouts during SCSI device probing, causing device probing to fail. This has been observed in FCoE uplink failover tests, for example. This patch fixes the issue by retrying the INQUIRY. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_scan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 39070d9e2d11..e3c8edb92164 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -665,6 +665,10 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, .allowed = 3, .result = SAM_STAT_CHECK_CONDITION, }, + { + .allowed = 1, + .result = DID_TIME_OUT << 16, + }, {} }; const struct scsi_exec_args exec_args = { From patchwork Fri Jul 14 21:33:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314228 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 449E3EB64DC for ; Fri, 14 Jul 2023 21:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbjGNVhq (ORCPT ); Fri, 14 Jul 2023 17:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjGNVhp (ORCPT ); Fri, 14 Jul 2023 17:37:45 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A92C33588 for ; Fri, 14 Jul 2023 14:37:41 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4XJF019325; Fri, 14 Jul 2023 21:34:35 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-03-30; bh=39561NT93TtshZ+e8b4H+vye+D1uuCaaXYP6WMQiQL0=; b=0Y1CXCgcpOQBmL0fQsQZFDZOcwIr6fwWC6dKILPrxVEi9vBLlkbMAQ1o+QOHltRP2slx y3qCEPUtrid/TXnB0XCbgo3Yz9ZF9sXyrlF2agd/p2XDeuPDzw0/K7iUajDuGvUQWXaW ESvArsQ1wk55rxFVz/4Wf/g/8uwcrqhkLVeZbF5dNU8S8TC4d/4KxOSWXXfL+CGjQArc WqyuRI1YqNFlJ7W2DLEycA7R+18xZuq5YKMPBBJmDnsjMoHVk9N+4j2z850iFCMWh3fB H7Mr8ci8pupb4Ck3CaoDRhfZkoPOhffxAyBDV+038xuRdro0FHWQFlKc8wthWrxcPE32 PQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpttjfgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:34 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EJuqFY023540; Fri, 14 Jul 2023 21:34:33 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvxsd0q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAmLepOETv3azXXIPvU5qZpxTiNsP5Lmr6vMJIHOJg7lF4WWTEbps5ssXyhOvYGZEkztbKXTQSyXndsjfheLT0RN9JyK7u3fQQEhjzdYusCavF3LmthDZtu6nd3+9jn4aJl54Qyxtz2A+2n43rYRHayeHtRjp8pglBkFsul+ELfCcq61p/BRmaJ0WZNEeKsi4BLnnaBQ4NNMbe2hOD/hbo9tkXybGL//F0WEkEebkfg+TiOaBxtvhwGTSSYo4HyNgbNNYfpq3lG9UAGyuKgHIzOPEWBkLCwc3nyqrB9YBrtgeO3S4MKlUkf1vk9zGipsz2iQU+7DZQGIFUlmQs4ixg== 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=39561NT93TtshZ+e8b4H+vye+D1uuCaaXYP6WMQiQL0=; b=D2cdAh/OeM9ar88sXSdrSKxtoTsdHRejsNwNmVPWMXRkeOyNrsSWwRBq6lxQHTuF1VUHobmUErzXFYIRYgHQKsuq5+L4CNoLgUKic8LhXSN8JLtPWoL9on6Ei3bCjhNF4xpWN2GZNVGH2MQtnmC1iEQsXQswSOqVyKNIRpXxHrE1emwqgbvzsYuMSYIZMyXVKyNtWS5chfK5V7mrzwGghoFapjluQsgTb6O5AojXbR+KQl1Yigwha+XNa0MQJtlak7OUF+a0orukARh8JiN/iTLu3BHKFsdXHZXVaYeWmAR7lpD30HptGkeqzUsua/1xzT+oZ/joXNOkENs2aHw0lQ== 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=39561NT93TtshZ+e8b4H+vye+D1uuCaaXYP6WMQiQL0=; b=Y+JfAtSM1TOAb0wNjTc2Nl1GhMUh9ubDzTpklFI8oUHjS5wgG4cTOPlT/pmxoZyQbzyWl9CwfVSDqBQRosYr8uw9LoAgwfQKIr0t2y8rH+qpyhNY5ODCRBiUzVaCwkDbVh7oyoPzvB9jsU4pYlT53KvprAXY+w41CY1ShF2BrJY= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CY5PR10MB5962.namprd10.prod.outlook.com (2603:10b6:930:2d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:32 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:32 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 06/33] scsi: sd: Fix sshdr use in read_capacity_16 Date: Fri, 14 Jul 2023 16:33:52 -0500 Message-Id: <20230714213419.95492-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS0PR17CA0004.namprd17.prod.outlook.com (2603:10b6:8:191::12) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CY5PR10MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d767aaa-18a2-47ef-2b11-08db84b21c6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZWxwSj9b7ZhEwjKM+Hz1CCPsBzvYKCOZQu26Dfr6xFQJbKd2gbI+hL9Kif51FvrnmP9aKmdnU7Lhl99SHYWr7nNj0Uhr0JbB9sq40DEJ9JF7ASHi3wKupi57IvZb7QCIl1tBiAbxHXDayC4Br7bcJFJ4ADp75V5jF88XQ/3aP84XtzG6J6xmvxmnvX+4GioMYC+hREElzU4m0DWdPQcRd9EIL3LdO8++/H9XcrLDpoH9foDkbUkhMxenEar4r2SSp7T4mBzgwIw2YgC3MqvAY4MCZInE0WTzzki2c1GY4U3+M/dZ2eq/tkR1LeHMQ2DRPueNnxxhosLqLFis7zbyzQ1qKYhhzgfUFgJTns0vLbVOvd7LZM/MXcpXe8AiITK1eWWRgbe7w9iPZFzmU4/SICsyzpOq5vdfds1W9RwGnj/KwozSi2D5G6XVOh23f+vcKvborgSOpD6hymudospnthZh04NFCx9R2m/6Jhu/WKaOhbofpxVxkL7+LrFyZ/o2fJ+ZADUbyIpPKlNibYjdWnYNtA1GQHX4kwEOtIStHgU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199021)(6512007)(36756003)(316002)(8676002)(8936002)(83380400001)(5660300002)(38100700002)(2616005)(41300700001)(66556008)(66946007)(478600001)(107886003)(4326008)(186003)(66476007)(2906002)(6666004)(86362001)(6486002)(26005)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dtC0+l1yDY2+z8F4k6PvAM/pGe9hYYzUskbl+qtu3kR6Qi4QIosUFR4OTD5ayRpUmgcP9UxGAaTXiZIB8UT7fh6FHO7e3CvTmX41I5GkGrCy+2Bu6ZmkWZHA7pmLYtvsvKn65EbxpYspnvDbf7DD7M0l6jq2S4IlqMkuA1icijqp3Ods4nR5rDE4LbOTxlERC1DFmotcCY2urBBMfIIKVSoqeYoA2DBl9Pu3ZRN5bR+I2Yu/ekau+lk+PUP8C78zjx5jpV4DMVdRqFZ7OBGe0T7wu729BKq33L8cIu+67QxD4P9XrY9nHsn6YP1y4DPnaWyWGtHyUMLCaxj78JIUm7qQQ4DzkOZ0vO50Y+vtWh/YEmhk3QCZb2SRHFR6aOvMyZbvhCZEvuIGhKP5Z8YP4k+VSV0Ia+B0xBl6A2aesZOnYDVktOdzeP6ORrf7YeFV9E8KEyYGbI17JXVBaiOPA4l/TyBWSmoSvfki3UpCZsWzq11Rn7q6aFZ5fChZhqtptGjKVCpbx+u4bWxHYzbVFrKYFQONHVohV5Z5vBePn2pTp/thja8nv2AwVYpdaynASWuhN/fXsgFxQfNlF9dg2tkRYTrM2McAY1lCO+iOdxuhD86lhrZbjbxeeABCuqLZ0VVeVJIZjqPuijdPfgoDsDmuP4Tx/rXgjOzmB1/xFFhx4yhhbaxs4jS8A1lkRHmVCFLflzS/KyrpdOVOy66kikoObJzyN/F2ulc7h1tR5JjztAaU376xR3myWpOjsFuadbEbwLNyuY5AHBBOeuGmYAxSBfs2uuOKeTp0cKo27PVQUDeVaW3cIlCibA7iI92sbeLemKElt4oapMSqDM6LV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PSlMG1qMLygwp2XX+mUjgYseIKdQ/Osu0EHpaMgJF+jEkl7mHp+W6+TR8oNtB6qrK93xw5RM3a9JJ8Z9pojWTx/htjPVupWZGp5kxw2/QNY2w72Vj+3sR4l1Q5hsSzjjHtRcNtjMN+29+5zdrRyqcx0CATqXhSB5k35U/DjaulRZw7Je+vBsaldCu64DZz+O46/NTErUBtUMK+OILx29F6kh1QTpQwkg+ZYQjy7tWu6CTbZPBf2ia+VuRhOqKNBCwxXZpIJ/J9kRMjlxGAehCtCeEPuUj34FNxEdT68QpdRlvSUy74r+IxoDIUgT+BC9P+Xu2GTy2vsKRNZsVA6xU0peLMVo2ihTuUaXIQQZPLP2L+1swcOMBC7DRbmdH6bySk/0VWznGZoB8dQQLJBUBsFqm/n7NYNhGSmmgbAk8aGOt3/iyKHeqSnqPBRt9WqMusaOksD6lg8ReZhKwJ+WblTAnG3hYQ2eRbZwTn0awxXZbxFwcjmBPXbAz/LYpKPqgXnhz7Fu0i/gQfXh0tnXqz6yCg4s2jGCxZHQJQz0zMf5+dWSKYP/qJsjPhYEVqQ6nq1L0jomUeZWalL+WdN5exv2wRSrObxO869FhjbdsrkIKq6NPBL/pONJfpZsdkdsHfkqwChHrpO0ywhTfg8h1RouQ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d767aaa-18a2-47ef-2b11-08db84b21c6f X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:32.0675 (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: hpORLISgQC4bIwbFtD+jurdu9Dn//Z0I4vJcft6AVPcoSQFFw0+yImjNe1A+G8gAPvvcrrLgPWrv41dMMd9+MAJlCxEeEMqfGR+zhNbeqkk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5962 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: nNQkBCGFbBij245dPb9eWJh3r1RI4xZo X-Proofpoint-GUID: nNQkBCGFbBij245dPb9eWJh3r1RI4xZo Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Bart Van Assche --- drivers/scsi/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 68b12afa0721..755b09beff2a 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2427,11 +2427,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, RC16_LEN, SD_TIMEOUT, sdkp->max_retries, &exec_args); - - if (media_not_present(sdkp, &sshdr)) - return -ENODEV; - if (the_result > 0) { + if (media_not_present(sdkp, &sshdr)) + return -ENODEV; + sense_valid = scsi_sense_valid(&sshdr); if (sense_valid && sshdr.sense_key == ILLEGAL_REQUEST && From patchwork Fri Jul 14 21:33:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314222 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 574EAEB64DC for ; Fri, 14 Jul 2023 21:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbjGNVgv (ORCPT ); Fri, 14 Jul 2023 17:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbjGNVgr (ORCPT ); Fri, 14 Jul 2023 17:36:47 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32CD358D for ; Fri, 14 Jul 2023 14:36:45 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4XJG019325; Fri, 14 Jul 2023 21:34:38 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-03-30; bh=qbj/BrLOPWzCCtwFGk+xP7kMGwmlsSYqbLJY4eV+3oU=; b=xPTarPPtQdy7+dPuPSI1zyV4mplaTigLWHU8KBe0+00rD7dqO8DcCyQ+bE+P21ziQLiR peqLSjr4lTIuysUzyxrY3Nk4ZCA3IAlQ6t3SpjuIaEXARiIgkYNKVnDpKxzbhvsyCA+5 YalZjM35sYgImf2gdMo/6TTDTNBTmJcFW4teKjtXVEqZ22RiwytQac/YC2/CDBHkKGj8 6e0j9lbQQYvGpzJwLng+fhZcCE/C+u0+OCYd9mBSPGA4b6AUnMVATym2WzdHI/PsfO8X S0v2nbn2kJEhOl05dhuk2hgAaJmQz+PXJ0kquj8hZFAqL9WdvFkqrsIb1gYufZyI16Sm gA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpttjfge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:37 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EJxrJO023357; Fri, 14 Jul 2023 21:34:36 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvxsd20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OF7vOzz12Xfyoeg3OffAMZkXz3yUZhGCWAVePVL244iMiyAoAAljbuY8rT5/gXsNIUBxbzbw8V0z80nTDbSDQDIZFryeXPcFUAT4xVodaYs0lQNVjmg/n/arEmsMlaffHAWS6qmQQ8oz3hqi894MLSw0ogQXAlrPKhsqCSx5ifyWvbQ04sXvu5g89owMnhlbcA19d6SwKN2vJUGoEZ6KRHz6uwTOswQibPWPlHf/Bti5nKqbgrpTjTS3AhgTA4WTwKA0cfL5AI8VLoCnQ7uk5NqWBAYCcIOhdCMLuVPdV/cZQTTa0uYTHLfQKf3YjV7aYx3KVyytWxa+aoG/+hFCgQ== 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=qbj/BrLOPWzCCtwFGk+xP7kMGwmlsSYqbLJY4eV+3oU=; b=jYI81c0EVut14ieuQg/WXDy6LXyGssTW29HoIG7uY27ZVi07CUqDZmT3QQ6/tyTnOtnTtbBuVyzyrEz1b21pZpjfGMxj1A/2yEc6SaQntO6oOWVhjI86c4PvCLuu0MjUUPyZjZZ9FUsHgbelLNas37y1JrqO4pDYk6OfnSMrtjLvtCsfFKL8Khx5pVhRKk2Qm5GcrqMI5H9CBxyjWrwCnVqL3+Vl5SA+WjfKXzJGRKSAEzGL2eyyOhUVdTCS1ry/0JpyPCKytDV6/fiWtrfmFyw7lBIkVI/x8WjbezerCjvUk4nAeieoLJ7OIJS5m45E9/vbeJ+bkDnLMF8Y5dVw5g== 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=qbj/BrLOPWzCCtwFGk+xP7kMGwmlsSYqbLJY4eV+3oU=; b=ibU0wmJvBif4X5hQlQf9WFgLrmJTadPAB7tQgLbA2E7FhSRzjSN+XlQ+oMWO4z1eiWQbETFZC4EEgQgObhKbeeqPMxPmFoX05az8oP2xKIB3tvuJDRbFNxVp1ctQnWIabqpHPzcCAk/hE88eWgfWuBeUuU6sr4qw+SK7bC+Rmq8= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CY5PR10MB5962.namprd10.prod.outlook.com (2603:10b6:930:2d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:33 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:33 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 07/33] scsi: sd: Have scsi-ml retry read_capacity_16 errors Date: Fri, 14 Jul 2023 16:33:53 -0500 Message-Id: <20230714213419.95492-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0150.namprd03.prod.outlook.com (2603:10b6:5:3b4::35) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CY5PR10MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: d8a82952-ac4e-4299-d881-08db84b21d58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: io1EUPG2mubEWgCCGi7apYYijPHcv7LbbfHbAVxddy6AvGkNrYxZy8PUggZNuasjSC+QlOOgh0RzAT8ka4LyZUl/Xsup+0vE0BDUYXhrqkFFCIw2pQBi1+w1/UT4sPjv5Ae0OhFUDYFLCApicCUkSTHraHugnfxyAWlSkyxYvZbicShEt5DhiptZCDxnoVDtDmuTrYs2gpSwgtk4eb8QOT9k8VDcaS9P/nsp9Y16NI393LbiXDoIje7NGrFXL6tpbrJ0YfIqR96zl3NqL1jBgBDegzKxht9FYlFidEKCtotXzdOLpc0cP3ep2J6C35fAybiSL5JZBrGK5OMnRCXQRgx7fhmZ+hNusqdL9797Q4V2qqDFqDkOQJcKTPvizxn0uzRYF/aup75bSHjULyBzVkvaKht27HLLK4XB+ynuXFVFqfBgIvWdhKolOF0IaqQ+n6nKPY0+Q78RxR2RqGs1WfkBgW0+K4SRf+2i8pLErB2obw5bR5CCXCJrAJNMCXXx8UqW4EJ1mC7BuLTlvjpC1XURU9NKlgqvsz/W0424VprBZZ8TtyCruiJ7GbC5/fps X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199021)(6512007)(36756003)(316002)(8676002)(8936002)(83380400001)(5660300002)(38100700002)(2616005)(41300700001)(66556008)(66946007)(478600001)(107886003)(4326008)(186003)(66476007)(2906002)(6666004)(86362001)(6486002)(26005)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kFTNAjjZfkGRBz0rhrxTThFBm3M6k/RRUSM3xj6DNWgmg07lxZguSOcNuL4nNeoREynCvCBKw0Q6lRGXYOIztbaeg5MyJKijQjI+yPKfNNasQY3qH954s9KOTSF5CXWkmF53Rp/wXnbzGqByQM3Zt0HCkFOVVzTAg+C5ic1fI3zqz1vAOwLLsdOj5AYrphamR+v0AMXOHRsrwTCEORLvthROXWsvx2bnznMbvg3l2Fb7Ju+atEjepfaZdCpAdw5sbH/gH+FKKInRf03nBcrd/Co4h1/jGymN0yB4WbFdgOPHwP4cHx45Li9Yxk1GzLojDyA7/Bn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Z9BDTZYcF9yfu4tccy/d9Nk/oBZe9Rm3VM4EVHbAlP344iU99fesx1oVciyiGYlx0z68G0hdwtEcAIuRWMhBNHyyUbOA9mJJT46gmFPYoFpHIWQaglpew6voyGO+1m1jyqk7sIOoo7CPYFkSORiM0DTQU9fvDH2h+3aVOqxE468MF9jNG+Tf6oxtUheI4Q59FA511TuZBjrwU/ahPsM+6kfw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6znppTcVT3OBcL/To5enBJO5eyUf0xXia4xoM1f21nOZPZvUsOlXSGb+StEBY5Y8/rJWmcM9HSOMKJWh06iruBq+bGv63q6zwqXI0oLDWB5DzTcQTDbykWVXZ5wtv+1CRoK8KegdoQoWNSPOHgdyiiZ7QMW9j10tud0HsueT6zLC24hhzO9k8RAnv9lKeP/zJd7uKwDoi3ThgbWbwdT5YoehhLz+o2R5vrri7jCh72GLJfH+OpZ1swxILxVaFoHfl4vn447/MV8iR6uvmhuXdMiF6xWuCObWOIPiQhd5bjMekzhInKTw8dHtLsCgVzd8NT64mAC6avKvgZVVSCBk6HPnirA80cX68wBe5Wcp1W89AV/4BN7IFh2FvcpuY3Koy+jkHQFuf1sVPD30PBMLBwo3lgp7+ioQzxU9AFzeY5sgcnYxcFNvaRqHAGBlIBAICdu6wYp7UxPavvKbywdAtQd9rlmcw09DU3KfHTjyklvU+5uina3V6sz74fNIoXglUCjZiltHJcAN57VapofXBtXZB2JgdovLus7F1PSLiY4nWKvSEjSqG4FLatqbDiKkkNyoA3S9pFt4qthfG3V1afQF8283UI3rA/egZnsDy1Lz7PSEwrgETiV/dpW2ckPAt41yKSZL1m2fhHPlBCo6dMLsXRiggOKHu6stlsAMebdCwVGpN8O/y/+AdZbcGeul+mpCnuEisyLVr7oi3zXutlVZ+U0iqyaOOVqWn82EnXB8R+Qo8TZv/rR7jtfs/noLWVNAfFZoskbw9dzRZ5A/08yu9kHtvwHcRfNGBxQpYQnrQjzRJwny1UYe9kRrhLMB8Vq3S2ZJW8p7dzCJxAUnm/6pDRy3C8ZTVc4r8GbRxANjy7Qcug1/MKpapZDjjQY9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8a82952-ac4e-4299-d881-08db84b21d58 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:33.6244 (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: bhxF6MbvWZpf3yrJyLodn86iHUF+ynvbKigU8B/Adjaj8cfmEGl4d/y21QprLahZ9/+G9ZB/HkjZKCt87TF+I9sSJwifEhBJpygpMa1Iu0E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5962 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 57lSPtKU-Mu367TIeG4yw5MOhf0qhUlU X-Proofpoint-GUID: 57lSPtKU-Mu367TIeG4yw5MOhf0qhUlU Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has read_capacity_16 have scsi-ml retry errors instead of driving them itself. There are 2 behavior changes with this patch: 1. There is one behavior change where we no longer retry when scsi_execute_cmd returns < 0, but we should be ok. We don't need to retry for failures like the queue being removed, and for the case where there are no tags/reqs since the block layer waits/retries for us. For possible memory allocation failures from blk_rq_map_kern we use GFP_NOIO, so retrying will probably not help. 2. For the specific UAs we checked for and retried, we would get READ_CAPACITY_RETRIES_ON_RESET retries plus whatever retries were left from the loop's retries. Each UA now gets READ_CAPACITY_RETRIES_ON_RESET reties, and the other errors (not including medium not present) get up to 3 retries. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Bart Van Assche --- drivers/scsi/sd.c | 106 ++++++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 755b09beff2a..245419fe9358 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2402,55 +2402,87 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, unsigned char *buffer) { - unsigned char cmd[16]; + static const u8 cmd[16] = { SERVICE_ACTION_IN_16, SAI_READ_CAPACITY_16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RC16_LEN }; struct scsi_sense_hdr sshdr; - const struct scsi_exec_args exec_args = { - .sshdr = &sshdr, - }; int sense_valid = 0; int the_result; - int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; unsigned int alignment; unsigned long long lba; unsigned sector_size; + struct scsi_failure failures[] = { + /* + * Fail immediately for Invalid Command Operation Code or + * Invalid Field in CDB. + */ + { + .sense = ILLEGAL_REQUEST, + .asc = 0x20, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = ILLEGAL_REQUEST, + .asc = 0x24, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + /* Fail immediately for Medium Not Present */ + { + .sense = UNIT_ATTENTION, + .asc = 0x3A, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = NOT_READY, + .asc = 0x3A, + .ascq = 0x0, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = UNIT_ATTENTION, + .asc = 0x29, + /* Device reset might occur several times */ + .allowed = READ_CAPACITY_RETRIES_ON_RESET, + .result = SAM_STAT_CHECK_CONDITION, + }, + /* Any other error not listed above retry */ + { + .result = SCMD_FAILURE_RESULT_ANY, + .allowed = 3, + }, + {} + }; + const struct scsi_exec_args exec_args = { + .sshdr = &sshdr, + .failures = failures, + }; if (sdp->no_read_capacity_16) return -EINVAL; - do { - memset(cmd, 0, 16); - cmd[0] = SERVICE_ACTION_IN_16; - cmd[1] = SAI_READ_CAPACITY_16; - cmd[13] = RC16_LEN; - memset(buffer, 0, RC16_LEN); - - the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, - buffer, RC16_LEN, SD_TIMEOUT, - sdkp->max_retries, &exec_args); - if (the_result > 0) { - if (media_not_present(sdkp, &sshdr)) - return -ENODEV; + memset(buffer, 0, RC16_LEN); - sense_valid = scsi_sense_valid(&sshdr); - if (sense_valid && - sshdr.sense_key == ILLEGAL_REQUEST && - (sshdr.asc == 0x20 || sshdr.asc == 0x24) && - sshdr.ascq == 0x00) - /* Invalid Command Operation Code or - * Invalid Field in CDB, just retry - * silently with RC10 */ - return -EINVAL; - if (sense_valid && - sshdr.sense_key == UNIT_ATTENTION && - sshdr.asc == 0x29 && sshdr.ascq == 0x00) - /* Device reset might occur several times, - * give it one more chance */ - if (--reset_retries > 0) - continue; - } - retries--; + the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, + RC16_LEN, SD_TIMEOUT, sdkp->max_retries, + &exec_args); - } while (the_result && retries); + if (the_result > 0) { + if (media_not_present(sdkp, &sshdr)) + return -ENODEV; + + sense_valid = scsi_sense_valid(&sshdr); + if (sense_valid && sshdr.sense_key == ILLEGAL_REQUEST && + (sshdr.asc == 0x20 || sshdr.asc == 0x24) && + sshdr.ascq == 0x00) + /* + * Invalid Command Operation Code or Invalid Field in + * CDB, just retry silently with RC10 + */ + return -EINVAL; + } if (the_result) { sd_print_result(sdkp, "Read Capacity(16) failed", the_result); From patchwork Fri Jul 14 21:33:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314229 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 D4DA5C0015E for ; Fri, 14 Jul 2023 21:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbjGNVhr (ORCPT ); Fri, 14 Jul 2023 17:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjGNVhq (ORCPT ); Fri, 14 Jul 2023 17:37:46 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A01043585 for ; Fri, 14 Jul 2023 14:37:45 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4ZFZ029810; Fri, 14 Jul 2023 21:34:39 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-03-30; bh=gBSMRjp2ehAq+40L3V25ma6ZjBs+ezfX2HQpljKz3Xc=; b=Up/KyCCFbRH+WXazmf6hNHEJYbDwYs5ybmzYiuiPnUy3B/OpDQoD9bZd7CN2z9XJsHY1 /fva+Y+YIzuNQ0mEQ6cAsBA2A0F51udPY5Vnm3GH9t94t0V7HK/xRXkgxyR7Mgl5R8dd Yxejjrgx0gnZKtA/EDBgkU2iENt6IWZiSZaoy3LNoO4rJRIdIsAUqk0XoIdoVfWuAsTo cCUD4TWZ/NqJ6HGU18HZas+SLQXondDOnF1E9pMswfXTtN7wKBQMVi1hvbUxbzPT/AlV l5yDEV8N5aind42u28YLrQbh7NYSB+nOMMtkoCasLMkFZipsgzyll/FkCpqmgwnn3T2t rg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtq8atd3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:39 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK1X2i007651; Fri, 14 Jul 2023 21:34:37 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrvp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q5nki6vPaevY0uTG+AgUieWno2gxFkbthIlTP9oC2eRRBrNEDfTNNYugnlWFgjZDOvGj+1yjycclxXjZjf+XjiTRec/iNynM7XmOP2gns1jlP4BHa0c8EPhqx6Cdt1xvw/3nB0pZlnF/543rLsmJOJpoj9UrAVLrtB5i8S120ODHWo6LXMP4h1eYYOQXnC6Cdne7u27WHhHh7JhbBT0aXr0g7H5hpFnjkSAixx/WsfFlIAnVWM3zfFZN24Fy4XuwqTrborqn91jFHGdhwniW9ltPJ8yS+Zf83l/HPzF61cbtq4OAMy9w4IfKOr3Dcn+0h+wa8iTS2lPiqzcY26N9Yg== 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=gBSMRjp2ehAq+40L3V25ma6ZjBs+ezfX2HQpljKz3Xc=; b=kBs0jLmh++WtOTMqUhS+FnqivtW11Ge8ZZYrdpFimDasgt4Ufe2w5kUcyu7kb6ZJEtN7bLjC/619AQl4CHwHccA7/ubwrj45ScCUR0xOO3A8IfJ++1qPG5/iq++mtznY1LTj+7kjhs2r7njXAaB8ZRsMSNO7cAWrc64z7jaVAeAk1Rr3dySrHBY442G9ou/q+9iYifCyiIcwvtWIWbkUFZlA6tbK0C+ojt2vpc2OM9Lz68n6NcIQfmRJkSjIr6ryJ7f5ADiFbNRSAGIzQ66Fgjh9f41LkqUdkOD6On31ziu+UV2eMJlTOEqOvS07Ooj6ZadaSllrl2OrCF+3RxTbMw== 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=gBSMRjp2ehAq+40L3V25ma6ZjBs+ezfX2HQpljKz3Xc=; b=s9AXsYeGA3hMKe5vJxlvNrn6U38Ro8LbOMjn9/Z4XUJF+xjRTb7DSaeXyFI5JrKwP+l4oSBhJ1S5EeU/61XrSGGWwfgLKU8/eFGkyYQuKkESYISeWFC+GQWkHU6RfwwiwG13fyQKXJTKwzYeNsFfF8FKD3rm9zXQ5/905juzSZw= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CY5PR10MB5962.namprd10.prod.outlook.com (2603:10b6:930:2d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:35 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:35 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 08/33] scsi: Use separate buf for START_STOP in sd_spinup_disk Date: Fri, 14 Jul 2023 16:33:54 -0500 Message-Id: <20230714213419.95492-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR11CA0045.namprd11.prod.outlook.com (2603:10b6:5:14c::22) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CY5PR10MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: 534699ec-4d5d-405e-e769-08db84b21e82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uy8xeyYGMWBxambCoEYstUagxwaFP8cV3Et4UFvuOPyC8/jDhmOsJyRWPktcQXxfJQ1VI5wsyJRAOEzQvuPl9HkXWIXNkyVhV+qg9g8Buhgv4vh7DQ7QfnaD+zqbmEqwiI77DIIZEm6yyRRoNv61vK+IYw178mPQc/y6A++PdQgRhAYmTOc9lPJMQSgDeYQy8GlzULPW63ZVz7WrUZeR9SE+LWEzK/FL4PgTNW3KkfBhKLosWKrwqsA99UH7c40+JsHN/zWUxzpJlGss/CVAg4Z+3lnmgjHKvQNGf2phH6UNZTilBeRhzz6OlqZESIM9dfJfUo3ALIraEF637UB1TbLW2JuM7cz3lESg7rnUG0Ag+C5IxYSUYb3D7o1c7E77cJhN6ZbuaTagps+1iFH8OpErjP16yDRk55I7qrxFVEpI0wMhrydPEnMuB9mYh1viTgg5WV4yfr5+3Ho1RlcMZeJG5vnAq536rzVn37XBg5MGpke2NYVYsS67RL0VUzoXUNA+0+J5cJ3RJTMT3fDK8lDDVtR59GvkbKRctopzGthcne52+6V9Gujj90YjwfrA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199021)(6512007)(36756003)(316002)(8676002)(8936002)(83380400001)(5660300002)(38100700002)(2616005)(41300700001)(66556008)(66946007)(478600001)(107886003)(4326008)(186003)(66476007)(2906002)(6666004)(86362001)(6486002)(26005)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A0EADzCc9QTVExfgtWNui3DWdgC/MQ1J0CwgOgQOZ3cSyikqVFCR8WPCFtiX8D6nOse1QiHYYKx64oSL3csPHsrc49R96XbLFDhP49QoQgDNO8Lcrrek9RbjU4BR1X0l2jGWyV8V7Tzmad2dqiRMP6L3rwOF/coMJ3YryWN6gbKCVaHjExkqqwtdd8eDwUsGwV+O2ohkYP6aGqe7DAyYNK+S6Z7x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t8wVHphyCx1ms+PS48kRC7FEL+LRYOcoF+azv1Ui8R5DCCYwj2Ap7ttaLeqQI/hN6aa6sqUGwgEZwDdTlimq2lGv8+8evN+270vVGVaDJWiqaRKJMVNbolXZ+XEZzbpnN5RBtzairtmUbTEWwi8/pfXGqCyhSO3X/vmGnE8HNjRrNEOd3gK/UpuKEIZffHyErC/XFmTSHSETdpyP9XPXH3NRqXatuSL4 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 534699ec-4d5d-405e-e769-08db84b21e82 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:35.5109 (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: 6jVoUohNVZ5vsPkTgR8UPod8yi41hRHSBwJg9D3e8QfZshvG/EzM7yxJqADAhe3RJqllUflLoQzx/ilVS4dXGXa+Lz6WuMREl/hWoyzBolc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5962 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: 13km6UGPBzkhhRll-h7nGmFgrpTagvDm X-Proofpoint-ORIG-GUID: 13km6UGPBzkhhRll-h7nGmFgrpTagvDm Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We currently re-use the cmd buffer for the TUR and START_STOP commands which requires us to reset the buffer when retrying. This has us use separate buffers for the 2 commands so we can make them const and I think it makes it easier to handle for retries but does not add too much extra to the stack use. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Bart Van Assche --- drivers/scsi/sd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 245419fe9358..f75e2d7a864c 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2267,14 +2267,13 @@ sd_spinup_disk(struct scsi_disk *sdkp) * Issue command to spin up drive when not ready */ if (!spintime) { + /* Return immediately and start spin cycle */ + const u8 start_cmd[10] = { START_STOP, 1, 0, 0, + sdkp->device->start_stop_pwr_cond ? + 0x11 : 1 }; + sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); - cmd[0] = START_STOP; - cmd[1] = 1; /* Return immediately */ - memset((void *) &cmd[2], 0, 8); - cmd[4] = 1; /* Start spin cycle */ - if (sdkp->device->start_stop_pwr_cond) - cmd[4] |= 1 << 4; - scsi_execute_cmd(sdkp->device, cmd, + scsi_execute_cmd(sdkp->device, start_cmd, REQ_OP_DRV_IN, NULL, 0, SD_TIMEOUT, sdkp->max_retries, &exec_args); From patchwork Fri Jul 14 21:33:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314230 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 96D31C0015E for ; Fri, 14 Jul 2023 21:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbjGNVhx (ORCPT ); Fri, 14 Jul 2023 17:37:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjGNVhr (ORCPT ); Fri, 14 Jul 2023 17:37:47 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7AAC3588 for ; Fri, 14 Jul 2023 14:37:46 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4bbD014922; Fri, 14 Jul 2023 21:34:41 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-03-30; bh=lhqwKUhVo0nv0zUMT0iBk2OrhAmvSi3FEd/mIHhXiWw=; b=IErDkrbaEGqtxXTOLPHUU//zvb+GwjNs5zjERXZFuYc1fyxZ90ohB5Aii9RiQFW06e4O GMUlZK3Ej7Th/QcZsNId74Jki70fTezY3DxtVUBcyat4/MJdjQzcovi9wIuuLfsoqG/g F5SCFsGvcLOaBG4HHOTxtAqNoUSNp98qWC7nsYkEzTQ9ZRn8pmF1TpRpLOkrfwGOL/d2 HT6fWraG3lestl/wnT/geAOdo6ztBt0nDlg+Xv0gfVmS0+qRBR+CR7y4LxjW4d9UHfyJ USDW+YxaBPvf66hkR43CIhLF/xIxHHUYev7/60MUJ0X/5zUTe9SKG+eX8n1vPp0JTl6m nA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:40 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK5Iqi027199; Fri, 14 Jul 2023 21:34:39 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvyh6ne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LhNTJ2tcopcudQTqYDcBXpmR2koFiIYmAxNUtCZq5WhQFTTPIFm4aPjPYLcpYM/eTXkvdYn/MlGQ9Qk5CyEI/AHKmND4AY6ELvwpZ5yAzPA9YkOWkrdwBvg84Pzic4pYznWbBFB9iHKEM46QFK8viz09MPPlZlI5L4FEoYT6pzFAKWDRCNyNdSYVQe7BHo7Cpwu2y4PKdI7VSyGc1UnjbAT5ZiiQWXS3kJFck/9QkO+l3ViF0jf9g0gX8gwHK0dy5sN9ZRRtTpVA3LrIG3ZvY627Vkf80iPohNgy0MSLqwWnMe+pXtvMkv7EFhdsOazyNxTX7fJe122YLcLORKGiAQ== 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=lhqwKUhVo0nv0zUMT0iBk2OrhAmvSi3FEd/mIHhXiWw=; b=iBUJ8YKSNUk6mlvFiERjO6N9Mfb4Y7kju97sslGAEn+y8dc7nMd+j4P04AL8OfnmB+D1nhFZ1Aeft49gyIr7uLPKAD/8pzmIQllkJXZmTXfzqtZUZFBH5BKB4LJDSGvvoqtemXQzn/4g1nUtZSfk7sssSaT/zDtfzSjGXgRfFjlz2iz2iHSBQTKjENS0BPoL0c//K8+uFZPcsTIvABkPR802LP1DPdPQwy+56jcNFjPFg6qtsDk2zA8is5/E1SF3UGRKKHfaJ/L3xGno5lm3HR9zBg7a96c3xHFr+ixcYZMOgfgghZsozVRvkHTib/F/hqfdV1qRrPXfdGw3kqXTMA== 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=lhqwKUhVo0nv0zUMT0iBk2OrhAmvSi3FEd/mIHhXiWw=; b=y1ed2QXEXNdBc5lJtt//42P3wSU0pUMEkerAibPf46qBu++pmDy1+cRgxmeW8oZm7NbMok6Ki9gXappePCzRXEP3uhr42B/lCR1dKWnoHLAcBH942W3zsW46DpmC1AWukIjqQfqH+gr5XVdqPrmuIOHiOYg56Npo0+VMClNKKFs= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:37 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:37 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 09/33] scsi: sd: Fix sshdr use in sd_spinup_disk Date: Fri, 14 Jul 2023 16:33:55 -0500 Message-Id: <20230714213419.95492-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0013.namprd08.prod.outlook.com (2603:10b6:5:80::26) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 93019a78-7b82-46db-9471-08db84b21f8b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: coh4V8dZKAthVtx+lt3/JxRpFTw1OariHKsIg48ip6sUx1KU/q2plLOz8dq/vuwKfI+6mIFaaPNL4koIR+17xb2hI9ZWk3MP2tZzwOhEhXmxeD0nMo/v2yk/T2Rwac7MuYCfv1gUwgWNtng9Bqjp5LgNrQGJ5gpbGhBahvivSgzvktkrLFVjeAvpWTfbZcRAJmBjlT1js/keJyAT6VjD4CddTiX7sd4zZtPlsc57lk66ZDaVaQBFvxmTelpzcP9mYqqkMa5b/jWOEzeB5ctU0v7QiVynFWBq7mnVJrIya24pvD6laCQKuOHO2rE6zbxDCxwwO2Sy2xJp3re7nRHLplG+cK71N+6Cku64n0yReCbFy9jRYa4JiufUcmQiakhhlCUbAWQxyEoujcf5NbR0NfqtvN+qEMV7v5t2hXsxth5ZHoSJfji7/U3PiacVNYBInNj+rraWEyneW6repJOSvPkGe1I2tVKXKmu8XyyC+GCltHfr5Yu5k01MJ1Ud50kI4CgD4l/MvZqRiccm+4HZMMjIJOfB2e1Bwk6L5exvemtXVbrHZMhH+Am2Q0aeClMO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0kCG2XV/+dr/vb3qLS5pf7a2FVmSZOmD68X4uc/IqWsQyaOxi2aZ6mdeXbPR7V/G9/ZqJkSiJ5FdWtJ5fJ7gDR56ULhVORSA51D6d0dgfL2+u7OOw9GM07luTbnBmHh/AXdvNByU/4DsoBWGjdIFNyycoXpeMW9DGE+gceMs7ooPGj9xPXzfgE7yi7nJe6ciMXMKZUD+klcwc3sWCCdMqEk9OI6BfgRs35frGgJlwV6/tKuS5k91vbSvzxxpGt2A8RHxaqblvAFKlwsMiuPrgWLB3oK64dHUcWlILzwnJB5OW/eu7/k+QWZNbKL7XMFlMRPjsuwt2guK/RI+W4+SVaBGdKtPbiKvQ72djbl6+VP8NIfYAb1/2/DykJipllepf/4XkmsgO2rTo8h5EvIg0QoHry0uG3c7nicw1d4OxwWgHMMaaSOk3KuLcwsWX0rh7M0t7p4PL4vArxorJ8OMX5UUkGXTq3coSHbML5oxYRenXq1jxDWihDZ2Xa6+PkK4dbtVHQztjfjdyobmv8EVOVE+u/LuMPkUO9U9JuLwL+Y7D2hKhPvP9I1rTOkqwFsj4uSYKvismygGobryZRZY0E5eeHX8V48s102D3qFGlAWjt/dTUg43yuiwdJyrXot0OjKo7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N+M/0PMfZcw92FxmoeByEhelWmruGbw9GGa87k+GHTd8+taq/ICucDzFUDPpvTNUwOLwrU7ZZK8ZgnDn1giTx7Q2J/PNQxABSlyfgh/4k/fmG3ZpntEHPMvXwTXFzb/fWASpcsqSFuoStSqIBOXht7h2q3nRDq1BO0qdnlirtAnHE2GhJZfjhiKf5rXQN8gvbHnX1T4cHzyF2ardeQX7xFuej8ka4TDSZi0VDx0sFiRrWYG8WWP3jNKguQ2Fql6dQm2WE19LgHMRlFfwr8XjcCKWQvjYkpZFoZZdke5k+0isgleh37Q+PkJRbtH3yb7d2ClNJvBJpj3Qtj76S+9wD79JXC/uju9eL+uASh6aiaKeBQs8mEa0GbH68Z+3q7Xwso4uGwWZ7J7H6HycSoEqb3UdPlROLH2hIxvlSAttvKrr3VZrrHSW80hp/YCGpLf91pwRw1CYe9wg1jApdPCQcMbGzfIMKsLI6ToZWrdOCuBZX5207bfhUULwZdartydOO2Fr5lrH3U/UTMHY6bj/RSpamCNuROI2klqO1zzoFnYEXkTTyVT37H6YePz7U0zNaB6/DPFuzybe01D84ciUNLgvrVWrpsWz9q21achUAzc2JPcd6uGTahcUD0grRg/AfOe8UwdF+fbOvo4GINnKmEmtizJ5SJFsJ+AdhwQLwq5DXGCMLUds5BqPrOnhR5iIKeU1OMcLRCorfq+I2KZ/kE3KjzpzePpE2JGhnGyvZs964S7NcFvMl2IeQ/VQsdAZr+KyWmglLgRBX+7C25IDol2bL3O3yTLES0GqPFU6bm+M1Xou8QilUlOuRyFcxJTLpKqWiBoMgOI9HApZNdjMfeswI4pcYiJY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93019a78-7b82-46db-9471-08db84b21f8b X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:37.2619 (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: T9v+MCaWnc7TuS8vEscSJSfsufiY/6ZwxCq05rdSuNrQFG2+52Donhg9QvLgO5gK80+w0y40srrjDe4An8K/+sS9xVjj6N0XLBgZmB6Etlk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 6suIGZfvp_j1x4PfSsP0nElvydmtxC2u X-Proofpoint-GUID: 6suIGZfvp_j1x4PfSsP0nElvydmtxC2u Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Bart Van Assche --- drivers/scsi/sd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f75e2d7a864c..753f18457ea1 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2219,19 +2219,21 @@ sd_spinup_disk(struct scsi_disk *sdkp) sdkp->max_retries, &exec_args); - /* - * If the drive has indicated to us that it - * doesn't have any media in it, don't bother - * with any more polling. - */ - if (media_not_present(sdkp, &sshdr)) { - if (media_was_present) - sd_printk(KERN_NOTICE, sdkp, "Media removed, stopped polling\n"); - return; - } + if (the_result > 0) { + /* + * If the drive has indicated to us that it + * doesn't have any media in it, don't bother + * with any more polling. + */ + if (media_not_present(sdkp, &sshdr)) { + if (media_was_present) + sd_printk(KERN_NOTICE, sdkp, + "Media removed, stopped polling\n"); + return; + } - if (the_result) sense_valid = scsi_sense_valid(&sshdr); + } retries++; } while (retries < 3 && (!scsi_status_is_good(the_result) || From patchwork Fri Jul 14 21:33:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314231 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 B6C61EB64DC for ; Fri, 14 Jul 2023 21:37:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbjGNVhy (ORCPT ); Fri, 14 Jul 2023 17:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbjGNVhw (ORCPT ); Fri, 14 Jul 2023 17:37:52 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB20E3593 for ; Fri, 14 Jul 2023 14:37:50 -0700 (PDT) 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 36EL4A8j019574; Fri, 14 Jul 2023 21:34:42 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-03-30; bh=GcD7zNCBsD70u8DJGJmCj4vi3ARiPBK4L5L/xdjZoT4=; b=kskFfdj4GMSrn8lcy802G1xGk7CyXtPyO2j2AY2WH72oqAxp9vdfENEL7BaAikvnBPJJ Ifywgi0pno/0wmCrzsL2dTPorB/4q6hgTt/KoJq7pQu5pE93SgfcMV3fbDyLA9xOJcx6 qCp1F6DfcGUn1Xct/ChoSOifO+ocDOEgW0ZwCJDeisPE98IzlAaoj90gz44JXfEYNVoS E07nVot3s/qEYGoaalZMFPZdk29noxepGxHLOh3x9GWR2AlxzIJ2op6pPqEmwhAfyWzS 6mEbR9cd2aswZI33JTwlJS/3a5cxLaKXgvTEps0D+xEof5EUqqCkrCfh3J/TGgHBWVf/ 1g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqgr2aq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:42 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK1hjV013905; Fri, 14 Jul 2023 21:34:41 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91na-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sviwqqent/6IynJAfp4hDD5jwmdnljEVQatUlaR4sMXDD0ceeX9lMPFDBE8PqhBqYNusSUPAnlEhAZVLkSNJUB3F+knmgTot3cQOQgNy+m/zKVfIuj2GU/jhNcx4SM/d0IDjGKzaOnWjMEdd6jwDIWYyQ1tkoQZEUUFD3OjwsIE4HwSFO3kNkKKyyCEsTmYfvYOP5+V5O8WVLcV+O/eEGsZciW/nn/NFWshU4uu6LQiTG3/G3AC0AO1poZdcRGEkksCO8yZJ9ybHYo2cHRLiGWJ8YRh0MU6SNLQTJhPc19INP+YoOg8DpLeI6BpTdX7iaP78zClWAQ+ffGR8vakxJw== 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=GcD7zNCBsD70u8DJGJmCj4vi3ARiPBK4L5L/xdjZoT4=; b=SdpTJ9aTSoKaaS7YVHQ8T0RMIlVR07j9ZYXXIaBFijOdN12Kvg2al3NobpGrq8dxqo0VLl8ndvPard4ZEcUGP/CAeIDoY4Es8g5wUkw5gLhmvo0HUkCbwLckrPJZt61HcgAdQJPzQbvoT7mpo9qidBM/XfwEp14duaVofbQtFfozEOkRV0jBUWwGegWyLwJolRNO6eVXxzcYFuMsOy6+NdczhhtFOfoekIB0NtSFeHT2yChFK5cAg7FbbX4m19p4S25aCDmdlxvndBm/BNC7qPrX6XXiFwhafQ6U0OFi/LmL7ndQIs+7j77euzN4GD1gJ0P+ikwOO3wJyZoWpTCBoQ== 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=GcD7zNCBsD70u8DJGJmCj4vi3ARiPBK4L5L/xdjZoT4=; b=vO3J1f2Ax2wjx49zvuD+UvyHMTE8u9tSOorAra82c1m+bvLwICh+BPmTBMHwxXrJcDTqQ6/zsrhTEVTwZrmQRZBFHzq+SpauGjbRrXHfSY4JtssDanbUfx8Rpw5PZ6GokhjWm1W1XwWt4k8zW3t8lFUZpZFzwmy/WC+rPOHu1O8= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CY5PR10MB5962.namprd10.prod.outlook.com (2603:10b6:930:2d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:39 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:39 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 10/33] scsi: Have scsi-ml retry sd_spinup_disk errors Date: Fri, 14 Jul 2023 16:33:56 -0500 Message-Id: <20230714213419.95492-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR14CA0047.namprd14.prod.outlook.com (2603:10b6:5:18f::24) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CY5PR10MB5962:EE_ X-MS-Office365-Filtering-Correlation-Id: b27e9da4-47a8-46cb-54a6-08db84b220a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xk/k7Q3znl2HFU8sga7S1vohm5Avc3ZbjfjGbEpbv95WDO80bdKVTcVzW7vtTtMQ+IGYW1nMLu+Fpmwlyg6q4MXsDinQdc/1sO24vLc5SYC9bq6vagr68or/WOGNty1R5fbjcLoaVn1vEhanBe/wma8KMx77cqG2dB5Vb4/41BnnqA9hKyVh+9HGLwOfyToAm6U26X1FH6Y1yVcV2s6Ltx27kZqLg/099aRNJetm7bJhFONST9hJHykJI0Lfa5v2Hwkwr3cU3SEVKzjuGungFF2pLdaVlzhu9YpXA6zb03mKr1dOtlBARkpMb4tLMi52GgVPygGRuA0Bl5A341vAKZkyUS7TKDHZjKjlF3DgKimTE3RbZKqFWMyHbyufOxaZRRfGR9Qfb8qICrMdTal3YDKtUsdbZCcZ9WmBcpuQTn91dTpMjNgNh+7sQ1YuaKnZWtrNRuclMJr/wjwWVUFE9CMM5J4VYupq7AVtgZwrS+Yvf0jYPJek6xdYM4D6PB5n1D44stP1tfEj9oJCWotpBBgQsUkiHbzuQaCDqUWBzDHXOsv2Rd8neiih7NQl3Z7k X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(376002)(396003)(136003)(366004)(451199021)(6512007)(36756003)(316002)(8676002)(8936002)(83380400001)(5660300002)(38100700002)(2616005)(41300700001)(66556008)(66946007)(478600001)(107886003)(4326008)(186003)(66476007)(2906002)(6666004)(86362001)(6486002)(26005)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z4Pm0BqZtG4urIaUBSB+/A0DSi4FE5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FuAvc+/DEJlxJCXvrzrbsgYGztl3t9fq6aC8XQYs1Ao75s61nkbjugD/vSY1uX9zPNbbuq6adD+PMNh9ozYjeaSHGk6sHc+czQOezHxhQvXWrgY5FYLMgVzzvmYpDYP/mqnWmygLefxcDwquWHueYZFSVvFYXix/+CEwcCN1G4nrT71KS7ZlhD+tOKKQ/R0MDTDbuABgdIWJwC4WhLx0wRw63Zt1z8mvWopr4xLNNOnRF+9xkbDV5gnK9Z/dQ3WEsHosmdHZ6rK3yWVhxctU5XSXmZkxsCw3O2dj07Fc7Zhy2eM3bvW7rU3V3Wn0RPQatQ4mjbK4sH3N3nvReiaQiQtKzoSu6mmVLDDqHVlNhUxnDZz1NO0WizmF0CX/e3N/aKEHU/ac0KHKPzNT/88qRZ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b27e9da4-47a8-46cb-54a6-08db84b220a7 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:39.1781 (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: Mkxf+K2wQscekuLCwPYy88aONj1zBbXJxzrBvvIw/A3jwS2Hnf4aMNsNas6jKWA44F3dSgoJnj2/s/9vBPgRgPGt2z+eDIX18VMhavhWvco= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB5962 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: rQl6KHjACGZytpCiThTzn5gRyE2CfMHA X-Proofpoint-GUID: rQl6KHjACGZytpCiThTzn5gRyE2CfMHA Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This simplifies sd_spinup_disk so scsi-ml retries errors for it. Note that we retried specifically on a UA and also if scsi_status_is_good returned failed which would happen for all check conditions. In this patch we use SCMD_FAILURE_STAT_ANY which will trigger for the same conditions as when scsi_status_is_good returns false. This will cover all CCs including UAs so there is no explicit failures arrary entry for UAs. We do not handle the outside loop's retries because we want to sleep between tries and we don't support that yet. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche --- drivers/scsi/sd.c | 73 ++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 753f18457ea1..34a1149bfff2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2190,55 +2190,64 @@ static int sd_done(struct scsi_cmnd *SCpnt) static void sd_spinup_disk(struct scsi_disk *sdkp) { - unsigned char cmd[10]; + static const u8 cmd[10] = { TEST_UNIT_READY }; unsigned long spintime_expire = 0; - int retries, spintime; + int spintime, sense_valid = 0; unsigned int the_result; struct scsi_sense_hdr sshdr; + struct scsi_failure failures[] = { + /* Fail immediately for Medium Not Present */ + { + .sense = UNIT_ATTENTION, + .asc = 0x3A, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = NOT_READY, + .asc = 0x3A, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .result = SCMD_FAILURE_STAT_ANY, + .allowed = 3, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; - int sense_valid = 0; spintime = 0; /* Spin up drives, as required. Only do this at boot time */ /* Spinup needs to be done for module loads too. */ do { - retries = 0; - - do { - bool media_was_present = sdkp->media_present; + bool media_was_present = sdkp->media_present; - cmd[0] = TEST_UNIT_READY; - memset((void *) &cmd[1], 0, 9); + scsi_reset_failures(failures); - the_result = scsi_execute_cmd(sdkp->device, cmd, - REQ_OP_DRV_IN, NULL, 0, - SD_TIMEOUT, - sdkp->max_retries, - &exec_args); + the_result = scsi_execute_cmd(sdkp->device, cmd, REQ_OP_DRV_IN, + NULL, 0, SD_TIMEOUT, + sdkp->max_retries, &exec_args); - if (the_result > 0) { - /* - * If the drive has indicated to us that it - * doesn't have any media in it, don't bother - * with any more polling. - */ - if (media_not_present(sdkp, &sshdr)) { - if (media_was_present) - sd_printk(KERN_NOTICE, sdkp, - "Media removed, stopped polling\n"); - return; - } - sense_valid = scsi_sense_valid(&sshdr); + if (the_result > 0) { + /* + * If the drive has indicated to us that it doesn't + * have any media in it, don't bother with any more + * polling. + */ + if (media_not_present(sdkp, &sshdr)) { + if (media_was_present) + sd_printk(KERN_NOTICE, sdkp, + "Media removed, stopped polling\n"); + return; } - retries++; - } while (retries < 3 && - (!scsi_status_is_good(the_result) || - (scsi_status_is_check_condition(the_result) && - sense_valid && sshdr.sense_key == UNIT_ATTENTION))); + sense_valid = scsi_sense_valid(&sshdr); + } if (!scsi_status_is_check_condition(the_result)) { /* no sense, TUR either succeeded or failed From patchwork Fri Jul 14 21:33:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314233 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 A6010C001DE for ; Fri, 14 Jul 2023 21:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbjGNViC (ORCPT ); Fri, 14 Jul 2023 17:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjGNVh4 (ORCPT ); Fri, 14 Jul 2023 17:37:56 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 838633586 for ; Fri, 14 Jul 2023 14:37:53 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL3moN003889; Fri, 14 Jul 2023 21:34:47 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-03-30; bh=i74eLM0gYYLfBKQ58eUwPhldoNfeqtnqzPMiKTZMjK4=; b=YusmBiQN720RyUltYX0dPsqHPLNWtKRt1nW5ts+4YVG54o/+uFg3fRVYxlFC1StsiWAM oAQnkVo0NYgmTcUxrIkyOwDqOp/tHe8AW3f+ScCxnzEzR54rUuPBGBlZrCJxy5Hq6NK8 WAbA9cxHUg8TJNtI+uuSdm9AeUazMHSXofS4XrbmAstAIbc1/efZzF11QwNLd/m6rX0t xXDS2wzsP6o2COmUA6Cs6mvBonB2VwyVKZq7SgaV5RrYDhEn9annGSsIBZKUcaTxnMd3 E8z2wsHXoINmJHAVje/uS0njDpg3e0QG4ecpUOZlOuRdc0zmsXGCSn1hdytZdxu4kvYM 6A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpth2dw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:46 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK45HL013796; Fri, 14 Jul 2023 21:34:45 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91q4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i32akuYOVRzdZSXiLyYQMCfGL6WMa5MTNfWhKbnFioYFW4kiPtoSA1yrcB6NitobLid0dzvKhInJO6ZAE8xXB3vxgpZlP9OZZjd0MQpqT5utiRo0xvYdvPW32lKkfRpCQvj4wG8QEbW5jfv8HxeDm3rlMn3HKCXKjgxh3to7QM7I8lzsWs/jrpF5LyWf1x7JN6fBRzC7XCqPbEWN9FhPAuwdBwSQOw8QxLGgeCAXCNjjTVxLnA9bAg25MKAuT1T5mO7zhLHvmfBWYQlFdGp2u9MoUxJLVlSGXoXPprHDNRBHj12S72BonwhO58heVJ1hcY6q3HfWAji35st6d9VNZw== 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=i74eLM0gYYLfBKQ58eUwPhldoNfeqtnqzPMiKTZMjK4=; b=giFxbXJ8oOGouW6wH45O8kEJ4YIBWZJIXY5y5SKW8B/EIGLcKjk7vB3V1hD/RPKcSX9IUAreULw0q81Hui2ALg2UO8v9vcoHwpD8u6BEn2KnryXJiENLqca/Dt7nzV26dlei1qbT7LlDTHIaRDzu7NWWnp5hBPqikFfSHcsIz2IKZSgOJaFef+lJoOYdioddwKGB/YwySYXL9sOTAu8jzNvLCBkCckOzhq3wAdgiD94u3D60T9ljwHvOyV0PrF6u4aqRmuuqBbeKge2rSi3eEzmoXl4NEfSwZxIglU3Mkva+1trAmlBdR9yIRcWQsdfBraQOvfwAi5HSdS+KSI0t0w== 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=i74eLM0gYYLfBKQ58eUwPhldoNfeqtnqzPMiKTZMjK4=; b=Eo8OFcXzADynrOZOl9OnoCmh7rZpl15Ia0orq8s6cO9JYAt1IWswSBjJlsPTsnQaX9oyOpiV9vAY6g+aDd3TTFqxcAKdiWkC00t5i34ZhcMK+aUS/9oqwvp/eHFSPWEH2/IDnXrAQKX/hd/9NISQ0h+f/jnMSn+NEfStyYWxy8U= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:41 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:41 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 11/33] scsi: hp_sw: Only access sshdr if res > 0 Date: Fri, 14 Jul 2023 16:33:57 -0500 Message-Id: <20230714213419.95492-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0097.namprd06.prod.outlook.com (2603:10b6:5:336::30) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: 84e3842f-ed05-455e-8afe-08db84b221d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eXQHfimF/Xhn2WKhOv9m8xtC/fE059udBqIts+bguL8KkR6epsvNAGBE5yNIcwjuz5CH9VNUWHVJGHGCv/NbNg7Ew4JAw2sG9johLGqLccHlnQddrnK2lf9P18jdMZIL5+c3taXGRKNb2ZdAMe686Acum8E5p8lpNEA4+fn3efIhMDHcYGbrS5lxfgXFiRQBfZjAlviKgZco/9zDbuTJJh42qx9J0m+L42GGbt+XZ6YR6qSJ57nIQVEMjtxQC8/VoH4d8zVQgsmf7VguK+R6YAPjCl77R7UaJu/rQ4VoE1qoY9ZNSl74pBXwC1/uc1BDn2mxBV3yyw9hEL0PkY7ZVIc4r2/AP1ABumCPOQAL4qnKd6Vlq1d9+uRZaO4xqWrOW369wWetCP31GGytZIHd0KqAsSlC4pLdKY3IazsJWuP6wOqkYWEmAaM8CNeSK6W8is3t2YRx03IwAFrnQXareLXj5lOQLByw+kvxfIUEUiJHxKYkY7M7WdHZI27MhuUYK2mQzYpFS9zIDaid6zpQEeifnCfRfQRHjIxltjA0CeOU+6+S5f+K7XhSEH0me/zy X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mCtNcoMyM+E4uU8m0CCUcigfe6mrHE8CXtAmnWQH/JEjoO779DOkQ+b0fz/fGoHqKHGGizUnVvbwe+dyMsMMJB/PE/rEQVva8tRkwZ28ULHEmoSO88opAry7mqw7ptRMKCWIEQZTmJ87ohkVzomKdtcg0esnWm3vEMsPHFdYhzdiABpmce8HUkOJPjFzqzh6By/6TFQkTNiq8Gz1Gy+w/NRjuvt4AgBAiT2g2FvjE3hM1XqSrbwc/pUFC3v6ggCx3gRRzeuxNCf9PtENtlyD2xGciPKkrAKHa5jLPzHRVsz7LIBtPZF6JeP9sdtG6nfjDs4iCYWIZGCt5n4kZ86ugJlL51pocPOV/zYRvMBrL9+o07RpShIKvizpu1sIAcvN3E6s2gIJ8A3uj6h7LUh2T6jiYK7Ca0YxLju7ab/1lHq+R9uoxlkAcNRVKC9HelqNAUHE90dK0wKxb/JO3KpQPevi9RyjxoTWVbFlbY2c9ziqyWHymM1yroqLByec/4iZANf7W6ifTVwbChenoVXGeoi1PJc0um81rQtPRCHG5g8ITozvgG5sjRyUdl3L6h7thq/aWElBzVLqqPVa4z0g3dkvadjiUhg4PXDAsnTCJ+n3JCHBko2FNarY4oPw+fAy7eEunY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ThhjvW+H7eoqlIhYGrGQpYyQYqpvon6qF32EZzfszkMbC5uQA7GHZh7tGdN2KaOT9C4M6YQ2piYOVI5Ec3vO8UuqSYINNGfWoSLc0FR60zKduPqm5S/HuKdpcJ3sNWhmCA35OaqaNEvo471aoJQQvBLCvI6/BNFEacBIzfxkhQyrweyWORFyP58SUAeFlvbg86+bI6i1WHwH7jXZa2g+Ozx2mNygOAh+qg5tGPM+9ABlvIeNpJ3kZwgXarpSVLZ5qU2QtHBoJ6WznOQAQwjV2Wp4TqdkBlu+mnBVDpB/7CN++yIEJ9RQnsN4do7MHDoNdEVytkffmTIAlIM3aMVei6hmJep8SokOJFY+Ey+VdgT0fXbhXSE2DpSly/9JG4+diVQnNZM7nQ9tbGR87PG4UbrXeG8dpaOgaJ3O2oO1mlHY/PlO9G5Vdn66t1ML8dntX/enH1I/vxqyk+LLgMJ0RnMBXLUuHsj3Xn0CjKleYKNj6j7X558T5RZ4iATDZkH1/FvR9mkEPmbrT9mXqA+7eVLAeW8ZjNeLZHcUTalcUT6l5fzrEJ5VAOvNu43DiS0Fpu0We1wC1t6L5nhalD9d1t//JZ0pjWkMmau6eUS0bhYwoVRpxJjhPcRP2mmWLkVM5FUuzZ9GokEWoPYwi0LDwrW/eNAVEPrBXqEevHawbl2ylAF6R1+MbF5Dc37ZK2IDWtBfKtaQIRheKV4LtJ5DcgQUK5ojgE2PZ+do5JxyYFO4VcQJjLUKgQIDS5lk6kjRAPp3FbkIYyJiJONe49KgM/l0CqQJJD56oagT20uthJpbBPilys+J036YZ2+QABwIdRR5UFR9o1Fgc0i0Mhjmy9X7JcdUqK20Ih0DHY+viF5I X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84e3842f-ed05-455e-8afe-08db84b221d8 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:41.1400 (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: Dpgg57G8lQZQajP6XK+kRDgdYhMsa0WQH/H0jfvdvKHn4CGpR68wITrltEY5kOJlIJYsAaLquCseOPgk/Pt+YbAisqxG04PK8LYaMs//xP8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: ea2HnslWzEd8gH7iTL1j-iNvpe66jY9c X-Proofpoint-ORIG-GUID: ea2HnslWzEd8gH7iTL1j-iNvpe66jY9c Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 5f2f943d926c..785ab2c5391f 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -93,7 +93,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, HP_SW_RETRIES, &exec_args); if (res) { - if (scsi_sense_valid(&sshdr)) + if (res > 0 && scsi_sense_valid(&sshdr)) ret = tur_done(sdev, h, &sshdr); else { sdev_printk(KERN_WARNING, sdev, @@ -134,7 +134,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, HP_SW_RETRIES, &exec_args); if (res) { - if (!scsi_sense_valid(&sshdr)) { + if (res < 0 || !scsi_sense_valid(&sshdr)) { sdev_printk(KERN_WARNING, sdev, "%s: sending start_stop_unit failed, " "no sense available\n", HP_SW_NAME); From patchwork Fri Jul 14 21:33:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314219 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 1CD39C001DE for ; Fri, 14 Jul 2023 21:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbjGNVfC (ORCPT ); Fri, 14 Jul 2023 17:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjGNVe7 (ORCPT ); Fri, 14 Jul 2023 17:34:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17ADB3593 for ; Fri, 14 Jul 2023 14:34:56 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL49xQ004095; Fri, 14 Jul 2023 21:34:47 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-03-30; bh=KmI8Y38YF//rU01w5PKjCUWggEfA6OIWeI9DBs8nPaw=; b=pr+s6NMKdKkFeq70hjd/MPz2/YkEF1mu/QfPhXTLB+Ni031Bw+0PA0IRbZ9Iz8ormW+i gbLWByp8LvIc9Gwqx0CPMIfUrJjl9TFB3oCdM/eAqUHpRj2lVL+B6voVPjuImxn8VYRo 8ePeJNj4qryGEIWvUW4Iy7voVpfx9ApFiLzefAbNKvhs+7brFPaYiw2Rb2NIc7MMjK+V 2VWgYf51DRhMLccYb5nX6aEmTcW7aOhu2k6CIMOcMvwJG/2EMTKHcmifUAIvC/DPccFf 9aiUiqB8uCSDDnelpP8KR/nW3p+l3hnvGHJ/g/xHGyIs4eTApgqnSArozzzJ9HBMfsfo cA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpth2dw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:47 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK45HM013796; Fri, 14 Jul 2023 21:34:46 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91q4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awoju5mD6xvN/Zf4vOTc+wPDE4jtApjZ6yjYYZQnbZS2n5v49NMBwBCAqtllpno6pABxyhuozQMbEsj89miujKGnt41y06S2f1eEh7MdSyZb75bSfbRkxQexRVufZv7cZ2uKzbNu6SSHYfKjcO4tPFnOHgeowcyIDGDzD5F7d3g3oxCHrcfWNjlTlhRnpKOYOjL7OxVnNvx05i8gfEvEKycILCu3MXwHu5WYrXW0EW7uhehd3ZJs/zPcCvIIEsFcTXaGMhPTiBsclB9Q05OZO4EC6ZoNyDtlJAY+X0YTpSTNvuEiQPmRbPw4CPcNKEIWzR9Cw7JuGEgR6/Zkyg6lSQ== 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=KmI8Y38YF//rU01w5PKjCUWggEfA6OIWeI9DBs8nPaw=; b=LPFxRJvQQYy0t1sgceJtQoebQXKaTE+lRGbU/oI11fDWXw9NYoMRem04EDXfOUrsDuwb185ACC0hoo10vMwnNDABfq3Z0rw32HEnQB0U96OuGaW+PvdM9lwVbdxnX3wxq9So2oYZdNFgkl4AICBfPGNYIQDt5IPFHAFRWzn5Fgv1zG5oACJYkitFBA9IU69c6TFS4EhZ2JEz6oWc/SV83+zCmmxbwUigcFm1HWvrwkFBJ+YzCAjC6fK5HVHlqs4dUTqA5LNLUDV2aFPtkxW1Gnsf9dopNPXfW4uZYGmc4OPOEo0EhhZIFGV7WLDEkU78foq5NCi+KDZC8SyplTU0qA== 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=KmI8Y38YF//rU01w5PKjCUWggEfA6OIWeI9DBs8nPaw=; b=DxWAz4nDa3ZS7a5CLtpxz4UbSV5YbJ7U+g22awMTCrM3VzfVeQcRu0XkibYv19UIkLmYBxw0+tNz1qxHkrnRgSZXVH++KI7z4jBdY4MEvZjskRZZCgQoXYVPALdr94X03X1VdBwUM+k1BOdLiHg+BNVBJB0TGJyaEuUqQjGR11k= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:43 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:43 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 12/33] scsi: hp_sw: Have scsi-ml retry scsi_exec_req errors Date: Fri, 14 Jul 2023 16:33:58 -0500 Message-Id: <20230714213419.95492-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0020.namprd08.prod.outlook.com (2603:10b6:5:80::33) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: d668b71b-91ad-46ae-e952-08db84b222d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9UPBimO4O02Wl1Mf+f/71DSD1EVCUIJNI9QUrgEnuhoXoHgedU0QHALiIkiBbC/Y5/y96JlIvwfMe5uL5CTHuLcJdcHHVOVJX24KXrVWPp/a4ELlIboEUtgdzlgm7LKtHeM9aa8EaWe0heHN3eqOgle8g+tUKLXwYnys8n558sgyhf+M/37WS1JoOHcnzXk8YJbVCBIdZE3bqFbMA8kVJ8jWfgtJC+lIY1I4RFBEt2LZOo++H8I15TE96glFgbRZHcJxu3P3nR79J9W0WFSreQy0KmKawyzs5F1AXybML608Tjw9tWhffYEd9doN7DSJU/R2AzY9bK5WNQx2hL4Dv/5fyz3gpzCHl33KodrVRCzO/Otlok9gQ73kX5yFt+2HmCUbThUhDX2y327dnqBU2o/LwyJf9arZykIQ9zF+uPUMpxvn+s7DvaSiZpk44XuFddoHFlDxVzJ3yM9Rk1+OTa7EXHhUL94AbgrhlC8QVbc7I7ICF8MnpqoYrYteMLrG3wyW71+TqBN/bwyjYgl9up7cyfQOwe5rFseoIRcZSjfALJHCF9qO95tapWMX2H9h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WDOeGZHV4D2vGABn2UwugGgcxJonjsxQYKaIK2rSFdjf9TC6OPEZyJbspUISQt79EKKjtDO4x3/qpJpzpvBodOuPrnnBuCIRSzyBtNQokbrLf5esnCRD/78Oq1LlVlpBhg2UaM6DcrcjnQPruzJYt2i3cDFq6UqYQ68SM6PouvbagPoj0l32B89H2cdhI00J5SaQ8i896tV5sAiHZcO6uNZlQWf1cARAsHceInj9zaqvf+HUg3w5uUqvCOyP/p3CIyi1CMmkbL5UOZ4tNBmtSuoaJjyXXrOEbu2evtoX2Poj78iHknSnaI5HDOKHadsLWVvQsaDkUwJNhP0ZkmIM2x7Hqcn6/IVZ3xZbh/SfaVTIdujnBJX4EepGyoYJfNP28lbACn8xQi7lhWnUJUxQeQps8+Lzk18byp+tj66RZhyGBxcYDycJJt/KCsAkN/pmDdBqy4tPato0HJgT1J/IWtKja75jyOhiKnRv0sFJUr/TQNWmXaIBB4ail3WWVSW+dGpL7qdzzxYlBjVlT/jiZU/M8GcASYiQIpWvMa5iNUhloeckjGVsWaXi+vhj51cj5G9gYQsoEx6KY/c4dTflbJ9BgZkpX4qjGZWYE3f8DL/6IEke91kkdGXP2DJblr7ivZyr14ULIrV2Sbkhnhmd3XaofKMi7qOpQv7rE1xdXshlTgpCEYk+yUbi2+ywtdye4Y8KGQ2sr0s8tG6+VvcY+dxeJwqG7n2Jq5IagdzGK5rM9Hfr3XXVS/g+ojTwjhuic05B/XyyVe/WolyjyI6/nFRmc2srztWSeVOTyL5w2SWblgdaRRDs6+/5vlcoXK/OuKZxy1xCfyMCxitH4z+t20rXLoakmavAkxShXOIKdlP5HsRn5FnmmUHeVpYZpaRMoekVYrPR5GBI4f2kTpHj7Mzj3FYiYDqlcOIkKQ5tek3Gcwu5+wZbtO9MvmorT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uK415Q7CIMl3r0DbjQfNo22C5PfJPoQzModQ2fT+HiDeZWJMEBOGypE+pcMJBi/9p07nLoUD3l5LCIcnCnKGdn+GPf4m6BWNHGBGgyIIOHKS7kLiHS62n+EL/11puXJE6xN+PYpv/PRPw7ttUHzUR//QPov8gJYXq5IRxoUvgurz5ja7nXmakTnyYZ0XLH4s9WoSRioCIavQ1TBGHUYuXLDLTdWxAdtqMzMyDGHUTQoVphq4OmHmKsnpE9xRILZfmJ0fmewAGIkQWqA+ePOOv3oXChzcEMeVlelIm3bo9ZFQxcMukHjx33jKlaGoTbKPVlc+3J++7NJMbj3qLz2nceVSLtfCyybR5MkZQaJ7nCWBR1dvPt0lV40P/SOCBy5ovHI/xyjxNJLdnmHGxnBtulKBvXqFHAunLQijkZ7e1SjxUueGlaN5m3KaZXLIWvqk6rgMEYZvoqNFAKqyJN/OkyVu1fKxg8fxmGI+QWjcqLiRi2PEiz6ZmQ+1YYWPojEGLaTXvkyBcrO0Uu3bg+Qnk6mtE5svsmN5Q13XTjY+tMkcHY4QQGU80 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d668b71b-91ad-46ae-e952-08db84b222d2 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:42.7642 (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: 3YJHI92pzoYZe25uUj0sk+TeVQbTTb1I7b1QeiSofmvJN7MWVk+ELPfE8C2VsK/RN4+KWVVp6cZ/mTtg2phKGt2pBs1mUNoT3RE1xLJTAIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: IgH9UkLCu4hd5IoraWaHsKfcUBwu7StM X-Proofpoint-ORIG-GUID: IgH9UkLCu4hd5IoraWaHsKfcUBwu7StM Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has hp_sw have scsi-ml retry scsi_exec_req errors instead of driving them itself. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 42 +++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 785ab2c5391f..e25161aa7b77 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -46,9 +46,6 @@ static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h, int ret = SCSI_DH_IO; switch (sshdr->sense_key) { - case UNIT_ATTENTION: - ret = SCSI_DH_IMM_RETRY; - break; case NOT_READY: if (sshdr->asc == 0x04 && sshdr->ascq == 2) { /* @@ -85,11 +82,21 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) int ret = SCSI_DH_OK, res; blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = SCMD_FAILURE_NO_LIMIT, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; -retry: res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, HP_SW_RETRIES, &exec_args); if (res) { @@ -105,8 +112,6 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) h->path_state = HP_SW_PATH_ACTIVE; ret = SCSI_DH_OK; } - if (ret == SCSI_DH_IMM_RETRY) - goto retry; return ret; } @@ -123,14 +128,28 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) struct scsi_sense_hdr sshdr; struct scsi_device *sdev = h->sdev; int res, rc = SCSI_DH_OK; - int retry_cnt = HP_SW_RETRIES; blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; + struct scsi_failure failures[] = { + { + /* + * LUN not ready - manual intervention required + * + * Switch-over in progress, retry. + */ + .sense = NOT_READY, + .asc = 0x04, + .ascq = 0x03, + .allowed = HP_SW_RETRIES, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; -retry: res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, HP_SW_RETRIES, &exec_args); if (res) { @@ -143,13 +162,6 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) switch (sshdr.sense_key) { case NOT_READY: if (sshdr.asc == 0x04 && sshdr.ascq == 3) { - /* - * LUN not ready - manual intervention required - * - * Switch-over in progress, retry. - */ - if (--retry_cnt) - goto retry; rc = SCSI_DH_RETRY; break; } From patchwork Fri Jul 14 21:33:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314218 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 CA4D1EB64DC for ; Fri, 14 Jul 2023 21:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229584AbjGNVfB (ORCPT ); Fri, 14 Jul 2023 17:35:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbjGNVe7 (ORCPT ); Fri, 14 Jul 2023 17:34:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965E43586 for ; Fri, 14 Jul 2023 14:34:56 -0700 (PDT) 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 36EL4UYa005192; Fri, 14 Jul 2023 21:34:50 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-03-30; bh=OGDOzxotRQrQtlmfpOl5xsft5tbEQR0IyjIeqYnTkzg=; b=YtB+DpuHEP1lKVSRTskFyZHtppHDePHbZdA/cDNlYt12woDCfKNSZGITqQHTeuD3y2vz 1F5E98t5cjxt0iLzQOXck3YXWWM7M6wDRKxm01qlWHBsXd9ID26FwyXWDxDos1QCIlIo Jcn9DeDKjnYCEAShvvWBG7kYcFo+YrOyU2/850Xc9AE1gR8/lonfLIwwi32WdvAS/Eal WH4G4F4zq4ex5pKO9M3TCxIQrAGDXeAlbCEdLAmGMLBxap5fKYKQC3mbS5suRLbN+X51 YswtuPYAXFjNHKpLQ2FevftCaft71T+oQ/pj4FcBnSbbQbczRN01QExnhIS6xJktuQVA Fg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptn2d0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:49 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK6HF1027202; Fri, 14 Jul 2023 21:34:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvyh6t4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lv/tAnxx3v9dTfK8ouBsCZsBePBcrRtBwlZEgocL/2PGFnsf3/5GLtF9O3bWQ4a1qb7ojOn3GctUHMuzH8BMDFrCshRuNMa+vnqi54ALq4H3KYDueKi70obXM6SeUcnkvmcX25/BhQs7XmQoJw2woPsW1DHyOw06mxBVzn/o4Acqvv3KXK+6i/7rvsMuskUNESkihEUPS06IzsGxSUh7kR/LjIN0h7zDkjtFCpguZMaZChgrkdLU9LoSFkMUJ5p4h6rTcxCuvlUXKrIcGWgtmyJcS06ANos++3RwI18xMhuga632Y6syfzJHFFBYLnUTHW1ogzlwiyyczAxhW0QwWQ== 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=OGDOzxotRQrQtlmfpOl5xsft5tbEQR0IyjIeqYnTkzg=; b=P+N2mJpsblsevlTtJIyXj0tJCY6P/ItulaKXSuFdhJwudOZTHp8q/1iA2vEKSboPByuQJ1Kmx540+odvBfsnINvLw80w8/BTxjMifxQ1D2+vaiX5VRXRqCTmhvYi4MFWf5RtYrRJEPSQxkEUkPcvScXSaaQNEI2DmU2PUjJfnlJl368IRY0PXgN2LEXTY9h+YfV596G/9N1n9kFhA3SvautGttVQtFm96/KM4SlnQSidNSZ+B1KpNfIKwg2rHN+xMuL/yh6A6N0Q96htLSqdIbIAYfOolsW07O2bLIq3aZFEd/9kW+YahSUdEmjRHFuU+La2qownFv7Bka4jbesXog== 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=OGDOzxotRQrQtlmfpOl5xsft5tbEQR0IyjIeqYnTkzg=; b=l228RO9OR2Qx0fIDcxIT/vlgR1eM4225f9cEk9m/JqGnDu8jV7ck3Jsj/B522Nk/GQKpNK/FzAnlbDOWqWLTgCr1s9e674Ki5zBAmGf3739rFI9gR0CR3Xbeqtjlumwx0jO7fEfo4maicG7b2hvLhGOZUZ6RlDkILnnFsMJVDpQ= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:44 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:44 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 13/33] scsi: rdac: Fix sshdr use Date: Fri, 14 Jul 2023 16:33:59 -0500 Message-Id: <20230714213419.95492-14-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR08CA0034.namprd08.prod.outlook.com (2603:10b6:5:80::47) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: f6cbf681-d008-447a-95e4-08db84b223fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zZ6evMETkANPK8Az9iuFvZi99qDFrHAbHrhCDYzPHCvHm7u/HylOCHVE7vDZopLfrzCQsvHXzCU+YpfEyTneZ0sN3u9CX1e98gHwRzxrowjGOwuBxKe12aca+/xHojyxpGMKYLFMlmD6/03XDHDxSyOgZe3QhBiZIsABQdVud30DtyMVbzwXHTKyHBmjKEKBqzZBi3Ir57J1jin++iiMp48R4qA3NW0jL6SJ7n3wk0Stl7U7lUCZ48rX5wUiGtEojuVkD9WGSplFoTcnswW/DP6bzcrKhHL8gAuAZZiG2ZwqhqL6+ksLfbq9Q0KqgRSnCRrNAKKPOB2yA0ZjW2zK0YSVzG/0xo71DTXXzqJz1jzRmnSLDDIBKIHbMHNNya0uIghsi7Fcjic6+GCsyMuWms0Iko9Vb1ILv+GkzM8O98+DLFxuGmGuKehiGcbmSuTuWA/LIY2wJoUnWZE+hX8IERAaR9BgHHjX3C+Ek5kfqKIHt4d6XAZEbVziD1UVIOkCJIwUfcRzjsfhXVccz/fm9Fs48GByd16MHHuWD3Xwkb3TYooRwyFMWPKom+K1nq3E X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O5UvarQadRwv7gdMbFWyf7B4vChvXbHlPeJXGvYSscfK/lnXEkh2mLDie+kCzx6W4AwL9cqvhHkoqJqV+wmCXZCVjSoOt5uyyz6Zrxishm06JRdnOv+N8SWH1ehJICnIH2W8vJYGwxmC579DmucjUFbiHqFNv92nyD3e1XNe6zxbrx/stTL1TIiLzHJtL/N1A3AZ4EvmDQ6BAo9oJ/XO7b29IZWzPxeLeCGdEX+ycBerSPkjadcBU/PKnvAiH5tzjqTUuiiVIRnWxf4b1Rhjwg8YHWV3G7c101LfSL4dtIggFF2vuc/hR17FGuXb2f+0dUGK4F/d8A2zWB/M9Qt3syz+sdbhlDk9raY+m+5q/Hk1tnTChY9Cfk/9unEqLY6Gc8IaGSewKKvOsbL3oE0yxKrYt0/Ves69RyQJAEY4wY7ZN3n4T/HYxlrkriB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ZFcKAlnc2UcgCqODeTXing2HNEYGubOvPtlfZtYKg+X2xhZxxivboOC2UufN6PPKO86MnjKO5TNYbnk1ur+f6cbxgp70zEXNIQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: t7FCqVrdqkHSZ3wQIvDJviPXZ5pCICBedeF0awsYoaRnAKvNmo+vKcucTCfO4lJf1DoafpRg0rzoZreH27p0160gs3cnRq6+qg4FrjKRaBQaQJtcypmIzwd+6HXaoRx16xwoTPnnAYeTdrqtzjT/fqkLFijX3nVOD7NkvcQt7PihRTT5eu04WxSG5eKdZ9zy+upwgQ8aRWrtjUZm1weCV6VHkaMJMg9st4740GkhJ0zPqHhar+LPvxwjKEvb1JOrePu3CKWINutobPsZGiyms79SB5L0Ed+htY8H3BtLDhC+6rW9m7Zm3Jp+uzN/ODQA+eKrZH+qa6DQTExIRARvp2rbV/PaJclYpEWg3vknQsooxRr1rbFwq57vOH6PnPnMdvw1JDjPjX3Hen7dXh0SMbPdIP+WStN97ynSs02d++vvPcjx2u2Kvurj7sa2RTtPl30kG8isdwZlII9h7aDXh6+W1+KNdS787ko7EeocSkUTIuBqOmz/1a139Mk6IopI1YGXq36vKYUjDHBwvDIkn0+ZqGlr+OFR7UlfuBffeVYWQ+aUsvJYFiIuXDM5fU/x2eoCNOiJAfJTa7tYB9wuJKnm2+qq2DU4fTv8aGpRRgP70rcsGsz7pxYwrExspFSXxjf6UyanjMOGqWlBnXYJz+bwKz1F49NqlR7s8ixQ71wAziR5uhlxhYrwfIYpsQOCmf8oH88AYeekoRdEF1DjwCoyyi1CdKADmVg6xhtzTsvAnkgFJz83f4LrRVpveagyFM39Hn5tPkS9jCVcKqsGzlrVuzi1shE3q44M6prC6Fjb8sfTLRumeLIBTC0JhWimBDRb03FsA2IzVxoXMEvSmOEDHstmIkuy9jMsuVQywVCkICILz4utrGXYQimVZvNa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6cbf681-d008-447a-95e4-08db84b223fa X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:44.6959 (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: Wv6l1wViIMx0f7+Ue+V+yIVRtA4jQxQm1Q06V+g+gQrBGhrPC2/Qjz7yYtMO5BjeBwlsmjyEQZmacDS2xA7jTzz+9LSz8tvW7Eat3k2d7ws= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: Unoujl9UZxUz-MWLeVVenoGnrUXkye0M X-Proofpoint-GUID: Unoujl9UZxUz-MWLeVVenoGnrUXkye0M Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/device_handler/scsi_dh_rdac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index c5538645057a..cdefaa9f614e 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -541,6 +541,7 @@ static void send_mode_select(struct work_struct *work) const struct scsi_exec_args exec_args = { .sshdr = &sshdr, }; + int rc; spin_lock(&ctlr->ms_lock); list_splice_init(&ctlr->ms_head, &list); @@ -558,14 +559,18 @@ static void send_mode_select(struct work_struct *work) (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); - if (scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, - RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args)) { + rc = scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, + RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args); + if (rc < 0) { + err = SCSI_DH_IO; + } else if (rc > 0) { err = mode_select_handle_sense(sdev, &sshdr); if (err == SCSI_DH_RETRY && retry_cnt--) goto retry; if (err == SCSI_DH_IMM_RETRY) goto retry; } + if (err == SCSI_DH_OK) { h->state = RDAC_STATE_ACTIVE; RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " From patchwork Fri Jul 14 21:34:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314235 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 9C796EB64DC for ; Fri, 14 Jul 2023 21:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjGNViN (ORCPT ); Fri, 14 Jul 2023 17:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjGNViK (ORCPT ); Fri, 14 Jul 2023 17:38:10 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C93BC3AA7 for ; Fri, 14 Jul 2023 14:37:57 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4Exb003082; Fri, 14 Jul 2023 21:34:50 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-03-30; bh=2CLbWCOE6iwWCbt5W7HlXokz+ovF05gLH2P7Z0Ly8ro=; b=JwatEcWu5MlhuZorPGJLZhtMzpzMUlmt6JUjzSlhwx1SHv7erWBHRi6insLK2vZmeY2i aklFH5b5k1oCVznmwNGT2Ftne3V6E/CDWnlYpeb2Kakcaj68EDkB01TK0GAPPTP3so8m CQ8xlHmtXwmZ1o2xRLoiY8w7qPzI2T+kbXePbzX4GYUMzVa3YCnlRaQMWzJszv/INito sBzVD37ixdTa8qDpmC9i2SpEZ2FOyENux7i2e8LFshC2glzMp2uDadSu/S/ETBDoflly KByoNbbZQ/blhHrBC5IXlwDjywoRFCcqNT+jvEOpvb3PplgNikErvhMCzZAFoijK1baE +w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9uj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:49 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK6HF2027202; Fri, 14 Jul 2023 21:34:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvyh6t4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V68VVeqSok+nsFy8mMANHLl/+EURNZekSxQNJprzv+yhwdevnVM7Xv3xfjn9HYXEty49D8qms/fQDMRDDUKW8EsLIdLOwtUJ2sMguTdvxd8WssOnY6ewbk6AXu7V7txKtZ9m8u3pmrKdDxLBuruH4fDWbMN09qx6aZtz1yxNPBkv0KaUoyi9t81Q8iRgYCHHlDdVsXL1KJak7yKUXc8N/aLq2c+VLVvmMSgNMWg+TBtfVrgr6R1otamUIgzVLvQQ5R6PjqE/K2BeRh3ZHjWiluVbSLDnYi6v8Kxz3EVn1Y+3pTvbecK3AVrkwU4IYNSeL/xTYDo8BY3M6j3IjXDaVw== 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=2CLbWCOE6iwWCbt5W7HlXokz+ovF05gLH2P7Z0Ly8ro=; b=nV2rtYPvvQYuXeebb/UBQl2ZTAWLbxfDE0K5SAXlriRktwzZvTfMqeWMfLeDhmjHj3FD+Rvh47L21VffzyRecyIPWNBsvmTXOvsvKCIa/PAXU6jg66OUYMXwOUQbzjSmQE11dipBGD2LoM0Dq/IM8Q6LNmu9S63gXUMLLpIaJEmBXTJIQ19BCNK1vNAmM75dXhPM43C2xFcKpq93kNY+2RUh7n05RA3EJ0fZBkg/xz+26+gZTxgcSpcwbrqu/xiLXMSxW038TB1A2wV/aqmqEkwlOPai5YOCyq2d3NIECCZKgXS9AUJmiYTHu+mU1cKYn/zoV5ARNwYgJYSRgqOf5A== 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=2CLbWCOE6iwWCbt5W7HlXokz+ovF05gLH2P7Z0Ly8ro=; b=l1GZEzGfFDPfmz1bneJPwTyKilfHApD4C9YypIYZK2qcA66hdKs+x3V+sz5ifoD8Xdk2OALnvYKpU3K8o+TxuuQEIYIvdP92+sRVRFXaxOAHqwBORR/v01YHm4UvDxaVJr4Me6rsIvTgQntlNGtDgBLqlptKwSeFQK4m1SSImjU= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:47 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:47 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 14/33] scsi: rdac: Have scsi-ml retry send_mode_select errors Date: Fri, 14 Jul 2023 16:34:00 -0500 Message-Id: <20230714213419.95492-15-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR01CA0005.prod.exchangelabs.com (2603:10b6:5:296::10) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 7664affd-446c-477d-1a78-08db84b2253a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4YmhbVSosY2fvCkcrIKOhrh+DZSncgT5dLByRj+L/zubTCgkxldBckZKTkqr5XGj4QWRoMSsrnRVrQGWrgGJcN4omF8AHyMuM1cDib27yU6Z8el9FNEuxa5bwoBBwvIu1tAgaJV7F7OWjalvLxQj18oqowwtXnbR0hase3YpkU1a4ixUVqrlVfqSZ0S5GFirgUw+ihs2I3bUBHHrFYivik4aRAQInZ96nDVM1KbpCfB2l2qTgGOedCxYA1DgrYVvqX4Mk6tVsBD7246Y8D7AZUJR0rv37HWwP9O30oYq8iYUGzHzrN4hzObBnh+kjn1TzRzM8AdGOAULEaDyDXDLY2ODzfVizGflMiRTZlqme9t1NxLOambK9uvumqLdJWiH/xxHcNf867yeuBsm5SBoeP4smiip+NA/IARB3RNP1QpVDosA8BRxFZS9m0o8gJ+3J1UMGi2WS4JXUhL3h9sgTG3nEN/hDYj9kvsw4RVWuZ/6yEJ8QjVcj3P6pSyS+7XK+ubzOB4aG5Y88w8We5s7b1bV5rNsMJYKxbBrbQYwTnp7z7Zjkw580sh4XdS9WykY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1/6fZ/bbZ5NTb8eO957KWR7u4sEl5+QymPG75YWWbQn4UOd9oHOGzRb9lgp7V8YjSW00299T2d2qJATO3M1/nQySIYg1JCJKxOwIcc4NTXe+/0GL4CoggaB9JYH5Gyx/PhXX1ODmbo/zqIBZeOEYfOGzexhYOjzVT73MWpkruxfcltohmmxMXkoGox79OBjIf0flqWnyQh+REaHgA5KgfrMpc0Z29yv/DnxADj3eFMv2//KAh6tlhuY6eMyCG0GLXFxzn0YTKd0gwLPqhscEa+P3MOrlfElZ76JCDqU+YONC/70aw1opn6FAd54F2y54U3p7fb3b1h11FB2CFROKFO5Aac8XmapQBbISiqgf1q04hKichHzqwxmHVR3SJeblrq/tg7e0DPMxexve+ajJ8x1J/GLkdGX+INE2qlLVHNET2d9WbysXdEcyzAdNZ0WMb2oTSgW/v87y8gl34PxAXpDrnYgPWDQDAAh9JGGU4DDRH/gdEHqqguueYbXjj6NX3bExAURfnwI/7Tg1hiYP2PV81lTOvpFspVtZsq72bB5pg3t1iQeBU0ei7PWsVXrRa7YyVQYL9CTCMXAlwV9TjVnWRsloYcHOsZLutiywCAM2vOWlJtyEsleYAH4OQ1jwPZrlTvXHwIRqf5OprVR0ot7qNZmPp2bZMAE7K4bYY+JY/I8p9kL/BCAK1VeS93O6417E9x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aaZneW05HPFHPuswAR4Aw7uxtRqDmjCgYkBNJU/6/74ej1N7kzsna5upFuzPWRmZ8obAR/5Kxj31yes4Kz82pXNy2T2RiA9aloW6OCx70oap1tavWasRtAl/5amM91o75kQLEimkyWW1G9fnPdoVPRnMXWfQhJcnzQyLGzRqq3Iplrde1rBmGQEqc9kjA74xmJMuvvwLL40IL/fGeBPF0tdemiNiEdj7NnCu15FuQ4E8+09X9AtkhqX6JtsXLtUWVG8VEVNfP6Z25ZtM9ORuXwpRPiA1mM2uR5vEOJHRbzv2DswkuHAv1spHdWLIqKTZ5LZtzqc+ymWWODUUPj+qZhKzOWWcDjdLTTn7GdXUqeJ8sWTJdkqdhRCJPMg4R1NN7VR7RoWvgdUe+txulPK1lWgtSXZpWgMH1LWS4P97kDR2sbyZlHZ1F6DITM+VzN9guV5zDrkurxytAdkyFe8wCdbivc52P09qHrFV04+xjwFF/t5L4LZBmUUznW+3cjvlf56CNacF1XIw5P1mAfcueqRdOf/H49ptJRZYYH/AUOyEEKHc+UGjTu3jz5lah9u8p3FF1GAT9cDWtGlV582nLm4LpTG7Y0BZWta2zBXzoHel2qseNdKBJ9TEABtuWG3bhHWF7PNcKQf9r0uOr6HgTKcBKOPeROX69JgCJQhNAAPa5htGbjLBecHiRzJbTDmLLKHAee1uxjn3/2gVrHeBYE9Mt2qr9jVGJDbsVju5d7hX8hAD/MLtaGBQvShJp6Sm2qFASqU4j+p6L61dFLbymTZT/MEc7JTE5l X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7664affd-446c-477d-1a78-08db84b2253a X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:46.8433 (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: kzT3oW4YK7dfdLefyrxufAlSY+0Xie1lsWWr7qXJP5UnnsvZ+Jv0CfT9GtgAAuFyqQilOeTpl3706XuJLkWotkaslFNymnWel8azVV+7Hcg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: tzXmrp3MShIInK_JtSIH-iTeD56bBz9L X-Proofpoint-ORIG-GUID: tzXmrp3MShIInK_JtSIH-iTeD56bBz9L Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has rdac have scsi-ml retry errors instead of driving them itself. There is one behavior change with this patch. We used to get a total of 5 retries for errors mode_select_handle_sense returned SCSI_DH_RETRY. We now get 5 retries for each failure. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/device_handler/scsi_dh_rdac.c | 92 ++++++++++++---------- 1 file changed, 51 insertions(+), 41 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index cdefaa9f614e..1db217be4db4 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -485,43 +485,17 @@ static int set_mode_select(struct scsi_device *sdev, struct rdac_dh_data *h) static int mode_select_handle_sense(struct scsi_device *sdev, struct scsi_sense_hdr *sense_hdr) { - int err = SCSI_DH_IO; struct rdac_dh_data *h = sdev->handler_data; if (!scsi_sense_valid(sense_hdr)) - goto done; - - switch (sense_hdr->sense_key) { - case NO_SENSE: - case ABORTED_COMMAND: - case UNIT_ATTENTION: - err = SCSI_DH_RETRY; - break; - case NOT_READY: - if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01) - /* LUN Not Ready and is in the Process of Becoming - * Ready - */ - err = SCSI_DH_RETRY; - break; - case ILLEGAL_REQUEST: - if (sense_hdr->asc == 0x91 && sense_hdr->ascq == 0x36) - /* - * Command Lock contention - */ - err = SCSI_DH_IMM_RETRY; - break; - default: - break; - } + return SCSI_DH_IO; RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " "MODE_SELECT returned with sense %02x/%02x/%02x", (char *) h->ctlr->array_name, h->ctlr->index, sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq); -done: - return err; + return SCSI_DH_IO; } static void send_mode_select(struct work_struct *work) @@ -530,7 +504,7 @@ static void send_mode_select(struct work_struct *work) container_of(work, struct rdac_controller, ms_work); struct scsi_device *sdev = ctlr->ms_sdev; struct rdac_dh_data *h = sdev->handler_data; - int err = SCSI_DH_OK, retry_cnt = RDAC_RETRY_COUNT; + int err = SCSI_DH_OK; struct rdac_queue_data *tmp, *qdata; LIST_HEAD(list); unsigned char cdb[MAX_COMMAND_SIZE]; @@ -538,8 +512,52 @@ static void send_mode_select(struct work_struct *work) unsigned int data_size; blk_opf_t opf = REQ_OP_DRV_OUT | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; + struct scsi_failure failures[] = { + { + .sense = NO_SENSE, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = RDAC_RETRY_COUNT, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = ABORTED_COMMAND, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = RDAC_RETRY_COUNT, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = RDAC_RETRY_COUNT, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + /* + * LUN Not Ready and is in the Process of Becoming + * Ready + */ + .sense = NOT_READY, + .asc = 0x04, + .ascq = 0x01, + .allowed = RDAC_RETRY_COUNT, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + /* Command Lock contention */ + .sense = ILLEGAL_REQUEST, + .asc = 0x91, + .ascq = 0x36, + .allowed = SCMD_FAILURE_NO_LIMIT, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; int rc; @@ -549,27 +567,19 @@ static void send_mode_select(struct work_struct *work) ctlr->ms_sdev = NULL; spin_unlock(&ctlr->ms_lock); - retry: memset(cdb, 0, sizeof(cdb)); data_size = rdac_failover_get(ctlr, &list, cdb); - RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " - "%s MODE_SELECT command", - (char *) h->ctlr->array_name, h->ctlr->index, - (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); + RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, MODE_SELECT command", + (char *)h->ctlr->array_name, h->ctlr->index); rc = scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args); - if (rc < 0) { + if (rc < 0) err = SCSI_DH_IO; - } else if (rc > 0) { + else if (rc > 0) err = mode_select_handle_sense(sdev, &sshdr); - if (err == SCSI_DH_RETRY && retry_cnt--) - goto retry; - if (err == SCSI_DH_IMM_RETRY) - goto retry; - } if (err == SCSI_DH_OK) { h->state = RDAC_STATE_ACTIVE; From patchwork Fri Jul 14 21:34:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314236 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 75874C001DE for ; Fri, 14 Jul 2023 21:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbjGNViO (ORCPT ); Fri, 14 Jul 2023 17:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbjGNViK (ORCPT ); Fri, 14 Jul 2023 17:38:10 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D0843AAB for ; Fri, 14 Jul 2023 14:37:59 -0700 (PDT) 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 36EL4A4v004674; Fri, 14 Jul 2023 21:34:52 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-03-30; bh=fbUZGGzHLP/Gms+L5XHc/EadHFm53cAHpcjH7HxQ0f4=; b=evbEyLjXc7p58ej2zp/UH0es07ewpBEeVmAoECpMRs8Flee4vcEVRxmodVsvd0IO9KKn O84/ImR7l20Fd8aM8jcCVUweTS9z+vUVIoRbzKbNvtgBoTPutuqpQCxU6FHXPeq3wExW pjmcQTsh859D9r1psLCKqh0h1jUydENbJOYjv377TJOJecfDXJVrArtRglJMmkpucNxO XUayJCD+Wg8z2xMvlfdzGBPuKh+2jboiMnB94b+4NT4aPIUVtvWuPCAIUrzk3ME3Xu1f kHS4jVdq4nwD7Q5oL+gSbfhJ1R/pCFdV05GRCAJv6SyJmgCer01UOqLo23snrTNcgV1m Kw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptn2d0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:52 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK3hSk007714; Fri, 14 Jul 2023 21:34:51 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrvv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TOpM3t4bAU1WkAu32ilVbz2vDRUtBiGoXdrI0/VCukWP7RQV79s9IsqDMv6Pz/pCCGE/LFJwfLeGG2hs6K8YzJWiD0NVLoICVt8Ur2Do+kBhKyYSY7ZT4tKWQlLHXqSlfNpE4W3oirXNL5/ge/0MxYFEYV98urLwHnnepeIhqAIT/lNTMYhOUbv3HGMvmJY8BfER0Rund96qa82dcRstd5XwWy6FTiKggoWCWRFbHT0Lboplc9Xg6H7E3B9ZeMpH8zb8qVGloSEZC3qOz1wtmuobcnjkl/qwTgTeUsQtJKeNRx+USN9KHRouvUlXqzLROqFQIipebg1wW/u4rQb+Qw== 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=fbUZGGzHLP/Gms+L5XHc/EadHFm53cAHpcjH7HxQ0f4=; b=V2sp6sLSelOGTYXjauzkl73ZDehB8dGHTzUEeTP9MQzmKG/b/BHmaQx8zD6DRzX5A/EPUdVEJK575IAOeRnUJmHr4f0o5gYbMRM94X0bOMIA/Fegy0ZGNdJaSlX3wJ38ME0XQKjq052OqIySrZQl7/JN6P0Z+8LVBAu388v3vdoalNEUnUZCv20LZ6AkYDKbMg0au0hm+1XpjzJMCATcHL9I5QTBeK+O9YD224gnKrx1xdmuHRJMy2qAyrcjxMQluUs+ZVPzUDxoCWomknr1L2+Rr/vksNdh5sHbCO+xezRVf6XUIWAHJzmRd1yn1M4XlkpoIO3XXKoOuG7BEbraYw== 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=fbUZGGzHLP/Gms+L5XHc/EadHFm53cAHpcjH7HxQ0f4=; b=FYbf9jyds32070LEo5UdFRr2kMolznWIcWf2xBauCL/0JTWGLJDWwPJUntxME9GMklPJF3+nBNZeXYQwDeEbNjuCXYNZU1yreKjqU8yNGKwoALmoPIbz8PWXtdftWpytkX4pM1yKdS4LMGXo1CAlQCzZIMMzuJTpuZNiNzorQig= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:48 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:48 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 15/33] scsi: spi: Fix sshdr use Date: Fri, 14 Jul 2023 16:34:01 -0500 Message-Id: <20230714213419.95492-16-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR05CA0093.namprd05.prod.outlook.com (2603:10b6:8:56::17) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 603c8ad6-0da3-46c2-3d4d-08db84b22658 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dmPTsilICzS2JfpDB/uk+QMyGIlOlMIhUtprBJdmtEaZubFBenKUB1e5IOZM6QO8t/ilHSUOIgxHG2XjTcGJBkIyNYgyLr3jDWups2MFv5XbX3rS9bf2lv1H8U9eLI0GbUqobqPowNIulvmjk4i6LZOqqoeuLlKmsKVWQ7E5g4LojfGQcFJ4pwHO8/X1rP0KQZx3Ycdl9rYp5Rt27mqnSfOYPW9fqv1rWMdAbKCnqtmzmQTZGwEGXHFKokwlEndSYOPnqnDxqFMZ0WgEzDkeUIj5mnY7v+Rw44zmVrm2tT0b1E1q5dje14l9xYKIc2T9m3fJwOIom1IdGA+mvDx3+IOVh0YjFZC1FoKf+2Qe/Q/ZvbggiO6BGOdpM1tQiZROupfdfYPTYiBEZ+RiZdTWfrPvvPlMGyL0biVmkVBQyqkTp8gr5E9xmfDp91ocLmbkxnL3wKeQzei9cFXFoysxFPx/Iq19KXgJoJmN45AF16FUJbKy01CeI8tTIsCADHP9oTBEPPwuRX8aJD5sGlnrdpkoberwJxfouCrRL6KvcMVhU5XSJqVMJmiZ9aZTu5B8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vY0bwmsxMVOcp4dxVdbOMqtwlEyz2C20TZ/fDCvKb4txo82RMSMRuFD4+ULwk+p/wwtIgRGpDhu6SurhFzJ4TpjQaMqPUHRIP4CByx3apCpXKZaQIOjsUYNfn+GmxgY1iwNzT/QlIRfLG1IBeqdme6vdYoJYNZjZivZ4nzf1MQYhd2ycOHMyBNP587U8H7NzqRecdFkjG8FOE7v/ZFl+1kG9sdLgLx49ashnU6klXVBfdGJuT2N2mjhHgrfIWUdJBK82MYrjxdHGZ4J9g7MeMAvMY62pWBHmLYKugvJvJTsBCRaSog7E06pDRIZhGO7FWrfomWFYLvcCyc7SCi2bkXQzhR3IhRJlSw6Znx36lxtrygzgED8huEZLDWduWyLNs/vfrxB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1j0FLQC0Mm1LIQgMLry5JhzqRT1EpZaKBmi2oNi7u0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 603c8ad6-0da3-46c2-3d4d-08db84b22658 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:48.6595 (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: XL5yLL89gprluZRQEFw/rqdsEaNPF5rB/CEUzVk7wLwCuTgjGK4nXX9WhsfPl+n5sBAHwfeIBL9Dm/FopvRDYM1Tf+XY8gRxuexjo32e93w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 5pg73nyV3bNplGc4bD15jzQ5Fd57SYUp X-Proofpoint-GUID: 5pg73nyV3bNplGc4bD15jzQ5Fd57SYUp Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/scsi_transport_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 2442d4d2e3f3..f668c1c0a98f 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -676,10 +676,10 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, for (r = 0; r < retries; r++) { result = spi_execute(sdev, spi_write_buffer, REQ_OP_DRV_OUT, buffer, len, &sshdr); - if(result || !scsi_device_online(sdev)) { + if (result || !scsi_device_online(sdev)) { scsi_device_set_state(sdev, SDEV_QUIESCE); - if (scsi_sense_valid(&sshdr) + if (result > 0 && scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST /* INVALID FIELD IN CDB */ && sshdr.asc == 0x24 && sshdr.ascq == 0x00) From patchwork Fri Jul 14 21:34:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314220 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 114DDEB64DC for ; Fri, 14 Jul 2023 21:35:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbjGNVfE (ORCPT ); Fri, 14 Jul 2023 17:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjGNVfB (ORCPT ); Fri, 14 Jul 2023 17:35:01 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215273588 for ; Fri, 14 Jul 2023 14:35:00 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4E8C003214; Fri, 14 Jul 2023 21:34:52 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-03-30; bh=/sZ9717gUsbKAIbR6r5pw5kBb//q+6sjoyz/512Cl5s=; b=M+5dVpI8ePccNdGeKLlEXvhxNWHkopiYDt3FdcCJ21qfUZxV3OZE9RCNBqIxEqEOe4QI 6rFxiSI0xLJnDBuZOgLl/INmSwW/1U8aiclqgjZehFbwmmW5W+g2iXOqD20IqFkI8yvc QTWAb7z+D6BzynsSuErbviy9/zZEZ2V7MXHhT0k13TeLRzmpHSevoy17VWVSD7uw2git a6chR1B5xOPLAMtzlUHie7+ojYbc0r9O33YhcrK3H27CU7Pbs0I7lh1XqKC+D9S8DhUw yPNtXDnZzzVw2nVBTVpG77qAzyxPN+Ps7j+XinVKf7u5Rc5ltY23Vjkon5A7yNmylp39 QQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9uk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:52 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK3hSl007714; Fri, 14 Jul 2023 21:34:51 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrvv5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HBB2dvT2Ov/jGJyNJI0sRZNoxbDgtcZI0KNwQs4v21saLWKbddT/pTJe2AdPiD1SEz+ULeQjTpjCVB4qKL+0VgVrEXkH9x3bdaAb8uMpEqsSf9E2mtY/eVHNJk6Oy106W3kLRNtJKOanEfvxSc/3O18Wzm8Fa5hFWyEJ/dk3jgmEDx/VEzrXlWZ3JHOX5hGCt086HACuOydtzuxQlbGDUt2iA4zgtI84J6skEzv5gWauKYJYA5o4fmZ7iiCwjiE151xEXTbsJDA93/H9duXb7YXRTNuqlXr1jKGZnYqJIvMMFjSxRSljAyLxcf+NRX1DeTOHuJpgytVpTe6cpE3CXA== 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=/sZ9717gUsbKAIbR6r5pw5kBb//q+6sjoyz/512Cl5s=; b=QsJBsuhM7t7ENRJpHBEK9pcxrvFELugjxJaTimGjsuLfOVwpbKPDJnttlSWcWeBiHLpjhRh1BateB3w1q860gE584B+Zq9yLlNRgyde5VEQQaKhUB8dqEE+EyJ50+1bcUc8+0aWk7cKTpCYG4DnwM5bURdYUMjbHC5MR2+7BIjr1B0YBpbHITfvVOI0dhds09e9lAyD/2xGetHGKdmOSm74dh0dRJPKJmxDAl6CFbcasGMItzMXW4hmsuu2LqWSe4qiywLJzPwyl2J6cbYTuxRPacPMuDvfq7Hm4pVgon2fVh1wLidXKRzMyIn/bxLoHV0vHzwkpYv/XfAJTqcH+6w== 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=/sZ9717gUsbKAIbR6r5pw5kBb//q+6sjoyz/512Cl5s=; b=Vfs6NTiCcmmBB2QWZcb5fWva3mXCbU7hLXNMpJ6/JqtlLKDC3PFZomiRcNpMkNUYpat+ku2ZPYm5ObulLse73HW7GAocAo/pD/3rBcb/LzYImKFkm343EOzAP50Cjju+QH0w6Cr7LEBWdaDMA7VJ01lYnS7SvZvGJpm/u2T98hw= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:50 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:50 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 16/33] scsi: spi: Have scsi-ml retry spi_execute errors Date: Fri, 14 Jul 2023 16:34:02 -0500 Message-Id: <20230714213419.95492-17-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR05CA0097.namprd05.prod.outlook.com (2603:10b6:8:56::26) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 3038d500-c010-4a18-88f2-08db84b22720 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1nHCNIXQElLF1EgAxvLcIaP6xu/V2SHEF0R6OkLxzuL3vHX87VOv5xG032BfG9zlXzuUWoD1DpgC1MUbsUH81l+aipbBxOkvPMZo1GcXeug/fkikSbBlKggrbO+8MHjR9eAjIduevpnG8JSoZc3YP8oMwJWFK6eU69ubYUl7CsSJ9GB8G39exW18x4KGlYgXCIPSQo++c1Lqp9tLR8AcjJfphZL2UkyMjRsd9c9y9bRyDKlsyzkdShgavy+i+E4+mEZSs1LWgf6oHmYazCHL04Mr0wuYkUckTU8DL07r9n2UHB7lew2oTyDi9Rby6qRYudK5wAMpmUO7r+wpJXI5kCYOW2kVyNBH5V3dbKQ+DRCsJ/k/XoM3Fj4wMz5dAkml6av6nCj8mOlLFSQFkj8BeMXGbOfp+ZYiaXxCwDTVSWS4aWR9yXkXn0FKg836MLJseVOr+pecf2VSnsrWE6tD9GMUbAm7Rrn/7TSeiHaT6hY3blL5rwwxNF7Wa0DwiObb/TQ3VTLg0Ks8Nys6Y6/aHN86qg3/X+aXSgzca4blEMzTvsFlwqOK7Ah2VmM300SM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qc/gd/7twUHwlqcz7Y5MVWMY9EvyzdjlRdqeQZKZVwcfCp6DgH45tnl4n93rKysauexhpxELsg16qXduXRMM6GPe0Du/ncUdOzrviEnCGs8UinsqE+JwBqV22W4k5C59QvHttGpRqiQ7gKRWG+jEp27dUAMVn5oF0tNNmnM47psjGBwRtPeIjepAnOlx8XYDrlf1d5ndL35ES9WbGY9JhUjzBdyygJQqeeG9q0qYDMvwuwiOFd925uc4XOKPhTY9u5LIJAlmS71lyAgIdPnYsp6zN39neOW/Ym9MES7X7CHheoxl4J1JIKgeujyEzSFVcpiVizk0yAt6ijP2Lolj+tmmhXJQXGdDNmX9FPDTzXKBj9+QpcieFR3p97vH4eS+0Wctredg32GjxgoRu5MQsEggIxAdt/UwR8QHAafXx+5MI3NFTZs7BUZnOUoa3OnwkYDb+WHweNPTNDhZY7LL9KTTiCpqZxljbeNi67he+4isARn0bEWkSwZv/hHjcEEe8tfLoeMN0ooMLNgln/R98YR1JopbBAR2kb6DAdrIYHUi6avqrIyacT1MRb7XK7Pw/kCqZc7dFrOnX6vA3Grgb3EfozoyRdSs4lZsFn94NOt0SbBkKnhSY2i9wfzT5OXaj5bSU5Y0HpSuz+wcIxxtfJ/HIy9AcoItb5hweu2xFUcDFJBe3YzKp7k63oQKUSFig3TC2Kstqfe+oFVSEyy2FNr5el6W18UXlOyey1XFK0OVNyw3dsE7Xv5N/UCBm38UG/uNrRfdqAVI2P6w6n5Eu85uuOVuO+E8+MDItVald2Xweq/m0DPInw7WI4MksoxiZIpBtfSl6i1o+8Uke0Yhg5kdg6WHblFxLgP068S0XAmScw8OBw8sW8r8DJxcHnHl8gV86oXDlx+GCTTurd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ieRhnfAB/HhmAZ3PJmbaRgyk2TjDUeseNnKcHx4E5vrt3CBimpg/ma88r9TDh5kFhOC2eMOQQYkjRupimPF7UBiGwZFBD5dUdk5zPrVmF97XGUAcqimk+l/DU40zP5IyrYaAroaJlJTTZ1VJ7NJk9pZovSefPrGHhMhkxBlQy1qvM05sEfYbqRswt8qPFmPCRlfaslxXeMr1MoOQPtYngFiASjr20GbPwDSnKZnVbK+qUCXTGrx9W9TXxIAs9yboJeHZwUSSyYaFWSDrM5OC70PwHAuduZU/quKg3PzCluDJ5b4OUPqgD9tnUF7QF1koG3C8+qLAMRkt4LfSbHxRjC9ykDeFw9cJZeR+i5/xgvRuJgnEdW+AhMWxIcjL5GPEwE4MDnpgEr0CFKCsJQ4IBBIq/M56557W2jArHJYsfwqvUrSMkIZVTI4ZsNz0ORP7VyEVcsFtWANUXSIpFWy+/9SfdqkXOzi872D+GfMW2QWjQG5d1hCg5XP+AUl4PI1yck9ayXq/DQTXjG60QznV8XGuSuzHbtq4OuSKFpoZSxf8lRe7kp4fo+3g1ySJ+ZN05yLCYQGTZQiAlEmVFAEqkUY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3038d500-c010-4a18-88f2-08db84b22720 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:50.0288 (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: zJkJIfYqeDYkrSFKX3NWOIZ02uIbF4+G7rICpbULFGbklaG7rGWB0dfkJHdaXJ+heQIo0rB25hPWU/IVIbceL6If4w13NxWD5ZVDjOEYmyQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: BljgZ8G8ALf7IuKEfLSEVAGRKGZe8MW0 X-Proofpoint-ORIG-GUID: BljgZ8G8ALf7IuKEfLSEVAGRKGZe8MW0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has spi_execute have scsi-ml retry errors instead of driving them. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/scsi_transport_spi.c | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index f668c1c0a98f..b2f5c1d2b451 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -108,29 +108,30 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, enum req_op op, void *buffer, unsigned int bufflen, struct scsi_sense_hdr *sshdr) { - int i, result; - struct scsi_sense_hdr sshdr_tmp; blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = DV_RETRIES, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .req_flags = BLK_MQ_REQ_PM, - .sshdr = sshdr ? : &sshdr_tmp, + .sshdr = sshdr, + .failures = failures, }; - sshdr = exec_args.sshdr; - - for(i = 0; i < DV_RETRIES; i++) { - /* - * The purpose of the RQF_PM flag below is to bypass the - * SDEV_QUIESCE state. - */ - result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, - DV_TIMEOUT, 1, &exec_args); - if (result < 0 || !scsi_sense_valid(sshdr) || - sshdr->sense_key != UNIT_ATTENTION) - break; - } - return result; + /* + * The purpose of the RQF_PM flag below is to bypass the + * SDEV_QUIESCE state. + */ + return scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, DV_TIMEOUT, 1, + &exec_args); } static struct { From patchwork Fri Jul 14 21:34:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314237 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 69508C0015E for ; Fri, 14 Jul 2023 21:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbjGNViP (ORCPT ); Fri, 14 Jul 2023 17:38:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjGNViK (ORCPT ); Fri, 14 Jul 2023 17:38:10 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B333E3588 for ; Fri, 14 Jul 2023 14:38:01 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL3nup003896; Fri, 14 Jul 2023 21:34:55 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-03-30; bh=nnccffaNIP8ZkmRsGLKj/rirb6+FSHHlXVHzCwgVhXE=; b=MjxpfKKh42y2+9diSPig/Qrk72YgzjlxKSGM7c3Qmcdw8HHUDkUbUDtGCMCbEc2keauX 0zbJUHNlBomgr1kxUVErv3bMN6qb2aWtcwCDOkNeidl3BsRYQwgAQbbvvyH1Ek3ChsuI S57nY+uNVaPC/bXKF6ysSNHmygIKssNU8yhjef9c6gmLVaOUlOhbE1gVogfUscs5bqhg CQ4YGoAMW2ePya2B8HgiIytmjXa5M580FXZSfgAIGsxechWSPpADJmAhweSrLLCslaKx UetJ49NABYtdyo0fjOdbV6yqC1mkAY4mFUx+82/oo+0RW45ncwFbz3notKL/O/p6UX/K lQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpth2dwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:55 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EJxgd5013858; Fri, 14 Jul 2023 21:34:54 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91u3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwV/wS4pIJoj/SSOQBcxJlNzXQH8ifVGupHi99liKMvx6nHRMqe9OMF0mHd45emh49fTpRpFg+1pjvB2eem6dXMt05CLtm3tqqPpqpeSLQcBXFQGVSWSxBW1eAeiU69ahqhXQ4Cau0KaOWduQf9Z05SYMcUT0CWXdyEn2NZ5wEPSwEx+gzH3AhFN73AVQ/J4Imn5LQaOiaoocIH5DJJxwpp9l2ofbqBImn6NbR4j2iEFIKZDf2PuhGN3QEC0QTnKMEAtothf8HaDVPYb9rjYEUj4FbD84CWQl8IsApsIoOz4pt7BYfNUpUP0pCnXZzryDfP1x9cFHmPYp2fQRvbuEw== 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=nnccffaNIP8ZkmRsGLKj/rirb6+FSHHlXVHzCwgVhXE=; b=JbJqGlCSQYkuEJ0Gy3EbduiPPAthhbr0vU8AjoNLmlF93k+C8IE1c+2j4zk7JlIFuVB/jgWrmy7BYNUWAsSczZnneWA+at19GryMHRy3Plm+XiRjcnnWeXnEIdJ0SX/feHZmgKqflwdkvKehjdgf4wqr115cUk86rv95QvSqYuf+LtVQ24fSnKJN/HpVTNIvV6IP1CZfFe90EMd0O0/0q0lvE6XP0hRnOov79+sNGMMDGGGCzqSH6jJnSZ6FCwmB140iIbgHLr0JrCMmOkLun2Cr5kiBNZjhuG/DgAxaoGY/8FI0ZNKvkuy1gjXTROG4QHxVQ6ebFsvD/UsuXCeROg== 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=nnccffaNIP8ZkmRsGLKj/rirb6+FSHHlXVHzCwgVhXE=; b=Yt61aPwuQbdPlW30GJFwzUgpwTExk3sQpJ/Uo6OEI6X5dxh13sPEWj7ohLu7Uasx9d+wKeuubMVWcc2xdRIOTuVeo3AfNSDW0y8sX69Kj3cK8lIfbQ751Onj/1kXMuuTDKdUYxNMyy0o3F20d1E57FSAR8Bq1jFlo8SlpPNqjII= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:51 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:51 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 17/33] scsi: sd: Fix sshdr use in sd_suspend_common Date: Fri, 14 Jul 2023 16:34:03 -0500 Message-Id: <20230714213419.95492-18-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0185.namprd03.prod.outlook.com (2603:10b6:5:3b6::10) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: a1ac471c-80a2-4884-acc0-08db84b22800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kT+RcyVgzA64Luhi1mC7hfMvBSYtF94hmt2lzjAzc4xTAjBr9fPfE/38I8lOvKkuc9jU6tdnWA2yLnZSPMhdQoy7UF1oYFnMXXYVtObKtrLi6Ih3eLbliUofSrCplWTGeeMzMPFIWG9X6H9SJVbqbg+CmwZn/+te8Ta7E4926anQczZCgBa1QmitQCd3RlR8Qeuf2px/HNUXYV/v7y6qsKqoDCbZciMZ/GB6nzcl4nNDqBJa6xn6cuvb6qJX7SSbZ+cXtbYDeIH1hZbt+pHf5+3Hx+VIPDqjkjFZTq/qoniyTgrQwp1ataGMXDJvS9xqjOB0F6Vqk4hZ9fzuIdkUYtJZXq02+O44s6fJ3scD73bOqH1lO5C8Puc26c1vf/aAOi+7vcRYM/USFR+1iuBxPBUHxwE2aEWSQJpLuYtlG+HxRi3fUTM+VumtRL90B0YYBKL/3zNLdt2kwH7sSjBSaU9DOJN20TehwqvLhosyLYUFVDXHH/Fy3lKiJSU7lDuLz8BOTnq0xkdPiKkg2yZAu3dMMtmsFSP0JXHVDXw8IaDN2aWWFGw1ie5n4ppIcE5B X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-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0RhqyIL39EMJHRs3sGEnIK9jpkN7lurU68uH+1la5gegCc/4oE0P0uTQCgttkr6tlyMMYbIzXvG0iv4D7wBxjENNeyQr76p+VXLMCJ7j+NW6KH43wMPqIFk0AWcm0YhOYMAcDzt/b2TbJOYPKz9J1CRd77DX1thcnPfAJ3R49fk+gdYW4a+IdjNSEuuxe/YK7YQQUD7pwlMCm7aL08tZmJsepN86KgIgWWPVT3bSo912nni6pPhsM3Wp/MlDiYqUU7W/WkaDSk3udms7YV+HN3zGz4L9OiIV/2p/O13wq5rbBakXeyM2S5jJe5vml63IwcfiHW0/acMF1ZTano+/1e8GtyFrSJQaaxoNE+5KPMsO6I+MWoxBrT+AAHZC0cnBQFPpilqVQHTtSi+KAV9bViHusvg/YqBjqfTGA6p2GCHgCFZWeNiWvm+s5FQMZMqPHHJRrY632N X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1ac471c-80a2-4884-acc0-08db84b22800 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:51.5147 (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: urNAQHDAmqTg0hRoQyTbgdFHyp07Qa7LFc8f4bGv1MqyaTAU9azY64SbnQSkPaf3unGMCpfwZ4KK2nddqwkxYU72Sy065JMx2PJGeYHAfAo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: MqZiWnRjVMtdac0H9s16d7bB6VVc9CqM X-Proofpoint-ORIG-GUID: MqZiWnRjVMtdac0H9s16d7bB6VVc9CqM Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. To avoid where sd_suspend_common will access the sshdr but scsi_execute_cmd has not initialized it and to allow sd_sync_cache to convert device/host/status errors to -EXYZ values, this has sd_sync_cache convert ILLEGAL_REQUEST to -EOPNOTSUPP. sd_suspend_common can then check for that error instead of using a sshdr. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 34a1149bfff2..1f110d646896 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1603,24 +1603,21 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) return disk_changed ? DISK_EVENT_MEDIA_CHANGE : 0; } -static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) +static int sd_sync_cache(struct scsi_disk *sdkp) { int retries, res; struct scsi_device *sdp = sdkp->device; const int timeout = sdp->request_queue->rq_timeout * SD_FLUSH_TIMEOUT_MULTIPLIER; - struct scsi_sense_hdr my_sshdr; + struct scsi_sense_hdr sshdr; const struct scsi_exec_args exec_args = { .req_flags = BLK_MQ_REQ_PM, - /* caller might not be interested in sense, but we need it */ - .sshdr = sshdr ? : &my_sshdr, + .sshdr = &sshdr, }; if (!scsi_device_online(sdp)) return -ENODEV; - sshdr = exec_args.sshdr; - for (retries = 3; retries > 0; --retries) { unsigned char cmd[16] = { 0 }; @@ -1645,15 +1642,19 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) return res; if (scsi_status_is_check_condition(res) && - scsi_sense_valid(sshdr)) { - sd_print_sense_hdr(sdkp, sshdr); + scsi_sense_valid(&sshdr)) { + sd_print_sense_hdr(sdkp, &sshdr); /* we need to evaluate the error return */ - if (sshdr->asc == 0x3a || /* medium not present */ - sshdr->asc == 0x20 || /* invalid command */ - (sshdr->asc == 0x74 && sshdr->ascq == 0x71)) /* drive is password locked */ + if (sshdr.asc == 0x3a || /* medium not present */ + sshdr.asc == 0x20 || /* invalid command */ + (sshdr.asc == 0x74 && sshdr.ascq == 0x71)) /* drive is password locked */ /* this is no error here */ return 0; + + /* This drive doesn't support sync. */ + if (sshdr.sense_key == ILLEGAL_REQUEST) + return -EOPNOTSUPP; } switch (host_byte(res)) { @@ -3848,7 +3849,7 @@ static void sd_shutdown(struct device *dev) if (sdkp->WCE && sdkp->media_present) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); - sd_sync_cache(sdkp, NULL); + sd_sync_cache(sdkp); } if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { @@ -3860,7 +3861,6 @@ static void sd_shutdown(struct device *dev) static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) { struct scsi_disk *sdkp = dev_get_drvdata(dev); - struct scsi_sense_hdr sshdr; int ret = 0; if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ @@ -3869,21 +3869,18 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) if (sdkp->WCE && sdkp->media_present) { if (!sdkp->device->silence_suspend) sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); - ret = sd_sync_cache(sdkp, &sshdr); + ret = sd_sync_cache(sdkp); if (ret) { /* ignore OFFLINE device */ if (ret == -ENODEV) return 0; - if (!scsi_sense_valid(&sshdr) || - sshdr.sense_key != ILLEGAL_REQUEST) + if (ret != -EOPNOTSUPP) return ret; - /* - * sshdr.sense_key == ILLEGAL_REQUEST means this drive - * doesn't support sync. There's not much to do and - * suspend shouldn't fail. + * The drive doesn't support sync. There's not much to + * do and suspend shouldn't fail. */ ret = 0; } From patchwork Fri Jul 14 21:34:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314223 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 E7689EB64DC for ; Fri, 14 Jul 2023 21:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbjGNVhH (ORCPT ); Fri, 14 Jul 2023 17:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjGNVhG (ORCPT ); Fri, 14 Jul 2023 17:37:06 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C3603585 for ; Fri, 14 Jul 2023 14:37:05 -0700 (PDT) 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 36EL49cQ019565; Fri, 14 Jul 2023 21:34:55 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-03-30; bh=SKEfSRjnLJZZXmGNlO6J+pl4qaOrbJ5N+u1ePPRXhBo=; b=zB9vJYIE7iThePMo/aSMYu56CUjykM56TvRSXOSVBIykTO5+EZe8Ypjyy1SbsicPV28p 05hsO86GYTWqUJRUt/KTKRY9OUySkf0o2Utvr6OcF6ZSvQ0Un9XhUDTXUg+G0iAoQ1Qq B+J8Ce1FQPmgT0BYhz6dUTBc8NtQqhVB8AdISYOZtzlA45uvjYefo4JKsneKCaIJkPHB 1qzC8Eos/iOKjxIZPjMW4W1zvMWB2UdsyOTIDvTBQ3166Q+Urwz2VtsUi+eNclWeyS7t s/bjL04lnuCI26hPMVMoO5nlSCD5skGQEhWN1kWDG3qa6LC/d4gFEsVO6Kyn3Ef9rXJ6 Jw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqgr2aqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:55 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EJxgd6013858; Fri, 14 Jul 2023 21:34:54 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91u3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9M3DZOp4TnEQ2BOiAooFuaRzjy/CElOj4dleBfFZD+DzoqqUHbdViy7t9Kom9XdgDpetK+jerXTBoZ9CzBLTMDj2nNDJxJ2rmipHp4qjGqQekbThdUxgzIpg48I39ueswDILa6+uXojW/Q04zbUbz4TdaWWJSUyX4IgyTT94Zt7GK+fpAboPiB7DlZuhHMX6MYkHM7VYX31LDj2+VB6L7WoOJjQNrVJpr/R996pClkpgAYr4OmGy6s3UqpZrDL2TGkcQDiCrmmNqaXP1mBfjhzduvGdQXSnEy2Snv2H+0KPFwYnSAulbz5NNIUBh56AaEZOAlgnhrKJTaSWIQ8n7Q== 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=SKEfSRjnLJZZXmGNlO6J+pl4qaOrbJ5N+u1ePPRXhBo=; b=P31TKl3iuY7AD6bDdrf92Lr5D+mDbw2G0NsiqAt+cB3jWISeGpsl6KCoUzGdmQ8HVjZYHvTGBdq1AqlepI0otj5HNUZt3YGCNiDMiRKJ72kAxFpGUvvWFbdPM07XV0Ag5cLODiG3miXG40UXeTJfHpFDIRWnleEY+aIJD7zW872dSLFmysE/qiZAh/pB+oyjxBEnxa7bWS3WuHdrW8rNHCHqDHVlkt7lpkJxMhwRhosljW+AKgX5Nd9fwsV3MP968/IRNI5JSO1HnZa4ObRzzVelb6fCy67P4RH3cLaGSd+uJtkTWVq8e4x2vxlIxtY9TYAkkN9KpFRHXcYvp35qzw== 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=SKEfSRjnLJZZXmGNlO6J+pl4qaOrbJ5N+u1ePPRXhBo=; b=GR+bnD2Tfj1t+LPkboT1aamEq+W2rmUCWXq3NFlpxTDRz/oHshR/qy5mijXlPZSsFANajl4ad/lunlKUMUH6b5GRzmXlczJXb3YsmekMINvl1YtTA+HQMtik6wv4dK3ser6KrNKraouzcDq8xDfHlZpXK05FvuIDT27Piwdgojs= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:53 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:53 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 18/33] scsi: sd: Have scsi-ml retry sd_sync_cache errors Date: Fri, 14 Jul 2023 16:34:04 -0500 Message-Id: <20230714213419.95492-19-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0105.namprd07.prod.outlook.com (2603:10b6:4:ae::34) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 27e13e4b-4e09-4657-0b22-08db84b228fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: knMn/DTgRE5bSv8vAvfJM5j7DHLdqyPWuOFI8vegEtJhE+sCxpk9a/e0B8STOG0HwaVFvacG/CAQ1xH/1dq8uR7UQ9HeDPphSeKPPFS4regcrUXfK4L8okuqpemnUT6Gc5dIjNem8ssdlrP9jH3JrYnh9z0kuTB09zTMiWVDrUFBVDfYPxDJavYB7BKbsobM6VuR4/GPPKjj+T+JOMgOV7GccuFh+PtUVQhqXOoCWfgzmCkmdrS4IbvS+fx1MA9uffHsnbwjIjc6qjGWb2nTGKWyuy3ZUwnxKjw7l86BbTPqpA8+k+yvk2aBXI2R/ZvJSQQqhFXamE2bV9WA1496hn4vsXxj6mssVeWBS1BW4H108si8zfTSApEzH+1Hjk0Mku7QbIyZVN7LnaCOWlzN0tvZjp4k7tORp24EMt5bCPlzwhGF9r/xkL2fDXLNhYZ+kEBB0jwpaZPflkcAcDhUzH/cTxK7AzsZiSXDAbtIXDl0Ih290hmxabgGsihcJFwA9Z3v8oouyprlcK5LRaTGrZ4VkKeCSPXtl84e72XT8nG2bQcDbVzGs1kTmvYWGxrU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nJpun9i5WD0k7UY9wQTvhkjjj+jB7/hBS2I2GJLH7AIjvSl8HRenLxJCjDY7ArR9kJNNcmo6pqQT0DBLUqrFj2Q+zRb4+gAy0flOYTd/unnThl2D6RI8LUhMFWHAWpiAAmwdzECfOwGpk6N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mBdiSOdeeDRM6PoucHtEgeX2PVAMQmUMv4NxPHkZpCGSW59yUvWKa8NHZD9apmqyl/VoDyrSo02erDakXB7VrYujFQaZTCuZ/18h2rxaKDXDfB5SsjqEstUBvZ9WloDw4vTauvgT1ZSpHhGGuewf7P1Cp2SRH+XIZX620MRM4ZtVAy4ylIU6v8YNUkbvOGhQAa1vO5cvyBk1uwMBbvZ9/2lWAL7+0AyKwgToIlKA++zHlR03UrIkSxXq88BwPrninIlNkDVzUCY6zG+okLM5da+4/+FVvE7Hef X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27e13e4b-4e09-4657-0b22-08db84b228fb X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:53.0970 (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: MwibzrVK/ByH9pUA/rukO77+6/fNx60yeTm02O9g6JHeDQSOt+n/d3P/s0Mb0CKsnl+mRlSko9TJWotgIOGii6jxtkBdQHNxLvpREKK7Wxk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: GBW7TgPeD7EI4XRcJZpzxUhvUdTto6OS X-Proofpoint-GUID: GBW7TgPeD7EI4XRcJZpzxUhvUdTto6OS Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has sd_sync_cache have scsi-ml retry errors instead of driving them itself. There is one behavior change where we no longer retry when scsi_execute_cmd returns < 0, but we should be ok. We don't need to retry for failures like the queue being removed, and for the case where there are no tags/reqs the block layer waits/retries for us. For possible memory allocation failures from blk_rq_map_kern we use GFP_NOIO, so retrying will probably not help. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/sd.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 1f110d646896..deac35fb520b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1605,36 +1605,32 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) static int sd_sync_cache(struct scsi_disk *sdkp) { - int retries, res; + int res; struct scsi_device *sdp = sdkp->device; const int timeout = sdp->request_queue->rq_timeout * SD_FLUSH_TIMEOUT_MULTIPLIER; + /* Leave the rest of the command zero to indicate flush everything. */ + const unsigned char cmd[16] = { sdp->use_16_for_sync ? + SYNCHRONIZE_CACHE_16 : SYNCHRONIZE_CACHE }; struct scsi_sense_hdr sshdr; + struct scsi_failure failures[] = { + { + .allowed = 3, + .result = SCMD_FAILURE_RESULT_ANY, + }, + {} + }; const struct scsi_exec_args exec_args = { .req_flags = BLK_MQ_REQ_PM, .sshdr = &sshdr, + .failures = failures, }; if (!scsi_device_online(sdp)) return -ENODEV; - for (retries = 3; retries > 0; --retries) { - unsigned char cmd[16] = { 0 }; - - if (sdp->use_16_for_sync) - cmd[0] = SYNCHRONIZE_CACHE_16; - else - cmd[0] = SYNCHRONIZE_CACHE; - /* - * Leave the rest of the command zero to indicate - * flush everything. - */ - res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, - timeout, sdkp->max_retries, &exec_args); - if (res == 0) - break; - } - + res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, timeout, + sdkp->max_retries, &exec_args); if (res) { sd_print_result(sdkp, "Synchronize Cache(10) failed", res); From patchwork Fri Jul 14 21:34:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314238 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 40291EB64DC for ; Fri, 14 Jul 2023 21:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjGNViR (ORCPT ); Fri, 14 Jul 2023 17:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230158AbjGNViL (ORCPT ); Fri, 14 Jul 2023 17:38:11 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D02358C for ; Fri, 14 Jul 2023 14:38:03 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4cng014937; Fri, 14 Jul 2023 21:34:58 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-03-30; bh=wWBykNyV0W/DWHnV1ut2kLWbv92OoXAV7RUhFvuhhGU=; b=D+kBUQw4H2iTbihkUy3cVQpj57+F2z6BQaFwlrw7ox+Yb4AJPIF5FI/fCPKrMes6Axoi GAQC+Q8BJ1TiSzqIKZtbh6hM+RoFl6/TQYRuIslZGWdrfC9DaVUimYUi4nu7i6Ui/6ci U07g2yi3M04g7GFN3KcanRHuxR2GdzBIEVrpmK3MGR6HUG59RRdEYHuih+ZqVa3Bbi/A TgseYo2zGqIbq+OgbwGgS4IZ5DFimISRF/IJMfpV4y/lxB34eltIL904Xh3Gqu5I9mkt K7b+JVjAo4g2J+idOas1/zApBIOt0EfJemirPMGC35PA3fJO1mHGIQho+xmFQ80rDY1t 1Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:57 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK6nO4013815; Fri, 14 Jul 2023 21:34:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91v0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hKvRk1tIGNZchofqjMpI1Yn6y7F8Ob/RPkV6zF5YQ+YyiAn268xRu8Dwyl8QGHkUOy8Pi1GUVSBfac5+Fqk1dgF+rFxtH4M2Fz7e/6qkqfqXtAa3JOV4usB4sv3NnJwQr4ieB+sLmGtiFT1PI3yzS5QzJ1thiBhycwLl0IUdJcPj5Qi9j3pXpsWT01BiDf3l4JRjuoLP3SfYVTS0cnuP7+/7QnW3BHJq28t8XkT/N54E8dcW7fdYaoSANpvsnLSYVvhHuD5M03lfe+pXlkoWWv1/YNA5iniffZE6Lgu4XWFXO8qhytGHTpL5T7RZWygHOQWSh3FuJLfPY7duGMp7TQ== 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=wWBykNyV0W/DWHnV1ut2kLWbv92OoXAV7RUhFvuhhGU=; b=B6d3fGYJMrOowjI5bzMFD4KMniH1k/M8pDGgT38xy3zxSWFulIZqT6gfT+PJ33H9+m5iT2zU9y9W8+D6BX8tuGCHEGbpGHZ3nWp2hx8zF7ChkGTfk1jhTp2je2wtvaVtVTSr1Re/8Xd3qAmNuzam+gFbOlXtZZjk/C+Cicy+c2nKt9SOIyue55i/W3CgqvZ1ki0kW5JJaoCdxZPMnvlm3ZyfZhCqYGeE5lPaZnyNIxK9uFy2hudQha+2pUIG666XkPEFEQqo6io6EUIMfOfHN3ydHQTvlZwTUydQAWSoOW5GkA74yKsqikkUklZHq1UpQgFpcdXiF3VUayjfaeVaTA== 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=wWBykNyV0W/DWHnV1ut2kLWbv92OoXAV7RUhFvuhhGU=; b=BNKcaupEnMpEJSoL7aOPpvFf40Mv0MN4gvCd7sQVs4QLjKZMgfqPpaREuPIdVkznoGsM+7HxgWQm2731pxuMTf9Ny7SgVKjeQ1njF2H3eL+wCmWmrkcgPhZoBX08LirFIGRveEic+G2lQ1joxp5ckFUdcDQ1KwiWddYeyVP8ZHA= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:54 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:54 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 19/33] scsi: ch: Remove unit_attention Date: Fri, 14 Jul 2023 16:34:05 -0500 Message-Id: <20230714213419.95492-20-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR11CA0021.namprd11.prod.outlook.com (2603:10b6:5:190::34) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: dca0be5e-4cef-4344-cbf4-08db84b229f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2L3Ye3XCNCW3C+8jmVrxbiBYc5u3SGstDzwDEQPkJUhTt7c9zojxq3ZQxcIQV2SZ+mw1Wgp0P8fuGy8FZp3uji0mIGeJmDz6u0XPapW8lqRJCzhwAoWYXocjfkp3LnjuARNgMUZYV0CrrtIPDA5flmLOKXjZ9KXOFiUCtDSnaToZPNTDoX5+/8PdCpJDMKPILmuOWcahRrl2awGfd5CiLsLKUJK/NA0h0Taogivnx76CqezdN81LVGI1LXN0hSjWI63NHE/1Phe4gBA4keRUzALshbP4pH6bG4Kfizc5+YhQ9y6twglgHqKoBQbKsnFwGbZNULG1MPFt1AHgP7y1gn5r8zAaaaeeYZmnj7dfmxxTD3f+NQ88J0LA41eudKZRoPFjnJM2XCtP76N/yecC4YmbMYI9/xBKHAikjQLAP0FhXF3LdiuPMisuoJjKti4kKJf9cQwRrNzcbmdGTFo0TUQVquE0b4hh05/FCzxVPqZJlixo3UwoAqdaoRtJGxTLldBZX89tD19B+qNv5udIBiGkrFaTZQHDmX+NNFSLKW+0hivup6guSVh+QUJv9uRp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(4744005)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yv1DRfafjaEHglAbKOVOvZXVef6S8tHTnNdLCrOGwI8JHvtgI9rX7aa7GJ25Sq1uJUqZPazWxoHqT11kx2GEVCAMc0uRNwnaNa3Sr50emmoGJVqzKFE5fU1P5JaUadRcd4YJ5JF7Gr+xJdxO8hohioV4+sPvs2V2jdP4pq2cpB3ilH0sZN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0G4Gc0N+XghxagI15BhYjBbEosdkibo9jGEjzH2fZi1Ppc7aw6wuoili036sAzx2R+QXkQas5tqHREfF2nBBiNRWLgBclw71GE4K8GJcUDyEys9DWcVHpTQ6X/kCmXsHZeevmYit7VdQ4vL0gFNq1Jv8uhUG77smFcwynJ2YeZPIgDi1NrZisypxAx2JY/pfNFsPZOB+BFIU0c9B75LfVP0/HCrTSPpoMvV/jrzR/LIFG X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dca0be5e-4cef-4344-cbf4-08db84b229f7 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:54.7405 (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: bJQvEvaMbyKhj619RSFiAIX3cI0c5D4KMhCJZ+FNJlJevNKWqKlFIbMCPhXfR6ahhmlE/LKQs5YNGpxtoQUT6MOZL1UPhemnJR+Z9pQD8Vs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: fPhmWMhUa4fbQdde1x_3KCIcthCj-IwL X-Proofpoint-GUID: fPhmWMhUa4fbQdde1x_3KCIcthCj-IwL Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org unit_attention is not used so remove it. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/ch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index cb0a399be1cc..1a998e45978e 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -113,7 +113,6 @@ typedef struct { struct scsi_device **dt; /* ptrs to data transfer elements */ u_int firsts[CH_TYPES]; u_int counts[CH_TYPES]; - u_int unit_attention; u_int voltags; struct mutex lock; } scsi_changer; @@ -208,7 +207,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, switch(sshdr.sense_key) { case UNIT_ATTENTION: - ch->unit_attention = 1; if (retries++ < 3) goto retry; break; From patchwork Fri Jul 14 21:34:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314239 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 4B89CC001DF for ; Fri, 14 Jul 2023 21:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbjGNViS (ORCPT ); Fri, 14 Jul 2023 17:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjGNViL (ORCPT ); Fri, 14 Jul 2023 17:38:11 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D930358D for ; Fri, 14 Jul 2023 14:38:03 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4Vik019246; Fri, 14 Jul 2023 21:34:58 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-03-30; bh=QnApxjFn2MRiD0R2l3EAMEwbfo+TS9PHUPPqpFCR5+o=; b=uy7llSc3XxVIgDQcSGdm7iijjB0SPqRT+wACKHCm2m9/9kU/Ujx14gpfdNyP8L/Wdy0K KHRKe5nJtjCRzmpp4zQCRIEB/NVnrskg97h3nuFeU1ZkozVgeENv9PQMF6pVt0rJsNd3 y89Aj6rXqRm9vgl8t/tFnkqGPEabgtjBd6mZazR6fcDXkecEc8WWfkQXdFAgs8FmEiIk rpQZu9/tPyPcWPyFYPh8oRqhEO7MZnd9bMFuKVl1U5ZpJazo5JzdvI8zLJVxvQEFbHpt rGhz03uidfmQ7BPkfuTWGpMJ9X/O397cEit3UAQ2LuypzqwRQFV/HCOyXPE2nUxVrkE5 0g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpttjfgr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:58 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK6nO5013815; Fri, 14 Jul 2023 21:34:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91v0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:34:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OeBvyEMgjx5vXSAFnDXdNmxeuCGMX4Obp3gl9oMhBL1RyffmNXlEdf0ZO4GP15ql9x7bVCKq+IGTFgAKJTj5hdVU5wvqZkiPWVNI7EN3MPuwlAyO8ohIYZDl3ZviJDGT8rHrx4728f3UXS2UJckcRAsxJ98xGTkoPCCsH5rDz7t1EzDMfb/x0hgtJF+aMMMEFjnv99YYkhz0ChRoJUP+kCmxR7AVEhu/4ofQubx83zYpoy7FudvuCLhWWcJU2MwHN7npC4vU+z3eHOoAlpuRwvJT1kN96siYy5DabRycLIwnZLSbvdz55qmwaahKYLqvUEePw4nj+Lf+x4l/KSUjQw== 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=QnApxjFn2MRiD0R2l3EAMEwbfo+TS9PHUPPqpFCR5+o=; b=j0/5EHYWbHCnzO/mwo+RYfjU74HaLRcvixSIYtz/D3BVFEcEQrsQsl+iEYBMCuMh+og4D2r+nIFDxvJUZDURNKAJoWSIfjWK48UIlE0wSHvioZRbhTmBWZF2+kr2svEBu2TTyJxxEy/fb/kHjN+sT1i74NFsPr2z9a899Xk34ZmPVWxXa47CyRrpFwowwjbRczMB/8t2mUIOdC5ldWZc3CRxtSuGPun4BqvxCVf1jX1GNNi67UUFUPy6TYJboA6NF7aaMO4LYMvEdYHy/5SER6ekdyT2r/w7XIy9C+AAGdUPE8ICz7MqmT29TlSp6J1s9rEjyPG6nxHWiccN1paWIg== 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=QnApxjFn2MRiD0R2l3EAMEwbfo+TS9PHUPPqpFCR5+o=; b=JySy/dAoCJR8FB3pR8aX/mueuVrBnWQbn7OedQoIsFV0bo8ehN9MoEAMvpQxbv8CDughQM7n2G1wbrnTZKFe1YDHf1FTVHyMNRlJBnShBTLsrJov761MtC2rvobMPRO0c8BZGgGg5tdpwbi2wQJbFBx5aVXr6jMQnc+zEFMMPgc= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:56 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:56 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 20/33] scsi: ch: Have scsi-ml retry ch_do_scsi errors Date: Fri, 14 Jul 2023 16:34:06 -0500 Message-Id: <20230714213419.95492-21-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR08CA0060.namprd08.prod.outlook.com (2603:10b6:4:60::49) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 50a53656-d4d5-4f24-f060-08db84b22ab8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0zr1NC/TsVN3Mpg+s5X3IX9H4qBo+ddj8ZphZwFH4p2it5+h2c+btGxnK6m20YGcIyH9igPS9rzbDtDNGybVfTjLoD/lsq4i+ros50RyaOZiI/qYr5YtRcYRGIysKWIsVrawUzj/SoJtDYuwp5vwVABTHaaCkK+PYgEbJNOr7qbaiBWX0sz2KLZMhXFH/sy/N3UT8H1Xj3RnWMXiOkyT1VY6ls0XzjNjpbqAy/pqueiTd1AGGJZccyU0EWzlNMASTYANVXt+YcggikTC8WpPuVmlv+4uPvvEs035awlVYv7nNbRdBe0CLJZY7NBfH8ZMb5ah0o0yIMef7voFOiR4Ed+0Tsk9+4M/qVqiHTBW7OZIr1Wetaq39f7MRwx6444w5Os1+PtNbB3kehOlLhYVWFcs+IaByMUb7q6BnYl6qvOb8OUgh0xpVb6x/K0HronbNTYczSD/9P8TebhvWFH7no+1vqk2U/MOziTD9ePbf5IdhftmmAy1cHfNA+gNWurIep12nUwwjDHX4RxLg1Z5vTpkeb+8vm9ECSMTFwYooqizpuDGbhjxI5rrrYUn2uMT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fg6LOYaNFA2N0tfRyFY1gn9Qq/U56QArfv82ju1YUhQPeXHtvp+ub2SlAPAN1bYevnpXNdspEDS3zG8T+RqnrXIhSBnCPxBtbVTWer6NChRHEtWnZkItNl2iB9lnqd3GLhtQQh6z58nMQmP9ZK+f7t3ubCD4JE4NKkV0b2iPJYo26FhYCdxad/Pp3qcrQuoe4pQW+1yVrN9M7UqiIC6WBaN11N2dKfAyWUFvYZKq92ZwtJi3OXT+IQj2DjOGuo9CUzWSau92oClFNRZ2AwiW0dRJfGNaTXYHQidDjz1Mvt6HvJ3dh3ZyosKt+6OQv7k3Nr2Nhc2LMUf6lcp/33/wauAIxLHaUZcBZpSpyWHRoFJHfHkkz8PLv6Ysa7KEnVSHeLiKF9CrVf7KW3bY/S4BcNJzSgmTsdTc1J1jRx4BGDnSGGvqpdfaRESLm8C3VSbtL02kEmHp3IkdIFS/iaxxadyiORLnUaZo9Pvd+aGBe1HI9v6KEsuZ4jX3X0uTOdHWYfA++I1lDA8FsJ77Z/fu8X7PkZwmV8lvsdxLH8WhR8r9aDiQFVgEUNTairbk4pYS4fO/Atr2Dd0wDbUGj4prj3i9OAQBU9MhLnKmpkA13fkkgm7E8NBXC5GsrWfl+rWY2EeCTXB3xmQyKDZlhRtYczHqGnNk6dD+wTQn7x6LIVy7n84xkCNzhrTtNlYVRZbnPlN4pVupBNAfROJ1oPbHNCfT/kJL5ffcaYHUvDb3OxLirqpqK/978G6XZDsVb+vYmW/jcsByubyMV4qhyCQrdn7O5dR4nS0VtEO/AO5u1T15BXCXPpEwudbKGEkOccauGUt6QxBY+zyLRojhAr8jlLcLIEL93JdCpRri26BnOBg5CNO80NLwHekJ63oqAKOX5/PxRJA2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gawvT8LTTvU7IA9lFsZb7AeW7qwr1ZGVCE978x+JDtj06FKKhCMA7Mu9yBv1lu/cq2RhEmyK/T9EbwwiVd16rcV8FbS65nwCLzAnwhBsOHpbFBswKKJIDP2O7wqEhLwNTCLnO5os0YbH/eGhOgsqElWGZUoWehtvZ4pogvygbn9gG3TLEYjI4E3c5s33XvhM/TC43n15GGJNWnrtloqo0oOQYw5U4G7f96X8CZiqFRMGcyRGkTkE27Rvhv0aFcntjjfwLqlywx5nolpNV+BCXkJjUhD8hclVIVJQJ2BXOHF4JVGlYG1DCuqa/tJHMciDMxDUrys+QbEy0o2WTsItPX3vz8JVGOnL5LXv6dAjTkaX+84oGCPWJHgPQhxyAhHL7V41frUkyp763B4M7DURaClgRJOSUWaBy9NqTeWu78N0GAUe7lZM2slIo8CITd+jigfVs9qxmoW3ywgIEIa6QQyFMGZXlD6SxSvBqdeOaLFCIJu3Qnz1FkmuKrfLuoRUBg3R3JOpfzutQarDhdoCxFFuWIl3rQ4gH1TlHKyKOZ+POyCKTm/mEO5VAhK2Mdm4pOwleSV4t7IQRIVyJHe6UeggBjo23ZwTjUNqwBGBCXrrwiZ4m X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50a53656-d4d5-4f24-f060-08db84b22ab8 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:56.0322 (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: KwRQvxF4dJSJ/apCqCj/4bonoUV0YZoNLmn5vv8iFt2WrzkH9zFWt6tAf0+PQSrWrvvRHzbBDTWrzI9Nuy+zMGzvnnz7sT8BjFaS8WLCCks= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 9ZuIdyQNNjx93CdSFPTEC8elA0OXOlZQ X-Proofpoint-GUID: 9ZuIdyQNNjx93CdSFPTEC8elA0OXOlZQ Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has ch_do_scsi have scsi-ml retry errors instead of driving them itself. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/ch.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index 1a998e45978e..8ea498e6eec2 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -185,16 +185,26 @@ static int ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, void *buffer, unsigned int buflength, enum req_op op) { - int errno, retries = 0, timeout, result; + int errno, timeout, result; struct scsi_sense_hdr sshdr; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = 3, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) ? timeout_init : timeout_move; - retry: errno = 0; result = scsi_execute_cmd(ch->device, cmd, op, buffer, buflength, timeout * HZ, MAX_RETRIES, &exec_args); @@ -204,13 +214,6 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, if (debug) scsi_print_sense_hdr(ch->device, ch->name, &sshdr); errno = ch_find_errno(&sshdr); - - switch(sshdr.sense_key) { - case UNIT_ATTENTION: - if (retries++ < 3) - goto retry; - break; - } } return errno; } From patchwork Fri Jul 14 21:34:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314224 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 585D0EB64DC for ; Fri, 14 Jul 2023 21:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjGNVhN (ORCPT ); Fri, 14 Jul 2023 17:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjGNVhM (ORCPT ); Fri, 14 Jul 2023 17:37:12 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F01FA3585 for ; Fri, 14 Jul 2023 14:37:11 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4Y17029803; Fri, 14 Jul 2023 21:35:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=zVQuHo5PAgEorlZE0AKnomrHYuG3KT/osqtZmqcMGeY=; b=Ig49GwOJJMzdvs3U6OaKSwydzlUmWVpcRd71Ql3Q0jgFHzyulOwsOaci5doLn2I6OCsG WAKvaNLgSJaEx0u3V+fRWIOE6vib1di/u7hL3x4JL4exKIFEXo8mRLMT6LGVzOWn2aL5 7/PefbZak4SOHt3BP6SHS+7V0SA4HWmxe4ERSqVTDtyROU911Zimhn5QcQvnKMXGup0F nJEXVZM42L5qanpeD5NcYSE8T6ACLK4ZebnD0DReOlkaAuDHev9ZwPl11ZwYQwkBq/RY Yx52a9YFv2VHJmbdiUUZiudzL6ZY+J+iPslWYnlSbMlNZQUxqkyDVitgE7MjBbrifVmA 0Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtq8atd4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:02 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK1gsS014020; Fri, 14 Jul 2023 21:35:02 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91yq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eFL7urm41/zhg32dlmAaYyCR50VOz+5GOWhgzKRJEzPKW+lzpzi2xtrc5TNCJq9x9uRwfJss28yDHWKQ7esfutBDk+05CCUhNHNVqK82XcwTuQ3Gr1m+4IpVUv1/bmwylHnbKN7pRJkadFVsXX11WkjXgTgyeA1BtbSoAR3yhT9yfTrciY2ND0vhVbVGs9xoINGLzLHwqqv65HaliNpGrnqTRPoXOaKDM93fvnlIBN7DQ/r8xDQuusum6vSyABhoyaT2/mM4aXVIXXVP74OB1yC8yR1EtKssF9FtpU5RbZTU5H5FaqJG2t+SHoHY3a8XDNz2Hm2iDvR4LeiMn57OIA== 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=zVQuHo5PAgEorlZE0AKnomrHYuG3KT/osqtZmqcMGeY=; b=O3GDA60CNL+w3cROxx0K+AM6oeNK1BX5Eo0Av2uwC81KJk7ZAr7FTr2wzOYjvBjdELPi8HPXpjuskSZk2kPbpjnrFeBjrSuOllWUvBT1WkTfJZEvfQ5xnoFcmxMunk88uWzYhMnqk+EUMjVcKEqYT+jP9OdcYr8iTNqtFUspZfnvIk2nMhSYOP2hv5qAyA3L/kjAdNvQYHcXUMTZCbGZzExoUyqxvlg+0SX+dBnVrZGWpsEO8BNzOgAxS8TBWhxwE/a2/0Y3IpKJVWmOnoNZ5bZPPILVNrHJFzpVO2nZm1vGMpcszoMu1dBR0cdDW6jQRsW+yBAqAQU15l0Ao/CVaA== 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=zVQuHo5PAgEorlZE0AKnomrHYuG3KT/osqtZmqcMGeY=; b=EAVoAMc/2ypF5igPBTZN/3nAIHV4J+KvogRhHq+Dz/DZrjjVRP74Xkb6VLnyc4gdVcydVdkd42PVWYypYj0cKdshFcjZ6G7wMFl5tub6nQDeZM6PdGfDKtgXYi9/pyJbNV7FjdTd2xIxJ4SEsgPdQbcs+2WeX6OTr/6AjIXYKs0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:34:57 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:34:57 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 21/33] scsi: Have scsi-ml retry scsi_mode_sense UAs Date: Fri, 14 Jul 2023 16:34:07 -0500 Message-Id: <20230714213419.95492-22-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR11CA0060.namprd11.prod.outlook.com (2603:10b6:5:14c::37) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 5df6dc94-b66f-45a2-ec33-08db84b22bb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kTL6KISvOJnbNZ2bJouWiPCZFtmj+HPMmyfl34jat6PcBnZ0v0shOMlIIisTYKVl/0cOt5Sy/bvua3d8V8e9gIBJpkzCpAJbCr47DqfwhwBdlYzM2urQjKNDrgrYOQ3+08X6ZcGY76VvszJw825U/vAlvxxmzwDy8TJ+Nkq7u89VU8OZtGLoDLZ3MHNAYKSN0KpVsRVyccmGdDD8Gh+9eVq0nXp+aDKgnPU6HBgY/jZ2fWTa3zujMGRxObsaPdlLAlnvKmh0a/mzo0Z+GNZzpmi0FyCt+wlO6li5TvAPHHyF3addpLOyejmP40mp1P3iYgaRUlousPtOHkpKDTmjyedz29VzzUI7EM1hOcHUOUJilOxF0P4lzqtNcMdZVYeLaBW/dIzfw7DIwuh3X6o3/pnYDHgvbIttxKPznt2jrqYbBufPbTR4Az116uQdUPrT6GORzCRAdmI3/dN3RAonFSN8NLpv486gtQq5BCRRiYDR96BHbsLOK72P/d7uXPS2B3G9oSvCzZroU0vDibcvkSITaZM3MTijjJ2j256DVhvmEtGjO+/s/oWi8674eRFi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LXZErJoMkQpsy8960kMYRbCy7O7wrlSHnVsK3hNIg0C58y1J+88wAf0bh7XwkNJDoQTAfKffzQbSeR7gkY0BpD4Z0ANM3EgnCdwTh8Q6nueVyh+HT5rG34kv9TRD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Yovbh6ykFwOTLa+9lX5u18Ys4mv6GKIrX+QFt/VK6qEZMrF1B8hqiF1yjxKzA1FUFvA9Rhkq9sFxtsblaA/oRTSbwuJiscC7G07BLBP0pD3zduL6IPDBEzSseLNkVLbg+BCsvKgBvX1cLem2lZwgp0GFvSyWHZ8FTWYtTzIF0QAKVDVcxi4R5vs01NJm3r1OWIrH09g6SMJvm/QWbwZnO0zPYukOqjEGlPoFlNSvSdgygLNmK41C6Fcn679PDir5bkIXI8yEaZhS4a9jbc+NYChigBKg+DleF4/ooFemYhwT6SzuYJotmNo3gxctzQzxJAZXrOS+CdmkydmO7wXw8yJ4dUcDO5yTa5lQ0RQxo2I97qFkrJUtu5Hw89WYuof0B97dTtCKxlqdHK3BSG+4KscogBf4A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2aQSp59LlAaDQM4CgdXB1uERGJNODDUu/7EDrShUDQ2G4FvwyVar3s2Xzq806D+Kp8gPL/mt+r+nflolTi39bO20h2yUVRPAg4u/Qj44tjetroYsjLUuvGedFyXbAV9Kd020Tr5OBRi7csKew3b60gJqJr2CO/o752kMy++M8ByPIEhkOoiUJG6qnwJPn2OHtZioBkf3xqZzHmlKoUtaTXf8OGPJgIwJKFjG1Aoha76pNoJs0J4nDNr0ZVXKduzIByWudmFC37jvlRNHCgD8Mrkejofeac03ElXKfRfEWQRbr3hG+nORKV/HuHgZ3vQY2JMM5dumaWjKc+xvvsNTBqOtsmooja39NcrxrrjIAwC4G3SBFFN+QzB6z/cImL7VRPUd4dxtAoXE7R46taig7ziOW5QGVg4tbA1eOW5+SlpSoPquiOqtKfeed2NlhO+u47/x9purFcU9zd3javnEtoQ7MwzUoq6H8Y0uLi5JHnk1OV7FzDMar2ghHkD4hWu/YEz8ILF25Vjwwu36MJ3cjcwAcHQyLrJI1irX2epidBYDtmUBaQrBSQtG+vrHieYUmhCmA88DmDV8tS0uUFcRS6U4UeJfY/PoCjcHjzi/HxQaOJXXBHa0ukole4tqqwuglCL4oNS9RTcC6Xw4o7YHVhpxc4TMlWVk8TkwlMfK7M4ZBOBzEcw+KMS43aWRY7JPOExrJgrN+skONt2dc38td5pPy7RRyBT3gbzxEKND7/pjyN90EOThB1JvBKNFvBBEEkv1P/an9N61cDLEfsh+cuuHm5IfKvdQkIBaAGjFkN7FxIKPlipR3lsdnX6yRIqKx9+F0DQgH+dhVlTuSByNYyHeaWESe2NQn2g6xUce2VtcU0uHmZO4gjnX0yeNYjQa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5df6dc94-b66f-45a2-ec33-08db84b22bb0 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:57.6307 (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: e7AC9lAPht3AubC4gkDBRVxXKOyhqTmYdu7Kc35Ylcq3ZIGHZCOH3VwWo6fQk8BKZr/Dabkl2pCsNh/dzH1pOvzbdxZk7ENl/sBs8+AUCD4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: 6BZVk0ddGVRG8bcN_F4Q4buhi6i51Jjr X-Proofpoint-ORIG-GUID: 6BZVk0ddGVRG8bcN_F4Q4buhi6i51Jjr Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has scsi_mode_sense have scsi-ml retry UAs instead of driving them itself. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: John Garry --- drivers/scsi/scsi_lib.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 0097166814a0..26b21e20ef0c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2186,11 +2186,22 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage, unsigned char cmd[12]; int use_10_for_ms; int header_length; - int result, retry_count = retries; + int result; struct scsi_sense_hdr my_sshdr; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = retries, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { /* caller might not be interested in sense, but we need it */ .sshdr = sshdr ? : &my_sshdr, + .failures = failures, }; memset(data, 0, sizeof(*data)); @@ -2252,12 +2263,6 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage, goto retry; } } - if (scsi_status_is_check_condition(result) && - sshdr->sense_key == UNIT_ATTENTION && - retry_count) { - retry_count--; - goto retry; - } } return -EIO; } From patchwork Fri Jul 14 21:34:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314240 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 B5239C001DE for ; Fri, 14 Jul 2023 21:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbjGNVi3 (ORCPT ); Fri, 14 Jul 2023 17:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbjGNViR (ORCPT ); Fri, 14 Jul 2023 17:38:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6B863593 for ; Fri, 14 Jul 2023 14:38:15 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4bbF014922; Fri, 14 Jul 2023 21:35:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=jShRc86RcpXJp2CZoTusRJciBGwHWbF8uDVpgqKyir4=; b=c8iz/k15Kek4wJeJy7m3VA8vrT2pC3VPswtqbhYkh+VSKGer/M/X2ASz49ezx2f5qcpX 9H9t9aPk7F5wTS85yZ/19uQoapsCmJx6Kko26GJnUNqpwqcqmbZiIYyHQZXJEpGmgqNl lqNimZy/ypoRuQFocAUqb8Tkc6Tt1nwDdpuphJMeNHVfiJ/Fp1ePDL/+SdZehfk9J8nR cDV5aB/f8cwNVpGNVBEuLXctUFJOO1WwAZVrbEwyWDZO04Wfu4zmjhQYhoRBMvOkVjIw ngFMey6NOX7JBUKwSKvuHK8AcK9wG2zMJzJyca49x5cryVQpvIy7fdafYfSXX9dTQQTp Yg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f6n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:03 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK1gsT014020; Fri, 14 Jul 2023 21:35:02 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91yq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n+R0mNZ2lJYNv1JSQAL5hi0SsEvGEmB6kbLYALoDjlqQkN++tWy5Q22E1g/j0Ym6Wxg4E7uttNGno3COf/TpdBBn76YU6W1AXeyrdGcoucY7oQ3N7Pe8DdX/jJBphPegPgmlFCsZLV0pJW/dgnO2yHiBlNcr7IEtjofyzNgGNbN1RXBDbFZRsi5thUDGlfKVql0BHrcbA7HSxJ4D7qX5mgigEocl8gn7ku3cnqsmzFZWBUr4Hk4WL61SmsFLLMbyaexVSMjYEpcCVtGnK9ADaq7OZ+y2RV+JYZgQZ/3hl3o5owEbrW7k48Vu92Yn89GitYPxBE7zh9m5YBpz4jq5Qw== 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=jShRc86RcpXJp2CZoTusRJciBGwHWbF8uDVpgqKyir4=; b=esBK7fhSiP1t9PmsBlobFrhex0vwJZlmnEDTTO8nB8WGgZl1oiZ4EMK60/jJAVHBVBHOE/F9GSv0FEgXOHhBtJNvyeRxzF4KLi3qJS6Up5R5bocpsFDa7x3pW3B/qzgkVIQVwGf+p/Z7RAP7VNAZkRvmzBm8lNMK+Jb3bAVEneCfyiiigheVAal3Pp34XmFeTVtJ+fckdDrIGiruGYVwmSGUiwx+rW/DElsYpW13h0IpVjtq9P882Zt0NbZswHO7oXOm+qFjWno9agtVAAvsYPsUUUjOl1skdDinvmsN9bshvZ3yGFPGV1NlBwR8yCuIQ/JBlKfCMj/VS9nOMPoCsA== 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=jShRc86RcpXJp2CZoTusRJciBGwHWbF8uDVpgqKyir4=; b=wFjIHtf0Tq3rEW8tP7YMJ/NkE3iKUtHAk98A/1eB7hcHWOhlfQhfkSQZJPSUjPKH5m35zDngCZsWwEemoqDjWpBbAhxwzsXSn3sPn8Eva4YOmIEN6mO8YnpU3ARD9Tx3GAqwRRlmGUupUzuS3n6r4vTv5+wUYCRxzGYs0763PW0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:00 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:00 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 22/33] scsi: sd: Fix scsi_mode_sense caller's sshdr use Date: Fri, 14 Jul 2023 16:34:08 -0500 Message-Id: <20230714213419.95492-23-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR11CA0009.namprd11.prod.outlook.com (2603:10b6:5:190::22) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f1b8588-4e3f-4f8f-84de-08db84b22ce4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 16s9yb5S0+cWcIZdvaV/NWCysvObeBpmBzRRbDkL0H1OM11AuEhebaPkuqx8Nn8FsYwVJ7e4cCQUolF7Y+mhvHFigFxywZDfKE+24YHwZRaD5M6GQz32sn59YhIYc9PopF4QwLYFsg3NKhhHFtbjYfUSt1PV+So+OrVCidlspzArggRMivwGRPRRXsfQ7IAPt1InynxO5Y0VMrXcWkJEDE7unPa6rxan1pFqZo2QTuR/gzIpEeQbHQYVVxYMOq/OCErTxTRKwvO8oAiFDkqw1/TNCI2umnMbxLvKQ5Q2AirkYjyVCngE3suCVMbmOnbzpVYOReelsuyoIFNz7pB0/SOFVus6B8g5YQbbWEkWelD9Zvu7fp3/iDeA1gQ3KvkOC/px2vvpZW3PO+Fcov9RxHAaqWFUiTUQM7Szr3qQ/yX1V6UiWLud1ECi1UUdXDaYHI2eZgZ2ra6CATVZdnhg7nocgJpfWwKyj+J+zvQ1ceIhWZjLjFS5Sa33qAcq3g76vD68mWdwT2u05+8k2a6oZYsHxpDHZ9L1vNkuyzAuSohidX5JocR7Nn3CAlE5mTLL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ErA6/ZlmTy2CjMXwB8xdRiKzozdbGbApt+SXouimHqvBi6AveQlnQIIZrjkT0tCGvTfr/Szn/vgaEg+ktsnzSM+qSf5kqaoPgch4P0UeLv2pSlzFOcfw5fpsOu+94KBoQeSu5pbB6xcy4Dib6JVrCB6dySpcQ+bIW7B56xmbffzhpAHG1KRGXoCBzUBc21LhEu/AzMU94NwP5DG4GCsBTR7iBBUO1Ycst+0wRhYjO/wpClPb4evRHhku8uurjY7Az02PAq0u2EQZf+i+eUipjuLg8xcpJqm//ReQRtTthBIf1BfESgKmfpyhA2EgRtJJcKhxsEEPswmHFWfUwWOm3tkPDDvWdvO/4W5b3RDslE1B5weDn9c9HrUXKkCj7nf0u/x76VhLFIQbEPiNbj1MqtZ0MC6+2Jc5yl1V8Ixc6gvgJPC024ritdapGTk0F9iTHl7Y92qlLqxawFgIBPcyEPG/Qu1VwFlk2HBxiQBteAjmqi7Hh+Th4JGW0x8XHNU4LAHm9rAkTO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2+U4Cf7Sw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mN5WoENUMepd5jfQw2hH8AfBMGEkGlj0SJ0gK0oROwWgt3f05ll/2PBppSIJV7bRCYGAfc+veVnrbLVEVOw1CM7uYmdjh29JIIrkM5gztDWS0Nrkl/fUf8lnZADohGTbDmUclGpAU+S8KSmhqTDfuS6DpJIGomw5rtEIWnJRDjLDFwFY9t11wBTd25a78+6SZejmNC6GVvNEPrAqzUm3ozM6kt0d69PD/n6VbYWmtX69Q2nsKR0Dz8RAPtdHgzxQRW/Cng6t3YsulLRL/qruFEbBE9CV1JHb30ptj9l1ClS5DOnj3JGN2GkTmAFMdJxFGwQdqZBpadn+UFmZIuPW27sX/DYIpdcoO/LVAw+kUYs8cdRppdOGGTJEt46f9Y5pMSN7fzEo1h2PbmBX3/XOZflBGfwkgKM6Sqzdcu3QklEHr7Irpg1o72P+9+f1eFjf4SwNB8Jcr5H2vfQLiBcjDUDORMk5kvK85srI5DGjkKWymuEVtkcP1Ug7oCV8QgaQBcPM3Hhz8qLwDxGoU4LAGTghZUZj/OL4/AXwdGRz1suPwJSypYwpd7noAvT2N/D+LCvp9mV0/qj24nhugxz35QvzZlUhqqxnVqEwmei7nBI4KqCIuOacSRuQL3TBUiKAJVLRtZIWoIiVTlTmjRUNemIOJFu1yrLJyb7azddZHIcoTcTft4bcNvj9n82P4s+uQg/O1Zz6NgsonsFX8Me9rR+Ki3By/1CWwqffyMwBHXq0ukJwcTGPEArgpMmqW3DY4G8lmoX8xpmLSu68FLpDRPf5lP9Co72J0Zz6v3H+iA+sppFbHXOYhwVJGVqWFg4WRqNXaWO9QTfnDtnkUs9kEIqpWmWEWS81t8SD9cYrTiUozjUDMLswFbrfSjeqgFAp X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f1b8588-4e3f-4f8f-84de-08db84b22ce4 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:34:59.7006 (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: RelHH2kot+c6aXBkMeqpLQKK4SL1KytyF0FrmrYsrwKHsL02bbGYrf2P2ti0eIHRSaK8XDCZuo9Ze8wdiy7XfM0Nsia1ZOTDcld1xDoOoZc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 5G9ESxCgVENoQAUcxyT4m_d8mmA3TrLY X-Proofpoint-GUID: 5G9ESxCgVENoQAUcxyT4m_d8mmA3TrLY Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The sshdr passed into scsi_execute_cmd is only initialized if scsi_execute_cmd returns >= 0, and scsi_mode_sense will convert all non good statuses like check conditions to -EIO. This has scsi_mode_sense callers that were possibly accessing an uninitialized sshdrs to only access it if we got -EIO. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index deac35fb520b..53719cf9d86e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2966,7 +2966,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) } bad_sense: - if (scsi_sense_valid(&sshdr) && + if (res == -EIO && scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && sshdr.asc == 0x24 && sshdr.ascq == 0x0) /* Invalid field in CDB */ @@ -3014,7 +3014,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) sd_first_printk(KERN_WARNING, sdkp, "getting Control mode page failed, assume no ATO\n"); - if (scsi_sense_valid(&sshdr)) + if (res == -EIO && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return; From patchwork Fri Jul 14 21:34:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314241 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 465E7C0015E for ; Fri, 14 Jul 2023 21:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230051AbjGNVib (ORCPT ); Fri, 14 Jul 2023 17:38:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbjGNViT (ORCPT ); Fri, 14 Jul 2023 17:38:19 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F11735AD for ; Fri, 14 Jul 2023 14:38:15 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4DeX003063; Fri, 14 Jul 2023 21:35:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=+SXl29Ia7Ei3HnAT8/HQQBdOqjXpLbtPZGu9+GIfWb4=; b=LtndDuPY8tBV5ASrDnBuOy0wC/CUlArBQHHNp4c4jPp81W1sSB/BsTAWR1nHtSIEMlz6 VRmuQtbXE8S6HB3EmJwk6McMwMyyGHToOceHj5/h1gYWhnaNFVIGIdroCj2dxaKHBxDZ Bi8YREmpkIZqZjANrEcyopRkhfk1cbnsNI8k0d0Ad7orf1A5Mee9UN+yUNfGoscrjqug 2kMlDhCWJepoQdgzLYeVzX8eT34Ln2zHbGwABNh9BavmHGKUuM3PffbVjPyOEnJc9Jgl GK84Wbnaik6Po8anYaQ0RzEIhtL7RQdknvdgRzy6wmAtH56ynaUy0qFdyCytIaCbATDu zQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9v1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:03 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK1gsU014020; Fri, 14 Jul 2023 21:35:02 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvs91yq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B5+WBlFnKIKCizA+EdWKCOCOIDBwLfAOcZYNJY40vgKR9Qkqnam056KMuiWWw5Vy86tWQZUZpaJ3GV5z4hkUtoE2Dyrg5d1A5gVEliVSd9K2FTv39pcfw2eDrSmcjGIh4nF/9wFIaz3gskYwUtWfiDOTBydjgV3OylxS083W02iFjjRxFwFLiThgfwfX4UMaOtoGWyIz2mbHq/pFKmmOJv70T/wkVNKle05nc3As/4eHrhHhKt1FZ7QUt7mfOMfDj4rV+Yfp/1MRJw01HrMG4vmrC/WMFNMYtZZZD3J7bXHq82WnGKkrAB/TwnnYIgpLSIakeau0AttqLydeOsjewg== 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=+SXl29Ia7Ei3HnAT8/HQQBdOqjXpLbtPZGu9+GIfWb4=; b=XpdzuZHIU1uZYKa9tGxpDkdtZFK11UMXyZVYL8wYso3e3jCFpAscJaovjt3ejeRcRPqhHW0avBHg7AF7pyO6kPupurpiINCT16kzhvYHxqrCXVkWni+qO3V7ZhuDRXhoFF7p1cGpksaeudIwn9YJnjhsgXRo33H9Piiw3hYcZ3zvRxNLBEVjr07FVT5spkUFHZXuns1pTC7vsOE2IUShwwDByaFPiXiBwAxjrhOZkPv8dejrcbf+os9lhZt9MFhADM5rQHZwDyP9J3YgETXkmTprScRsCBzdvbGncUGUbHwzqMcShTfX/U0p9QHSCSshUprzl8nfnVPA6z3rG8rDUg== 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=+SXl29Ia7Ei3HnAT8/HQQBdOqjXpLbtPZGu9+GIfWb4=; b=VlsX5zQHc+2yXVJ9bVsPNPNoto72Y4b/IFPSU6Tt3BteFAq6oxYnk080fUMWbAMWIYSwwDoH5w7H7/7Vw1BBR0RmE/0SjGBJC0D2SQG41ncxGAFbDeIIo2GeGgra8xVujwYo+oFUkEBndnwlC+Gm40swV7/aI64zmIRfnU/2IiI= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:01 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:01 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 23/33] scsi: Have scsi-ml retry scsi_report_lun_scan errors Date: Fri, 14 Jul 2023 16:34:09 -0500 Message-Id: <20230714213419.95492-24-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0080.namprd02.prod.outlook.com (2603:10b6:5:1f4::21) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: b61c3e78-39ae-4d84-804c-08db84b22dfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e9RkBxoJpi2g0NrSRKwIXdqosd7WAGxo4lP4g9xseTk6DDb8/SCPq8ztki4A1UiVYYSJlJRb6ta4XB6OJRt15V0fRbwLXZoHpjWfUG0KqQhkS9ZSOGuFkFM8Sl7/gyLTsESXHxuUYDaNWVqxM2YhtAmwbtxZjk2mAmEOMLF5NyzPHmaJFBB8TNDXvtqX0of6QQI5OevZUEJSrZNC0/Jl+9+FTpmO+rkJe4j8JCYJKHum1Y/J6d7ekwhaIGqTYDlwynTY7MBstJlPmVtBYhMKGjyj3pcfnrehblex+/4JmOY7jIg0CMhxz9ZCVARybyPzsjy0CDNBEydoR2ewEJtyVhSegwKlh89OxI0K3/qxMsPYQ8QwiY6UmrEsC1KjKAZZV9A7ZaGdp/Y+XmTPz31WNqwEZZxpz2AMkAV+0ZAWFJMXBQrlickzGfosnKnPOzNJa0gysSsH20rQJHv7pM1PbgyKL/IfDPfpi/cG1g4ylfb4QGN+RKSVHQzEOs4sVUAXioI+ukDg4ufCt3rYPOzJJeKyUUE3qUPeoBFI6CyLE7smSmZB9HHQNkWg/h2/Gar3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR: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TZszxL6g0iTBFIBqL079PHJNfqULFLKowyT4oG/ox53Mxoz4wkPYfaKavj3IAwYdxsfK5hPT+sWSqRtbgZiumZTNHKZJq/nffoD+JcI50yLk63rZBwWdzBvdMDWXrIx5bygK98e/ophWE+6FeoWII4v61vznBrX4PCHYcFlOK8NeW0Cs8WFB1NBARRSX7qnqna1i+nQSRILYkgosWx6lpsyA4q6x0BdL7AcaJtVryyY0fFnp4pQu0zpZW69fQkBJtRtwuO3fOR88pVERp89c1iqW1Q2lMlLNuO7ai1Y76U37564UtwDuxbDE2vYFXoU9qs93hSFrk/rW6htAQVBcxOjM/S/IGyVAo5YV9tl2v+zSm6bgiNRXf126OGcRJQaQ41r52hqMfgSvzeNDnSgez+43CXoPLqFH0fNN793i8ugOOyzZ9MQ6zg+D96XeLewMONnWlwRcm0+cJKrRVYNdesQL0NbSgMWuyZl0dxTUC3xpDULeejsz+nxAELDAYMV4du+xdm85ohkkWDhv8zNJEkJNN9K74VfJ9fdpTHioKQnb+/wDq972e9nzdcgkAo38s8TRXKLjxQe3IXV9pwJOPtxTS7A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rrwp2qxoqO9QyxHGyNrl4vQR9bt/M/mnVT2GS/kEtPMsz72QWdhnFhX6m/tNkIMh1vtRIG4LlgeSknicl7cqQcF2uxvQ6GvwUUHU9RkXGe8I4tPG3zuh+++/zij4uJdZdV5nyx73EpHMKfZLvs5HaXj2XVVr3UEaMNm5dTzfVxPEWoK76Ueo3UmnzcnOVu7qPVZQkYkQkk/3UD8Mz+OYGygNhlrS0ilrDqEll8tXkRM8iMD+J16S/PttYtSc+OnSeM7w3SvNkT0R0ve2kYEZAF5UnAHh1oFQmAGI6hAXdP926ZH79NH0mXHzBHNFyZJwTfexD1BY3TIQ71VzBwK/ZymJ1MwtbuL23O/Nnpplru3tIsBaMyr48sb9T9vQYu+acCnLvofnDsnTV6j94yVvjEXsR/z50P4OJ5fGx19APRArCdHoYNcXTLykQaRoOIywR18lWQbyff0n/4xdjGF0lg0rS/nbaX4NyWD/C99GNXBgjWFd0uXpnaL675Vc/oFcURebwDzseaxiJZT3CY/6ViSuJx+grlfOdiDxFs1TMSQjE+yz7eMWtLTux2S9FX5cATFbehosNfPe+/XKhW7GcIeYs3rPX4HEkNpZWK2YRQKeVCSh6+CQDJGhfW9qBUUCPlxKd+bQCP5BK7EGhPZ3l7p5D28Xak3xAclkLEKhBmU62lClP46tqze9wENClraZmTi/3rE7OpgsLLZWkXR6brt+5kU3SpSsD2zvuhzEYZtSAiTtfepa0skb4dQcjN5St71jdn8INpsQi8T1sxxJt9ln2TChaPLxWx21dje9py4cMGXVsF5PjwsXZkuVmhS3D0xflZ0jHYcFv44rAg7Bwg/3mpofhUkxaZWPQHSSu+5z849QEJLgh4+PxC8/RBIw X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b61c3e78-39ae-4d84-804c-08db84b22dfb X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:01.5165 (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: goMZBBwqDhXX8Y4UWkXUQpYAWhKwsnNetroJJbWX+I+TbdqoDC21Ikobcj/+bFcHCBZ+iXQN86h+7RhbFcCGVtTfWs32fTn94DH/j4IVUOM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: OcJpfQdQJfniTpjmNKVhF0cGwV-KxZcP X-Proofpoint-ORIG-GUID: OcJpfQdQJfniTpjmNKVhF0cGwV-KxZcP Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has scsi_report_lun_scan have scsi-ml retry errors instead of driving them itself. There is one behavior change where we no longer retry when scsi_execute_cmd returns < 0, but we should be ok. We don't need to retry for failures like the queue being removed, and for the case where there are no tags/reqs the block layer waits/retries for us. For possible memory allocation failures from blk_rq_map_kern we use GFP_NOIO, so retrying will probably not help. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/scsi_scan.c | 56 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index e3c8edb92164..87c64b51465f 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1412,14 +1412,33 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag unsigned int length; u64 lun; unsigned int num_luns; - unsigned int retries; int result; struct scsi_lun *lunp, *lun_data; - struct scsi_sense_hdr sshdr; struct scsi_device *sdev; struct Scsi_Host *shost = dev_to_shost(&starget->dev); + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = 3, + .result = SAM_STAT_CHECK_CONDITION, + }, + /* Fail all CCs except the UA above */ + { + .sense = SCMD_FAILURE_SENSE_ANY, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + /* Retry any oher errors not listed above */ + { + .result = SCMD_FAILURE_RESULT_ANY, + .allowed = 3, + }, + {} + }; const struct scsi_exec_args exec_args = { - .sshdr = &sshdr, + .failures = failures, }; int ret = 0; @@ -1490,29 +1509,18 @@ static int scsi_report_lun_scan(struct scsi_target *starget, blist_flags_t bflag * should come through as a check condition, and will not generate * a retry. */ - for (retries = 0; retries < 3; retries++) { - SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, - "scsi scan: Sending REPORT LUNS to (try %d)\n", - retries)); - - result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, - lun_data, length, - SCSI_REPORT_LUNS_TIMEOUT, 3, - &exec_args); + scsi_reset_failures(failures); - SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, - "scsi scan: REPORT LUNS" - " %s (try %d) result 0x%x\n", - result ? "failed" : "successful", - retries, result)); - if (result == 0) - break; - else if (scsi_sense_valid(&sshdr)) { - if (sshdr.sense_key != UNIT_ATTENTION) - break; - } - } + SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, + "scsi scan: Sending REPORT LUNS\n")); + + result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, lun_data, + length, SCSI_REPORT_LUNS_TIMEOUT, 3, + &exec_args); + SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, + "scsi scan: REPORT LUNS %s result 0x%x\n", + result ? "failed" : "successful", result)); if (result) { /* * The device probably does not support a REPORT LUN command From patchwork Fri Jul 14 21:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314242 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 19781C001DF for ; Fri, 14 Jul 2023 21:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbjGNVia (ORCPT ); Fri, 14 Jul 2023 17:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjGNViT (ORCPT ); Fri, 14 Jul 2023 17:38:19 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F64135AE for ; Fri, 14 Jul 2023 14:38:16 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4cix015000; Fri, 14 Jul 2023 21:35:06 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-03-30; bh=w2orixFRdn42BUfmqu1rB9BYmZWXH6/gCfe+pzXU7mk=; b=Qnp8OR8CGmmX1ByjewhGAyGGbO6rJzoLMB/0kJKDnziMEcyhWYnpo3lDn2rz5yYZ/r75 AInmDHup1eUDzXpQY+B+s/sczJOIvbX+4WrSlppP0s0mcW7SCHWSfyUdaF+m9tnNgiwt Ut8p10tv5aeFm/izZMXoEsqjQmLw8DuFT7O4mf+dud67JNO+hsgvGjnHLuNb1AdtX/FK gDj5eInuwR2VmAG//VLCvkOWrOOdNyhFHrxF66XKIO/fwEHWXIa0mxpKUXB6YuD0klK5 X/mJ6X8QvC3XFeu+aACXIlbYjoiqYrmXSBU5PxmHXVvrtdgYWhAtkysIjDkL8PvEOonW GA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:06 +0000 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 36EJrurj032969; Fri, 14 Jul 2023 21:35:05 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvrs4sq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+FD6cPT4DD9+pp19urTJ/IppcL15yWPxYhsejPM23D2vIyckmoIr0uYE4HSIkJOgC99CxEKpv4jNIZxN0aijcyzVVLDKF6XQfupSJBwHGvBTcvWQL0JmLqsEUbzPrt10Ke+PamN5mPoQsfn8TAdEAd9MVo8NFkJwDaimM/ZkRvMopNs7975o7tClEbXp/f+S42yc3BmW1soa4TlkDlJPSHLm7EIrQuUjIlIml1FJWjiaDOF7v1QQQvgV4Og1fipgobh2FRuNXWPrRu+e/x2ks+PqcF6ZIhRd9SIIBdYjA5EkaBQAYOXRAa83Ayw8W0Xwn1skNRWUAJl5gUSDwUXaA== 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=w2orixFRdn42BUfmqu1rB9BYmZWXH6/gCfe+pzXU7mk=; b=Nqe6Rn9+Nnee7x8eKy0BXtEY9z/f6AuFHi2R7QHKRpugXkDnPIgtdrFxPmeTnuFSXh2w71UWysct+U69pVsSZ8Ayq24MVJ5GGJbQPloQ9Htr5rx6eHL8g89MsOfTqqf6Odp8AHOklFG7jh/0KC2FjZUFZYgDgCGyknbu+VWUUqIQKbVo4vzdsqVDuc0cYbd5f6C5G9gN6l1prVjkJ5E8bElje8+f8EPqTLcj6jq/7LZkyI6sR9CJVlhuTZJQ+WnXeD3AiZPJd/yRCMCu2EXXmChSEilSPBEKfSq5bYgEVZGnelITVFX3n8DUvm1sVqVBWR50sLO41+HvtlA6VVPNFA== 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=w2orixFRdn42BUfmqu1rB9BYmZWXH6/gCfe+pzXU7mk=; b=XB2vawEcev+0vQy1a4NcP9TnKx8aFaFggcfkPXPQd1+NuBdiGWoyxwDnWz9ROK/NaOihD37St2fWzZEmPZmoRWdm997w7PZIAE7DBw1fVpehuAEQHgsijieOxmTAqUZYhi5zZzaeZrjltItarqAibE8AMDoaw6OGWVd2C2fNTBU= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:03 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:03 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 24/33] scsi: sd: Have pr commands retry UAs Date: Fri, 14 Jul 2023 16:34:10 -0500 Message-Id: <20230714213419.95492-25-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0026.namprd03.prod.outlook.com (2603:10b6:5:40::39) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c9388bc-68d4-400e-f2a3-08db84b22ee9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aZ1kN8ZEnyYPLuEKfG5TBZ2cP1FJLxVlTHugJ8dz0c74wDA8A7FSaTz+J6Td9XQZK/rY3O/AuW8guOYSMyC0PB9KgF8p5VQ4V+a3lIAzQJloezQ2iUkLgKAao5f7XjSYt8mJ5dn8yv37DMAsnOPLO4arYDzWU/2/M5q0kiP8Aj53WPY2/1N7SNxiWC/K9R2WAUhNyiUPiyuy5LLtnWHaAYMOXq7p6fHfZlCJ4bp2gJGlrm+rN4fn3fh2M2yy/wHsqCrkCnVfS0XJEmIpWdSBOIIrJnZ7hJJeogsuSPRbXl0WRRcJIBuEUglRthIsGdGDudV4tqGo0MwVEwsXQRIo+Kc7/fqvL01OKiktFmvJ5J2dtO2ZasbQFxgULN8ZAXjqqbbQn5A00lkC0WHGyrodTJXSUOgEX3xzxGynvwr3b4gDoHztx1zwSnWD9yuIeOeqeBVvjW6x24xHbtkCAEkF8dzr/zazu6sqVMGSw9EYv1AJ4nj9G32xMDrZCDY4ZoyIP9Z1OvkbgUQyX5CoYL5a2evrQsFQVDtM9XnWeB1+zseL4eeFFTUxsPI3ZPIt+kHz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xq6tjvzTATASzEqcwjwTYHu9++mpsgXPD47dwuX52l160kMjWoQ+Qyin6zDvd0z7AG04CikAJbtNEpl7a/5ZMg89KITiX8TsqEd3LWw3ZaNXMZIo+kEdTkgNyxvnoX3E0iknA1mTpEnJtpPoSJux/YfeFSLh6YWOJP9yJ0SHt53OPMB8G22bBdKt3GJeBOZTQ51dt7BH6K3zmc/ntE0HVaoKOGlUu1izVu9/u8ZwTsFZUGLpGA75nG/rUyQ2pouPDqFASf7eidakQ1ixh6Y41iN8EJADfWR456dt9qXhZlEFZnIZEg0+EVrF2HL0IUn7qB0I71aYSVqddT6qVl9vB9cAMiV941TvqOqBIslrKoxWS8X3V9xM8abnpv3nvAcRlDBF+bWI4pWswtggjli5oXRLeNP8EZOPBguCMY+XbV1YdXOqW5YNh1fb+HviBrW87bFV0enpCwmN2Te50bRuL86ONumogoPUXeMNF++SItf8N1KGmbqy0R10QahV6j0Ikx5QRfIeLZZFO4LZULQHhPysMICkiR4zRq2JqzFnlaAojeInUJ1OoEPgnT3nPdMyCEmk+ciq2iLefJFr3/DcGDo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ternalHop-MessageData-0: NVSihunr5U2ZjPvywnQ1U1AKGGMwxfRV6c5T/sPz0TUfPmtgOlnUN5+9jwFoHPcnmAx9LZ8Y7QlcV64VjkFrznSyKANjYI8tKy51NHO0APPcLUi/4xbZbnsUv3GH6SHAzhfKtXg1AFQge+fdGI0yM39BL9xjeKcXlfUrbp21x6Heo8/OHHlpEfItV11NM0YTphSBV/hL8sask42SXwmxkUO/WkfAlRN4Dn/Elke2yU1+FZEM1E3Rqlc6Ku1dBrzyFkv0/T4Cx1gVh/PMn5PqFukabUFsOV7VHU7jvGG+C3PtFcbi/wfihWggApfY4FdKf62cwVqw4PkxKV5j/oDrvXDYUNwUjJZPuNmxOQBBEeyny5VynxVn13DahAvFL9szf5MXzxedX/bQq1W135G5OczCjSZfm6fd23Lairq9kGE4evBoEjkiNqJhfnCecFWod8+OonoDU2IfwBrI1DaRsSHR4lHGqdImpvWL+QYcxa4l3ceO8DJR8Uaty2Qze/ZqBrIPzpJAC8MHcFXvjkNV97cK011uSNk8cDgZpWe+fo93LHaLqWW0gN18W/oIe+1xVJwTgCSaT6yGFsDYL0pV4FlzSqfpnd8MJ9cFP49FtIYK4UvmHAovUxZ5huEBlu/rBTXNLOk35i30poZkKZXjarMeCsbDcwW1yDI/fijLw70qKTh3bZtcuihWDyzLkr3XYhDZMgdngx+k08N8Xhya/dqnZt4FlDflR3PcWDbiiUQxmLYdQ+qcnUIo9H9pp2bx8loFmArt4WuAioe7ZX2eYi+Qi5T4EUjaCFJA/Y/c4KT9oizAq/RvSSOGnnNixhUK54VDH3AVOaLX/iPJ2K8XoUOnwiLyjXMAod1UIVUK/X8mRLrqmPrfD690cMp58EfM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c9388bc-68d4-400e-f2a3-08db84b22ee9 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:03.0300 (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: Gr6vNjrx64IeJFaelfGL/FiF24ytrm0fYyfouQLq7hWxL7PKLgrjJiU1q3dOis2V8J5q/oKBlog5gX+gvMJoiuWUrt4nZtSH9f69LLRinGc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: rONwYjjXbpxV90evKbfD-mkcXS5s6nS8 X-Proofpoint-GUID: rONwYjjXbpxV90evKbfD-mkcXS5s6nS8 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org It's common to get a UA when doing PR commands. It could be due to a target restarting, transport level relogin or other PR commands like a release causing it. The upper layers don't get the sense and in some cases have no idea if it's a SCSI device, so this has the sd layer retry. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 53719cf9d86e..c4de2f959393 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1753,8 +1753,19 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa, struct scsi_device *sdev = sdkp->device; struct scsi_sense_hdr sshdr; u8 cmd[10] = { PERSISTENT_RESERVE_IN, sa }; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = 5, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; int result; @@ -1841,8 +1852,19 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key, struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); struct scsi_device *sdev = sdkp->device; struct scsi_sense_hdr sshdr; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = 5, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; int result; u8 cmd[16] = { 0, }; From patchwork Fri Jul 14 21:34:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314243 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 C6468EB64DC for ; Fri, 14 Jul 2023 21:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230328AbjGNVig (ORCPT ); Fri, 14 Jul 2023 17:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbjGNVi2 (ORCPT ); Fri, 14 Jul 2023 17:38:28 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880A035B0 for ; Fri, 14 Jul 2023 14:38:16 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4UnD014849; Fri, 14 Jul 2023 21:35:08 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-03-30; bh=LUsnTpta+9/seOcvNpXVyv3it8SDWrVVs+QJ+dFI3Ug=; b=ekBePXSHdT32kbwiex48B0EY2cqWmR1xGe5BzeqYGLCjvB32ln+ddiFj9BH78+1C0Jq6 FNiewlniS4grASW8ZcBCpxtdoOb7eKsGUf0zC7blFh/SeJE/YXE2f23jkJ5NjzU9Axhx QQ58UUj6BWzJ5Uvd3kUlC9G50x15seuiMJzkt3gaS3aihrSH/hkFx6baKS1wegS4Wo+e ZHFkUexDWq9qKOdPy2ZNVxhLDw0Ma+uh/FQqncrjtaHooFz/L1M/Fd6sUhii1GRy9sDc 2cTZr7o5LyiU1BvcbVX02fT/CcxIhGmAVIpzH4WObVVZQGf4pH4sxVVSc67//qyrIyHh Vw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:07 +0000 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 36EK4Y79009048; Fri, 14 Jul 2023 21:35:06 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpw0h812-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OhoFrWPHAqv3TMyzxFQDpawMeK1jSAR5mbLB0K6OJiL47j3hVXpQOjPiFjtrXVsy6iwRDEI4UlBGV/ENQcFuWy5/bGhm38F2bJn1CqWJMOLKxwYJCyeulPcxjaFLuqBdPTiiWMK4J8n7K9uNzLNHkBuuYxAgvclyis4NAGr3VoBTy3cEXfbPbUxTaPXduxcTfwm8ZYKHslFVqpPNWgK/t12LHGxKl0w/r73BPWpyx6oV7/o7AkkeCqhcEe8iql3e1jqitFp/+4OBbcWkhifmfjANrSV4W2gdIAiGhUEeXlCDyGlOT2IlqHRh9XzCGc7ePmE5YyeGg0L4y4LnhNrhVA== 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=LUsnTpta+9/seOcvNpXVyv3it8SDWrVVs+QJ+dFI3Ug=; b=ZoaYAE6GpdLkAxDR9h3WEzlrIOHd3GGPpV7+ifB7ZOeZyr+NNMiYc8XcVQSMMFVTuvPraPBbTajoil6uJ4Jm/EnUN44NrnodwWEp5UIdqy+Frn0gacTMnSDwSmc0YU6xxk78aauEx4qFQ/Shb2nRKCAV6MeLoLBwqCqmr3G4zoDJiiDTgkwNKxGhaQsuENvEAUtqOSPpZBxUlXToSCxYUYiCsgmbmPkICSN0ovemN4k5aVOOaPV6T+yTfbQzICarHXXPvXr18aMa8OB77mjzO/JH299AlvJ9kSEc7T0k40KydyNGxX7F5UqD/l/Z8Ga4edsc5LPmLW/klbVVI5WPqw== 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=LUsnTpta+9/seOcvNpXVyv3it8SDWrVVs+QJ+dFI3Ug=; b=bPnzUEK7fLzXyVt+7hNt9TwlPzS2qNDXy2n9coaIyzScuLksSa9f7PgOdNlk21x0hXtKTLBpUQpJloJu7+muPyJ4Y0JtTiDkAllP1g01cWXe2fDhmSeSEmm6jUYjG0judNckmkdmcdGxowQpR6jKao+0TurDSpSgg8f+kXL4PUE= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:04 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:04 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 25/33] scsi: sd: Have scsi-ml retry read_capacity_10 errors Date: Fri, 14 Jul 2023 16:34:11 -0500 Message-Id: <20230714213419.95492-26-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR06CA0007.namprd06.prod.outlook.com (2603:10b6:8:2a::25) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 53c320ae-9116-405a-02a8-08db84b22fd6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YQWKbRxQpfgoQMLUfMtbtzYJElFzGHeI3wDPuvNE++7E+4d3eFBHkDuhbyGcwIrYgnjMkKlLntgE0vyH/QayavIAkvnMqQbFzJGDmudXmaBZPmBc71jQEHYM1dC830OsN9jgST9l55w9s3ppSiUpv701RR78SIWbYMF+2O2cyQr7ix/qYHsU4H0NhIpRg2QKiPuOKu3YVDhqA/roK4WdmsuBqzS/wvpmDfEiANQj6CWq6keUvi0HP7C0xxURHVAMOVKzI7REtBAjs/tCYHh4kq6DMhpwxSDUnBnLgdHoGGIQ0B+/QGtVNDBcDJ9l2WVvA64Xu0y/2TxOsehjmwOmb9kOEkLE9zrwXHubsWyX+yU54y8Y6OpvhqRcHi7JB8Yny+cEEvAwIlmXELU11RSiPKLHjNGV0SK9r13y2AtmCMkmwNe+wyvoIISpaTDkxBdIStS/uqJT8TGb+1XzL/5hSsKzoBakimO/hFDvWCYiEXLXZ01NT9I2M4qPryFxH9iSzd5LHQolc3PIj8BqkDPW9BTv3uFkQ8QP7Jjt4qQGZZJwMYCtlg4aJdz3Tups3hPc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ViEE05GhRG6e45ECt0KhHqJ3ZzfsDfEpdBUnY84kJh8c5QQBTc9BFX6cpSxN0QRp/FotuCBh1slfAVkzIpGUq6XOCafJ14RfHy/wIEynnc7NF8x19W0WmsEtTvKnbX0EHprXnaoP+Z6izMNG9PDyeCWipOX5ahTYiECTTz88TGvHaRVdqlBvHOL5x7uu/zxDnwEwMGI8CsZ6KX9o+fC/LXqk1YsPzsHU9RVhFr27LgQnvlDkg8GeQ1grtfs69d58R27kb9OxXueEFo8/IpEsfDkWoXxfR52g9pXlI/znfuYthDwynGL4sOxCxYFCGlJsTbYnVDjSqSkz3sXHbnb7g9586LRYf6p7mGK0r2RiLh20NskilWL2F87tOfzlK0ZQr0vsyjMGyUChih5JxPbWfU/vbolwp6N4aJRhgORDCfk8N6V/poyJZAlMgQh8jZ2P/lqP3WNlgft5pjFi9XXeIOTtOclz7TtUn50ry33NzBCSlZG/EnKbvnejbg6T22kry5KL0TeYtVyQQuIg5lu25SZ8kkBKd0E7l36ZuEYbbxPLSD6YR7RDYa5DiDr0lDOhDkamksojg9becUBZ6TKkP4NSuSrkXzqfaKtlwRT24ppEa/4pR3/45jiaGRBDpmPrehnuyeu4cErs4yXE18i5upxBAyZkh797HLb+EHo3p1YmS2Mh6QrcyZ5Dxk0nUA7OTV1mpSXKIAaLretsCMsE/1GFoqvfWVYdnOVzJHDGTzVmkW2JPOkiAlk7TkRxHTk1r2pHd7t1ZoJprwbJxzVcr+Vs9/FIjCsqZr0TmTnPP3I9SLDhqHsDDnS5xXtQmsymFdkgQB/rBrMSuNNgNy+Dkc+X7Vz/YBYd7wHozIy0vNa0L+myCVf4U4MwBF69ER10ehnK1tylz/XU3LH+knRt2par/Pt/hPjneifbLwo/mbnSviVGGjEPwbkmutQl0eWVhSM46pUG/dvQeOsTQ6/Wq5/h7x4428BX5oB9XcPcVqEuWGk1a/xTq5JV7f299EQv1SMYDczyMMQ8xa7cCf1g+Zg0tqWI3vmCzyYFIb6GPYlHMeLLRWzPCDs7QSerjnj7Ae6shyrVHAOJBsDEKP+PK+LrN2ab+OpKVQ5NZ81ulDf4aldGsasQrKPXZ9YSXAhK7+LmXedRaftQiMQZLjv4QoDndqmuKggXMjnosvYLZDFc29hkbZFs8ZWpp1gtInJUk/574CL/v5AVaBh6TNKYjH+JlKSNqL+P4hai6fbV/Tv/owvOjNI4MDAHF6M6p1tCQMtY7KUukMrLJcZM34skURGfVHAgqbRZhksGDYzGaNCj3RYdNzAag7I0Ri2/SRSDl0FMJP8zNxFwlEed5AfljjIpFn0WGYTGcbkRYorOEPpXs2rVZNdl73243eFtTdbJVUIl/TC/hxZQLt0kEl822G0CeIqgU9AgFmfGCfDtSP+ERCdWi2pfCdIQACasBspOgqfNwMEbAHV5Ww3tNmPF0NFUWpcdUS8umqczDyhbyPMvF9uZ+uWuDrYTZb0EHdtiraWxVszhCcmU+ZmVLn4FN1Io3MS65PBDf//aK9ke4GRvA9/xQSVY1pVCNED/sue6Y9OsBqTYOYJ0weoHsqbUIg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 568mTiWgZWlnAjRqkU3LbQErHMBiU45u1XCcGb+I7W1wOSUYPhpqauEq3+sApeJDQ4ZdkjGDGxfOBM3tUediaa4HOuhyELUE/EZUMW72H+SoK9RSOvT2d5AXa0pDdxJMTsjrccUd1PRxXOfnuqwFmzX2xfErh/cD1osxG5WU8o/oVxWsQWb37prKC7KtC/EDmvp3+LF9GFJW60rPfEF2h131BDZHcazB5D+CSNB+56cRxfj/kO5sGFu8sy63bkLVrK+3DG8ZmtwgeM/vnSLlZzvYGgHfH6zmsoLhut2wyeBg5NlaqGaw1iLXHflQMVRz4azR/xe3OSa4IOfO5OL+/uftySNOBLmAZNH/767s9V5DHKnjYs7D2o0SIq9eBOBsofxeXRgg6fdVIK4SU5UykP/8LGtsFjWZM59V3Gr8SNlJqU2QdCt5LNMiz1xKo41d+Gsz6wWA/jLbC3l4PJq+g9qbTfUQQouyD0rEdUxbuA6vDGJzVQwa2m1qIJzWCHA5b1zo0TJqcaQLlyM2f9L64Z6FnwLlV1+OZ2qNaYKO6dFgzwr6W4h76MUG3Sgu2inxd+1FNj5Gx+tMPtcjuyMr9uNMGUlpRpCsNOkPseAfbvu/dx8AlvYBtlTMpct2TKsMDOdTG+0IVdXpB7DVBt+CwqozN3i9EFu7/iTtTQVGi11l/syGtgCUOhpshhyx49w76kHAJ6Fyw558QYE7lwDSEES+d0pX6n1viIgZ7W8Oj1uNwmIHuR9go5Y+cSpWN1ixdUvyLOJaEEzeX4lmZi/6ykIVSlDQIMzQD0EE9SEsBJ6JZcyt7/vFExGTqaWOqZTzc5X+spMeUV4wly7nofOKlQDhyBM8Q+bOEItFpozidQSlE9l+Hs2jPlcOc3JsmwB5 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53c320ae-9116-405a-02a8-08db84b22fd6 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:04.6222 (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: ynQV1IWhTgtEMfI/Zd/Kgsb51W8AmI47HowX4KJl0in65P4/d0EU388HI0Vyz5CrDV4Sl5Z/pYv1RUJvEUI5jMFt4Ua+cmoOaU48Om+oNzg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: c8zkF71O6_btgxpV0fispN3QmOEsr5BT X-Proofpoint-GUID: c8zkF71O6_btgxpV0fispN3QmOEsr5BT Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has read_capacity_10 have scsi-ml retry errors instead of driving them itself. There are two behavior changes: 1. We no longer retry when scsi_execute_cmd returns < 0, but we should be ok. We don't need to retry for failures like the queue being removed, and for the case where there are no tags/reqs the block layer waits/retries for us. For possible memory allocation failures from blk_rq_map_kern we use GFP_NOIO, so retrying will probably not help. 2. For device reset UAs, we would retry READ_CAPACITY_RETRIES_ON_RESET times, then once those are used up we would hit the main do loops retry counter and get 3 more retries. We now only get READ_CAPACITY_RETRIES_ON_RESET retries. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 64 ++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index c4de2f959393..34fb0f8d189e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2556,42 +2556,60 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, unsigned char *buffer) { - unsigned char cmd[16]; + static const u8 cmd[10] = { READ_CAPACITY }; struct scsi_sense_hdr sshdr; + struct scsi_failure failures[] = { + /* Fail immediately for Medium Not Present */ + { + .sense = UNIT_ATTENTION, + .asc = 0x3A, + .ascq = 0x0, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = NOT_READY, + .asc = 0x3A, + .ascq = 0x0, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = UNIT_ATTENTION, + .asc = 0x29, + .ascq = 0, + /* Device reset might occur several times */ + .allowed = READ_CAPACITY_RETRIES_ON_RESET, + .result = SAM_STAT_CHECK_CONDITION, + }, + /* Any other error not listed above retry */ + { + .result = SCMD_FAILURE_RESULT_ANY, + .allowed = 3, + }, + {} + }; const struct scsi_exec_args exec_args = { .sshdr = &sshdr, + .failures = failures, }; int sense_valid = 0; int the_result; - int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; sector_t lba; unsigned sector_size; - do { - cmd[0] = READ_CAPACITY; - memset(&cmd[1], 0, 9); - memset(buffer, 0, 8); + memset(buffer, 0, 8); - the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, - 8, SD_TIMEOUT, sdkp->max_retries, - &exec_args); + the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, + 8, SD_TIMEOUT, sdkp->max_retries, + &exec_args); + + if (the_result > 0) { + sense_valid = scsi_sense_valid(&sshdr); if (media_not_present(sdkp, &sshdr)) return -ENODEV; - - if (the_result > 0) { - sense_valid = scsi_sense_valid(&sshdr); - if (sense_valid && - sshdr.sense_key == UNIT_ATTENTION && - sshdr.asc == 0x29 && sshdr.ascq == 0x00) - /* Device reset might occur several times, - * give it one more chance */ - if (--reset_retries > 0) - continue; - } - retries--; - - } while (the_result && retries); + } if (the_result) { sd_print_result(sdkp, "Read Capacity(10) failed", the_result); From patchwork Fri Jul 14 21:34:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314225 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 14647EB64DC for ; Fri, 14 Jul 2023 21:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjGNVhT (ORCPT ); Fri, 14 Jul 2023 17:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjGNVhR (ORCPT ); Fri, 14 Jul 2023 17:37:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9723589 for ; Fri, 14 Jul 2023 14:37:15 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4cnj014937; Fri, 14 Jul 2023 21:35:09 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-03-30; bh=fAOCTf0mOfg0GmgaiGHbbYGPWx4hGLLimLoI0hEJihU=; b=DBMST7xhrSL9c9aV0k89mgNwkFhPS1NC6VmxE0FhimxBKlam8J2uK1ybd61ap8+QIuuY VqOJ0UhXxxQ+/85GfznSKxWnAqaHOz2ZQFVheJMdzhSRgcM+ZfKKsY4eTbNIc07ymwS0 qXJyf+LtxRe858HUWObe5F08l3PFVIj+3hdspC0lEjp8gGSNv0xvg8/HIAZOgsCnAMF7 0glTghUJDQ/THG8va41bC9KA52bfhqKOv7EgjlHpsgJ4OyKkVnGOLUMel+pSP1ljL7Zo RqqFpNqgRouQOixqnmIWgsXlsy0MMdRIbXMxhkJhs0hkQZRpv147dUxFuBRzU81xqu6J cA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:09 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK6Zlt007607; Fri, 14 Jul 2023 21:35:08 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrw5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3ZRn+h+gkVwsH+CtJDXhMSxXEgqYf4PDrdm8+6kLtLP6o/n1Re7H4IVfu8LIVniKdVSRKvWxcJongCXq7PQ8JL3HtfQi5uDILG/WeKzIPC/MeGmKeUV4HMdDcAYjnI4cuIh/NzUEBBPxHb3Nxd74GrNQn8ByJEEtvb2tPpoDvEK7Hpwz0IOgne/DGl7DA2Q+314h5vjuLVuhJDqYMqDeNjMBx5DkpgtJfpMHrqL8+BT+NGzFLYwJs/DZsCxZ+OyGdKtSGNaconUEb4MTA5Y27gGo30I6Q9qJznHJCQdYTq2dkKzF4H8Mr9Ti/Ct/dAYryygytJgA/udS4zuMpGfjA== 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=fAOCTf0mOfg0GmgaiGHbbYGPWx4hGLLimLoI0hEJihU=; b=U34rfTEMrhUAv4k8lJnb2tLOjVF+/curEa1wIae5ANGhP4md3r5QqJtWWCtSEN/OSCw0ObpFTDj9Gu5cAxfvfDKhHxr1khBM4PrwdfQzruZxXkj8H+FixZK50enobNQ5yoQ9rcwP6X+fcGVN8wlb1AAzqUmsEFYs+oq0Wom1eO8cqtw0SjM7jGuYcZO8wvsazhT8YCPecGJ4uS88H6z01T0XioAfZZb0y/yUaJIpVO7/0siqdloy4cgJX2lBpwUyXE2sS762aG3yckK0XnSafAk6NaMtM2WjCIv5t8D/xEnfUqun6TNdUpNtEBeB6RJCFroU9ZvQgvq9GIv7G2qguQ== 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=fAOCTf0mOfg0GmgaiGHbbYGPWx4hGLLimLoI0hEJihU=; b=EON57Zvg9XIEYXN5EARPFUAGJeLpXxwORcSm40Ca/cMCUeRY2sclwXL+a1E9yW+M66cHvIjC0IAgVmPSYEd0iLE0fgS/2SWGHD7rowgkQ47U+A4MD9P2IYrFCREvRa9+caTodT1C5eOd7C6CGS7mXsLhh3ZVSL/9UiIxCX+RIRQ= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:06 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:06 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 26/33] scsi: ses: Have scsi-ml retry scsi_exec_req errors Date: Fri, 14 Jul 2023 16:34:12 -0500 Message-Id: <20230714213419.95492-27-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0027.namprd03.prod.outlook.com (2603:10b6:5:40::40) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a6faaad-4335-4dad-39dd-08db84b230c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ajxx0GvD1vUsnm+P8+nJlj83oFFBqTODJHrJzzmaL5h60Db2Dwikh0uMClNpM0r4GBfrtz6XbY9M08IxRtYcOagT4xRU3WwSTd7v29Iw1DlI506lcXQOyrFD54QQetfOZIm4bIY0fFtbzKCIbzZ8DnphjNutAt0DP67YXI4jzQ0FiNfwHJGFIti28uPGrJBLVEX+elTuH8D4McL2vxPEOA5Jba08JLEryAOIqmAjf3mNjVynzzu/PZ2ZvZ9f8PzFwmtF49zI1JCXAe0dyiQ1kRV12eEfwTe6d4KCzQafzS34R55pd4wPx2gVEEAtkBwXhR9Ufc/kH7BFK72FkCCN1bgv9rcFIOH39Bj3d3dOZoSwtQHSGGKzAmX/c5y6uEUkZRidQXgz5kLH4otqf7R5dZqfJGVzlgjD7n2YWVPc9rRsParQjB9TMJeY5scX/0OmeVXxKn3Py1Re7jUp37I4nfrUouavjYue7Gyhvorm0/0MVazN5kg95qMF9lFx38CsS7U1p7+IT5XPzYtK4OlwiBSc0NZpK0loavyGPB/7X/VnL0kBmvTyoYYVc+NHQ2Zm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A12Qy1Cr7LEpg9lZLZ558nfF7ezGTobbz8ET9RHvmSCKY9U3Jm1gWnUfrCUVwC4zFWgWUsMx2oFu6VOvcgHwwFichJm175iXeBXeeSSD1L2mG83cpRLAMR/c8mWVRk7VKHiSuu6w8J0jonUUgwsA0+xZznnjqVo0uC6izfWGznLg3m2fQK1/OkdqJwbpkbjgq6uo8QCFd82vdlA2B7tPLoKxpIZ10HB9p4GyDbX91kSSoZ63GVY4TFmciJzOPjN3rHgtZvXm8sKsdMv8cN8VU6nYkFqrZjyX1Drog1HLzGR5s/zF78ji3dCgxVbfoIJEUH0hNsbVPuejusR99GGVqo6eJc+ZoL3iGxFsZIB51lYgrNzNacXuLDqDlOTikwP0AFJQv2S6OncxZeX1DIkY5BeI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fhRCsHMgVeTHnjgegP0/0QaBEcUey+ctaP0iOJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a6faaad-4335-4dad-39dd-08db84b230c9 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:06.2143 (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: DZ8GT0RHESuwIECqflJx0UrG3CCMcUqupCQOoYf1FczNZ1lyZXM1c/6veGmReMYGHv8xVrgsGDSdvZihIFzrgftj4uEVcuyOz56tczmRoxI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 8I66hg7ReKrm35LZ_7E1xk18h4VyuzEh X-Proofpoint-GUID: 8I66hg7ReKrm35LZ_7E1xk18h4VyuzEh Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has ses have scsi-ml retry scsi_exec_req errors instead of driving them itself. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/ses.c | 60 ++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index d7d0c35c58b8..f3d497366af1 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -87,19 +87,29 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code, 0 }; unsigned char recv_page_code; - unsigned int retries = SES_RETRIES; - struct scsi_sense_hdr sshdr; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = 0x29, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = SES_RETRIES, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = NOT_READY, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = SES_RETRIES, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { - .sshdr = &sshdr, + .failures = failures, }; - do { - ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen, - SES_TIMEOUT, 1, &exec_args); - } while (ret > 0 && --retries && scsi_sense_valid(&sshdr) && - (sshdr.sense_key == NOT_READY || - (sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29))); - + ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen, + SES_TIMEOUT, 1, &exec_args); if (unlikely(ret)) return ret; @@ -131,19 +141,29 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, bufflen & 0xff, 0 }; - struct scsi_sense_hdr sshdr; - unsigned int retries = SES_RETRIES; + struct scsi_failure failures[] = { + { + .sense = UNIT_ATTENTION, + .asc = 0x29, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = SES_RETRIES, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = NOT_READY, + .asc = SCMD_FAILURE_ASC_ANY, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = SES_RETRIES, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; const struct scsi_exec_args exec_args = { - .sshdr = &sshdr, + .failures = failures, }; - do { - result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf, - bufflen, SES_TIMEOUT, 1, &exec_args); - } while (result > 0 && --retries && scsi_sense_valid(&sshdr) && - (sshdr.sense_key == NOT_READY || - (sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29))); - + result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf, bufflen, + SES_TIMEOUT, 1, &exec_args); if (result) sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n", result); From patchwork Fri Jul 14 21:34:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314244 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 BBB33C0015E for ; Fri, 14 Jul 2023 21:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbjGNVih (ORCPT ); Fri, 14 Jul 2023 17:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjGNVi3 (ORCPT ); Fri, 14 Jul 2023 17:38:29 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6136235B5 for ; Fri, 14 Jul 2023 14:38:17 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4DeZ003063; Fri, 14 Jul 2023 21:35:10 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-03-30; bh=cVeL282nvfOA3+yvDKdOMj0c+JdqSKOdqKk3lKBB+s0=; b=UdsXGRMM8MmiVrXwZKqKDDbpPT5BpWMy6VCgi74DhEXaYNrjCRc/Zx4YIB6mR9Q5RFFZ W9N31CI3W2Mb6E59zfUyif6bEg1yeVtwD31OVQb0c1EQIBVzf0jLi5vtr+FAdUCFETD0 WEXQ9Vqoj0ZS1jA9gZ8062v/+bN3dxEu9ygDJE6zzTaZwW74SzyCzsqElGRIpsdc/Z3+ pYfDwrxu8TEGFmNdDOPLUYF2NOPlE49cL50HWQ+g30aPLQONhaAAoIDV8+PNoceqLUZ+ yN7fsfyWOODCzi1E/zMxvdJU+HMpTuKeue7wJqedaZ0FAtd8JQt1ZvmWu5yRFVKbd94N 7w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:10 +0000 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 36EK1QKo008666; Fri, 14 Jul 2023 21:35:09 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpw0h82n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DgspeLD0yzDEk2KxjAkvkourygS9fDn1PK7/30XmtrJMYikYdUWtzNlJIgr9dPwtEy++7nUpoF+SPy9D/Nko0rfUzoMtU1ntAm07uLUsYAKYhdMPENF3+DCpjXzG3TxEOJUqix5uIghRDMOs4iMM3PdQJ1r81J48K6ABoyfl2blXmYnH8v8eFQuqgK5BoYONKcHsw2d8hjWnJIcZgi6MgRrredjstLhg2iY1TDDVvxWyXhZylIaUSmpYfMKT53Q+cXVhp69b7Y2jdTuIEE4LCbbF+tnNvcpjzIawIt/LJScoknWIckHLPuACj3Tum4jaui752g0WjKAhaIA6CYEwOg== 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=cVeL282nvfOA3+yvDKdOMj0c+JdqSKOdqKk3lKBB+s0=; b=C4/V5U4ZLypgyXJTC0ZVLT/MZ+sokrfQ9hs1ds/T9rSLIXGTjgSylvkBIgk1XoxBY6B/b+gI1QcKtiblDIPj/xLhi4U8eZ6MlsJpiOcZcQ6If2lwnD3Mzjqfy0idLFqhgskifFCnXZqUjUdbkpq4u8vsLmHj0ATVL55yZJ1sWaX6lxXTIahs1y7hskERAh1tEuHRYujplplyHPcxuTiz2qg2yNIIIvwLjM6dV3yUsbQTr29z4pG3PczQYxEhshwaUXFEteGBZmzfkHDcmogtCD6WN0nOTSI5xIh3OO7TRFJ8Zqzq3kmyYrVen3uV8Xs/UikO2QQuIdq2e/CP4+pT4A== 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=cVeL282nvfOA3+yvDKdOMj0c+JdqSKOdqKk3lKBB+s0=; b=jcRV01QUM+uJXH8+2iiodY42sIEnO8LInl3vqAu6h7S0Wh046oKzjP0I5QT6Lo08cfK5zO2gW1Hixp4S7iWFiV1XyTV18n19ysSwmc6qpr4Qy+NMxLFkyYRymCS+eo1pu6Xx6bTYAqsIp6HDknMv80kG2/e4HHctQl50fytvc8A= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:07 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:07 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 27/33] scsi: sr: Have scsi-ml retry get_sectorsize errors Date: Fri, 14 Jul 2023 16:34:13 -0500 Message-Id: <20230714213419.95492-28-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR07CA0012.namprd07.prod.outlook.com (2603:10b6:5:3af::20) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: a4faf154-d54f-4789-fb83-08db84b23187 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WrP6QjGNVTmeCIchERh740uN/1JmMkPCWyj7N3TTwtCHyfiuuSv2XSexbsxcDeWhHl7OHgb3RL7x+WmqUd7q6qbE7KDHv1zf7GNv/iqk0I6tus5fdsWh6KdqJ1sAX4axDnMriSgb0FqOiTtFJd5E4uCjlNWS2UCGr8dRaILhLluXx5D5q1/9Ct163a2/mgYKp8txKDZz9mwKy/78m0p5oaET4qE7uDwR+gqPd6skQ5TMHgFs/GMrcfUowTDpuKuvVZhWfwmZJxtIm9QMJCrn4KYBv9JfOIEoNOgKXnLIC9RHMrUgg+LuMiVC1GE65fy+lKLEvgxTQEvDH+CF6ghchiEPUCK2fx95kQwuyCRXpyC8C+yuKe1Vfli9c8YyCdBUlpGSd4BKb3q8i2vrvXWrTh9f0TO5Bitcut7Bv80MJlVxdMpcI/plXDCrht60KWuTJH4ss3wbh0XksIYBZkBQE4dPOtrvxzES+QEXJwAKtatN5RruQETm0LzBqYR6sk3FWa3uj9dz9NxAOMIt+U3duMqzBPELLvYqSJ0BE91NyYkBcTIRvLON4xmKnWHjB8DI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VdmCjULnRQqGGV5PHf6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jOwE0v71cAmgjSU22UKqVtoGZOJ8oex2HbnomJsICejyzYa8kKa+BG2ARgXi1WNHcx2Te5YDLwduZDG+tZy/nxSXU/gaybxz9o33IO+CUs09OjV65FyQhMoZprP2lRRCLcKfwRAGZKPlEJlOXFUeRcBP7Esqu/wdyO15Nt7W+hmtNo/bbSQsNKpj6kcMYWLTM+ekbez63Q42AVk6CUJUnxxtmg8lyLashTEgjhu5hr/GIdPhPguhl+PBGCbpIqkmm7kl/UavwWcqJQgzHFH2zxKY+5hG6K3MvTX17/29CfJd2//1j2hZMcESmHA6SYczhy2PBURKWjfbT29KUNZ8HiqGdQbU3OKy+ndG2SkezUYRgX/dtA76SEeTfvnKwrKxBWbD10/qcM2urq6QAaw/cFa4ZOgIj6h3NzHsV2HsIG4Wq X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4faf154-d54f-4789-fb83-08db84b23187 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:07.4538 (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: /JpkcISXj4t4Goon5DYRSMoHFbJK9aQ/YCwQl7bvRTtfgQcgsmmhgmCTPTkxlyAgc07HAhjShZwrnv0NAstHS3W0YvDItNESav4tQtBF1DM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: qxkHvthSY2tvlZVcMe1zjjpM_CyR8qhw X-Proofpoint-ORIG-GUID: qxkHvthSY2tvlZVcMe1zjjpM_CyR8qhw Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has get_sectorsize have scsi-ml retry errors instead of driving them itself. There is one behavior change where we no longer retry when scsi_execute_cmd returns < 0, but we should be ok. We don't need to retry for failures like the queue being removed, and for the case where there are no tags/reqs the block layer waits/retries for us. For possible memory allocation failures from blk_rq_map_kern we use GFP_NOIO, so retrying will probably not help. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sr.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 07ef3db3d1a1..100480f5bc2c 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -716,27 +716,26 @@ static int sr_probe(struct device *dev) static void get_sectorsize(struct scsi_cd *cd) { - unsigned char cmd[10]; - unsigned char buffer[8]; - int the_result, retries = 3; + static const u8 cmd[10] = { READ_CAPACITY }; + unsigned char buffer[8] = { }; + int the_result; int sector_size; struct request_queue *queue; + struct scsi_failure failures[] = { + { + .result = SCMD_FAILURE_RESULT_ANY, + .allowed = 3, + }, + {} + }; + const struct scsi_exec_args exec_args = { + .failures = failures, + }; - do { - cmd[0] = READ_CAPACITY; - memset((void *) &cmd[1], 0, 9); - memset(buffer, 0, sizeof(buffer)); - - /* Do the command and wait.. */ - the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, - buffer, sizeof(buffer), - SR_TIMEOUT, MAX_RETRIES, NULL); - - retries--; - - } while (the_result && retries); - - + /* Do the command and wait.. */ + the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer, + sizeof(buffer), SR_TIMEOUT, MAX_RETRIES, + &exec_args); if (the_result) { cd->capacity = 0x1fffff; sector_size = 2048; /* A guess, just in case */ From patchwork Fri Jul 14 21:34:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314245 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 91703EB64DC for ; Fri, 14 Jul 2023 21:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjGNVij (ORCPT ); Fri, 14 Jul 2023 17:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230138AbjGNVi3 (ORCPT ); Fri, 14 Jul 2023 17:38:29 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F33E35BB for ; Fri, 14 Jul 2023 14:38:20 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4bNJ014926; Fri, 14 Jul 2023 21:35:12 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-03-30; bh=m92yvgf0SoTmqBy5CyfW+waaXUiO+ASPolyL+wf7mHY=; b=nStnpEhYpfWLuVOFuQgOvsX2Zo7ntyR0j6I/gG35H2fuuvwcKx/m3+sIp5ydgnK9RkEv uABN2NLHegfX1SUfkJhBztPq1K0gxbUD4e5wA3MwlHmUd/PXBnZpMWx/8ufolNfeWbsN 6DwXZJgmrBNnm4CTgr9gY8Q7903uAzCot1DtmQ+6BXbc5x3nvD+0Xeb07kOPBLh/dCic qNriIDLKHNIA8EQRwVK3KLB/bw/e38nneRRtW9jdughHwG4NSta9Cq2UoXIPLJ4mEs7m 6gzY/mt7pdg6VGalr1yjYdjJ9EUZF2P0JzFX3GUPpQKUt6yaj8r0nLLv20IFVs/+kCNd NA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptx2f6y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:11 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK7HeG007622; Fri, 14 Jul 2023 21:35:11 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrw6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7x87TnGadGC04B7EiY7G0TuiXMyJU7/BXjIbL0/5zQK7jMLc4BwtsXj34spW9Nz873sanWSoltVcWfjH9SfX0Kisf7GCZE6teVS6JSLtWVj287ksIzENwdkoMRg7psXf+hI0Edr3Ek1QePPTptaYu0yALmNko/BEQaAB8KW9388FpTpCHWcH9V7EjEit5c3LslIlg6sJPIpTkxDyaPndmseX0allOI7cBglLUVuU0zakI0bI5L+iy21uwFi6jtFaUhDCJDOhLo5XEmYYA95mf5od+PfVVVRUwlufab9MIcKX+ct0ZcIB15qEE1+YGob9P2LOJpEt7a0mJ2Tn3p2rA== 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=m92yvgf0SoTmqBy5CyfW+waaXUiO+ASPolyL+wf7mHY=; b=ZHF7Mn3mruHEwLcDvi0hJzIzSiQStw/AY1+tLitTrxtdGOS4NKDHhnEUpYG1/eTUwTEvkE6GSY08htQX3Nvws7tbp/A3BBl2Ut//fjVa5Fwyo5SFWZON727zcMKY50fqKtUy6pvlSBEwUhsIHAgwKMGDv+ZbXdiONt+ON/cwonJXpJL2VKVxJK+N+ih+q59sFqXSh+CrkUUaaTPLrpASLvlPtUjBUfhQiECiZkx5qWrpLds2KKIyijQi+wgFfGFEYLsrnmmov5pdGikdK/r0MvaFsrUm5YlcIeupVS4VakHX4FYS0yCMCeSn2CxAty0PnftA+UAoVEG/JsHN1mERMQ== 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=m92yvgf0SoTmqBy5CyfW+waaXUiO+ASPolyL+wf7mHY=; b=t4ibPB9coboWncJMB89xLf3N+4K8pRvHl9V9WE87MiD9qKrnv+vjFo7VYL3qDXZWQJljDxoHMhD/67nFcUwSM6Pi7XtNS+7vnKV8u8pIN2Amub7iPFHHOQMMrpoxsN9kFVUgClhv0fYbCXe9MDF1ukZ+VimWtwPJnWzeKcKGxDg= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH0PR10MB4921.namprd10.prod.outlook.com (2603:10b6:610:c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:08 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:08 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 28/33] scsi: ufs: Have scsi-ml retry start stop errors Date: Fri, 14 Jul 2023 16:34:14 -0500 Message-Id: <20230714213419.95492-29-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0102.namprd06.prod.outlook.com (2603:10b6:5:336::35) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH0PR10MB4921:EE_ X-MS-Office365-Filtering-Correlation-Id: 30f807d5-d155-4e73-0c08-08db84b23255 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IzTTyDSoymWOr0sPxQfxVejpH3VqF2h9Fl0MzaLo0whbRTOim1nS7jO1Epw4azKKbtDqqExX7qkc+9LOZNtavm9c+l6luQVhtOJONOmudoq80d+WobdCC4uBP61Vi5ojnfZYASqNx5UJN+VOOpv9XG4lS12diIGo61eqOfTB5/ThnNXzfVGly4Kkbs1hS2edQ1ZWPd72Tvm4HOREHmyonvxckmwhEOGMqjbTTsftKIEmy2wJieye9GE9U6nCeaW5VAVlK6fH7eEs16Otg2KQkequzkrGaNhN0wa+o+mo499f7Om4qKuMKVUhqFPZ5w72v/pu/ZoBMbkyUBdlC9OUfLX/STMMJ9OLzhO475K1l85Np5+Zg9R9rryUyUhB9z8Lng/3hHe+fclUYhhH8HJpeNphultnBk1BIdW/ZCYjIxFzvC3a739jeldeReNEpk0Csxs8iLIDK1PfGZ4s+PSBZThlf0lejw0PoKWFhwcLDOx+EWWE9IM/UjfAA9gR6n2sgyd0wCIfcXl5vv/HZO8TTQ+i/B1yzdxB4Z7FMDrRufqkQyGsdCCxJ3xwzWZEldpG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(5660300002)(38100700002)(41300700001)(8936002)(8676002)(316002)(86362001)(2906002)(6512007)(26005)(6506007)(1076003)(107886003)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(186003)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fBvyZqMml1yNRR80i0V4r48d3j+rLKUV3oAQAJuMP+LgN2nHpPPxArnpcNV6bVF6pQlLVz2zlLcLfqXv8cVTYsf6pmnF/s5PKJZdV9m3WsiRv55XYRErUE7sOWvDobA7/yudl7Vu+lBYkf4GtzqzpnxV83de7Gn4O3rtBNsgmCW8SlixmQ8JUrSF/cH9q1rwt0NCQlWY7VmVDH3xJyq7v12M8ERy0BvQtzAnKj/4zgu1LuTZbV0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/bLOFcsFt+TuqUg9CeprGCkfAtwDMIPr76ifSY6pi2/W1GGiYaZNaWocUpHYQL+Xl+UcpApmqMkaLgUq/P7Y8HHDrWdGPyvkhHB6KQAMcxYYN5vrsGRktbQgq9G4EGlqkVlPC3Pvvoe61VN8mQCqUIzfJLZlC+iMdIhSqM1EBnywgfUZEdpku8HllaJ5xqMB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30f807d5-d155-4e73-0c08-08db84b23255 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:08.7928 (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: Cr2dZvvW4NOF5e74ieZ3URMwB/bYs1W0PQY0ZYKPXT100JtZc2WsNE4of+fX4efQRVlaNxdRUk9e+vV39aSi6Q1ngG/mJREBLNGQptVSrbA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4921 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: sGVr7fxev82uYO8mLbCIExK8dYH-kVJx X-Proofpoint-GUID: sGVr7fxev82uYO8mLbCIExK8dYH-kVJx Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has scsi-ml retry errors instead of driving them itself. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 983fae84d9e8..267c24c57396 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -9291,7 +9291,14 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr) { const unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 }; + struct scsi_failure failures[] = { + { + .allowed = 2, + .result = SCMD_FAILURE_RESULT_ANY, + }, + }; const struct scsi_exec_args args = { + .failures = failures, .sshdr = sshdr, .req_flags = BLK_MQ_REQ_PM, .scmd_flags = SCMD_FAIL_IF_RECOVERING, @@ -9317,7 +9324,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_sense_hdr sshdr; struct scsi_device *sdp; unsigned long flags; - int ret, retries; + int ret; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->ufs_device_wlun; @@ -9343,15 +9350,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ - for (retries = 3; retries > 0; --retries) { - ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); - /* - * scsi_execute() only returns a negative value if the request - * queue is dying. - */ - if (ret <= 0) - break; - } + ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); if (ret) { sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n", From patchwork Fri Jul 14 21:34:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314246 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 2DB4BEB64DC for ; Fri, 14 Jul 2023 21:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbjGNViq (ORCPT ); Fri, 14 Jul 2023 17:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjGNVi3 (ORCPT ); Fri, 14 Jul 2023 17:38:29 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B068D3A81 for ; Fri, 14 Jul 2023 14:38:21 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4E8H003214; Fri, 14 Jul 2023 21:35:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=LJMee1VnjufLcgqGqlFFDdvzFDPxZNYpwlP1KqDbDWs=; b=3tQ+RwSLWjI5HCVBzXt0M4545fDxXfqCFQHfUBCiNDkcDc1cSU5F0YzZHjrAAkeQpmMY tVGHaiCACLqjb0muqUUd0T3ZUC9uyX3e4BIFpMtYq99+yxZv4pGrhK/DCwbW99C35OME yTrVabOXDTu169pMD5tCOUatRhqyNTJ6DKgpO+My3IXWsUpSCXxQVMZ28Yg8yeZfy2wY ipjiLD1d4CmusZqUj49qxIarRp7kH2txptuBNnbBoVhvyOSDKrYx0Amb0WoUFTOpQEmv yqojMcVwK1mL2pYgF4gdVgOPQfEkmn2s+VDQCkMPB7UuMScpgd65JXw9l7+6GL25UJPb qQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9v9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:13 +0000 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 36EK1CO0032984; Fri, 14 Jul 2023 21:35:12 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvrs4vt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qx52OHGA+YUh7pEnU2cHe6ZjXgH95gctdu7gVJXTdrCPo8c6rSDvn07n4ADWp9+DbOdKVCcluRYjezWquD0+a3pG++0GBl4/j2OSROU5IgG9LUSdGbhzqDbJVlLFtyUNuZEhULUJBRko+Jl+BO69RIH0rjM4G/ks6FlvnBlc2lh34Zy7vb+dFjlAVfHLRi+qnw2KTyo71HN/uUDcMP0F1ycWCVbwN73TqtvBP+PVfStBx+CVwoVCMZGB9wC0sdTkGJ14aKbA8+CIoR8TE+iDzWE8NnJKzaQAO+V6/8Ox/H32JvBBW9nxf9OIWD0QCbBuqAm8AKx4AqducgS8sKoY7Q== 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=LJMee1VnjufLcgqGqlFFDdvzFDPxZNYpwlP1KqDbDWs=; b=Yv7IiYuY+F/KWi1YSvhzTK3K1VSBl8h7SsQnvHq5odSuVz+IDdfDacIFPuBfXWn++o8xLVJ15CVEWOFSPOtzMmKV+yo5mQsEG/d3nKU7BcbpDq45zlDIl84BWVmlV+8WCNhJj2VtFIF6XuiR4Ygy6j13isFb73fiuB+D7yTqUlxihnFYuakW6aiteJKKEGcmNLMvJKoze6LqNCJ04Aj7nfZJ7W6nN8WbgRMAoBPc4Xlqr2A42flmRzNceLnlUKm//0y2SffiqE7BSn7PDRF8vtoffBXeHLPPaGyvTRniJEn93Hp4BbIMkHdZyk6nWpUkOC5PIrmsj4ivFdUiwdEk4g== 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=LJMee1VnjufLcgqGqlFFDdvzFDPxZNYpwlP1KqDbDWs=; b=lMUut+hAv5g89gAXapwLr07AhjuPtRSJNk/HY7j/27zUxPetD4TAK6W42OCUjoc+H7ZkKgRmCxgD+H90AqKyHhAtKL95wVmsWG4/pQX/qKkmbQzi+/byQq5SryX/AEEJoXvqefDL2fVlOWXcdab6jpjvpoM1XIjrkKGGtU0mlZM= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:10 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:10 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 29/33] scsi: Fix sshdr use in scsi_test_unit_ready Date: Fri, 14 Jul 2023 16:34:15 -0500 Message-Id: <20230714213419.95492-30-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0086.namprd06.prod.outlook.com (2603:10b6:5:336::19) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: b4d6a1e8-3e7c-497f-ccdf-08db84b23351 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EPuLzDd50H7+DoKPLkcj+nWc56+uwNcoGMCo+8xEsBqSz453qPdmpQY1Z301qIH0ouRxZzZKqFiMqfTnkIQBPWqCG3Tkbr/uAUeaBYitb8K2aN1oVhcXF5buGgh5BCU/jMO0NtSXcacZsr9umyJ3MgHky4YE/3Dea0MbgkY6J36XeUhU6kBoayFlRGtJ67d5K2Cdcx7EFIQMb8B77KljZ7qaJdJ/ozg5ykWh2PH+Hk3MQiT4STpJy+I477K0DNLv3xN77spLISOFWR/9R4ptgd7F2eyabiPOMwDTOcYWG/nlW9iw7WDjDmPzkVclFNjUnNLaxJgCiikKQYBWasLGvuxJ5Rh/9sMj0MnYTmXsG5bFwxLbkEwstochVJ8rmcLOx0nNf8OEW0il48UjGKREEB8Y+B2dwLyzxm0AmWSkq5kSB3QeLh689+Mp/Dif1KuhsfnK0OiM8UVQuhkV+oUlak4Fzwrx7FqtQtYLLkHRvJG3tFwIpGhkIEAGWvLsJRpSvZX1sVvDXCGJ3eDa4tLhzfvBtGXw8teGympROMM+AzajrjxOi+Mus17OArXM7kdX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uaLToTvtUG/qyAWSTmozR47fdrvWN7GjdvsnjChrb9E2+6O4vw155SnqRWSiwe+Mo18iW0MxJzUB3FhwFn6lD1qw5h+ACThAbJH81sObfix/9Mxr3ZG1vJ4bR+gITXMFP4BntD9+9rWyIwTDZVxN2zsskcicJZVl+G5I19ztwHDS+Yu/MxQXKpS4Pb8xRFU0kerzdYIe5BHoKEUEhaMNbPWOds3+drNz6VxSvpQrMjrR3FvJlpIBEMZJlagb7XRS431JToiFqaWEJTn2eYcH5BCJvBa/bwgszHEcmRSsYcm2x1buposFRI5pPhE3TJVQ70/dToebAPD0peQ8ORrDRueuZwvAbce6Xure+zWbXsY0477VkA8JtJnGpCJR2HzDgOm2IIOQjJd5pQvmz0oTLQKZrIQ6mwDLmjLtgbp87sLs637ErakRmJGV6+xe6hQC7rXS7oIQRb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Vic2I4NkU/BZJH20R/0VbmTXXQ1QInAaIAJnZjNmA2ZR156ZwZdlvCQZQ1rF8xqufLkhXn6b7BpsblLdw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: id8SnC2dlykDeVxVfo8a2LmjckKGeQMGhayvB9kzjwjsutEg5VuOtmHYIkq6N07YV/gR5NQmZLZa+Lj0udpDdRRACu9O/HjP+hzwMJcZjisbd/MBxvrXCiWdZMEE5B0FiJIfBhb18TBCsoI/b5ZOHCzzTJpMTtcQMJ9ADJ6+D28XIJbh2FDfW8SblsbtCKeplw6OfbGOKSbzATqSXxKR0hR6OJPU59G7fWfiQcRYJ91iJ1TC4lhe21h7xs39bot6yNsRgKF4gIThDdxil5ISFK6jesiNGx6DOsNgrjwP3NRZ9AlB84tcPc56k9G+9LmU9tlfpoKUZQxaJFPd4cRYiRXDuBhG+pdy20HO5QMpegsvAiyVOT7IPesXFmo/nMwib97lFz52W/MCKPjO2Y+0aU/v/ZnEnaXQpmrqQKdq1IdCPx3gAluOIkB4dhg2zUeifcuOLurUpVxzmb9Tiz6bsb45Zuc732VpK1kW3g7Sdaw5G7rWQWWlTcjX6FjVZ6ng9CIINjbi3XCpRa2cBUoqWtiDsxD9oFbHdBSVlG9PVDK4dN6rL4rHa7DWGZOhUm8IcMZ6vxJG3nf0qKIkq0ffl/Ijmacs1MelUXWjmz/9/2GKs8YVoezla14kSymtDZP7Nl2BxD1eRyxb63p9A8fIWoLpibBBMEb1jmNa0ZSw6R7YvmHf4OkUj6s0m6ej/OMvClXROhyu0mknGl9uZgGPZRfrJySgurDh/Popz9Ac7dPNLWeXW0968wOC3HDSbj+KOmKhNefHlUAUBqllp+e3mliztUNhn7OCfgJdcdb8/cwFr+DOoOIKmR9kB0pv7UayMzWK6yE3FLVINYPXc1lmLacWzT+QuJPn7jTBKm1mWKhed2ws9ekf1DIQCg8ngINt X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4d6a1e8-3e7c-497f-ccdf-08db84b23351 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:10.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: gZcAmayXSZoJ+TZmPBDfubZMgysi6b4N/dH7JxHplF4eAm8xooMTCuHqikqnwIow5Jftfr7q35bVHVzvgnhCerN149v7rXbHRR2h6i6/REc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: zQQAz9NYzm28UuGyoZq1LeTdRPA96Ttf X-Proofpoint-ORIG-GUID: zQQAz9NYzm28UuGyoZq1LeTdRPA96Ttf Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 26b21e20ef0c..393cc4fd87b7 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2319,10 +2319,10 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, do { result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, NULL, 0, timeout, 1, &exec_args); - if (sdev->removable && scsi_sense_valid(sshdr) && + if (sdev->removable && result > 0 && scsi_sense_valid(sshdr) && sshdr->sense_key == UNIT_ATTENTION) sdev->changed = 1; - } while (scsi_sense_valid(sshdr) && + } while (result > 0 && scsi_sense_valid(sshdr) && sshdr->sense_key == UNIT_ATTENTION && --retries); return result; From patchwork Fri Jul 14 21:34:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314232 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 39321EB64DC for ; Fri, 14 Jul 2023 21:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbjGNViB (ORCPT ); Fri, 14 Jul 2023 17:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjGNVhy (ORCPT ); Fri, 14 Jul 2023 17:37:54 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3748235AD for ; Fri, 14 Jul 2023 14:37:51 -0700 (PDT) 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 36EL4AgO004653; Fri, 14 Jul 2023 21:35:45 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-03-30; bh=RYup95xBobh23N98jIJ7ZY9ys72fqnmhj5Qepf31Stw=; b=DLOcUzQPpN2EZIwqlpRvZIu1/tcjcSrGFEs19XoJQ8yN20teSwG/CqQu4LEywCKqHjII otf9RqdLIEDWdF6pR5CpBcUYrmypCkfzMiFCFRwUOEtqwtx8HxJY4B9Z4cwjJRF3Oa4W YmT5Hykc+RsOqai+ZzkPg3pTqqRfi0gkd79MuodOZdkZRl9+KW4uwDeAZ4h6r6xNTbgC q4ubq3BVUZuCmESmVfpbEqNwI8LpEqf679JHRNTzZIB4PpzAqEOa9etTeJtRrJhRlHt0 kCDDQ+101X2Q7wj6Vkn8+wqRtkFCZeuFBfWWfwStdkhrALSz6nV68Nydm884kl/QhfYT 0Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptn2d4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:45 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK0JIl007621; Fri, 14 Jul 2023 21:35:44 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrwye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jG6vjlpwVtyF46F03rKtMvV9F7vugtnuqWCz/c1qTHmJA5iGXkb/+7pELNM1ctbQ1v5yyvUh8uFjTk3zGMiBQA0NxjGzMVf/UKlBIwkw95WK7d/swohqS8keREQlT4+62q/lcOf4Kqv+WfD9MiVRVDFAabXSvnrYsltO+D82XK8SfaMAQWjRg/GiJmifF/H2COMw+VsjoWFs9SpH5Vw+PqFC8ulMsqX0eLGKS1PaBQOV9qq/o32HrcE6zfy8dfHBO6cd5XtWEex7owjNo3/IflcTJnsu4/Oi2HIcEdc1l/BasEekqnCEVZ6I2wU8CZAYx32yiOTufpjdgbIA0IwJuw== 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=RYup95xBobh23N98jIJ7ZY9ys72fqnmhj5Qepf31Stw=; b=KchwxMfwJQxjmItHRvFOurH26qJrp4iTgd/5wMvb9tLawy85cQP0SrmwqNIJzZRe6pBkV1Mn3O+SqGIMc8TkmujKMCJZRYTmn+VuMvXmZPCMUn7YLbt/WNv2tbsw9DCj0eilqr8TuaANNsR1Tnwm9Bw40FuI7MWrCCEct9F7Y7wqF6U+GuWuXcFCnK94lwN/kuEODeMSlGkspvNRoJwbqFv9sl8RykdVTSu5PQH1gSyfyUA5ocaApZWw1nGx0n5hrP7S3jM5Ig1hBoZJ0uq2Y/xkPg8fFPA9pcFZvRXF6oNTE1tyALYPMvsLxqMjGJQZ9yUFFHoAHVvEpupGtCyHbA== 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=RYup95xBobh23N98jIJ7ZY9ys72fqnmhj5Qepf31Stw=; b=S2V8RPMpg+ivvovhs85Ldc9wETveXGnWc9Q5SP48Qjrg2EXOVstfF+gFUNk3oFt8mrGu4hggbiPhsGBWQSmubOribX7gsfpt9J7kMKQztjBorJWkHzMvDFeQ4F2iSFKhwf3simfAUXhg8g3kmZyVz8WyPYSl63FhEPwmYnO592A= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:42 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:42 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 30/33] scsi: Fix sshdr use in scsi_cdl_enable Date: Fri, 14 Jul 2023 16:34:16 -0500 Message-Id: <20230714213419.95492-31-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR06CA0023.namprd06.prod.outlook.com (2603:10b6:8:2a::14) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: be885a5a-1511-4424-665b-08db84b23447 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QL6KzPQ9B7nWI6MiH8awt5gtneP1DObaI5AhOCiHLEPRBcPP6YU3xH7Rmn+0qavIrFWZUClU6Ta0xxOaIj1hs3FZvTePMtl/TgbaxJnPseoPFsbRJ4Y/fRkRzLU1bfxXRUu+TryyjTjLEkOiJga3Z8Y3WPCXKd+sISlr6H3WqDma8GMGMVKZJrzQDl4LG4stHxoRf1t7PP1jiob6XNB3qiGmilONVzSJ9PAdHuxVw9qmKbw4i7Nx7tE2akbBDI1ArMViitZMNw8KGI5TcqmxeUpgx5tbd+1fbFbi9ZWrFzDY6ZGDTK/iQvu6RPQUf9IP8FlkUOm0oEF5WZUL859GLn4VJM/NIJCUEyE9NyeYG3ar5isEQ4Kd/J6SQOrHGrfq46ALrzgDNZ23VcTHiw3mKL9+q0bPerO0TxINreiwQLCN73auwi0fz6kZOTvbWsBKaTJi4YxEWtNb/HwHCdzr+If/NBSFhgfUe89HmuGt0Xxz6CDNMl+ErFvPmM9R7WmUmXx4LPS0dZCcccp92D26xWdaeGckCWQ3Z8dL7MJWkALChzpeMukKqNQU02Nq31+X X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(4744005)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT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LP0KYafbhfYYxwhs48CeWxE5fDfuewjWxujGHF5zBkjX8TLfd54m9BcqAjsSOk38toS7PrCB5MEJa8p5y0WTIKVl2Q3nx9EdKo51k3XY0TAhL9sqrFjoik8H7dO1X7CbTSkjyBVgEXbHUgIGSSHA4UmHnirAX4WxwXWEM7B4LpD3x1YMwF3pFXMLUv2X7VjPD69g9Urw/RHH5IN7OaY1aE9tlUvlbcLVkpmCVLKeCipSeS37x2cDBjmHDJTiDGd9RrI4AEpPnI6fwQrXkzKiBE+iqYbpdDYpeDvPRd/iEgGkoNm7i4dygG+3soNwuyjCXD5peDzXLqNq5RcQCRdvHN8osqJcm/L2mrTjfSTUAtdTDfTHv1yraVPAYvFpB18U7l5SLFwys4bUm0BVsYBhW+wvxEHmFJb9RLs+cQRV7zV6Pee3a4qs0CbcpYUMVybRWvMzbgxm28EaThCLAHeubUk4BykxVOJt+Yl+MEAjq X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be885a5a-1511-4424-665b-08db84b23447 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:12.0445 (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: dsV0W0jRrrby3ErHgE+76bXMSLef6lDgc9xr2I9X8M2kCDusgZCeaXvm7A6P+8/uL7ivSnB52rwPC205nBlt7w6p3Im+AJ7q0I1jgASbRdI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: 3cPFdro7wQg8GUwL06FsrrN53U1lJzt4 X-Proofpoint-GUID: 3cPFdro7wQg8GUwL06FsrrN53U1lJzt4 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index d0911bc28663..d1c0ba3ef1f5 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -692,7 +692,7 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable) ret = scsi_mode_select(sdev, 1, 0, buf_data, len, 5 * HZ, 3, &data, &sshdr); if (ret) { - if (scsi_sense_valid(&sshdr)) + if (ret > 0 && scsi_sense_valid(&sshdr)) scsi_print_sense_hdr(sdev, dev_name(&sdev->sdev_gendev), &sshdr); return ret; From patchwork Fri Jul 14 21:34:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314248 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 A36F9C0015E for ; Fri, 14 Jul 2023 21:38:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230052AbjGNVi4 (ORCPT ); Fri, 14 Jul 2023 17:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjGNViy (ORCPT ); Fri, 14 Jul 2023 17:38:54 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A38F93589 for ; Fri, 14 Jul 2023 14:38:53 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL4E8Y003214; Fri, 14 Jul 2023 21:35: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-03-30; bh=yYo8F9i4CSgMX+9SOo7HMBheVQ3QktMILoRdiajQEIA=; b=t/bqvPy1feV9SDiyEf9rIJ2HUX0Ta6LZX75xNimEkZVYN3psSEl4ET3r8RegwmtGVUlU 8WEPE7ZnC7HYQtAqayWXffi2apwSqv01ahOYfkStqbZiPdBHq/DB08lAv0O6MoA4pvYe 6ncZzCBQTqiju4dw5fZuBtBNeawyqXy/CVdNgmhcMJQLPQyp1n4Kr09CkmWohSDpfpts +mrFKyEs0oX8ed7RMzMqxEZf1KPlfQ+nLY6cMBb9yZXlr8WpQqWw0fTvcies+CWouosG 0y5nNTCl96Q0MovlcetFSmvvexl5oYwzP9ur6dMrAnZVNE04QxuX2fVSKofI2A6z38XT 2A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtqnct9yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:45 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK0JIm007621; Fri, 14 Jul 2023 21:35:44 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrwye-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NOnKFb4q6mIHwKZmEJlBBt7EBgzXLMJpdHZaukegCPFrhofrnZMAhialJVP8QVASIHQNtBkr+8jtrKUuFkSRaqRRlXFatcZwJYA7W0dzb2YRZoiTlrF4XBpI3KF/07VMGV7Mg7szUkNuLI3v1F6qZx56d6HW7tBsZsbGgFeZ+h/vqEe2y4UsvQZ13jCuSkPIAh3bw0Sgi4qvDb3NPkFCaMCNPNdIRG8E3LQ9w3djSrA2l6Zu4Wg80GCKBP0jXQFXu5X/wyeHgsSCsyHKBIy+DGsKUqmJsbs6CgDiS8CPatxiZu7RHcih5HHwRSzubE3rQ8jcglZTOVNVKDNPWxS2hg== 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=yYo8F9i4CSgMX+9SOo7HMBheVQ3QktMILoRdiajQEIA=; b=V3l5khzNPFsMoudspWZpEssndT+O08Tqqzal93Vz5bToZQuI8a0JEIXYXCWgpszzUKBDJ3QM5zESCQaS1V//0c6SAlZCSjxsEb9nRO0NnXLMHPx3AGezfll6DJqf908B80ZcFbOLfXZ4wKNZ5yqhBohIzeaYLi2+1OB0NIVqDY9C+Is08Gz73GXIGkhUd2M0cKSjuDnv8lo1eCVZyagxRyzx7Y4Ud4T6vCtctkPm4XeQ3s2nXzEko/Y8fEUd0z3RrZO8KBRKrkBQWgUSBrFkYI1zeS4JRN9Lbhlz8Zp0lFfEo3bMb1rKIOO9ksr7G21ooVAp6k3bcfUOYl9RhxXseA== 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=yYo8F9i4CSgMX+9SOo7HMBheVQ3QktMILoRdiajQEIA=; b=ljTgA+Qq654Fubsrj1shpcfeM/gzJHOT2DLW2xHLySwRzy6ltBodNvKiXgNtf+CoBLYu5JDi7Z/oY4e7M3ANL2vJ7lAnliR/uFxPjCImFq9bFmliH2fghgYd//nnJZE3A8q1TqLEOrMHGs38bE8YcUqqVt7MvDxNuuLil2GTTME= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:42 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:42 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 31/33] scsi: sd: Fix sshdr use in cache_type_store Date: Fri, 14 Jul 2023 16:34:17 -0500 Message-Id: <20230714213419.95492-32-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0139.namprd02.prod.outlook.com (2603:10b6:5:332::6) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: 826fcb30-5a43-4644-89af-08db84b23546 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XING3cZB6sCDLUG2VRkmQ2AKqnPqaMyLkqeURq0Hak+Qh30aVTHFW8sbhyXDLTo2ejvyrUaT0Vg+mt5LEMBaeNMcSAlf/PbuQ8o0cqeZx7Baq4u5OaIEZGynDawxWA/8OHkxbylDx1WQ+57vVduASHafU72p4BTjF36eS+5nu+OSS2okrc2TKvL21FrY8yd8rCASgUDjAjCmL7OR/biFZ3jvY4YlumrZ/E4KVgk41tvg2hmft7bY/Uuu92HOkYOcDZpkISrBvkSA8QfBSDUhYSEEsrPKPH/Kn6ZN53433eqJZFDB87mFBGBWJbEW9X9MQF+VVtPuWvuYI5jzq4hl5GZYv+0LgAjnp+HR4A7aZrvQ/67j+5mdVZOClW9iaIq5pQPYFnDZLnB6VogQ3xIHvuopeXhCkET0x0TF151g0YYn9YFivfMp7ZaTCCM0D7PI3EimPGhFRgcUxSaHSpQY5aA8i5RVe51a/3CVTeqajShqxcsuvs8Gl1UdXohOUelRSAQrK9ALKki+vrborIGAqIw+uS5Qd0GFuY6d4bzZOnHbfOMxIqzOdmGExq1J4jPh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OAgd1rhEYtyBsp/r2/d8m2ZU0eqXOR4MYD6aj3Wb0pAUAqk3fNRM/h5CTt9wNM7wPNBmY6UKXC8OFq/0UMf8OoO/3noEXJYH0MgkFB6L5lFeuJ/bq+diNJ00mlAXyYLD660nEEocn04QUIjdAtXBCAaqiWU3CjIVA9giBrC6TREqG5tb5yDCkgib8PFREVXx4hFLx8g4PH4AgkAGsGn4xNpiOJVrty5hUm+7ucrccyJBwLBsx/y54mZofWz4LqWBkV0i+AntRABxNd7ZKGLqRTOIAHV86krM7DiaYssujXvjm9XI0kBfg+5L+7rlJGBad5KBOm5FvzDg+pjBOdTK9sC1RAXbKkiOCAajLuJOgK68CkUyjD9otjNyMrSmi+IZXkrtOsyUffCySWkXmwSS7e4GTiviyqCVmr0dQLSP/T6wRggfotMHSns75fj+G/OW/GLHksghS/YLmO1d7iiQa2xLyw36J3TR4W+Yy1VK34E49cUWmBG6rElgnH7uDxVta9TGUoUFk77zpISEKX4lZmzLoAE2B+bIgpmGZNgaXGDZBh6FLW4YY0bU0Enp7CXzMd/J9eLyHHEzX/QFwJ4yfmJCGifqnI6vyRusC4BoxveH2tHvWheUPvnlT0HkSggVMq6HSiDKOmmD8OMFltCbgcQ8KYchwo6BSHgV0q5s5I0CLt5FdaKKI0yL1iF9ErISGDvB3v6wq8abi1Rl+JeaibG374z3iEmCV9R4L6ERJwaph2TNvJI2LpGSn1sxDQj8WAYMpYL966v5hxKwWIhD0NuKpoV7skzee9eCmK6ou5v+58gQ+CMClPRKeDRL0DkTxlqoTJWvrbK+Y9cEqFymzEl2oYaCdU3kTjYIgsrlfVR6ROeTBU+ce+naAxdTY+BB/lPYw+krVW27UwGGoCJcDOtnTJJXkrCOjTZHjejG29vRl/oOzSTPauD0RUUYxzFT9BGBzcS9KWnoIyBeg4Yu3TKW2PydpWbsicLYytC7Bb483wlvd/05o86O7FVTgTtynKeSC216tz65p5UqGXwnovxRhfBBdpmxAdb4kYF2RHcXjrtu9//chhT6J/6g6KaNrPEW/XPYqUklnxwUVernUsP6GQua93LTI2iEfZW3meEg3m2qyQh0bVWdNF9Qg28BzvN+mrynV/zvALxlFJROqhDJZSnkuBaKaArWXnsnzxG8mIjGoJ2OK4z63gX5VHGUCI6mO9H35M6fqONhenwKhiv7/ucMZdGka3no8ZXpi4XZ9UL4QcKWYKXMaQOjrlY6akuinFQJEUzl13vkJ+xsb55VM0hva1itMbbZ/MLS0OCNGDEzHbT4Ylt+R3ETYqjeS/EDaC7uLVbs3V66dpuZb2ha0exyz1ZhNWaCwJIES64hrtZc43hElwdNYBRG+qO3MBIzzGX3K6iDT2G63Vb9uFewD1gAqpSUlUEYDw9PivVKg1VbCAW/Tm7JKtzjXhf5gAUeoxRYGQZidiarmhXubkN34e2Fey33IJpewCxqMfteZpNBVxvVHFuARu0934HzdY3VGpJl296qjCYMiUJSu15MCeuvRu/cHl7fK+v8gCce2eK22tiH1DJjxQY474vE2WsYD+hlHr0elEFz9Y7p9w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ho7kSuopalgi+rtP2OR7lq5XIvwx4x6uUkTxuuPuivxwlFOeJzOgvShrsCzXqWarl7FAQZYYD0i7VHzUz1cCtOflQc6nR5BGGrK5bmp+czXnKSgFBZ2GYzdal6gPIgMfbHLl882KJ8DefJFq/FZPtmt2QhOPMxtsyCoI0SfTIiOl+SHAEcCcxFZmLdMpdju6nJnrlyFNt4BaeXMK67J9RKcrDih4mZB6Kmr92qBXF2Mim8R5LuN+NhF5betiaHbC1xLHrj1E4BfUrqmS29Dh4VTi1V5c9iOlZqUx6RZS+DwNlLohILcevY87SX9BjbhsAi3KeyT2gjyIZAiK/Tr5Ot+SRwf5hLqw7k3shErD5IWVMa2DHbETPVCx+CQs3cdU44tIEogNfGos/6kWycY7mhykL6Ty+WqZlambY0fvR4mHA5fulfsPMi6c9HqwgHdHCN3/s0VGfktIL0TXaaxzgcmKlpApfMbs88Rlm8xMMaIatNSUaI5IqgAgEYdRR4sjk9h+dKDeui3qvhydy5WBw3JQgNBmjBauOI1xgIWThpEewz3iX5KpgaAKa5VBvNAB2+K2EHkepYzyDamJKoXhdeKLwhUff29+5u1bShH/ATxBJygR/gNbCQ3GQ/CyLeWGSXXZ32r5AL5UNHgMlB+mi4tXNQYsUXJhCXI6caCOlkF48o0WuGBM9exAvcQIuzbw8eeukSsGHRWgToP+jONg61vkq/rWW3SGtfbqdQej0Y1vOaFLIxdPCaLsEGH+2Cgda34Z4cUpDmmVvqzwr+Kib6ljMLMLABfwfPk2Wc9Q+rL7NmaIKyIdpZ59HmBnzqW3gyMrN140Tx+LVgSf51GGoSN05gf1RTMv6b7T1Ov0N9tYg+lQitfRRySRrdVZRZqy X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 826fcb30-5a43-4644-89af-08db84b23546 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:13.7211 (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: li0bMN3BGai8eFiykiH3GS2ZJ6y97j31QZGKnv6ML2gTeC2KgCnyULqUoGTPwGvB17I/lBJkGWexd4ojkwBI7BzqW5crXzq/hXzmriXRiS0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: 475uceyaqg1Gx6Wbm87kO_svQB9xun_p X-Proofpoint-ORIG-GUID: 475uceyaqg1Gx6Wbm87kO_svQB9xun_p Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/sd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 34fb0f8d189e..da7afeecbf17 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -155,7 +155,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr, struct scsi_mode_data data; struct scsi_sense_hdr sshdr; static const char temp[] = "temporary "; - int len; + int len, ret; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC) /* no cache control on RBC devices; theoretically they @@ -202,9 +202,10 @@ cache_type_store(struct device *dev, struct device_attribute *attr, */ data.device_specific = 0; - if (scsi_mode_select(sdp, 1, sp, buffer_data, len, SD_TIMEOUT, - sdkp->max_retries, &data, &sshdr)) { - if (scsi_sense_valid(&sshdr)) + ret = scsi_mode_select(sdp, 1, sp, buffer_data, len, SD_TIMEOUT, + sdkp->max_retries, &data, &sshdr); + if (ret) { + if (ret > 0 && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return -EINVAL; } From patchwork Fri Jul 14 21:34:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314247 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 EAEF6EB64DC for ; Fri, 14 Jul 2023 21:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbjGNViy (ORCPT ); Fri, 14 Jul 2023 17:38:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjGNVix (ORCPT ); Fri, 14 Jul 2023 17:38:53 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8434C3585 for ; Fri, 14 Jul 2023 14:38:52 -0700 (PDT) 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 36EL4Aeg004646; Fri, 14 Jul 2023 21:35: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-03-30; bh=MXjxbiChnoKu/ylLJ1XXlVZ5TFFYhdQFYHWDQ43d54I=; b=r5DTij4ncHxJ7AHb0+vWc1SGt/23O7v0Z1jhBg2HFIrFSMTLMWNYSnoErbSnR0v3GYqf Iy6nF8OOGKaqTqjIC/y6gwGH29reJq1+7SkZujr9hSl/UBDzQDYL0m2sz8YsL/WgxyIA CCVEBPOXacQp8R0YRqXsB6GIxG6KncSBZtJUJhoM9o+F8qHmKWy85c7qWMI7xIJNr0NQ Kp5GIDb9lW+JpkCrtESZa9KCfip1eqfleb8NgI0JCFXlcRF73aK6nTCyzdhXEXavobx9 xGxd1k54O5mf4zo/AqRKtX0SNKHzQqJ72ItTEDpd4h1kwRQRoEJszBZ/kGDR5WqORqx9 0Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtptn2d4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:46 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK0JIn007621; Fri, 14 Jul 2023 21:35:45 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrwye-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DR524jgnYdbxhYyPaQJ7RS1/8AeP2zDa40Y9NDG5IHxEfXE/tMR443RrRRLV48hLNa6j77Q/pbp7+CKEYz5iT58GU8p89AOSUVHjHiuw2/1cSydgOCZdC1ezhnH9Oa4GAyceMrLcHNKMQuad8b3MgK2P2bvQDFNZ6ck1PMxEmsZj5ltmS6EKFVaTJcFpGQew+Z7DzYfDVH/9iU5Uxh6ZMT3bh8LwBbAnWkfQLt52w1LMiM0Typdox5PSxxF35O5GY/+WZ2Skdz73sLqGwpCXkdI2hkyPBw4twa7ebLIZZDHWZOJ8Q+tIgbo8fDCF/YNCW31yB6kltqImO0YsRAXcOA== 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=MXjxbiChnoKu/ylLJ1XXlVZ5TFFYhdQFYHWDQ43d54I=; b=i66i4r09im76AtT2U4v7XbD1/JKJfpLHt5PhOZW5KynTMO3NFYNQzU383cboxCLsnY28NdIh839Cbsqn0ajmclj8fMQR9eC6VmxBmRlZ2WddCxj/AjDUZ5Ox/29Mr+nm8KlBaaoRjEwos1JKejU00Lx8kuD5/6Yoo7oTJewrmLlMO3xB9lm4E5AJt41BKoMnF2sjgj0cmYBvYPBy8vJaMUZMxaEXL0iYicaN/+vLh7Pvn8J3i2X7o5vRSRDOmItaFVuka37q8SN+jSuLdsF63i+e+4eFtV7y6zZzDuKQvya3kh5mjleGIh4ntt+iOlT88aiFDnlwfTLeOU3nxg31DQ== 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=MXjxbiChnoKu/ylLJ1XXlVZ5TFFYhdQFYHWDQ43d54I=; b=rpRFeeBwLgkrkb8gOsDml8qIGHKRN8g3NvuDf4s38/icG4sg/ba6eTanqOECT0SYITthhuwZ4tAxoAHsfoF3GCMC+E9pxHOn8ZWYZIucS6hgs1jH6k8FYlPetLU6pgefi738ezcYd38Dj4cdjXeN4Q16h5IooYB8PDFMY80+si8= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:43 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:42 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 32/33] scsi: sr: Fix sshdr use in sr_get_events Date: Fri, 14 Jul 2023 16:34:18 -0500 Message-Id: <20230714213419.95492-33-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR07CA0104.namprd07.prod.outlook.com (2603:10b6:5:330::30) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: b8d9521e-b701-4f62-85c9-08db84b2363e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VvSYEfdwHMdb3Tr80CtwpZ2nIhvgJ8DWpCx8d7HQP7KUSelo3tsaFlgr5vNbuo5f+IWGh3rJaFr7nxlr00WCsR/2PKeE9MYf6owjQn7pXKQKwdcKBeKCdREwDP1dwCWeBnTdtKOu/QfLN3AWZTl0vK437f4WW/SZnI9eD4p/pWLHCKeIbNV+sf4xI17BTWolW4/hQJxfcPh3H7+GSnO3ZGW8pFu/0AC6mvtOfMkuJCjIm/kLVZMpF5LM+hFwJ/1hXyp0s+Vl0otxSagDgzHzhzMi8SDbjXDUW5Qs25M7LEKvxgyZlQM3Q+oDAYLpbHLuOFAjb1HlqspNVgNSaxU7Tepzhmi8/0WilA8afFWyx/vd/mIk/LESXxCUwINPZf/PVlDAjTKXQTH7X0uClClFZNuPZ9+EQXU+i5sAlzO1+EnJ125qgGMlVja5OBIHLGskHqBxJiMMjznDvKZtNG0XW5lhOoQUjN1e3vSK7TKV4x3BkiqNhkYnbC/YXlTm1lRlnHAMEtvWIXthBzlfx84rojCQM74GnAZNwi4/FIfN3PrlCizhTGkhRBgY4MeX+9Pi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: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EfhIz1JypB0sxyVqjPmvAgdFdqBEq7NGwhYa1Z1YTUyqT485XC6qVCjsc+tGG+9o5rLHT5IKa0F3hZoM60r39PzIn8JnU/xhared+iFTjiuxmtpQHNzLNTGUgiCZbCfGPHP8ueW+eORVanW9NLd2M+fSaXUxuo/65CVgwFMJ7DGudtBWYuvik2/Aw5C/72Hi/zVvzRfxytpv1MOeWp5E8dEZExTUewuY0BX6tRkhTN6TwLpH3sdebQFbeKkpbtNqsgk9E3YJ71Mk7u3uNfvM+2pb86fcKbRCylOk2dD7Bp4X/iXaXONVlNYv4hNNMPdMc5+c22/MvIv/50uk06NOasxW7rdC8rwSdWmn9Ud+LzKi9sbsdrnTF/uRD27h7qnHbGlsvc1EOE6yJeFiWrgnzThkDLO7uOiy5pPPDlJciB5TJXWKMCY+GWYkEGiZnItymxVPO7ysJr/SAVqbtdSW0K X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8d9521e-b701-4f62-85c9-08db84b2363e X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:15.3457 (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: O9R28VG/TOeTIvjiDi+D11Fy0ENWpYSdReMa1jMRBSK0Ogs5aGQCwkR0VHSYdfzF/HbUcjv29a5PE87VN5vEYObH2Td1RqRPgrjF9cc3Fd8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-ORIG-GUID: oAAGndg-gUr-TrWcz5cbgqV31iaxFNx8 X-Proofpoint-GUID: oAAGndg-gUr-TrWcz5cbgqV31iaxFNx8 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry --- drivers/scsi/sr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 100480f5bc2c..a1889709c84c 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -177,7 +177,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev) result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, sizeof(buf), SR_TIMEOUT, MAX_RETRIES, &exec_args); - if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION) + if (result > 0 && scsi_sense_valid(&sshdr) && + sshdr.sense_key == UNIT_ATTENTION) return DISK_EVENT_MEDIA_CHANGE; if (result || be16_to_cpu(eh->data_len) < sizeof(*med)) From patchwork Fri Jul 14 21:34:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13314234 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 3D263C0015E for ; Fri, 14 Jul 2023 21:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbjGNViE (ORCPT ); Fri, 14 Jul 2023 17:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbjGNViA (ORCPT ); Fri, 14 Jul 2023 17:38:00 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D832E35B5 for ; Fri, 14 Jul 2023 14:37:54 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36EL3n4I003892; Fri, 14 Jul 2023 21:35:47 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-03-30; bh=aBxnfB+v607HZrHGyIp/x/vDAHduZBnCu8EBg8Yj6vQ=; b=2v6lUn6+pNJ+ljG/TacOHlW0ZqgIgCi7LAMfX4Cqj0n9PAXuW/9hSq5+tjOuppazOQpn zjftNvRabV9Za4RYEUmeD8UCYZLW7LB9W1uFAuSOuZCpLWsHUsqlE07vhtAbl7ZVPL/P cO+j9pwp0ZdCB8haKUDkPIWmikUHPSS+ZWPuuhVWxSdAmy7hSEF+Ks9UJe8VDt3QaH7A 501U2NYSAYX0NfPbNVB0oug49nR1S901qqfBCiklBgPNNqIItRFcRQEDM2pyyxrjnCIM 0HIz3jg4iJbAUDEv2p56vH6y0vb4ZbLwFrpAnszrsUE77Z+9K/6YIE/iznERhyX96ELr Ag== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rtpth2e1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:46 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36EK0JIo007621; Fri, 14 Jul 2023 21:35:45 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rtpvsrwye-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Jul 2023 21:35:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DPHtEfRMDoll5SIMpcIGqKs9WS7iRDCeRxrnv/lhONg8onuqGdwK/ZvPPo0pyet9CXI82GNx+Psfvb63Otf82coOUuxCyzOzgg7/vsorErUpjXdzlj/+s7f4EBgqyXb093cd17w3AEDa+GJbKV5i3Epjrfwvbwxw4rLtzgZBq70n4cwtYBj2E8i6G3LIT2gekFNuSYzHxS0r8Hc06oenXiwvxF7vh65a4TGyq5i2RPUUim3GlemIRdiPXtzOqO3d12GNE81AaCoRjDTE/MyNYrtKLweuSlT6aZZJfwuREdnAU/G4x9o8Kl5CCsRj2FLv1z8IVCyY5neK/6fPadCpVA== 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=aBxnfB+v607HZrHGyIp/x/vDAHduZBnCu8EBg8Yj6vQ=; b=TyXxanIy+Q45wXvC7jPSvwELvEaY2aFq4v//8XXDp+x8V1vINHGQeJorgGzpOfNK9tJdnzvs932AQYreVFj4UL2E550wRZ3QLTU999dK1gOSeG+Ook0T0psyMmhSbuV1KO4+U7lecBgSgU52bbDB8kDAU0bBIlD1G7WiZKXHWWCqW/C2y8ViZMgSrow6OjjUVzKBA2P/0Y4AoRFQhJ/iXCqpz4U6pizKI/1msYPrqCdc115ZYTlb8UqR33naBnZI/+NDlIiGpsFNC2r0Q2xB7XNs3CzMhFyj4mD1Jzd0V1Z7zsyYoY4eqCgljxWH7auL6mrz2DQhm1cfEivuRlVDNQ== 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=aBxnfB+v607HZrHGyIp/x/vDAHduZBnCu8EBg8Yj6vQ=; b=AMPWLcQxQr+ZPaYu1zwBUXQ5WePA/xWp3BcHaBCqJ7KBOd8Ze5wBEytCxmIKgrln/+u34DOHvoHuYjsvVV8DZ2IqMPY2O0ZdMJBF24ucbnpWbsIvuarNygtqJuLAIMsLrqDyLi7RaXwfqaBfxwGzGMZd1OVgrlvarOTJbWOQfCM= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by DM6PR10MB4377.namprd10.prod.outlook.com (2603:10b6:5:21a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Fri, 14 Jul 2023 21:35:43 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6588.028; Fri, 14 Jul 2023 21:35:43 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v10 33/33] scsi: Add kunit tests for scsi_check_passthrough Date: Fri, 14 Jul 2023 16:34:19 -0500 Message-Id: <20230714213419.95492-34-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714213419.95492-1-michael.christie@oracle.com> References: <20230714213419.95492-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0028.namprd06.prod.outlook.com (2603:10b6:5:120::41) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|DM6PR10MB4377:EE_ X-MS-Office365-Filtering-Correlation-Id: a0d8ed0a-0346-4564-cfd3-08db84b23763 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H3KcD2L4z9Vue5r3ECz/Koczp8A0ph7R2Jmq0zIuVgsdyDXNgG02iULsyhvTkcGTZtDIHKry3O+90yg6LyXI4E6bYqp2kRqU7g7AZ8GUqEZ7tWgoDNNSwXZUZAWSNI5eXKoFqS1nRjHGcU/z/gBJwN2Dqc5ZvSw1y4uioAluu37N+Cf3Lit4TuFj/MHnGtqagWFYJfr2QLhjEooV6nUnQgSD+6Fvubw1D/zrUTB+8mPmGSmQYHpopqV7nknwGdHn9uktW2dkWnp986yXpnoM4L0UYvT81xuUEemaGy8wer9ROH8n+O6EAGFUb8LeXI/aIaZHxxzZnemXoHVrl/mV44eaua1EVSRhcy67s2LPjEN416M35AOgCmhMJOfc33YjpMbdshcfWwwKKVyBcv0UFuyW3tWDkzxr+Cc0jwQGzTMurlRb/0k6JoPBTVotSB46mdeBW9qALaYCrGx/rAnjLqD8i+X5QJXhOL4BJpSlHBMpyMTlE+v1nnbosrd/Yiqr/pa5dLD8EHcZtk8RcI7Ngf2B/R4tl8YEUmWoPiguJF+iOKZPreAFtDfCC/KjL3T9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199021)(8676002)(5660300002)(8936002)(316002)(41300700001)(4326008)(2906002)(478600001)(6666004)(6512007)(6486002)(107886003)(26005)(6506007)(1076003)(186003)(66946007)(66556008)(66476007)(83380400001)(2616005)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Lem0TNOB8tdKSMldsa8mWl7UG6gW4N0bgIDUgszAzARdmUWYp7yrem2q1umTVAJ5Bo72rTFGRavHRL3cj2bgdUeB1iGlGhM0thOjoWpjt/ZMyMNXhoTy+oz7pHmksx3AZRp+wmtzqcGigHYRV1n/VZSm0F7EI/9xf5RCHaDJjDdR6P6kxWqTCg5JqLEYxSs6u+V4CbDyfdVnVp4zTj2dOd4GtUmLDccz5hoT+1JeOUcDDVr+fkKZig/mdGxqry4fzG5sgreZBaYvnyBYq6PnKRM2cil0m6h5GZxCH1a1hN0IzhVsmvdKpYAskUX7Pkcd0ATPYTlDFutoQAGsfvd3SkazVlbpdPtilObcPVBncur1LVJ9b3bmE6DIwuEthGfv/zo+KsfCnhN5E4ZZCSGBJKu9ojgJMHY+eeOG0z73VKT0ThpMEDNWHnG1KnY90fT6rtH5ft3hWp5GjizzBm2GMVkATiOEXM0V3G02wwxdCnsBftVEMgYTfzVaF5ez8+W89a7fPgAb/D8sb39i4Zlm8tjiP8g3/XowD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change-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tMZqU2w3CHdpWUAJEfeI7qRAua/NsPf3xWopTaLfVo36KKacVGfnWOA2Kt+Y2b8prJxYhMp1EMZf9FkJaka+KBEAxy7MJEH7zwzMZ82kaoH1aZ5kyyZEDvoa4EFws35NzSdDkXD/UYbdOWY+OiSGHujUSPMj4/Y8HKnUnukCtCN1VugiIkZpDyK2Qo4RUtVGiP0z7t1JCjXRjcqMVVhZIkOE5WAKvKUps+Pay18KRQdexkTHkR8dDYIT4Bbn032b4rrjYNFEt9BbmepRmHLb0QXid3BSVXLuy4Y1SaYsWP97/ArbOCwKxIuf57sF2yIzU8jqCBgwQV2IzmtJxPt7ekQ0Ul4g2YsQelE4hFvZBWjEgZ6UoUz0CcYNbt1dwMy0cuLyUIAGFS/Af666DRz1pVBlAMBAsDY2p8FCgdq/zBEJreQA5iuQZWSDmTihfON7M9MTgNEvqxGXwSxHpsfyUecfrGwwSI4+09m530GU83VwbpL2EmGTplq7QbjrJ4PzRsIWW50IBygP95IEmXQXpUk+dK5I9VwyFvKxrdkLMjFiDGnJ6q5gH8zdIvHA3G1cDjspdZjVrueqbec/Zn6T4rS1ZRCgDzNxI5k1CbMbfuNNxpeXXIMQCzFCZVNFOVdAIjwEYtgyjeH4S/4df/m17AVaoVMT5gfEswrqc1hiokAq2YGpjQUm63v2gIKt52FcoqorAL3NVar8r/kVwAPrtq3fVNG3/cY6ABCE0nBmmshwyVHVj86CvnzFxSlTG6n1AUiS50oEckdd2MRrmBNZoq2GRr0mE0/suYM8Q6tw+GuhwAqWM8Cet1EeXzGA8xkGXkmFkpIPL+Mevfq68YY0Kj1w+jXqyBwV9ORjbMzwTUp1teuyN2e4hp+yFCsuWXLN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0d8ed0a-0346-4564-cfd3-08db84b23763 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 21:35:17.2654 (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: j7cvE8gXdhaYG7ZoiKmKQSfzEYnL47kanEkuUVoYwv5q+NRhmgWRmCDwxuxMypcNHfoIRA0d70a9WpQsw039evH1Nf/kjUCqTuIpUlEZ1zc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4377 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-14_10,2023-07-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307140198 X-Proofpoint-GUID: qvTmuQaJc_L_WQ4oYCQ7_MTxr5kbvrCR X-Proofpoint-ORIG-GUID: qvTmuQaJc_L_WQ4oYCQ7_MTxr5kbvrCR Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add some kunit tests for scsi_check_passthrough so we can easily make sure we are hitting the cases it's difficult to replicate in hardware or even scsi_debug. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/Kconfig | 9 ++ drivers/scsi/scsi_error.c | 4 + drivers/scsi/scsi_error_test.c | 170 +++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 drivers/scsi/scsi_error_test.c diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 4962ce989113..be9b6eb2fba2 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -67,6 +67,15 @@ config SCSI_PROC_FS If unsure say Y. +config SCSI_KUNIT_TEST + tristate "KUnit tests for SCSI Mid Layer" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Run SCSI Mid Layer's KUnit tests. + + If unsure say N. + comment "SCSI support type (disk, tape, CD-ROM)" depends on SCSI diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index d2fb28212880..f12ab199a03f 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -2663,3 +2663,7 @@ bool scsi_get_sense_info_fld(const u8 *sense_buffer, int sb_len, } } EXPORT_SYMBOL(scsi_get_sense_info_fld); + +#ifdef CONFIG_SCSI_KUNIT_TEST +#include "scsi_error_test.c" +#endif diff --git a/drivers/scsi/scsi_error_test.c b/drivers/scsi/scsi_error_test.c new file mode 100644 index 000000000000..c01201ad8702 --- /dev/null +++ b/drivers/scsi/scsi_error_test.c @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit tests for scsi_error.c. + * + * Copyright (C) 2022, Oracle Corporation + */ +#include + +#include +#include + +#define SCSI_TEST_ERROR_MAX_ALLOWED 3 + +static void scsi_test_error_check_passthough(struct kunit *test) +{ + struct scsi_failure multiple_sense_failures[] = { + { + .sense = DATA_PROTECT, + .asc = 0x1, + .ascq = 0x1, + .allowed = 0, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = UNIT_ATTENTION, + .asc = 0x11, + .ascq = 0x0, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = NOT_READY, + .asc = 0x11, + .ascq = 0x22, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = ABORTED_COMMAND, + .asc = 0x11, + .ascq = SCMD_FAILURE_ASCQ_ANY, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = HARDWARE_ERROR, + .asc = SCMD_FAILURE_ASC_ANY, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + .result = SAM_STAT_CHECK_CONDITION, + }, + { + .sense = ILLEGAL_REQUEST, + .asc = 0x91, + .ascq = 0x36, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + .result = SAM_STAT_CHECK_CONDITION, + }, + {} + }; + struct scsi_failure retryable_host_failures[] = { + { + .result = DID_TRANSPORT_DISRUPTED << 16, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + }, + { + .result = DID_TIME_OUT << 16, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + }, + {} + }; + struct scsi_failure any_status_failures[] = { + { + .result = SCMD_FAILURE_STAT_ANY, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + }, + {} + }; + struct scsi_failure any_sense_failures[] = { + { + .result = SCMD_FAILURE_SENSE_ANY, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + }, + {} + }; + struct scsi_failure any_failures[] = { + { + .result = SCMD_FAILURE_RESULT_ANY, + .allowed = SCSI_TEST_ERROR_MAX_ALLOWED, + }, + {} + }; + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; + struct scsi_cmnd sc = { + .sense_buffer = sense, + .failures = multiple_sense_failures, + }; + int i; + + /* Match end of array */ + scsi_build_sense(&sc, 0, ILLEGAL_REQUEST, 0x91, 0x36); + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + /* Basic match in array */ + scsi_build_sense(&sc, 0, UNIT_ATTENTION, 0x11, 0x0); + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + /* No matching sense entry */ + scsi_build_sense(&sc, 0, MISCOMPARE, 0x11, 0x11); + KUNIT_EXPECT_EQ(test, SCSI_RETURN_NOT_HANDLED, + scsi_check_passthrough(&sc)); + /* Match using SCMD_FAILURE_ASCQ_ANY */ + scsi_build_sense(&sc, 0, ABORTED_COMMAND, 0x22, 0x22); + KUNIT_EXPECT_EQ(test, SCSI_RETURN_NOT_HANDLED, + scsi_check_passthrough(&sc)); + /* Match using SCMD_FAILURE_ASC_ANY */ + scsi_build_sense(&sc, 0, HARDWARE_ERROR, 0x11, 0x22); + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + /* No matching status entry */ + sc.result = SAM_STAT_RESERVATION_CONFLICT; + KUNIT_EXPECT_EQ(test, SCSI_RETURN_NOT_HANDLED, + scsi_check_passthrough(&sc)); + + /* Test hitting allowed limit */ + scsi_build_sense(&sc, 0, NOT_READY, 0x11, 0x22); + for (i = 0; i < SCSI_TEST_ERROR_MAX_ALLOWED; i++) + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + KUNIT_EXPECT_EQ(test, SUCCESS, scsi_check_passthrough(&sc)); + + /* Match using SCMD_FAILURE_SENSE_ANY */ + sc.failures = any_sense_failures; + scsi_build_sense(&sc, 0, MEDIUM_ERROR, 0x11, 0x22); + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + + /* reset retries so we can retest */ + scsi_reset_failures(multiple_sense_failures); + + /* Test no retries allowed */ + sc.failures = multiple_sense_failures; + scsi_build_sense(&sc, 0, DATA_PROTECT, 0x1, 0x1); + KUNIT_EXPECT_EQ(test, SUCCESS, scsi_check_passthrough(&sc)); + + /* No matching host byte entry */ + sc.failures = retryable_host_failures; + sc.result = DID_NO_CONNECT << 16; + KUNIT_EXPECT_EQ(test, SCSI_RETURN_NOT_HANDLED, + scsi_check_passthrough(&sc)); + /* Matching host byte entry */ + sc.result = DID_TIME_OUT << 16; + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + + /* Match SCMD_FAILURE_RESULT_ANY */ + sc.failures = any_failures; + sc.result = DID_TRANSPORT_FAILFAST << 16; + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); + + /* Test any status handling */ + sc.failures = any_status_failures; + sc.result = SAM_STAT_RESERVATION_CONFLICT; + KUNIT_EXPECT_EQ(test, NEEDS_RETRY, scsi_check_passthrough(&sc)); +} + +static struct kunit_case scsi_test_error_cases[] = { + KUNIT_CASE(scsi_test_error_check_passthough), + {} +}; + +static struct kunit_suite scsi_test_error_suite = { + .name = "scsi_error", + .test_cases = scsi_test_error_cases, +}; + +kunit_test_suite(scsi_test_error_suite);