From patchwork Tue Jul 11 21:46: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: 701782 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 BEAECC0015E for ; Tue, 11 Jul 2023 21:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbjGKVrm (ORCPT ); Tue, 11 Jul 2023 17:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbjGKVrU (ORCPT ); Tue, 11 Jul 2023 17:47:20 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E2D1981 for ; Tue, 11 Jul 2023 14:47:19 -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 36BID1Mv015322; Tue, 11 Jul 2023 21:47: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=pHKNtgIUFHVEtc/4QuNyz0PNa7BvaEIkSWnhqHDsyRg=; b=mtHqHvw8Rtrrv/ecEBngnVXgixLmuQ4XSfUsHla/qw3C0rXOuEpqZpMrawhSSCVHDn/Y hEo+kLTLFMTcOHWMtX/LFPhbRAGXd0PQg6LjfW3CB1Eq3Iu1PVuiTPzwDZnyxzWIVqbC 0Y5Visi4Xbr9qv+f/uJ/BdCqgIErJOeCxWah0YgkFLuBpU3Qq4r3lvhXNUi9sJmASfct wC4ypHs3b5RbGDXwUBeHrJATNmOpthzopSxfP29+JnPf5cqNMJtddjKFkWdrFbOh/weY 9+XghlCqVpD6n7vIffdrIXUhR6f9K5Wthq2Gj34MXJ08DiCuVExEIo3canr/DaM/25Sn 2g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rr8xumf22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 21:47:10 +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 36BJxGbF007247; Tue, 11 Jul 2023 21:47:09 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rpx85h1d7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 21:47:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=khJrHT/h559GjB+jBwOkwJdYrYfgT08WlyVxLQaQvu4kMw/qkO+O94iY0EnD6D/x5SJGyol479u/PP7qRVL9Q66fLYUVq8fqhcwbuOp9jaQBZqY+w06FtYusfL55kcebQMg6riCkmKVWCjIYAxgFXoXzR1uD4rG9l69yEYrcGlYLWK5nAWXK7lKOBwuIJliAxQCGlLcWjt3W/sUiKZQczeNzeOR5lesqTdPNqtDcYYmbCJUBE0MFQF+hsDHJaeBXzI7q9+ZnAQBZCvqdB2fYeJ+ocnP971nMRhO1uDgGnS0MxKKYPgORjkFgtObJ72dOiqnYJcstGoD2BglwHUEREA== 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=pHKNtgIUFHVEtc/4QuNyz0PNa7BvaEIkSWnhqHDsyRg=; b=Wpfk4gM8esWEmR4Be2sRKO0xv3wI2BMFD28JEJyMmGWoiLcq5oqenjfnULsSuGtOpkpf4fpEDw/Zescb3pyOJlYkC5zECMi3a35HCLnG7PqOoUfuMWStpZQ2IUtTs1G9dGSp9DUCf/h0Iw2M007XZlLDpXVLbGIcNsiUx0oJtMVUZpLO7kmNG8ih9NbaQBDxK3qZZs9iEYdARtJHWtQE4PndQqWtsu2n3+kIU/FFRq3B6FgF16GkLwKmW8RFnDuKqBKrmoicoNvdsxdl6rSqMDJlwJ1zv0sxBQQQg8KZTveQS3azN5tDOl5aIbM8Fu+0M6rbuHxyyDyaPQ/MT+1FsA== 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=pHKNtgIUFHVEtc/4QuNyz0PNa7BvaEIkSWnhqHDsyRg=; b=cTtnpHy+eXtckG7xI+IiHmhegpCku3wR/xXm8CRDYeoFPjlKn34rCS9LcmKSRPwz3Eu8o3ceKRY0bPesj3+z7QtssK5f7R+IyvzZBpm/Tvivz3mLzKQyxpzZJYN5NPotu2bFGMqD4a77dBS1AG2Jm+I3bMe0ui0juaEuJt1M5qk= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SA3PR10MB6950.namprd10.prod.outlook.com (2603:10b6:806:31d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 21:47:02 +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.6565.028; Tue, 11 Jul 2023 21:47:02 +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 v9 18/33] scsi: sd: Have scsi-ml retry sd_sync_cache errors Date: Tue, 11 Jul 2023 16:46:05 -0500 Message-Id: <20230711214620.87232-19-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711214620.87232-1-michael.christie@oracle.com> References: <20230711214620.87232-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0005.namprd03.prod.outlook.com (2603:10b6:5:3b8::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_|SA3PR10MB6950:EE_ X-MS-Office365-Filtering-Correlation-Id: e60c40f8-cef8-4283-ebc5-08db82585bf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b9kJVlYjb69uqTfghsUvcBQHYWWMHRHLWOVmsApt8xMVREUp4NOEbp8/4rJZL/MTj9qBO6RWV8Eba7CeYHqxsPbMBMTbakq+3NMA8NCyjVvteeekWEEs+i3uV1njdmDd4eqKM1X86i4MY0yriSK854xBRdAXDOKOP//jEr1a+YfUyGTi1IeDsiOg5pYTE2t+jlFkY79gns7Z0arMVPpYQ50DneRrXICwolBAmvR74lWcr9t0g6DZtyG4zcBeolnFmTxq7wGjOllH+FriD9+TjmKyJgevWwR/o+yoJdl53/Ht4762RXG/rwdDPGhxpcVkA92dYFaoBPsGMXbaydKZCP0hRG0j47ygIti3VGGFGc1JYBTjjUzMuy+ve/EBNsBbZAkUD8VmC3WAwSWh25bZ/6dGLgoFOQ2Dn0oA6VIAZwaSmcA94YzEZcgalnzl24pjw2Th+5oqYURjns+oF8D+l2aVNLks7Qjxjz/vNZ2TgBF5uKPjDNePjQj67hwqAyr4+4r+WoTnHh0mg8q+zfpnOV8NI6/HQdvMQPJOyh9Mc28TVQqwYA6NjZitadD+2MXu 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)(39860400002)(136003)(396003)(346002)(366004)(376002)(451199021)(186003)(6506007)(2616005)(6512007)(478600001)(26005)(1076003)(107886003)(83380400001)(41300700001)(4326008)(5660300002)(66556008)(2906002)(316002)(8676002)(8936002)(66946007)(66476007)(6486002)(36756003)(38100700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kMDynyxkbGbvYDw+Y0JSrMN+lYjds+nnheY+i3/JOUBMUnqKZR1EQj3R8DkdFCe2r54GWv7xy0ePahpXsqOqIs3OdyRr2WMknGD0zGSvOX8C7tEoft+65kooa2xH9XcqkqikvJH5QuODT+4dDE4ew/jwvFjBYWwUPg5y4DLxz/8KrRPMbL7242xOiigxHllsUNuFkdb0xsOnhnQaLyxoixjRORq4zwQm7o8NlryrUpb+euSVhAO6pV9dxii0mRL9rUfEyebLVte+J608OfFkQ+/gXYVq+Dw1woyhvqatVSGfXiBwWD0EzrkdxzU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OF+6DPVqgjrDZJL3j4FVSnM+/cgLjh4oRpsxaLxJ+AP90xFJVHpvbxY9hzoM4X8heV3X0x5knbNvb54XLSqH/3Y/S34HFZHcdiyoE+JvTMLA5zqXhztF4mXl2lsNP76 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e60c40f8-cef8-4283-ebc5-08db82585bf9 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 21:47:02.2089 (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: zKhf4D0HVO66K2wpD2p7FsHpBy0yNlxR6kDjtWDnM0P6GFtA2+Kz5t2JFR6gXJuVyG1maV8OQozMN0JbaWHgr9SE5ZDY/ingnl44L8/r+lU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR10MB6950 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-11_12,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110198 X-Proofpoint-GUID: RVmV5a_h4axNhS_4_9JomeOy3lEFuwCr X-Proofpoint-ORIG-GUID: RVmV5a_h4axNhS_4_9JomeOy3lEFuwCr 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 --- 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 bb2e5885e41b..ab0d6b1835be 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1606,36 +1606,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);