From patchwork Wed Mar 28 16:45:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 10313585 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 DA92C60212 for ; Wed, 28 Mar 2018 16:45:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC67B294AF for ; Wed, 28 Mar 2018 16:45:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB19E29F89; Wed, 28 Mar 2018 16:45:23 +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 7346529F85 for ; Wed, 28 Mar 2018 16:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753223AbeC1QpT (ORCPT ); Wed, 28 Mar 2018 12:45:19 -0400 Received: from smtp.infotech.no ([82.134.31.41]:49556 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753148AbeC1QpS (ORCPT ); Wed, 28 Mar 2018 12:45:18 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 77CB02041CB; Wed, 28 Mar 2018 18:45:17 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WuOIPzJt+xaT; Wed, 28 Mar 2018 18:45:17 +0200 (CEST) Received: from xtwo70.bingwo.ca (host-184-164-15-239.dyn.295.ca [184.164.15.239]) by smtp.infotech.no (Postfix) with ESMTPA id 4337B20415B; Wed, 28 Mar 2018 18:45:16 +0200 (CEST) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, bart.vanassche@wdc.com, jthumshirn@suse.de Subject: [PATCH v4 5/7] scsi_io_completion_reprep helper added Date: Wed, 28 Mar 2018 12:45:05 -0400 Message-Id: <20180328164507.28137-6-dgilbert@interlog.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180328164507.28137-1-dgilbert@interlog.com> References: <20180328164507.28137-1-dgilbert@interlog.com> 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 Since the action "reprep" is called from two places, rather than repeat the code, make a new scsi_io_completion helper with "reprep" as its suffix. Signed-off-by: Douglas Gilbert Reviewed-by: Johannes Thumshirn --- drivers/scsi/scsi_lib.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 048b144de5b0..7bf7d3c4b9c2 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -751,6 +751,20 @@ static blk_status_t __scsi_error_from_host_byte(struct scsi_cmnd *cmd, } } +/* Helper for scsi_io_completion() when "reprep" action required. */ +static void scsi_io_completion_reprep(struct scsi_cmnd *cmd, + struct request_queue *q) +{ + /* A new command will be prepared and issued. */ + if (q->mq_ops) { + scsi_mq_requeue_cmd(cmd); + } else { + /* Unprep request and put it back at head of the queue. */ + scsi_release_buffers(cmd); + scsi_requeue_command(q, cmd); + } +} + /* Helper for scsi_io_completion() when special action required. */ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) { @@ -892,15 +906,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result) return; /*FALLTHRU*/ case ACTION_REPREP: - /* Unprep the request and put it back at the head of the queue. - * A new command will be prepared and issued. - */ - if (q->mq_ops) - scsi_mq_requeue_cmd(cmd); - else { - scsi_release_buffers(cmd); - scsi_requeue_command(q, cmd); - } + scsi_io_completion_reprep(cmd, q); break; case ACTION_RETRY: /* Retry the same command immediately */ @@ -1079,20 +1085,9 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) * If there had been no error, but we have leftover bytes in the * requeues just queue the command up again. */ - if (result == 0) { - /* - * Unprep the request and put it back at the head of the - * queue. A new command will be prepared and issued. - * This block is the same as case ACTION_REPREP in - * scsi_io_completion_action() above. - */ - if (q->mq_ops) - scsi_mq_requeue_cmd(cmd); - else { - scsi_release_buffers(cmd); - scsi_requeue_command(q, cmd); - } - } else + if (result == 0) + scsi_io_completion_reprep(cmd, q); + else scsi_io_completion_action(cmd, result); }