From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934956Ab3BTAW7 (ORCPT ); Tue, 19 Feb 2013 19:22:59 -0500 Received: from mail-da0-f46.google.com ([209.85.210.46]:36446 "EHLO mail-da0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934937Ab3BTAWz (ORCPT ); Tue, 19 Feb 2013 19:22:55 -0500 From: Kent Overstreet To: linux-kernel@vger.kernel.org Cc: Kent Overstreet , axboe@kernel.dk, NeilBrown Subject: [PATCH 07/27] md: Convert md_trim_bio() to use bio_advance() Date: Tue, 19 Feb 2013 16:22:21 -0800 Message-Id: <1361319761-23873-8-git-send-email-koverstreet@google.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1361319761-23873-1-git-send-email-koverstreet@google.com> References: <1361319761-23873-1-git-send-email-koverstreet@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Kent Overstreet CC: Jens Axboe CC: NeilBrown Acked-by: NeilBrown --- drivers/md/md.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 3db3d1b..cfd0a5d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -194,21 +194,12 @@ void md_trim_bio(struct bio *bio, int offset, int size) 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); + + 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, -- 1.7.12