From patchwork Tue Sep 25 22:06:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1506591 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork2.kernel.org (Postfix) with ESMTP id 1EEBADFE80 for ; Tue, 25 Sep 2012 22:09:35 +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 q8PM6abi008325; Tue, 25 Sep 2012 18:06:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8PM6ZYM024632 for ; Tue, 25 Sep 2012 18:06:35 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8PM6TZa000744 for ; Tue, 25 Sep 2012 18:06:29 -0400 Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8PM6SVa001508 for ; Tue, 25 Sep 2012 18:06:28 -0400 Received: by pbbrr4 with SMTP id rr4so845156pbb.33 for ; Tue, 25 Sep 2012 15:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=fOfKNnU1uPSQfd7KASOXM6ZHML8YEgyanK8ceZAXoRI=; b=BHVPEyqoQCyD8zm044OrRo84UDAaA+7algkkE/Ib7bKJUC4f+diQotnNaoSLbN8me8 3HSIWlB3BcotDZ+pjznSRTetj0AhkEfulUrr/2tOnQCKSNSmIsGQwym8iqvgiTD+2QsX pBbry+AE0mA7LApZmJDcw0/ZzVgxnWftr642vFl/RBqk95CVmwf2/U0iKsO9x5Bw1G14 Wr5Mt+cLMBg+ffdUFOLPuIwp8AlpctsBTQn/3cD+/StNCFXM8YZtx5I00zVPPFuIEjl2 Mp/X5N/IkGXLKcaSMV34XzTljLd5Qkpd8KlRIoDtXuQ1A4Hg0l5uaGgqDTqE03KbfG4G FVIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=fOfKNnU1uPSQfd7KASOXM6ZHML8YEgyanK8ceZAXoRI=; b=pZ0G2RO63cNgypGKItgF08AbNv1LVJG2k2bK9GpER/gU2gaOgfBz+/POYPE5lapo0B p/6rwZ4YzqiLKJ2SgH3wsytW/JZl35S6/EP+RYjephbTh6lc8Gv4uVGi0cC83Zrh8yfE YIsrbl2rIzP+E4zyI0MN/xIz6ss0VV5DN3fmTyo8JJFPoP/NyUy8gnsibbi9wjIuWm2w hZUVLCWjP02rcgu+60iRoJuQpFzFLGaPmgHthxOlxPOHdHdjAe5tVTgeZNNMYLh/0TkU nLWipyUhulsn94K8c3Ipxl2YLEVuJTf614GmjSe/RN5LSveGRuY46glXXzyzYKzrv5uZ vFCQ== Received: by 10.66.82.101 with SMTP id h5mr44216026pay.15.1348610788160; Tue, 25 Sep 2012 15:06:28 -0700 (PDT) Received: by 10.66.82.101 with SMTP id h5mr44215978pay.15.1348610788026; Tue, 25 Sep 2012 15:06:28 -0700 (PDT) Received: from google.com ([2620:0:1000:2300:be30:5bff:fed1:fc17]) by mx.google.com with ESMTPS id g2sm744422paz.23.2012.09.25.15.06.26 (version=SSLv3 cipher=OTHER); Tue, 25 Sep 2012 15:06:27 -0700 (PDT) Date: Tue, 25 Sep 2012 15:06:24 -0700 From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, axboe@kernel.dk, linux-s390@vger.kernel.org, Chris Mason , neilb@suse.de, Jiri Kosina , Heiko Carstens , Martin Schwidefsky , Alasdair Kergon , tj@kernel.org, Steven Whitehouse , vgoyal@redhat.com, Lars Ellenberg Message-ID: <20120925220624.GC22647@google.com> References: <1348526106-17074-1-git-send-email-koverstreet@google.com> <1348526106-17074-7-git-send-email-koverstreet@google.com> <20120925115452.GF8143@soda.linbit> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120925115452.GF8143@soda.linbit> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQmhkd7rEyTGfa1nKDtnaENjJx0U9zL+Mp3/BUZ9qz6kpbIKWshgi4dnkSFV+EEEjmMfdxttXXSz7K8fjw9dp+EPrUMHgZyXjDQgBwkg4zNYEyu6okQ/uRJTs3LPEyd3Ixq2cBk962suOTbA0ZNGOQoiGduhnN4F6dwZXzfKdvfHZ1Pv0uiY1L1/STDzWbNiAK9g6wwc X-RedHat-Spam-Score: -3.514 (BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com Subject: Re: [dm-devel] [Drbd-dev] [PATCH v3 06/26] block: Add bio_end_sector() 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 On Tue, Sep 25, 2012 at 01:54:52PM +0200, Lars Ellenberg wrote: > On Mon, Sep 24, 2012 at 03:34:46PM -0700, Kent Overstreet wrote: > > Just a little convenience macro - main reason to add it now is preparing > > for immutable bio vecs, it'll reduce the size of the patch that puts > > bi_sector/bi_size/bi_idx into a struct bvec_iter. > > > For the DRBD part: > > > diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c > > index 01b2ac6..d90a1fd 100644 > > --- a/drivers/block/drbd/drbd_req.c > > +++ b/drivers/block/drbd/drbd_req.c > > @@ -1144,7 +1144,7 @@ void drbd_make_request(struct request_queue *q, struct bio *bio) > > /* to make some things easier, force alignment of requests within the > > * granularity of our hash tables */ > > s_enr = bio->bi_sector >> HT_SHIFT; > > - e_enr = bio->bi_size ? (bio->bi_sector+(bio->bi_size>>9)-1) >> HT_SHIFT : s_enr; > > + e_enr = (bio_end_sector(bio) - 1) >> HT_SHIFT; > > You ignored the bio->bi_size ? : ; > > #define bio_end_sector(bio) ((bio)->bi_sector + bio_sectors(bio)) > which turns out (bio->bi_sector + (bio->bi_size >> 9)) > > Note that bi_size may be 0, bio_end_sector(bio)-1 then is bi_sector -1, > for an empty flush with bi_sector == 0, this ends up as (sector_t)-1ULL, > and this code path breaks horribly. Man, that was dumb of me - thanks for catching it. Version below look good? --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 01b2ac6..47f55db 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1144,7 +1144,7 @@ void drbd_make_request(struct request_queue *q, struct bio *bio) /* to make some things easier, force alignment of requests within the * granularity of our hash tables */ s_enr = bio->bi_sector >> HT_SHIFT; - e_enr = bio->bi_size ? (bio->bi_sector+(bio->bi_size>>9)-1) >> HT_SHIFT : s_enr; + e_enr = bio->bi_size ? (bio_end_sector(bio) - 1) >> HT_SHIFT : s_enr; if (likely(s_enr == e_enr)) { do {