Skip to content

Commit d868ca2

Browse files
htejunJens Axboe
authored andcommitted
ide-taskfile: don't abuse rq->buffer
Impact: rq->buffer usage cleanup ide_raw_taskfile() directly uses rq->buffer to carry pointer to the data buffer. This complicates both block interface and ide backend request handling. Use blk_rq_map_kern() instead and drop special handling for REQ_TYPE_ATA_TASKFILE from ide_map_sg(). Note that REQ_RW setting is moved upwards as blk_rq_map_kern() uses it to initialize bio rw flag. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk>
1 parent 8968932 commit d868ca2

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎drivers/ide/ide-io.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,7 @@ void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd)
248248
struct scatterlist *sg = hwif->sg_table;
249249
struct request *rq = cmd->rq;
250250

251-
if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
252-
sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE);
253-
cmd->sg_nents = 1;
254-
} else if (!rq->bio) {
251+
if (!rq->bio) {
255252
sg_init_one(sg, rq->data, rq->data_len);
256253
cmd->sg_nents = 1;
257254
} else

‎drivers/ide/ide-taskfile.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,26 +424,30 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
424424

425425
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
426426
rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
427-
rq->buffer = buf;
427+
428+
if (cmd->tf_flags & IDE_TFLAG_WRITE)
429+
rq->cmd_flags |= REQ_RW;
428430

429431
/*
430432
* (ks) We transfer currently only whole sectors.
431433
* This is suffient for now. But, it would be great,
432434
* if we would find a solution to transfer any size.
433435
* To support special commands like READ LONG.
434436
*/
435-
rq->hard_nr_sectors = rq->nr_sectors = nsect;
436-
rq->hard_cur_sectors = rq->current_nr_sectors = nsect;
437-
438-
if (cmd->tf_flags & IDE_TFLAG_WRITE)
439-
rq->cmd_flags |= REQ_RW;
437+
if (nsect) {
438+
error = blk_rq_map_kern(drive->queue, rq, buf,
439+
nsect * SECTOR_SIZE, __GFP_WAIT);
440+
if (error)
441+
goto put_req;
442+
}
440443

441444
rq->special = cmd;
442445
cmd->rq = rq;
443446

444447
error = blk_execute_rq(drive->queue, NULL, rq, 0);
445-
blk_put_request(rq);
446448

449+
put_req:
450+
blk_put_request(rq);
447451
return error;
448452
}
449453

0 commit comments

Comments
 (0)