From patchwork Wed Nov 27 00:45:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 3242451 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D67709F3B8 for ; Wed, 27 Nov 2013 00:47:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BF3A201B3 for ; Wed, 27 Nov 2013 00:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B7BF20166 for ; Wed, 27 Nov 2013 00:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754683Ab3K0Aqb (ORCPT ); Tue, 26 Nov 2013 19:46:31 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:39337 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754228Ab3K0AqL (ORCPT ); Tue, 26 Nov 2013 19:46:11 -0500 Received: by mail-pb0-f53.google.com with SMTP id ma3so9110185pbc.26 for ; Tue, 26 Nov 2013 16:46:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kisXa9KUu2Cxy27W3JWiC9Lb631/Sg+lAbjogrXYU8s=; b=UANSSX5pC0gtPV4hg++PusxPIoxKClhafzTxyLsSVncrMWePqD+uiZjrNZ6L1xw3Rz pmoouODDsQ5dpOd/dZt7ZizqLqkIdULec8ekqATX052DSANxXvV6gweQyLF7EJaRZ0IQ Pg/hgKDylKNTshlpffANVHpZ/C1/3TtD95rUzbzOSn9E10R8BNGpbkoSvjYqyrQiOX4d UuV5v1EYkKWFKfD49c7F9+WuPw4B13HBgvJhG754Wl31lD3sgs+VT8GCYVpLYWmD08Kg Py6+599Vj0r/w1McfHTyQTkXh+oHSBVbuKDxdJS+1MtgT5ntpWubaYR5umiJlEUNkewF 69Kg== X-Gm-Message-State: ALoCoQnFKAzfqF2fJzUOEJL/nrMTr1GLswp5GESiAzvHKJxA5x+KDCmJMPpLqZdR2mJ30oKOWKaY X-Received: by 10.66.171.13 with SMTP id aq13mr38511834pac.30.1385513171268; Tue, 26 Nov 2013 16:46:11 -0800 (PST) Received: from kmo.daterainc.com ([157.22.22.146]) by mx.google.com with ESMTPSA id dq3sm83554293pbc.35.2013.11.26.16.46.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Nov 2013 16:46:09 -0800 (PST) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org Cc: Kent Overstreet , Jens Axboe , Yehuda Sadeh , Alex Elder , ceph-devel@vger.kernel.org Subject: [PATCH 18/25] rbd: Refactor bio cloning Date: Tue, 26 Nov 2013 16:45:21 -0800 Message-Id: <1385513128-5035-18-git-send-email-kmo@daterainc.com> X-Mailer: git-send-email 1.8.4.4 In-Reply-To: <1385513128-5035-1-git-send-email-kmo@daterainc.com> References: <20131127004422.GB21305@kmo> <1385513128-5035-1-git-send-email-kmo@daterainc.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 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 Now that we've got drivers converted to the new immutable bvec primitives, bio splitting becomes much easier - this is how the new bio_split() will work. (Someone more familiar with the ceph code could probably use bio_clone_fast() instead of bio_clone() here). Signed-off-by: Kent Overstreet Cc: Jens Axboe Cc: Yehuda Sadeh Cc: Alex Elder Cc: ceph-devel@vger.kernel.org --- drivers/block/rbd.c | 64 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 20e8ab3..3624368 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1173,73 +1173,13 @@ static struct bio *bio_clone_range(struct bio *bio_src, unsigned int len, gfp_t gfpmask) { - struct bio_vec bv; - struct bvec_iter iter; - struct bvec_iter end_iter; - unsigned int resid; - unsigned int voff; - unsigned short vcnt; struct bio *bio; - /* Handle the easy case for the caller */ - - if (!offset && len == bio_src->bi_iter.bi_size) - return bio_clone(bio_src, gfpmask); - - if (WARN_ON_ONCE(!len)) - return NULL; - if (WARN_ON_ONCE(len > bio_src->bi_iter.bi_size)) - return NULL; - if (WARN_ON_ONCE(offset > bio_src->bi_iter.bi_size - len)) - return NULL; - - /* Find first affected segment... */ - - resid = offset; - bio_for_each_segment(bv, bio_src, iter) { - if (resid < bv.bv_len) - break; - resid -= bv.bv_len; - } - voff = resid; - - /* ...and the last affected segment */ - - resid += len; - __bio_for_each_segment(bv, bio_src, end_iter, iter) { - if (resid <= bv.bv_len) - break; - resid -= bv.bv_len; - } - vcnt = end_iter.bi_idx = iter.bi_idx + 1; - - /* Build the clone */ - - bio = bio_alloc(gfpmask, (unsigned int) vcnt); + bio = bio_clone(bio_src, gfpmask); if (!bio) return NULL; /* ENOMEM */ - bio->bi_bdev = bio_src->bi_bdev; - bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector + - (offset >> SECTOR_SHIFT); - bio->bi_rw = bio_src->bi_rw; - bio->bi_flags |= 1 << BIO_CLONED; - - /* - * Copy over our part of the bio_vec, then update the first - * and last (or only) entries. - */ - memcpy(&bio->bi_io_vec[0], &bio_src->bi_io_vec[iter.bi_idx], - vcnt * sizeof (struct bio_vec)); - bio->bi_io_vec[0].bv_offset += voff; - if (vcnt > 1) { - bio->bi_io_vec[0].bv_len -= voff; - bio->bi_io_vec[vcnt - 1].bv_len = resid; - } else { - bio->bi_io_vec[0].bv_len = len; - } - - bio->bi_vcnt = vcnt; + bio_advance(bio, offset); bio->bi_iter.bi_size = len; return bio;