From patchwork Wed Feb 28 17:35:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10248989 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 E4C4F60211 for ; Wed, 28 Feb 2018 17:35:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7AC228D78 for ; Wed, 28 Feb 2018 17:35:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC28728E10; Wed, 28 Feb 2018 17:35:36 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3ACFC28D78 for ; Wed, 28 Feb 2018 17:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932583AbeB1Rfd (ORCPT ); Wed, 28 Feb 2018 12:35:33 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:9260 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932549AbeB1Rfa (ORCPT ); Wed, 28 Feb 2018 12:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1519839330; x=1551375330; h=from:to:cc:subject:date:message-id; bh=03blLOC+yKKTWs3YMJu+rQe7otV+hGYvhjLcPSCNKQ8=; b=ram2yhDnEPRp3w7BdkU6hAZNloDgg6QcqXN1WNGllO0WNwH9MmUw3zOy MO9+4es6i2BxTCKfPXJ7nyJn+pKlYlL5gYbFuTwhNIOybLDqOZxoKTTvO qwWcvApuH9I7VxWU2pqFcQ7pCj6sSBZ0QSvrbfoE60o83l2LIEIdhDXWd /odwWHEqdgmJxQWzpwhSY8/zU/1J4JUkKMAPmlABxm18pRCTZ2P+jCVVZ FPjnB5qeTqGCsWvuHVP4+vlkVo9wAcKJmG/QlkSkEywe0RgNbv3kVv7wR j7qGu0c/Z77E8drzwzJYwb2q1iCwxzw6uTBvBRNRUdgfNcJSI/LsLc8fw w==; X-IronPort-AV: E=Sophos;i="5.47,406,1515427200"; d="scan'208";a="72602121" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Mar 2018 01:35:29 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 28 Feb 2018 09:29:35 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 28 Feb 2018 09:35:29 -0800 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Bart Van Assche , Hannes Reinecke , Ming Lei Subject: [PATCH] mq-deadline: Make sure to always unlock zones Date: Wed, 28 Feb 2018 09:35:29 -0800 Message-Id: <20180228173529.24941-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.2 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 From: Damien Le Moal In case of a failed write request (all retries failed) and when using libata, the SCSI error handler calls scsi_finish_command(). In the case of blk-mq this means that scsi_mq_done() does not get called, that blk_mq_complete_request() does not get called and also that the mq-deadline .completed_request() method is not called. This results in the target zone of the failed write request being left in a locked state, preventing that any new write requests are issued to the same zone. Fix this by replacing the .completed_request() method with the .finish_request() method as this method is always called whether or not a request completes successfully. Since the .finish_request() method is only called by the blk-mq core if a .prepare_request() method exists, add a dummy .prepare_request() method. Fixes: 5700f69178e9 ("mq-deadline: Introduce zone locking support") Signed-off-by: Damien Le Moal Signed-off-by: Bart Van Assche [ bvanassche: edited patch description ] Cc: Hannes Reinecke Cc: Ming Lei Reviewed-by: Ming Lei --- block/mq-deadline.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index c56f211c8440..8ec0ba9f5386 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -535,13 +535,22 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx, spin_unlock(&dd->lock); } +/* + * Nothing to do here. This is defined only to ensure that .finish_request + * method is called upon request completion. + */ +static void dd_prepare_request(struct request *rq, struct bio *bio) +{ +} + /* * For zoned block devices, write unlock the target zone of * completed write requests. Do this while holding the zone lock * spinlock so that the zone is never unlocked while deadline_fifo_request() - * while deadline_next_request() are executing. + * or deadline_next_request() are executing. This function is called for + * all requests, whether or not these requests complete successfully. */ -static void dd_completed_request(struct request *rq) +static void dd_finish_request(struct request *rq) { struct request_queue *q = rq->q; @@ -756,7 +765,8 @@ static struct elevator_type mq_deadline = { .ops.mq = { .insert_requests = dd_insert_requests, .dispatch_request = dd_dispatch_request, - .completed_request = dd_completed_request, + .prepare_request = dd_prepare_request, + .finish_request = dd_finish_request, .next_request = elv_rb_latter_request, .former_request = elv_rb_former_request, .bio_merge = dd_bio_merge,