From patchwork Wed Mar 27 17:39:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 2352381 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 37261DFE82 for ; Wed, 27 Mar 2013 17:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753652Ab3C0Rky (ORCPT ); Wed, 27 Mar 2013 13:40:54 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:47926 "EHLO mail-da0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753624Ab3C0Rkv (ORCPT ); Wed, 27 Mar 2013 13:40:51 -0400 Received: by mail-da0-f45.google.com with SMTP id v40so4187853dad.18 for ; Wed, 27 Mar 2013 10:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=FSrn6U0MxA20Wifj6xMWEHCpD3ndS42AYTLwjqvTKjE=; b=f7y8PWi8onH2kxZMBZBmp8wF+a5AR2K0qBKbHVqqpaRqMOKoyvRKHo31eKAPHmqGhP 5wG1vv53cWblrotrIvM6rr9W7lCN0h7o6rV1D3tGj/Oxc6+A4s/cU3fqFD39sgEDFEhz Uuc9a4Es/gqctn3sOTeLLJ3pNzxk361E++RGIs0hwKmzqyvqyRFyOxfsynOIsKs53S6S 5ChWAvsa9Lp3IvDoChsAOhn92U/05CBQC21GI3bh2s8j1jhqdPaggxbdilkP9bCuhY1u 135teXaFF4SJPIkxlpFi9te6RDEkvNkELiD48g6zwUcncaHvrQu647PYa+y9KeP8TjiR EMhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=FSrn6U0MxA20Wifj6xMWEHCpD3ndS42AYTLwjqvTKjE=; b=ULgBdrrwdBiHIR0bcovdaN12hTq3qvS1SogqzGu2tBFr8RxmjGL38SD/6GumPtmAp/ OuW4vzBqgUMiUXO4kFNiIVCK+Tla7V0DDm2Mdaj5NG5/LtX5MW4HFFuffFqtupw/IZWW UxgM0j1kMpDpl+FNWoGg3ou/76NYGFLx6yoZCJCmPXBKYenCGUmz9uruE0CpKZl7m7ov vx/onkIjX9k2cN8QrBCNy2azhgTPry+chBCaa89OK5x2zVst9OyzEUgUmGVoavqXOdii o50s9RV7c+fULoSii/xaqQz+2X0U7jCKNynPKy1Q/VoCUpp7UIbKuzUfCU11nmgdvJU8 ykJg== X-Received: by 10.68.225.3 with SMTP id rg3mr10344928pbc.188.1364406051216; Wed, 27 Mar 2013 10:40:51 -0700 (PDT) Received: from formenos.mtv.corp.google.com (formenos.mtv.corp.google.com [172.18.126.133]) by mx.google.com with ESMTPS id qd8sm22195440pbc.29.2013.03.27.10.40.36 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Mar 2013 10:40:50 -0700 (PDT) From: Kent Overstreet To: axboe@kernel.dk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, dm-devel@vger.kernel.org Cc: tj@kernel.org, neilb@suse.de, Kent Overstreet , Yehuda Sadeh , Alex Elder , ceph-devel@vger.kernel.org Subject: [PATCH 16/22] rbd: Refactor bio cloning, don't clone biovecs Date: Wed, 27 Mar 2013 10:39:46 -0700 Message-Id: <1364405992-28424-17-git-send-email-koverstreet@google.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1364405992-28424-1-git-send-email-koverstreet@google.com> References: <1364405992-28424-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQnK87AwzaROvuH7X0gmcR+tt3vLBrxUzKIp1u+TPDGOwdeS9AdgpKXe5e3z8Jq8kAIXWAF96DLxJYGYUQl/xEbGUwZ/36Dd1qNDqASvdswXdi/9JyS2lfy9uTUy5BBdVPdB97qVksbFIW2RO83YcXTafWjHo2bgv+Wykdw7xYORhdE0m/j9kONTnOX+HpqvXT+MPeFCHnCsNKpw/40ZwoYCiygCbQ== Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Now that we've got drivers converted to the new immutable bvec primitives, bio splitting becomes much easier. In a few patches, bio_clone() will be changed to share the old bio's bvec instead of copying it, by default. Signed-off-by: Kent Overstreet 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 d1e4fd8..d4e2406 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -929,73 +929,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;