lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Sat, 20 Sep 2008 21:04:44 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	"Martin K. Petersen" <martin.petersen@...cle.com>
Cc:	jens.axboe@...cle.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] block: Find bio sector offset given idx and offset

On Sat, 20 Sep 2008 20:13:29 -0400 "Martin K. Petersen" <martin.petersen@...cle.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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ