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] [thread-next>] [day] [month] [year] [list]
Message-Id: <200707162121.32936.bzolnier@gmail.com>
Date:	Mon, 16 Jul 2007 21:21:32 +0200
From:	Bartlomiej Zolnierkiewicz <bzolnier@...il.com>
To:	Jens Axboe <jens.axboe@...cle.com>
Cc:	linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org
Subject: Re: [PATCH 03/33] block: convert to using sg helpers


Hi,

On Monday 16 July 2007, Jens Axboe wrote:
> Convert the main rq mapper (blk_rq_map_sg()) to the sg helper setup.
> 
> Signed-off-by: Jens Axboe <jens.axboe@...cle.com>
> ---
>  block/ll_rw_blk.c |   19 ++++++++++++-------
>  1 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
> index ef42bb2..ab71087 100644
> --- a/block/ll_rw_blk.c
> +++ b/block/ll_rw_blk.c
> @@ -30,6 +30,7 @@
>  #include <linux/cpu.h>
>  #include <linux/blktrace_api.h>
>  #include <linux/fault-inject.h>
> +#include <linux/scatterlist.h>
>  
>  /*
>   * for max sense size
> @@ -1307,9 +1308,11 @@ static int blk_hw_contig_segment(request_queue_t *q, struct bio *bio,
>   * map a request to scatterlist, return number of sg entries setup. Caller
>   * must make sure sg can hold rq->nr_phys_segments entries
>   */
> -int blk_rq_map_sg(request_queue_t *q, struct request *rq, struct scatterlist *sg)
> +int blk_rq_map_sg(request_queue_t *q, struct request *rq,
> +		  struct scatterlist *sglist)
>  {
>  	struct bio_vec *bvec, *bvprv;
> +	struct scatterlist *next_sg, *sg;
>  	struct bio *bio;
>  	int nsegs, i, cluster;
>  
> @@ -1320,6 +1323,7 @@ int blk_rq_map_sg(request_queue_t *q, struct request *rq, struct scatterlist *sg
>  	 * for each bio in rq
>  	 */
>  	bvprv = NULL;
> +	sg = next_sg = &sglist[0];
>  	rq_for_each_bio(bio, rq) {
>  		/*
>  		 * for each segment in bio
> @@ -1328,7 +1332,7 @@ int blk_rq_map_sg(request_queue_t *q, struct request *rq, struct scatterlist *sg
>  			int nbytes = bvec->bv_len;
>  
>  			if (bvprv && cluster) {
> -				if (sg[nsegs - 1].length + nbytes > q->max_segment_size)
> +				if (sg->length + nbytes > q->max_segment_size)
>  					goto new_segment;
>  
>  				if (!BIOVEC_PHYS_MERGEABLE(bvprv, bvec))
> @@ -1336,14 +1340,15 @@ int blk_rq_map_sg(request_queue_t *q, struct request *rq, struct scatterlist *sg
>  				if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bvec))
>  					goto new_segment;
>  
> -				sg[nsegs - 1].length += nbytes;
> +				sg->length += nbytes;
>  			} else {
>  new_segment:
> -				memset(&sg[nsegs],0,sizeof(struct scatterlist));

Is this intended?  If so why this is no longer needed?

> -				sg[nsegs].page = bvec->bv_page;
> -				sg[nsegs].length = nbytes;
> -				sg[nsegs].offset = bvec->bv_offset;
> +				sg = next_sg;
> +				next_sg = sg_next(sg);
>  
> +				sg->page = bvec->bv_page;
> +				sg->length = nbytes;
> +				sg->offset = bvec->bv_offset;
>  				nsegs++;
>  			}
>  			bvprv = bvec;
-
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