Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp197235imj; Thu, 14 Feb 2019 18:28:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IYtTlbIKpuOu/LS8AwCEmQXzI2ehSyakfr+NofFLSI3n3KfKA8t6XtKuPYQebxavPkvoJdc X-Received: by 2002:a62:35c7:: with SMTP id c190mr7614513pfa.76.1550197723047; Thu, 14 Feb 2019 18:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197723; cv=none; d=google.com; s=arc-20160816; b=v4BM2mGmZzvItcMfPx4C3gFodGKGQ3vjqaX9elezZ2yKAlX7WDnEu/eWQ8Mymilhdh AugxXr5gqB9h7wtP6U+0Ta+yIhKMmmPsZ0+MY9L4qTXDBvS19m/G56LDCM1Q29YD6mF6 XeqVnn5M6jNb2bSPy5hdzrhx/sYVXxP6Lj6pdHOJuRTUxxIBJF3ftgHkt3LPFU0WirhO 451Q+SnzEvsWQeWrTqFQkcRPoLzZO2kVwCDY/x10r9NR+KRR9tdH/A6WwZaCeh+e2N1p yDiS4inYJ/igEOBPoNYRBllH9iUCFdDH0R+r+UIUX27G1ahPz6bJoOrqp34NHVG5BLXh +NbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ylsraXuL33MBQM2kd+q3hDKrkwbxojdhs+aT3ozOg6k=; b=HG3aD8pN7jAf8EW5g7KzuIzy5oc1JdGlaPPTz/WQ65cEXWfcaRTtJCzqDpTtuE5P+9 D6dzgQkV3FyACcqSYFObAAPGno4dUcO8SXzH2Vn6GeCSMg1mweL+2wg7FOufZrPiPLvj hwsGpulFZMQXHbkJDEVSO0mr+X+w8qaJdUYq+JPF7AXELiCnVTAYEkQuWrIOtAXNBC6R 5dO7KfdPVAwIFKqeAPfXDLhWW0Qp5YqNR7fzVK+rgXOaM2pHeCeUL5beg3S82HmsboFF 6EYkEmQxqyqM92VA3XjGZ+lIvpbykCAfQaqV8C7TBUCnEWxjxWF+hD0YAOzMKYW1TkZ1 1RYg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18si2487745pfm.39.2019.02.14.18.28.27; Thu, 14 Feb 2019 18:28:43 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731309AbfBOCBG (ORCPT + 99 others); Thu, 14 Feb 2019 21:01:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43398 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbfBOCBF (ORCPT ); Thu, 14 Feb 2019 21:01:05 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A35AFC0AC371; Fri, 15 Feb 2019 02:01:03 +0000 (UTC) Received: from ming.t460p (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EA8A5D6B6; Fri, 15 Feb 2019 02:00:55 +0000 (UTC) Date: Fri, 15 Feb 2019 10:00:51 +0800 From: Ming Lei To: Jianchao Wang Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Damien Le Moal Subject: Re: [PATCH V2] blk-mq: insert rq with DONTPREP to hctx dispatch list when requeue Message-ID: <20190215020049.GA21045@ming.t460p> References: <1549936585-1702-1-git-send-email-jianchao.w.wang@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1549936585-1702-1-git-send-email-jianchao.w.wang@oracle.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Feb 2019 02:01:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 12, 2019 at 09:56:25AM +0800, Jianchao Wang wrote: > When requeue, if RQF_DONTPREP, rq has contained some driver > specific data, so insert it to hctx dispatch list to avoid any > merge. Take scsi as example, here is the trace event log (no > io scheduler, because RQF_STARTED would prevent merging), > > kworker/0:1H-339 [000] ...1 2037.209289: block_rq_insert: 8,0 R 4096 () 32768 + 8 [kworker/0:1H] > scsi_inert_test-1987 [000] .... 2037.220465: block_bio_queue: 8,0 R 32776 + 8 [scsi_inert_test] > scsi_inert_test-1987 [000] ...2 2037.220466: block_bio_backmerge: 8,0 R 32776 + 8 [scsi_inert_test] > kworker/0:1H-339 [000] .... 2047.220913: block_rq_issue: 8,0 R 8192 () 32768 + 16 [kworker/0:1H] > scsi_inert_test-1996 [000] ..s1 2047.221007: block_rq_complete: 8,0 R () 32768 + 8 [0] > scsi_inert_test-1996 [000] .Ns1 2047.221045: block_rq_requeue: 8,0 R () 32776 + 8 [0] > kworker/0:1H-339 [000] ...1 2047.221054: block_rq_insert: 8,0 R 4096 () 32776 + 8 [kworker/0:1H] > kworker/0:1H-339 [000] ...1 2047.221056: block_rq_issue: 8,0 R 4096 () 32776 + 8 [kworker/0:1H] > scsi_inert_test-1986 [000] ..s1 2047.221119: block_rq_complete: 8,0 R () 32776 + 8 [0] > > (32768 + 8) was requeued by scsi_queue_insert and had RQF_DONTPREP. scsi_mq_requeue_cmd() does uninit the request before requeuing, but __scsi_queue_insert doesn't do that. > Then it was merged with (32776 + 8) and issued. Due to RQF_DONTPREP, > the sdb only contained the part of (32768 + 8), then only that part > was completed. The lucky thing was that scsi_io_completion detected > it and requeued the remaining part. So we didn't get corrupted data. > However, the requeue of (32776 + 8) is not expected. > > Suggested-by: Jens Axboe > Signed-off-by: Jianchao Wang > --- > V2: > - refactor the code based on Jens' suggestion > > block/blk-mq.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 8f5b533..9437a5e 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -737,12 +737,20 @@ static void blk_mq_requeue_work(struct work_struct *work) > spin_unlock_irq(&q->requeue_lock); > > list_for_each_entry_safe(rq, next, &rq_list, queuelist) { > - if (!(rq->rq_flags & RQF_SOFTBARRIER)) > + if (!(rq->rq_flags & (RQF_SOFTBARRIER | RQF_DONTPREP))) > continue; > > rq->rq_flags &= ~RQF_SOFTBARRIER; > list_del_init(&rq->queuelist); > - blk_mq_sched_insert_request(rq, true, false, false); > + /* > + * If RQF_DONTPREP, rq has contained some driver specific > + * data, so insert it to hctx dispatch list to avoid any > + * merge. > + */ > + if (rq->rq_flags & RQF_DONTPREP) > + blk_mq_request_bypass_insert(rq, false); > + else > + blk_mq_sched_insert_request(rq, true, false, false); > } Suppose it is one WRITE request to zone device, this way might break the order. Thanks, Ming