Commit 26e36b9c authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] ide-tape.c: stop abusing rq->flags

Use rq->cmd[0] instead of rq->flags for storing special request flags.

Per Jens' suggestion.  Tested by Stef van der Made <svdmade@planet.nl>.
parent 662247b3
...@@ -780,11 +780,6 @@ static char *rq_flags[] = { ...@@ -780,11 +780,6 @@ static char *rq_flags[] = {
"REQ_PM_SUSPEND", "REQ_PM_SUSPEND",
"REQ_PM_RESUME", "REQ_PM_RESUME",
"REQ_PM_SHUTDOWN", "REQ_PM_SHUTDOWN",
"REQ_IDETAPE_PC1",
"REQ_IDETAPE_PC2",
"REQ_IDETAPE_READ",
"REQ_IDETAPE_WRITE",
"REQ_IDETAPE_READ_BUFFER",
}; };
void blk_dump_rq_flags(struct request *rq, char *msg) void blk_dump_rq_flags(struct request *rq, char *msg)
......
/* /*
* linux/drivers/ide/ide-tape.c Version 1.18 Nov, 2003 * linux/drivers/ide/ide-tape.c Version 1.19 Nov, 2003
* *
* Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il> * Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il>
* *
...@@ -422,7 +422,7 @@ ...@@ -422,7 +422,7 @@
* sharing a (fast) ATA-2 disk with any (slow) new ATAPI device. * sharing a (fast) ATA-2 disk with any (slow) new ATAPI device.
*/ */
#define IDETAPE_VERSION "1.18" #define IDETAPE_VERSION "1.19"
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -1216,10 +1216,14 @@ typedef struct { ...@@ -1216,10 +1216,14 @@ typedef struct {
* requests to the tail of our block device request queue and wait * requests to the tail of our block device request queue and wait
* for their completion. * for their completion.
*/ */
#define idetape_request(rq) \
((rq)->flags & (REQ_IDETAPE_PC1 | REQ_IDETAPE_PC2 | \ enum {
REQ_IDETAPE_READ | REQ_IDETAPE_WRITE | \ REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
REQ_IDETAPE_READ_BUFFER)) REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */
REQ_IDETAPE_READ = (1 << 2),
REQ_IDETAPE_WRITE = (1 << 3),
REQ_IDETAPE_READ_BUFFER = (1 << 4),
};
/* /*
* Error codes which are returned in rq->errors to the higher part * Error codes which are returned in rq->errors to the higher part
...@@ -1892,7 +1896,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) ...@@ -1892,7 +1896,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
tape->active_stage = NULL; tape->active_stage = NULL;
tape->active_data_request = NULL; tape->active_data_request = NULL;
tape->nr_pending_stages--; tape->nr_pending_stages--;
if (rq->flags & REQ_IDETAPE_WRITE) { if (rq->cmd[0] & REQ_IDETAPE_WRITE) {
#if ONSTREAM_DEBUG #if ONSTREAM_DEBUG
if (tape->debug_level >= 2) { if (tape->debug_level >= 2) {
if (tape->onstream) { if (tape->onstream) {
...@@ -1938,7 +1942,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) ...@@ -1938,7 +1942,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
} }
} }
} }
} else if (rq->flags & REQ_IDETAPE_READ) { } else if (rq->cmd[0] & REQ_IDETAPE_READ) {
if (error == IDETAPE_ERROR_EOD) { if (error == IDETAPE_ERROR_EOD) {
set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
idetape_abort_pipeline(drive, active_stage); idetape_abort_pipeline(drive, active_stage);
...@@ -1996,6 +2000,13 @@ static void idetape_create_request_sense_cmd (idetape_pc_t *pc) ...@@ -1996,6 +2000,13 @@ static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
pc->callback = &idetape_request_sense_callback; pc->callback = &idetape_request_sense_callback;
} }
static void idetape_init_rq(struct request *rq, u8 cmd)
{
memset(rq, 0, sizeof(*rq));
rq->flags = REQ_SPECIAL;
rq->cmd[0] = cmd;
}
/* /*
* idetape_queue_pc_head generates a new packet command request in front * idetape_queue_pc_head generates a new packet command request in front
* of the request queue, before the current request, so that it will be * of the request queue, before the current request, so that it will be
...@@ -2017,8 +2028,7 @@ static void idetape_create_request_sense_cmd (idetape_pc_t *pc) ...@@ -2017,8 +2028,7 @@ static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
*/ */
static void idetape_queue_pc_head (ide_drive_t *drive, idetape_pc_t *pc,struct request *rq) static void idetape_queue_pc_head (ide_drive_t *drive, idetape_pc_t *pc,struct request *rq)
{ {
memset(rq, 0, sizeof(*rq)); idetape_init_rq(rq, REQ_IDETAPE_PC1);
rq->flags = REQ_IDETAPE_PC1;
rq->buffer = (char *) pc; rq->buffer = (char *) pc;
(void) ide_do_drive_cmd(drive, rq, ide_preempt); (void) ide_do_drive_cmd(drive, rq, ide_preempt);
} }
...@@ -2729,7 +2739,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2729,7 +2739,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
if (tape->debug_level >= 5) if (tape->debug_level >= 5)
printk(KERN_INFO "ide-tape: rq_status: %d, " printk(KERN_INFO "ide-tape: rq_status: %d, "
"dev: %s, cmd: %ld, errors: %d\n", rq->rq_status, "dev: %s, cmd: %ld, errors: %d\n", rq->rq_status,
rq->rq_disk->disk_name, rq->flags, rq->errors); rq->rq_disk->disk_name, rq->cmd[0], rq->errors);
#endif #endif
if (tape->debug_level >= 2) if (tape->debug_level >= 2)
printk(KERN_INFO "ide-tape: sector: %ld, " printk(KERN_INFO "ide-tape: sector: %ld, "
...@@ -2737,11 +2747,11 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2737,11 +2747,11 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
rq->sector, rq->nr_sectors, rq->current_nr_sectors); rq->sector, rq->nr_sectors, rq->current_nr_sectors);
#endif /* IDETAPE_DEBUG_LOG */ #endif /* IDETAPE_DEBUG_LOG */
if (!idetape_request(rq)) { if ((rq->flags & REQ_SPECIAL) == 0) {
/* /*
* We do not support buffer cache originated requests. * We do not support buffer cache originated requests.
*/ */
printk(KERN_NOTICE "ide-tape: %s: Unsupported command in " printk(KERN_NOTICE "ide-tape: %s: Unsupported request in "
"request queue (%ld)\n", drive->name, rq->flags); "request queue (%ld)\n", drive->name, rq->flags);
ide_end_request(drive, 0, 0); ide_end_request(drive, 0, 0);
return ide_stopped; return ide_stopped;
...@@ -2778,7 +2788,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2778,7 +2788,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
*/ */
if (tape->onstream) if (tape->onstream)
status.b.dsc = 1; status.b.dsc = 1;
if (!drive->dsc_overlap && !(rq->flags & REQ_IDETAPE_PC2)) if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2))
set_bit(IDETAPE_IGNORE_DSC, &tape->flags); set_bit(IDETAPE_IGNORE_DSC, &tape->flags);
/* /*
...@@ -2792,7 +2802,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2792,7 +2802,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
if (tape->tape_still_time > 100 && tape->tape_still_time < 200) if (tape->tape_still_time > 100 && tape->tape_still_time < 200)
tape->measure_insert_time = 1; tape->measure_insert_time = 1;
if (tape->req_buffer_fill && if (tape->req_buffer_fill &&
(rq->flags & (REQ_IDETAPE_WRITE | REQ_IDETAPE_READ))) { (rq->cmd[0] & (REQ_IDETAPE_WRITE | REQ_IDETAPE_READ))) {
tape->req_buffer_fill = 0; tape->req_buffer_fill = 0;
tape->writes_since_buffer_fill = 0; tape->writes_since_buffer_fill = 0;
tape->reads_since_buffer_fill = 0; tape->reads_since_buffer_fill = 0;
...@@ -2806,12 +2816,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2806,12 +2816,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time);
calculate_speeds(drive); calculate_speeds(drive);
if (tape->onstream && tape->max_frames && if (tape->onstream && tape->max_frames &&
(((rq->flags & REQ_IDETAPE_WRITE) && (((rq->cmd[0] & REQ_IDETAPE_WRITE) &&
( tape->cur_frames == tape->max_frames || ( tape->cur_frames == tape->max_frames ||
( tape->speed_control && tape->cur_frames > 5 && ( tape->speed_control && tape->cur_frames > 5 &&
(tape->insert_speed > tape->max_insert_speed || (tape->insert_speed > tape->max_insert_speed ||
(0 /* tape->cur_frames > 30 && tape->tape_still_time > 200 */) ) ) ) ) || (0 /* tape->cur_frames > 30 && tape->tape_still_time > 200 */) ) ) ) ) ||
((rq->flags & REQ_IDETAPE_READ) && ((rq->cmd[0] & REQ_IDETAPE_READ) &&
( tape->cur_frames == 0 || ( tape->cur_frames == 0 ||
( tape->speed_control && (tape->cur_frames < tape->max_frames - 5) && ( tape->speed_control && (tape->cur_frames < tape->max_frames - 5) &&
tape->insert_speed > tape->max_insert_speed ) ) && rq->nr_sectors) ) ) { tape->insert_speed > tape->max_insert_speed ) ) && rq->nr_sectors) ) ) {
...@@ -2819,7 +2829,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2819,7 +2829,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
if (tape->debug_level >= 4) if (tape->debug_level >= 4)
printk(KERN_INFO "ide-tape: postponing request, " printk(KERN_INFO "ide-tape: postponing request, "
"cmd %ld, cur %d, max %d\n", "cmd %ld, cur %d, max %d\n",
rq->flags, tape->cur_frames, tape->max_frames); rq->cmd[0], tape->cur_frames, tape->max_frames);
#endif #endif
if (tape->postpone_cnt++ < 500) { if (tape->postpone_cnt++ < 500) {
status.b.dsc = 0; status.b.dsc = 0;
...@@ -2840,7 +2850,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2840,7 +2850,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
} else if ((signed long) (jiffies - tape->dsc_timeout) > 0) { } else if ((signed long) (jiffies - tape->dsc_timeout) > 0) {
printk(KERN_ERR "ide-tape: %s: DSC timeout\n", printk(KERN_ERR "ide-tape: %s: DSC timeout\n",
tape->name); tape->name);
if (rq->flags & REQ_IDETAPE_PC2) { if (rq->cmd[0] & REQ_IDETAPE_PC2) {
idetape_media_access_finished(drive); idetape_media_access_finished(drive);
return ide_stopped; return ide_stopped;
} else { } else {
...@@ -2851,7 +2861,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2851,7 +2861,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
idetape_postpone_request(drive); idetape_postpone_request(drive);
return ide_stopped; return ide_stopped;
} }
if (rq->flags & REQ_IDETAPE_READ) { if (rq->cmd[0] & REQ_IDETAPE_READ) {
tape->buffer_head++; tape->buffer_head++;
#if USE_IOTRACE #if USE_IOTRACE
IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor);
...@@ -2868,7 +2878,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2868,7 +2878,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special);
goto out; goto out;
} }
if (rq->flags & REQ_IDETAPE_WRITE) { if (rq->cmd[0] & REQ_IDETAPE_WRITE) {
tape->buffer_head++; tape->buffer_head++;
#if USE_IOTRACE #if USE_IOTRACE
IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor); IO_trace(IO_IDETAPE_FIFO, tape->pipeline_head, tape->buffer_head, tape->tape_head, tape->minor);
...@@ -2886,19 +2896,19 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -2886,19 +2896,19 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special);
goto out; goto out;
} }
if (rq->flags & REQ_IDETAPE_READ_BUFFER) { if (rq->cmd[0] & REQ_IDETAPE_READ_BUFFER) {
tape->postpone_cnt = 0; tape->postpone_cnt = 0;
pc = idetape_next_pc_storage(drive); pc = idetape_next_pc_storage(drive);
idetape_create_read_buffer_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); idetape_create_read_buffer_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special);
goto out; goto out;
} }
if (rq->flags & REQ_IDETAPE_PC1) { if (rq->cmd[0] & REQ_IDETAPE_PC1) {
pc = (idetape_pc_t *) rq->buffer; pc = (idetape_pc_t *) rq->buffer;
rq->flags &= ~(REQ_IDETAPE_PC1); rq->cmd[0] &= ~(REQ_IDETAPE_PC1);
rq->flags |= REQ_IDETAPE_PC2; rq->cmd[0] |= REQ_IDETAPE_PC2;
goto out; goto out;
} }
if (rq->flags & REQ_IDETAPE_PC2) { if (rq->cmd[0] & REQ_IDETAPE_PC2) {
idetape_media_access_finished(drive); idetape_media_access_finished(drive);
return ide_stopped; return ide_stopped;
} }
...@@ -3195,7 +3205,7 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) ...@@ -3195,7 +3205,7 @@ static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq)
idetape_tape_t *tape = drive->driver_data; idetape_tape_t *tape = drive->driver_data;
#if IDETAPE_DEBUG_BUGS #if IDETAPE_DEBUG_BUGS
if (rq == NULL || !idetape_request(rq)) { if (rq == NULL || (rq->flags & REQ_SPECIAL) == 0) {
printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n");
return; return;
} }
...@@ -3301,8 +3311,7 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) ...@@ -3301,8 +3311,7 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc)
{ {
struct request rq; struct request rq;
memset(&rq, 0, sizeof(rq)); idetape_init_rq(&rq, REQ_IDETAPE_PC1);
rq.flags = REQ_IDETAPE_PC1;
rq.buffer = (char *) pc; rq.buffer = (char *) pc;
return ide_do_drive_cmd(drive, &rq, ide_wait); return ide_do_drive_cmd(drive, &rq, ide_wait);
} }
...@@ -3571,8 +3580,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct ...@@ -3571,8 +3580,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct
} }
#endif /* IDETAPE_DEBUG_BUGS */ #endif /* IDETAPE_DEBUG_BUGS */
memset(&rq, 0, sizeof(rq)); idetape_init_rq(&rq, cmd);
rq.flags = cmd;
rq.special = (void *)bh; rq.special = (void *)bh;
rq.sector = tape->first_frame_position; rq.sector = tape->first_frame_position;
rq.nr_sectors = rq.current_nr_sectors = blocks; rq.nr_sectors = rq.current_nr_sectors = blocks;
...@@ -3621,8 +3629,7 @@ static void idetape_onstream_read_back_buffer (ide_drive_t *drive) ...@@ -3621,8 +3629,7 @@ static void idetape_onstream_read_back_buffer (ide_drive_t *drive)
printk(KERN_INFO "ide-tape: %s: read back logical block %d, data %x %x %x %x\n", tape->name, logical_blk_num, *p++, *p++, *p++, *p++); printk(KERN_INFO "ide-tape: %s: read back logical block %d, data %x %x %x %x\n", tape->name, logical_blk_num, *p++, *p++, *p++, *p++);
#endif #endif
rq = &stage->rq; rq = &stage->rq;
memset(rq, 0, sizeof(*rq)); idetape_init_rq(rq, REQ_IDETAPE_WRITE);
rq->flags = REQ_IDETAPE_WRITE;
rq->sector = tape->first_frame_position; rq->sector = tape->first_frame_position;
rq->nr_sectors = rq->current_nr_sectors = tape->capabilities.ctl; rq->nr_sectors = rq->current_nr_sectors = tape->capabilities.ctl;
idetape_init_stage(drive, stage, OS_FRAME_TYPE_DATA, logical_blk_num++); idetape_init_stage(drive, stage, OS_FRAME_TYPE_DATA, logical_blk_num++);
...@@ -3896,8 +3903,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) ...@@ -3896,8 +3903,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks)
} }
} }
rq = &new_stage->rq; rq = &new_stage->rq;
memset(rq, 0, sizeof(*rq)); idetape_init_rq(rq, REQ_IDETAPE_WRITE);
rq->flags = REQ_IDETAPE_WRITE;
/* Doesn't actually matter - We always assume sequential access */ /* Doesn't actually matter - We always assume sequential access */
rq->sector = tape->first_frame_position; rq->sector = tape->first_frame_position;
rq->nr_sectors = rq->current_nr_sectors = blocks; rq->nr_sectors = rq->current_nr_sectors = blocks;
...@@ -4099,8 +4105,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages) ...@@ -4099,8 +4105,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
} }
if (tape->restart_speed_control_req) if (tape->restart_speed_control_req)
idetape_restart_speed_control(drive); idetape_restart_speed_control(drive);
memset(&rq, 0, sizeof(rq)); idetape_init_rq(&rq, REQ_IDETAPE_READ);
rq.flags = REQ_IDETAPE_READ;
rq.sector = tape->first_frame_position; rq.sector = tape->first_frame_position;
rq.nr_sectors = rq.current_nr_sectors = blocks; rq.nr_sectors = rq.current_nr_sectors = blocks;
if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) &&
......
...@@ -195,11 +195,6 @@ enum rq_flag_bits { ...@@ -195,11 +195,6 @@ enum rq_flag_bits {
__REQ_PM_SUSPEND, /* suspend request */ __REQ_PM_SUSPEND, /* suspend request */
__REQ_PM_RESUME, /* resume request */ __REQ_PM_RESUME, /* resume request */
__REQ_PM_SHUTDOWN, /* shutdown request */ __REQ_PM_SHUTDOWN, /* shutdown request */
__REQ_IDETAPE_PC1, /* packet command (first stage) */
__REQ_IDETAPE_PC2, /* packet command (second stage) */
__REQ_IDETAPE_READ,
__REQ_IDETAPE_WRITE,
__REQ_IDETAPE_READ_BUFFER,
__REQ_NR_BITS, /* stops here */ __REQ_NR_BITS, /* stops here */
}; };
...@@ -225,11 +220,6 @@ enum rq_flag_bits { ...@@ -225,11 +220,6 @@ enum rq_flag_bits {
#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) #define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND)
#define REQ_PM_RESUME (1 << __REQ_PM_RESUME) #define REQ_PM_RESUME (1 << __REQ_PM_RESUME)
#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) #define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN)
#define REQ_IDETAPE_PC1 (1 << __REQ_IDETAPE_PC1)
#define REQ_IDETAPE_PC2 (1 << __REQ_IDETAPE_PC2)
#define REQ_IDETAPE_READ (1 << __REQ_IDETAPE_READ)
#define REQ_IDETAPE_WRITE (1 << __REQ_IDETAPE_WRITE)
#define REQ_IDETAPE_READ_BUFFER (1 << __REQ_IDETAPE_READ_BUFFER)
/* /*
* State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment