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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090413085233.GA10115@liondog.tnic>
Date:	Mon, 13 Apr 2009 10:52:33 +0200
From:	Borislav Petkov <petkovbb@...glemail.com>
To:	Tejun Heo <tj@...nel.org>
Cc:	bzolnier@...il.com, linux-kernel@...r.kernel.org, axboe@...nel.dk,
	linux-ide@...r.kernel.org
Subject: Re: [PATCH 14/14] ide-cd: use bio for request sense

On Wed, Mar 25, 2009 at 01:06:16AM +0900, Tejun Heo wrote:
> Impact: unify request data buffer handling
> 
> rq->data is used mostly to pass kernel buffer through request queue
> without using bio.  There are only a couple of places which still do
> this in kernel and converting to bio isn't difficult.
> 
> This patch converts ide-cd to use bio instead of rq->data for request
> sense and internal pc commands.  As request sense is issued from
> atomic context, drive->request_sense_bio and ->request_sense_bvec[2]
> are used via bio_map_kern_prealloc().  Internal pc commands use
> blk_rq_map_kern().
> 
> cdrom_do_block_pc() now doesn't have to deal with REQ_TYPE_ATA_PC
> special case.  Simplified.
> 
> Signed-off-by: Tejun Heo <tj@...nel.org>
> Cc: Jens Axboe <axboe@...nel.dk>
> ---
>  drivers/ide/ide-cd.c |   31 ++++++++++++++++++-------------
>  1 files changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> index de6ce8d..22c95b9 100644
> --- a/drivers/ide/ide-cd.c
> +++ b/drivers/ide/ide-cd.c
> @@ -209,8 +209,12 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
>  static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
>  				      struct request *failed_command)
>  {
> -	struct cdrom_info *info		= drive->driver_data;
> -	struct request *rq		= &drive->request_sense_rq;
> +	struct cdrom_info *info	= drive->driver_data;
> +	struct request *rq	= &drive->request_sense_rq;
> +	struct bio *bio		= &drive->request_sense_bio;
> +	struct bio_vec *bvec	= drive->request_sense_bvec;
> +	unsigned int bvec_len	= ARRAY_SIZE(drive->request_sense_bvec);
> +	int error;
>  
>  	ide_debug_log(IDE_DBG_SENSE, "enter");
>  
> @@ -224,10 +228,12 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
>  	rq->cmd_type = REQ_TYPE_ATA_PC;

by the way, this line can go too, since the correct type is REQ_TYPE_SENSE now.

>  	rq->rq_disk = info->disk;
>  
> -	rq->data = sense;
> +	error = blk_rq_map_kern_prealloc(drive->queue, rq, bio, bvec, bvec_len,
> +					 sense, 18, true);
> +	BUG_ON(error);
> +
>  	rq->cmd[0] = GPCMD_REQUEST_SENSE;
>  	rq->cmd[4] = 18;
> -	rq->data_len = 18;
>  
>  	rq->cmd_type = REQ_TYPE_SENSE;
>  	rq->cmd_flags |= REQ_PREEMPT;
> @@ -556,8 +562,12 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
>  		rq->cmd_flags |= cmd_flags;
>  		rq->timeout = timeout;
>  		if (buffer) {
> -			rq->data = buffer;
> -			rq->data_len = *bufflen;
> +			error = blk_rq_map_kern(drive->queue, rq, buffer,
> +						*bufflen, __GFP_WAIT);
> +			if (error) {
> +				blk_put_request(rq);
> +				return error;
> +			}
>  		}
>  
>  		error = blk_execute_rq(drive->queue, info->disk, rq, 0);
> @@ -847,15 +857,10 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
>  	drive->dma = 0;
>  
>  	/* sg request */
> -	if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) {
> +	if (rq->bio) {
>  		struct request_queue *q = drive->queue;
> +		char *buf = bio_data(rq->bio);
>  		unsigned int alignment;
> -		char *buf;
> -
> -		if (rq->bio)
> -			buf = bio_data(rq->bio);
> -		else
> -			buf = rq->data;
>  
>  		drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
>  
> -- 
> 1.6.0.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Regards/Gruss,
    Boris.
--
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