All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: jens.axboe@oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: Find bio sector offset given idx and offset
Date: Sat, 20 Sep 2008 21:04:44 -0700	[thread overview]
Message-ID: <20080920210444.f083da7b.akpm@linux-foundation.org> (raw)
In-Reply-To: <yq17i96nyom.fsf@sermon.lab.mkp.net>

On Sat, 20 Sep 2008 20:13:29 -0400 "Martin K. Petersen" <martin.petersen@oracle.com> wrote:

> @@ -1300,6 +1300,30 @@ struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, int first_sectors)
>  	return bp;
>  }
>  
> +sector_t bio_sector_offset(struct bio *bio, unsigned short index, unsigned int offset)
> +{
> +	struct bio_vec *bv;
> +	unsigned int sector_sz = bio->bi_bdev->bd_disk->queue->hardsect_size;
> +	sector_t sectors;
> +	int i;
> +
> +	sectors = 0;
> +
> +	BUG_ON(index >= bio->bi_vcnt);
> +
> +	bio_for_each_segment(bv, bio, i) {
> +		if (i == index) {
> +			if (offset > bv->bv_offset)
> +				sectors += (offset - bv->bv_offset) / sector_sz;
> +			return sectors;
> +		}
> +
> +		sectors += bv->bv_len / sector_sz;
> +	}
> +
> +	BUG();
> +}
> +EXPORT_SYMBOL(bio_sector_offset);

Please avoid sending out kenrel-wide exported-to-modules utility
functions which have no documentation.

Not only is it a bad thing from a maintainability and reliability point
of view - it also makes code review significantly less effective.

      reply	other threads:[~2008-09-21  4:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-21  0:13 [PATCH] block: Find bio sector offset given idx and offset Martin K. Petersen
2008-09-21  4:04 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080920210444.f083da7b.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.