From patchwork Thu Nov 24 10:25:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang.junhui@zte.com.cn X-Patchwork-Id: 9445167 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 97B25606DB for ; Thu, 24 Nov 2016 10:53:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83B927B81 for ; Thu, 24 Nov 2016 10:53:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CE6F27C2D; Thu, 24 Nov 2016 10:53:02 +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 F1B0A27B81 for ; Thu, 24 Nov 2016 10:53:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938736AbcKXKwt (ORCPT ); Thu, 24 Nov 2016 05:52:49 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:46078 "EHLO out1.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935138AbcKXKws (ORCPT ); Thu, 24 Nov 2016 05:52:48 -0500 X-Greylist: delayed 1202 seconds by postgrey-1.27 at vger.kernel.org; Thu, 24 Nov 2016 05:52:48 EST X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20161124182437 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 24 Nov 2016 10:24:37 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id uAOAPr1J056810; Thu, 24 Nov 2016 18:25:53 +0800 (GMT-8) (envelope-from tang.junhui@zte.com.cn) Received: from localhost.localdomain ([10.118.202.203]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2016112418255913-48798 ; Thu, 24 Nov 2016 18:25:59 +0800 From: tang.junhui@zte.com.cn To: hare@suse.de, matthew@wil.cx Cc: linux-scsi@vger.kernel.org, zhang.kai16@zte.com.cn, "tang.junhui" Subject: [PATCH] scsi_dh_alua: Add return value and check for alua_rtpg_queue() to avoid DM devices I/Os hang Date: Thu, 24 Nov 2016 18:25:05 +0800 Message-Id: <1479983105-7264-1-git-send-email-tang.junhui@zte.com.cn> X-Mailer: git-send-email 2.8.1.windows.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-11-24 18:25:59, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-11-24 18:25:53, Serialize complete at 2016-11-24 18:25:53 X-MAIL: mse01.zte.com.cn uAOAPr1J056810 X-HQIP: 127.0.0.1 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 From: "tang.junhui" Activate_complete fn() must be called in alua_activate() if alua_rtpg_queue() failed, otherwise, it would cause I/Os hang in DM devices. So this patch add return value and check for alua_rtpg_queue(). Signed-off-by: tang.junhui --- drivers/scsi/device_handler/scsi_dh_alua.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 7bb2068..62075c7 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -113,7 +113,7 @@ struct alua_queue_data { #define ALUA_POLICY_SWITCH_ALL 1 static void alua_rtpg_work(struct work_struct *work); -static void alua_rtpg_queue(struct alua_port_group *pg, +static int alua_rtpg_queue(struct alua_port_group *pg, struct scsi_device *sdev, struct alua_queue_data *qdata, bool force); static void alua_check(struct scsi_device *sdev, bool force); @@ -862,7 +862,7 @@ static void alua_rtpg_work(struct work_struct *work) kref_put(&pg->kref, release_port_group); } -static void alua_rtpg_queue(struct alua_port_group *pg, +static int alua_rtpg_queue(struct alua_port_group *pg, struct scsi_device *sdev, struct alua_queue_data *qdata, bool force) { @@ -871,7 +871,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg, struct workqueue_struct *alua_wq = kaluad_wq; if (!pg) - return; + return SCSI_DH_IO; spin_lock_irqsave(&pg->lock, flags); if (qdata) { @@ -906,7 +906,10 @@ static void alua_rtpg_queue(struct alua_port_group *pg, if (sdev) scsi_device_put(sdev); kref_put(&pg->kref, release_port_group); + return SCSI_DH_IO; } + + return SCSI_DH_OK; } /* @@ -1007,11 +1010,12 @@ static int alua_activate(struct scsi_device *sdev, mutex_unlock(&h->init_mutex); goto out; } - fn = NULL; rcu_read_unlock(); mutex_unlock(&h->init_mutex); - alua_rtpg_queue(pg, sdev, qdata, true); + err = alua_rtpg_queue(pg, sdev, qdata, true); + if (!err) + fn = NULL; kref_put(&pg->kref, release_port_group); out: if (fn)