From patchwork Mon Apr 10 16:08:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9673141 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 53C9F600CB for ; Mon, 10 Apr 2017 16:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C43326AE3 for ; Mon, 10 Apr 2017 16:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31151283E1; Mon, 10 Apr 2017 16:08:41 +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=unavailable 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 D1D1726AE3 for ; Mon, 10 Apr 2017 16:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752738AbdDJQIi (ORCPT ); Mon, 10 Apr 2017 12:08:38 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:34586 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751602AbdDJQId (ORCPT ); Mon, 10 Apr 2017 12:08:33 -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=dlb2RqqCdTIAZsUnsY3UdlUcSSt9EZpoJk1QoIb+g6k=; b=gcCFHtAbFWay9ksfuXQYTdrod JrOYuAx/0nBl5HHi9954fnEwIplYkwu4sYUW1tYNmzpdeZRv/P0KEILEx9TLTCGgyqflce84rDYvi zsmvy8p0dlgISGI7mCsYgmeYrPkbKFYSTtlUivVuaW/Ps3UnLKQxZTgJT6H1lU5q/4xXuJ5K9pUK0 mKy0bDY+zSVmqNw/28AGFc2ty+LPShw3WRHVyi0a4RjPX5a0C46+fn2J3Y1R7ozQCWczz2t5A9lfQ LohUYQGVZLz7pvi67NIQVU5lY2jtN0F2yDWP8EfTwiCfvEa9I6pfShz9Wf2Dr1ghkVL6ZwP0Vn3y1 S8Rbo2oFA==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cxbrj-0008PD-RG; Mon, 10 Apr 2017 16:08:32 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, target-devel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com, dm-devel@redhat.com Subject: [PATCH 8/8] block: use bio_has_data to check if a bio has bvecs Date: Mon, 10 Apr 2017 18:08:07 +0200 Message-Id: <20170410160807.23674-9-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170410160807.23674-1-hch@lst.de> References: <20170410160807.23674-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 Now that Write Same is gone and discard bios never have a payload we can simply use bio_has_data as an indicator that the bio has bvecs that need to be handled. Signed-off-by: Christoph Hellwig --- block/bio.c | 8 +------- block/blk-merge.c | 9 +-------- include/linux/bio.h | 21 +++++---------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/block/bio.c b/block/bio.c index b310e7ef3fbf..1c9f04c30ba9 100644 --- a/block/bio.c +++ b/block/bio.c @@ -679,15 +679,9 @@ static struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; - switch (bio_op(bio)) { - case REQ_OP_DISCARD: - case REQ_OP_SECURE_ERASE: - case REQ_OP_WRITE_ZEROES: - break; - default: + if (bio_has_data(bio)) { __bio_for_each_segment(bv, bio_src, iter, iter_src) bio->bi_io_vec[bio->bi_vcnt++] = bv; - break; } if (bio_integrity(bio_src)) { diff --git a/block/blk-merge.c b/block/blk-merge.c index d6c86bfc5722..549d060097f1 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -232,16 +232,9 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, struct bio *fbio, *bbio; struct bvec_iter iter; - if (!bio) + if (!bio || !bio_has_data(bio)) return 0; - switch (bio_op(bio)) { - case REQ_OP_DISCARD: - case REQ_OP_SECURE_ERASE: - case REQ_OP_WRITE_ZEROES: - return 0; - } - fbio = bio; cluster = blk_queue_cluster(q); seg_size = 0; diff --git a/include/linux/bio.h b/include/linux/bio.h index 7a24a1a24967..86bf531f97aa 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -178,26 +178,15 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, static inline unsigned __bio_segments(struct bio *bio, struct bvec_iter *bvec) { unsigned segs = 0; - struct bio_vec bv; - struct bvec_iter iter; - /* - * We special case discard/write same/write zeroes, because they - * interpret bi_size differently: - */ + if (bio_has_data(bio)) { + struct bio_vec bv; + struct bvec_iter iter; - switch (bio_op(bio)) { - case REQ_OP_DISCARD: - case REQ_OP_SECURE_ERASE: - case REQ_OP_WRITE_ZEROES: - return 0; - default: - break; + __bio_for_each_segment(bv, bio, iter, *bvec) + segs++; } - __bio_for_each_segment(bv, bio, iter, *bvec) - segs++; - return segs; }