From patchwork Mon Aug 3 05:58:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lin X-Patchwork-Id: 6927361 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D6E619F39D for ; Mon, 3 Aug 2015 06:03:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E560C20520 for ; Mon, 3 Aug 2015 06:03:27 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB5F720504 for ; Mon, 3 Aug 2015 06:03:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t735wUtp019941; Mon, 3 Aug 2015 01:58:31 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t735wSlR030876 for ; Mon, 3 Aug 2015 01:58:28 -0400 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t735wRV7013444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 3 Aug 2015 01:58:27 -0400 Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by mx1.redhat.com (Postfix) with ESMTP id C8ADB91591; Mon, 3 Aug 2015 05:58:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BBAA203F7; Mon, 3 Aug 2015 05:58:25 +0000 (UTC) Received: from [10.0.0.138] (c-50-185-88-18.hsd1.ca.comcast.net [50.185.88.18]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DCF0520204; Mon, 3 Aug 2015 05:58:23 +0000 (UTC) Message-ID: <1438581502.26596.24.camel@hasee> From: Ming Lin To: Mike Snitzer Date: Sun, 02 Aug 2015 22:58:22 -0700 In-Reply-To: <20150801163356.GA21478@redhat.com> References: <1436168690-32102-1-git-send-email-mlin@kernel.org> <20150731192337.GA8907@redhat.com> <20150731213831.GA16464@redhat.com> <1438412290.26596.14.camel@hasee> <20150801163356.GA21478@redhat.com> Mime-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP X-RedHat-Spam-Score: -4.428 (BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD) 198.145.29.136 mail.kernel.org 198.145.29.136 mail.kernel.org X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.75 on 10.5.110.25 X-loop: dm-devel@redhat.com Cc: Neil@redhat.com, Ming Lei , Al@redhat.com, dm-devel@redhat.com, Christoph Hellwig , Alasdair Kergon , Lars Ellenberg , Oleg@redhat.com, Philip Kelleher , Joshua Morris , Christoph Hellwig , Kent Overstreet , Nitin Gupta , Ming Lin , Drokin , Viro , Jens Axboe , Andreas Dilger , Geoff Levand , Jiri Kosina , lkml , Jim Paris , Minchan Kim , Dongsu Park , drbd-user@lists.linbit.com Subject: Re: [dm-devel] [PATCH v5 01/11] block: make generic_make_request handle arbitrarily sized bios X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP On Sat, 2015-08-01 at 12:33 -0400, Mike Snitzer wrote: > On Sat, Aug 01 2015 at 2:58am -0400, > Ming Lin wrote: > > > On Fri, 2015-07-31 at 17:38 -0400, Mike Snitzer wrote: > > > > > > OK, once setup, to run the 2 tests in question directly you'd do > > > something like: > > > > > > dmtest run --suite thin-provisioning -n discard_a_fragmented_device > > > > > > dmtest run --suite thin-provisioning -n discard_fully_provisioned_device_benchmark > > > > > > Again, these tests pass without this patchset. > > > > It's caused by patch 4. Typo. I mean patch 5. > > When discard size >=4G, the bio->bi_iter.bi_size overflows. > > Thanks for tracking this down! blkdev_issue_write_same() has same problem. > > > Below is the new patch. > > > > Christoph, > > Could you also help to review it? > > > > Now we still do "misaligned" check in blkdev_issue_discard(). > > So the same code in blk_bio_discard_split() was removed. > > But I don't agree with this approach. One of the most meaningful > benefits of late bio splitting is the upper layers shouldn't _need_ to > depend on the intermediate devices' queue_limits being stacked properly. > Your solution to mix discard granularity/alignment checks at the upper > layer(s) but then split based on max_discard_sectors at the lower layer > defeats that benefit for discards. > > This will translate to all intermediate layers that might split > discards needing to worry about granularity/alignment > too (e.g. how dm-thinp will have to care because it must generate > discard mappings with associated bios based on how blocks were mapped to > thinp). I think the important thing is the late splitting for regular bio. For discard/write_same bio, how about just don't do late splitting? That is: 1. remove "PATCH 5: block: remove split code in blkdev_issue_discard" 2. Add below changes to PATCH 1 > > Also, it is unfortunate that IO that doesn't have a payload is being > artificially split simply because bio->bi_iter.bi_size is 32bits. Indeed. Will it be possible to make it 64bits? I guess no. > > Mike --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-merge.c b/block/blk-merge.c index 1f5dfa0..90b085e 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -9,59 +9,6 @@ #include "blk.h" -static struct bio *blk_bio_discard_split(struct request_queue *q, - struct bio *bio, - struct bio_set *bs) -{ - unsigned int max_discard_sectors, granularity; - int alignment; - sector_t tmp; - unsigned split_sectors; - - /* Zero-sector (unknown) and one-sector granularities are the same. */ - granularity = max(q->limits.discard_granularity >> 9, 1U); - - max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9); - max_discard_sectors -= max_discard_sectors % granularity; - - if (unlikely(!max_discard_sectors)) { - /* XXX: warn */ - return NULL; - } - - if (bio_sectors(bio) <= max_discard_sectors) - return NULL; - - split_sectors = max_discard_sectors; - - /* - * If the next starting sector would be misaligned, stop the discard at - * the previous aligned sector. - */ - alignment = (q->limits.discard_alignment >> 9) % granularity; - - tmp = bio->bi_iter.bi_sector + split_sectors - alignment; - tmp = sector_div(tmp, granularity); - - if (split_sectors > tmp) - split_sectors -= tmp; - - return bio_split(bio, split_sectors, GFP_NOIO, bs); -} - -static struct bio *blk_bio_write_same_split(struct request_queue *q, - struct bio *bio, - struct bio_set *bs) -{ - if (!q->limits.max_write_same_sectors) - return NULL; - - if (bio_sectors(bio) <= q->limits.max_write_same_sectors) - return NULL; - - return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs); -} - static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *bio, struct bio_set *bs) @@ -129,10 +76,8 @@ void blk_queue_split(struct request_queue *q, struct bio **bio, { struct bio *split; - if ((*bio)->bi_rw & REQ_DISCARD) - split = blk_bio_discard_split(q, *bio, bs); - else if ((*bio)->bi_rw & REQ_WRITE_SAME) - split = blk_bio_write_same_split(q, *bio, bs); + if ((*bio)->bi_rw & REQ_DISCARD || (*bio)->bi_rw & REQ_WRITE_SAME) + split = NULL; else split = blk_bio_segment_split(q, *bio, q->bio_split);