From patchwork Mon Aug 21 22:40:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian King X-Patchwork-Id: 9913921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D743D602A0 for ; Mon, 21 Aug 2017 22:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C401327861 for ; Mon, 21 Aug 2017 22:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8DB9286EC; Mon, 21 Aug 2017 22:41:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC85328607 for ; Mon, 21 Aug 2017 22:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754342AbdHUWkW (ORCPT ); Mon, 21 Aug 2017 18:40:22 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36575 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035AbdHUWkU (ORCPT ); Mon, 21 Aug 2017 18:40:20 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7LMcmA0074670 for ; Mon, 21 Aug 2017 18:40:19 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cg3uj4mun-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 21 Aug 2017 18:40:19 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Aug 2017 16:40:19 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 21 Aug 2017 16:40:16 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7LMeGTT65405156; Mon, 21 Aug 2017 15:40:16 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4DF96A03F; Mon, 21 Aug 2017 16:40:15 -0600 (MDT) Received: from [9.10.86.49] (unknown [9.10.86.49]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 1542F6A042; Mon, 21 Aug 2017 16:40:15 -0600 (MDT) Subject: [PATCHv2 1/2] scsi: Move scsi_cmd->jiffies_at_alloc initialization to allocation time From: Brian King To: Bart Van Assche , "linuxppc-dev@lists.ozlabs.org" , "abdhalee@linux.vnet.ibm.com" Cc: "linux-kernel@vger.kernel.org" , "hch@lst.de" , "linux-scsi@vger.kernel.org" , "sfr@canb.auug.org.au" , "sachinp@linux.vnet.ibm.com" , "linux-next@vger.kernel.org" , "hare@suse.com" , "mpe@ellerman.id.au" References: <1502902815.3305.22.camel@abdul.in.ibm.com> <1502904072.2421.3.camel@wdc.com> <2f686064-3e32-df8d-134f-962b5181da9d@linux.vnet.ibm.com> <1502985161.2615.8.camel@wdc.com> <71fb9c1b-9f3f-acdc-8bb5-aa1240aea763@linux.vnet.ibm.com> <1503092473.2622.17.camel@wdc.com> <0f7e2114-eba1-f149-ea80-d32d8b6d212a@linux.vnet.ibm.com> <1503094414.2622.21.camel@wdc.com> <21928108-3a20-577e-99c8-6da05637c158@linux.vnet.ibm.com> Date: Mon, 21 Aug 2017 17:40:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <21928108-3a20-577e-99c8-6da05637c158@linux.vnet.ibm.com> Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 17082122-0016-0000-0000-0000076610B7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007587; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000223; SDB=6.00905729; UDB=6.00453890; IPR=6.00685932; BA=6.00005545; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016799; XFM=3.00000015; UTC=2017-08-21 22:40:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082122-0017-0000-0000-00003B272C9F Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-21_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708210349 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This second version also sets up jiffies_at_alloc in scsi_init_request. This has been tested without the second patch in the series and I've confirmed I now see the following in the logs after booting: [ 121.718088] sd 1:2:0:0: timing out command, waited 120s [ 121.798081] sd 1:2:1:0: timing out command, waited 120s Without this patch I was never seeing these messages, indicating the retry timer code wasn't working. Also, after seeing these messages, I've confirmed there are no longer any hung tasks in the kernel with sysrq-w, while before, without this patch, I would see hung tasks for the scsi_report_opcodes calls which were getting retried forever. 8< Move the initialization of scsi_cmd->jiffies_at_alloc to allocation time rather than prep time. Also ensure that jiffies_at_alloc is preserved when we go through prep. This lets us send retries through prep again and not break the overall retry timer logic in scsi_softirq_done. Suggested-by: Bart Van Assche Signed-off-by: Brian King Index: linux-2.6.git/drivers/scsi/scsi_lib.c =================================================================== --- linux-2.6.git.orig/drivers/scsi/scsi_lib.c +++ linux-2.6.git/drivers/scsi/scsi_lib.c @@ -1154,6 +1154,7 @@ void scsi_init_command(struct scsi_devic void *buf = cmd->sense_buffer; void *prot = cmd->prot_sdb; unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA; + unsigned long jiffies_at_alloc = cmd->jiffies_at_alloc; /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, @@ -1164,7 +1165,7 @@ void scsi_init_command(struct scsi_devic cmd->prot_sdb = prot; cmd->flags = unchecked_isa_dma; INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); - cmd->jiffies_at_alloc = jiffies; + cmd->jiffies_at_alloc = jiffies_at_alloc; scsi_add_cmd_to_list(cmd); } @@ -2016,6 +2017,7 @@ static int scsi_init_request(struct blk_ if (!cmd->sense_buffer) return -ENOMEM; cmd->req.sense = cmd->sense_buffer; + cmd->jiffies_at_alloc = jiffies; if (scsi_host_get_prot(shost)) { sg = (void *)cmd + sizeof(struct scsi_cmnd) + @@ -2119,6 +2121,7 @@ static int scsi_init_rq(struct request_q if (!cmd->sense_buffer) goto fail; cmd->req.sense = cmd->sense_buffer; + cmd->jiffies_at_alloc = jiffies; if (scsi_host_get_prot(shost) >= SHOST_DIX_TYPE0_PROTECTION) { cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp);