From patchwork Mon Sep 26 23:00:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 9351359 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 7E4B96077A for ; Mon, 26 Sep 2016 22:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58A6928729 for ; Mon, 26 Sep 2016 22:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36F6A28E8F; Mon, 26 Sep 2016 22:49:35 +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 ACCCF28729 for ; Mon, 26 Sep 2016 22:49:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753022AbcIZWtd (ORCPT ); Mon, 26 Sep 2016 18:49:33 -0400 Received: from mga09.intel.com ([134.134.136.24]:3616 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751540AbcIZWtd (ORCPT ); Mon, 26 Sep 2016 18:49:33 -0400 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP; 26 Sep 2016 15:49:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,401,1470726000"; d="scan'208";a="13586108" Received: from unknown (HELO localhost.localdomain) ([10.232.112.65]) by orsmga005.jf.intel.com with ESMTP; 26 Sep 2016 15:49:32 -0700 Date: Mon, 26 Sep 2016 19:00:30 -0400 From: Keith Busch To: linux-block@vger.kernel.org, Jens Axboe Cc: Christoph Hellwig Subject: [PATCH] blk-mq: Return invalid cookie if bio was split Message-ID: <20160926230030.GB24200@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.0 (2016-08-17) 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 The only user of polling requires its original request be completed in its entirety before continuing execution. If the bio needs to be split and chained for any reason, the direct IO path would have waited for just that split portion to complete, leading to potential data corruption if the remaining transfer has not yet completed. This patch has blk-mq return an invalid cookie if a bio requires splitting so that polling does not occur. Signed-off-by: Keith Busch --- block/blk-mq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c207fa9..6385985 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1311,6 +1311,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) unsigned int request_count = 0; struct blk_plug *plug; struct request *same_queue_rq = NULL; + struct bio *orig = bio; blk_qc_t cookie; blk_queue_bounce(q, &bio); @@ -1389,7 +1390,7 @@ run_queue: } blk_mq_put_ctx(data.ctx); done: - return cookie; + return bio == orig ? cookie : BLK_QC_T_NONE; } /* @@ -1404,6 +1405,7 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) unsigned int request_count = 0; struct blk_map_ctx data; struct request *rq; + struct bio *orig = bio; blk_qc_t cookie; blk_queue_bounce(q, &bio); @@ -1467,7 +1469,7 @@ run_queue: } blk_mq_put_ctx(data.ctx); - return cookie; + return bio == orig ? cookie : BLK_QC_T_NONE; } /*