From patchwork Thu Feb 1 19:52:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10195955 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 125E660247 for ; Thu, 1 Feb 2018 20:36:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F37E5281DB for ; Thu, 1 Feb 2018 20:36:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1CB82882E; Thu, 1 Feb 2018 20:36:32 +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 A8D2728C42 for ; Thu, 1 Feb 2018 20:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754593AbeBATs0 (ORCPT ); Thu, 1 Feb 2018 14:48:26 -0500 Received: from mga02.intel.com ([134.134.136.20]:60673 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838AbeBATs0 (ORCPT ); Thu, 1 Feb 2018 14:48:26 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 11:48:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,444,1511856000"; d="scan'208";a="27345471" Received: from unknown (HELO localhost.localdomain) ([10.232.112.44]) by fmsmga001.fm.intel.com with ESMTP; 01 Feb 2018 11:48:25 -0800 Date: Thu, 1 Feb 2018 12:52:12 -0700 From: Keith Busch To: Jens Axboe Cc: "jianchao.wang" , "linux-block@vger.kernel.org" , Christoph Hellwig , "linux-nvme@lists.infradead.org" , Ming Lei Subject: Re: WARNING: CPU: 2 PID: 207 at drivers/nvme/host/core.c:527 nvme_setup_cmd+0x3d3 Message-ID: <20180201195212.GD24417@localhost.localdomain> References: <45f93661-da0d-94c5-1740-85242df8776e@kernel.dk> <0872b361-157b-a876-20af-3d7a4ee7ff31@kernel.dk> <8fd916ab-42d7-c654-5a01-8f1eb4be730e@oracle.com> <0b7686b3-f716-49ba-c7c4-929d84905569@kernel.dk> <7459ffed-c63c-38a9-84f5-456c2a5c4fe0@oracle.com> <0f6c248b-eb67-9b02-a4b9-0366d476e70d@kernel.dk> <20180201045645.GF27735@localhost.localdomain> <576ba7dc-78cf-b5d2-d1de-446d1f4b2732@kernel.dk> <7ec361a3-8900-d259-6842-e0b0b14a253a@kernel.dk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7ec361a3-8900-d259-6842-e0b0b14a253a@kernel.dk> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Feb 01, 2018 at 10:58:23AM -0700, Jens Axboe wrote: > I was able to reproduce on a test box, pretty trivially in fact: > > # echo mq-deadline > /sys/block/nvme2n1/queue/scheduler > # mkfs.ext4 /dev/nvme2n1 > # mount /dev/nvme2n1 /data -o discard > # dd if=/dev/zero of=/data/10g bs=1M count=10k > # sync > # rm /data/10g > # sync <- triggered > > Your patch still doesn't work, but mainly because we init the segments > to 0 when setting up a discard. The below works for me, and cleans up > the merge path a bit, since your patch was missing various adjustments > on both the merged and freed request. I'm still finding cases not accounted even your patch. I had to use the following on top of that, and this pattern looks like it needs to be repeated for all schedulers: --- -- diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 55c0a745b427..25c14c58385c 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -259,6 +259,8 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, if (!*merged_request) elv_merged_request(q, rq, ELEVATOR_FRONT_MERGE); return true; + case ELEVATOR_DISCARD_MERGE: + return bio_attempt_discard_merge(q, rq, bio); default: return false; } diff --git a/block/mq-deadline.c b/block/mq-deadline.c index c56f211c8440..a0f5752b6858 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -451,7 +451,7 @@ static int dd_request_merge(struct request_queue *q, struct request **rq, if (elv_bio_merge_ok(__rq, bio)) { *rq = __rq; - return ELEVATOR_FRONT_MERGE; + return blk_try_merge(__rq, bio); } }