From patchwork Mon Oct 15 20:09:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1595831 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork2.kernel.org (Postfix) with ESMTP id 0ED88DFB34 for ; Mon, 15 Oct 2012 20:14:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKBJKD006856; Mon, 15 Oct 2012 16:11:19 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKAede027148 for ; Mon, 15 Oct 2012 16:10:40 -0400 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKAZjH019351 for ; Mon, 15 Oct 2012 16:10:35 -0400 Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9FK9gLH018945 for ; Mon, 15 Oct 2012 16:10:33 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so5214109pad.33 for ; Mon, 15 Oct 2012 13:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Hkip9wWXiH2D1yhtSTceIt1irlwZy2I8UEwwu4GRKjs=; b=mr+aZq7cPNOVIok3El5sYvYc18tgcnLSykzNo7cajQWKqT9UMmLNiibK6iZMnFGDpp tQk+quMVO2h/FJLoJorQrSq84x76urEFsY5thKhRu9Ht1z1GWCHbZHqwF1U+u0GHe7R8 1KFFlkQtfIY18qMphW8OKFQ4++7FHy7t7lWrr6UKtAhVhwlFRL5lSUAPMSZc2UTplxa/ eRqRF/VubNKl6O9KUci+4RZSygVSVDrCMru44QQRg2KeAn/sDsL89Ti6hfWu/M7IeMA3 xVbIQj/MCWgoggooUMF4VBSi96Jr4LDdUIDIOqSntjjENioBtZPVqoekPcqqudslW/kP YsWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Hkip9wWXiH2D1yhtSTceIt1irlwZy2I8UEwwu4GRKjs=; b=bJkzcls8tLkgwMi7E2mufY0WMSSnH3Vyxbvc0ZS0X2Nepr4hOQBeqiAhQAqVNEhmlA +Ok8nEMvtD10jj3FVcYvv1DH7u7WXdzFR4mmNduFxaGCEeEVfx1eNAD8FAK2FChXner2 O//ZKVxGlmgvc5iNt11JGia5FQfYPRUGH7qwxKK0+ADyO47C8bdgCcaXPijlvq3x7Wlu lsB8HCUCXWIlja3vlHvDzusqMwdXKg4B1UTSQjkgvS2Zu39NF7YyeJ0KNLiTG+EH7cUt JPbxf3VCf0uLGHETqkh2dFHjRLBHsGrrQjesk/SHlxZlZ4U39aurtCCmbUvvC8O3ob4c eatA== Received: by 10.68.226.136 with SMTP id rs8mr40468161pbc.153.1350331833728; Mon, 15 Oct 2012 13:10:33 -0700 (PDT) Received: from formenos.mtv.corp.google.com (formenos.mtv.corp.google.com [172.18.110.66]) by mx.google.com with ESMTPS id k9sm3021703paz.22.2012.10.15.13.10.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:10:33 -0700 (PDT) From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com Date: Mon, 15 Oct 2012 13:09:07 -0700 Message-Id: <1350331769-14856-34-git-send-email-koverstreet@google.com> In-Reply-To: <1350331769-14856-1-git-send-email-koverstreet@google.com> References: <1350331769-14856-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQn3R5r6Yui1VPFhBXZZWxwuZrVzSmmA0HPXDthPintsXCtLVigZjE60+J0C6nKefhNlKScAq74I39i9Ns7WqYHa+gG6o6bDF37SJ/s6hju0YIz2CBY/B7MMkzTvuIIImznsrN+3lJsK9fG6xZ+RDhnFNl0E61E0MwUBfp3tx6jKAFf/ckbGQ26MBysQ8GaohtOwlxpE X-RedHat-Spam-Score: -3.072 (BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: tj@kernel.org, axboe@kernel.dk, Kent Overstreet Subject: [dm-devel] [PATCH v2 04/26] md: Convert md_trim_bio() to use bio_advance() 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Signed-off-by: Kent Overstreet CC: Jens Axboe CC: NeilBrown --- drivers/md/md.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 7a2b079..51ce48c 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -190,25 +190,16 @@ void md_trim_bio(struct bio *bio, int offset, int size) struct bio_vec *bvec; int sofar = 0; - size <<= 9; if (offset == 0 && size == bio->bi_size) return; - bio->bi_sector += offset; - bio->bi_size = size; - offset <<= 9; clear_bit(BIO_SEG_VALID, &bio->bi_flags); - while (bio->bi_idx < bio->bi_vcnt && - bio->bi_io_vec[bio->bi_idx].bv_len <= offset) { - /* remove this whole bio_vec */ - offset -= bio->bi_io_vec[bio->bi_idx].bv_len; - bio->bi_idx++; - } - if (bio->bi_idx < bio->bi_vcnt) { - bio->bi_io_vec[bio->bi_idx].bv_offset += offset; - bio->bi_io_vec[bio->bi_idx].bv_len -= offset; - } + bio_advance(bio, offset << 9); + + size <<= 9; + bio->bi_size = size; + /* avoid any complications with bi_idx being non-zero*/ if (bio->bi_idx) { memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx,