From patchwork Mon Oct 23 14:51:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10022657 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 5FE65603D7 for ; Mon, 23 Oct 2017 14:51:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DEE1285E2 for ; Mon, 23 Oct 2017 14:51:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40D06285EE; Mon, 23 Oct 2017 14:51:49 +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 CC8C7285E2 for ; Mon, 23 Oct 2017 14:51:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932340AbdJWOvs (ORCPT ); Mon, 23 Oct 2017 10:51:48 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:33787 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932285AbdJWOvr (ORCPT ); Mon, 23 Oct 2017 10:51:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mRrGNHfRmfglgWvHwdiPf8oFyoO4tY4+V0igG3pA2L0=; b=A9ydwHwyq0/2x719AJrXTeWwS 5nIxJNBOrwS03QufexHsaRL0Dm9v0hMUbEmG9uYXa39v6oxtOUq/VECzDm989g3BcYQUl76W3Xn1y h2K5FgpEpM2egjeX/+HOESkCEX6Yt1ToWJ28fAJPzTH75MTcsLhRtT3/NZEmyiGwSaVeLnMX8DbZx UHKHdWXFXcQP0XkYxc2bsfONrDdy6VbZHWfrMUxCL3j2v2r2FEVFq3I9LWkP8g6l+85WFeLpQqqlC 82EL/6ntcwkEp5mzVqIosmNupgpEwq4J5yVg3NwCq/Y/hfQewS8uE1mACPH/r/k2ll9M2fdAG69eC 7z6Wv/zNg==; Received: from 80-109-164-210.cable.dynamic.surfer.at ([80.109.164.210] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1e6e4s-0008FC-Qr; Mon, 23 Oct 2017 14:51:43 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Keith Busch , Sagi Grimberg , Hannes Reinecke , Johannes Thumshirn , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Subject: [PATCH 04/17] block: add a blk_steal_bios helper Date: Mon, 23 Oct 2017 16:51:13 +0200 Message-Id: <20171023145126.2471-5-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171023145126.2471-1-hch@lst.de> References: <20171023145126.2471-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 This helpers allows to bounce steal the uncompleted bios from a request so that they can be reissued on another path. Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- block/blk-core.c | 20 ++++++++++++++++++++ include/linux/blkdev.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index b8c80f39f5fe..e804529e65a5 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2767,6 +2767,26 @@ struct request *blk_fetch_request(struct request_queue *q) } EXPORT_SYMBOL(blk_fetch_request); +/* + * Steal bios from a request. The request must not have been partially + * completed before. + */ +void blk_steal_bios(struct bio_list *list, struct request *rq) +{ + if (rq->bio) { + if (list->tail) + list->tail->bi_next = rq->bio; + else + list->head = rq->bio; + list->tail = rq->biotail; + } + + rq->bio = NULL; + rq->biotail = NULL; + rq->__data_len = 0; +} +EXPORT_SYMBOL_GPL(blk_steal_bios); + /** * blk_update_request - Special helper function for request stacking drivers * @req: the request being processed diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 780f01db5899..45c63764a14e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1110,6 +1110,8 @@ extern struct request *blk_peek_request(struct request_queue *q); extern void blk_start_request(struct request *rq); extern struct request *blk_fetch_request(struct request_queue *q); +void blk_steal_bios(struct bio_list *list, struct request *rq); + /* * Request completion related functions. *