Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752763AbdIFJNq (ORCPT ); Wed, 6 Sep 2017 05:13:46 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5982 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752600AbdIFJMo (ORCPT ); Wed, 6 Sep 2017 05:12:44 -0400 From: Jason Yan To: , CC: , , , , , , , , , , , , , Ewan Milne , Tomas Henzl Subject: [PATCH v4 11/11] libsas: add event to defer list tail instead of head when draining Date: Wed, 6 Sep 2017 17:15:14 +0800 Message-ID: <1504689314-20072-12-git-send-email-yanaijie@huawei.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1504689314-20072-1-git-send-email-yanaijie@huawei.com> References: <1504689314-20072-1-git-send-email-yanaijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.59AFBC04.00AF,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7173ea166b119286ffd9d953b2b0853a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1412 Lines: 37 From: chenxiang Events will be added to defer_q list when setting ha->status to SAS_HA_DRAINING. Events will be called after drain workqueue. Those events are added to the head of list, but they are scanned one by one from the head to the tail, which will cause those events be called in the reverse order of being added. So change list_add to list_add_tail in function sas_queue_work. Signed-off-by: chenxiang Signed-off-by: Jason Yan CC: John Garry CC: Johannes Thumshirn CC: Ewan Milne CC: Christoph Hellwig CC: Tomas Henzl CC: Dan Williams --- drivers/scsi/libsas/sas_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c index c120657..b124198 100644 --- a/drivers/scsi/libsas/sas_event.c +++ b/drivers/scsi/libsas/sas_event.c @@ -38,7 +38,7 @@ int sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw) if (test_bit(SAS_HA_DRAINING, &ha->state)) { /* add it to the defer list, if not already pending */ if (list_empty(&sw->drain_node)) - list_add(&sw->drain_node, &ha->defer_q); + list_add_tail(&sw->drain_node, &ha->defer_q); } else rc = queue_work(ha->event_q, &sw->work); -- 2.5.0