Received: by 10.192.165.156 with SMTP id m28csp1759582imm; Tue, 17 Apr 2018 05:11:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx487T9PgxPQxWq/oIDPtjk8pPC1BvL9DDPDM1todMwbpDeB7/qsyfUo4iZCYWMnT6qVqGyXO X-Received: by 10.99.121.194 with SMTP id u185mr1559848pgc.409.1523967108131; Tue, 17 Apr 2018 05:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523967108; cv=none; d=google.com; s=arc-20160816; b=cHMBPMLavSn0XCVeOMPdrB7DI1oMsPGXJVS4tibsBnJHjNq9jejWUvkjlulT5RTd17 MmUdVA6RzmLxhoW4e7mD4R4xvk95INUjjG1JfD/M9PPG7HDkTzrfOwj8x2hXXvVlQq5e ygX+rk4TeYLr1xj40ZzQJ+MLhqbsAQMCTWGC6E2P+jukAuk2tY8ZIrRXbAOwvaWLxUK4 yXtxOlyi5tGOe1YwcPWMUBzsEdmWCwmFT/Rqil6b3cfWi14U2511Hw+KnTdpfEbIrcFs 4RlI6uZdXoxFIRXlc2ilSUt90mxp2B9knIMuCALqcEroRT4BdVyz6NSyuE0hQFwF9gGh C6wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=3HbJE2M+7TfKBjRTAKWaj/aD5clas/rTcjJr+wtu1Pc=; b=QfaPmsi/D8BF7zKn92wGrGmdaD8BbOY9E1eiAAwMc8mahLQXeQjDzGxnItVmzI0/2Q uZruAoWaMIT5u6uHGCHE1L4QZuT896Cwy4Qcuz6n9jyEka36iCfjZUfPBKfLhbm+5beX LHgVYzWXH+8ODICqPZXOuW+cVPMMjc8F8uMB+htW1BacJMfLwJ0pV9QXYnEe78okOdlg gHqkJLIgrzEoo8LqbxMTbfa7cRmVsodSlB5qDlBn35gRdDfA4ex5du+JRc93PMBzFH3a iaUUKS3Aod+Hkk81B1O+bRcpHbx1f4gjc1tgIaLA5FMbqwmUebrY+koNBgoyTDfA/vic wCTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c66si11575423pga.494.2018.04.17.05.11.33; Tue, 17 Apr 2018 05:11:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752800AbeDQMKR (ORCPT + 99 others); Tue, 17 Apr 2018 08:10:17 -0400 Received: from mondschein.lichtvoll.de ([194.150.191.11]:57487 "EHLO mail.lichtvoll.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752546AbeDQMKQ (ORCPT ); Tue, 17 Apr 2018 08:10:16 -0400 Authentication-Results: auth=pass smtp.auth=martin smtp.mailfrom=martin@lichtvoll.de Received: from 127.0.0.1 (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lichtvoll.de (Postfix) with ESMTPSA id 62B012F772C; Tue, 17 Apr 2018 14:10:14 +0200 (CEST) From: Martin Steigerwald To: Jianchao Wang Cc: axboe@kernel.dk, bart.vanassche@wdc.com, tj@kernel.org, ming.lei@redhat.com, stable@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] blk-mq: start request gstate with gen 1 Date: Tue, 17 Apr 2018 14:10:08 +0200 Message-ID: <2612135.Ur0PZolWSD@merkaba> In-Reply-To: <1523936780-1589-1-git-send-email-jianchao.w.wang@oracle.com> References: <1523936780-1589-1-git-send-email-jianchao.w.wang@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jianchao, Jianchao Wang - 17.04.18, 05:46: > rq->gstate and rq->aborted_gstate both are zero before rqs are > allocated. If we have a small timeout, when the timer fires, > there could be rqs that are never allocated, and also there could > be rq that has been allocated but not initialized and started. At > the moment, the rq->gstate and rq->aborted_gstate both are 0, thus > the blk_mq_terminate_expired will identify the rq is timed out and > invoke .timeout early. For testing it I add it to 4.16.2 with the patches I have already? - '[PATCH] blk-mq_Directly schedule q->timeout_work when aborting a request.mbox' - '[PATCH v2] block: Change a rcu_read_{lock,unlock}_sched() pair into rcu_read_{lock,unlock}().mbox' - '[PATCH V4 1_2] blk-mq_set RQF_MQ_TIMEOUT_EXPIRED when the rq'\''s timeout isn'\''t handled.mbox' - '[PATCH V4 2_2] blk-mq_fix race between complete and BLK_EH_RESET_TIMER.mbox' > For scsi, this will cause scsi_times_out to be invoked before the > scsi_cmnd is not initialized, scsi_cmnd->device is still NULL at > the moment, then we will get crash. > > Cc: Bart Van Assche > Cc: Tejun Heo > Cc: Ming Lei > Cc: Martin Steigerwald > Cc: stable@vger.kernel.org > Signed-off-by: Jianchao Wang > --- > block/blk-core.c | 4 ++++ > block/blk-mq.c | 7 +++++++ > 2 files changed, 11 insertions(+) > > diff --git a/block/blk-core.c b/block/blk-core.c > index abcb868..ce62681 100644 > --- a/block/blk-core.c > +++ b/block/blk-core.c > @@ -201,6 +201,10 @@ void blk_rq_init(struct request_queue *q, struct > request *rq) rq->part = NULL; > seqcount_init(&rq->gstate_seq); > u64_stats_init(&rq->aborted_gstate_sync); > + /* > + * See comment of blk_mq_init_request > + */ > + WRITE_ONCE(rq->gstate, MQ_RQ_GEN_INC); > } > EXPORT_SYMBOL(blk_rq_init); > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index f5c7dbc..d62030a 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -2069,6 +2069,13 @@ static int blk_mq_init_request(struct > blk_mq_tag_set *set, struct request *rq, > > seqcount_init(&rq->gstate_seq); > u64_stats_init(&rq->aborted_gstate_sync); > + /* > + * start gstate with gen 1 instead of 0, otherwise it will be equal > + * to aborted_gstate, and be identified timed out by > + * blk_mq_terminate_expired. > + */ > + WRITE_ONCE(rq->gstate, MQ_RQ_GEN_INC); > + > return 0; > } -- Martin