]> err.no Git - linux-2.6/commitdiff
ide-tape: remove pipeline-specific members from struct ide_tape_obj
authorBorislav Petkov <petkovbb@googlemail.com>
Sun, 27 Apr 2008 13:38:27 +0000 (15:38 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sun, 27 Apr 2008 13:38:27 +0000 (15:38 +0200)
Bart:
- merge "ide-tape: remove pipeline-specific code from idetape_setup" patch
- cleanup __idetape_discard_read_pipeline()
- cleanup idetape_empty_write_pipeline()
- fix 't' assignment in idetape_setup()
- fix idetape_blkdev_ioctl() w.r.t. 'nr_stages'

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide-tape.c

index c4b470999203742a9d00e4e236758557388f0b7f..a81644b2473ee559251e9fc01d119605f62716ea 100644 (file)
@@ -324,12 +324,8 @@ typedef struct ide_tape_obj {
         * At most, there is only one ide-tape originated data transfer request
         * in the device request queue. This allows ide.c to easily service
         * requests from the other device when we postpone our active request.
-        * In the pipelined operation mode, we use our internal pipeline
-        * structure to hold more data requests. The data buffer size is chosen
-        * based on the tape's recommendation.
         */
-       /* ptr to the request which is waiting in the device request queue */
-       struct request *active_data_rq;
+
        /* Data buffer size chosen based on the tape's recommendation */
        int stage_size;
        idetape_stage_t *merge_stage;
@@ -338,26 +334,7 @@ typedef struct ide_tape_obj {
        char *b_data;
        int b_count;
 
-       /*
-        * Pipeline parameters.
-        *
-        * To accomplish non-pipelined mode, we simply set the following
-        * variables to zero (or NULL, where appropriate).
-        */
-       /* Number of currently used stages */
-       int nr_stages;
-       /* Number of pending stages */
-       int nr_pending_stages;
-       /* We will not allocate more than this number of stages */
-       int max_stages, min_pipeline, max_pipeline;
-       /* The first stage which will be removed from the pipeline */
-       idetape_stage_t *first_stage;
-       /* The currently active stage */
-       idetape_stage_t *active_stage;
-       /* Will be serviced after the currently active request */
-       idetape_stage_t *next_stage;
-       /* New requests will be added to the pipeline here */
-       idetape_stage_t *last_stage;
+       /* Pipeline parameters. */
        int pages_per_stage;
        /* Wasted space in each stage */
        int excess_bh_size;
@@ -379,18 +356,6 @@ typedef struct ide_tape_obj {
        /* the tape is write protected (hardware or opened as read-only) */
        char write_prot;
 
-       /*
-        * Limit the number of times a request can be postponed, to avoid an
-        * infinite postpone deadlock.
-        */
-       int postpone_cnt;
-
-       /* Speed control at the tape buffers input/output */
-       unsigned long insert_time;
-       int insert_size;
-       int insert_speed;
-       int measure_insert_time;
-
        u32 debug_mask;
 } idetape_tape_t;
 
@@ -1193,17 +1158,7 @@ static ide_startstop_t idetape_rw_callback(ide_drive_t *drive)
        int blocks = tape->pc->xferred / tape->blk_size;
 
        tape->avg_size += blocks * tape->blk_size;
-       tape->insert_size += blocks * tape->blk_size;
-       if (tape->insert_size > 1024 * 1024)
-               tape->measure_insert_time = 1;
-       if (tape->measure_insert_time) {
-               tape->measure_insert_time = 0;
-               tape->insert_time = jiffies;
-               tape->insert_size = 0;
-       }
-       if (time_after(jiffies, tape->insert_time))
-               tape->insert_speed = tape->insert_size / 1024 * HZ /
-                                       (jiffies - tape->insert_time);
+
        if (time_after_eq(jiffies, tape->avg_time + HZ)) {
                tape->avg_speed = tape->avg_size * HZ /
                                (jiffies - tape->avg_time) / 1024;
@@ -1308,9 +1263,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
                drive->post_reset = 0;
        }
 
-       if (time_after(jiffies, tape->insert_time))
-               tape->insert_speed = tape->insert_size / 1024 * HZ /
-                                       (jiffies - tape->insert_time);
        if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) &&
            (stat & SEEK_STAT) == 0) {
                if (postponed_rq == NULL) {
@@ -1334,14 +1286,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
                return ide_stopped;
        }
        if (rq->cmd[0] & REQ_IDETAPE_READ) {
-               tape->postpone_cnt = 0;
                pc = idetape_next_pc_storage(drive);
                idetape_create_read_cmd(tape, pc, rq->current_nr_sectors,
                                        (struct idetape_bh *)rq->special);
                goto out;
        }
        if (rq->cmd[0] & REQ_IDETAPE_WRITE) {
-               tape->postpone_cnt = 0;
                pc = idetape_next_pc_storage(drive);
                idetape_create_write_cmd(tape, pc, rq->current_nr_sectors,
                                         (struct idetape_bh *)rq->special);
@@ -1707,16 +1657,11 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive,
 static int __idetape_discard_read_pipeline(ide_drive_t *drive)
 {
        idetape_tape_t *tape = drive->driver_data;
-       unsigned long flags;
-       int cnt;
 
        if (tape->chrdev_dir != IDETAPE_DIR_READ)
                return 0;
 
-       /* Remove merge stage. */
-       cnt = tape->merge_stage_size / tape->blk_size;
-       if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags))
-               ++cnt;          /* Filemarks count as 1 sector */
+       clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags);
        tape->merge_stage_size = 0;
        if (tape->merge_stage != NULL) {
                __idetape_kfree_stage(tape->merge_stage);
@@ -1725,24 +1670,7 @@ static int __idetape_discard_read_pipeline(ide_drive_t *drive)
 
        tape->chrdev_dir = IDETAPE_DIR_NONE;
 
-       /* Remove pipeline stages. */
-       if (tape->first_stage == NULL)
-               return 0;
-
-       spin_lock_irqsave(&tape->lock, flags);
-       tape->next_stage = NULL;
-       spin_unlock_irqrestore(&tape->lock, flags);
-
-       while (tape->first_stage != NULL) {
-               struct request *rq_ptr = &tape->first_stage->rq;
-
-               cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors;
-               if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK)
-                       ++cnt;
-       }
-       tape->nr_pending_stages = 0;
-       tape->max_stages = tape->min_pipeline;
-       return cnt;
+       return 0;
 }
 
 /*
@@ -1919,27 +1847,9 @@ static void idetape_empty_write_pipeline(ide_drive_t *drive)
                tape->merge_stage = NULL;
        }
        tape->chrdev_dir = IDETAPE_DIR_NONE;
-
-       /*
-        * On the next backup, perform the feedback loop again. (I don't want to
-        * keep sense information between backups, as some systems are
-        * constantly on, and the system load can be totally different on the
-        * next backup).
-        */
-       tape->max_stages = tape->min_pipeline;
-       if (tape->first_stage != NULL ||
-           tape->next_stage != NULL ||
-           tape->last_stage != NULL ||
-           tape->nr_stages != 0) {
-               printk(KERN_ERR "ide-tape: ide-tape pipeline bug, "
-                       "first_stage %p, next_stage %p, "
-                       "last_stage %p, nr_stages %d\n",
-                       tape->first_stage, tape->next_stage,
-                       tape->last_stage, tape->nr_stages);
-       }
 }
 
-static int idetape_init_read(ide_drive_t *drive, int max_stages)
+static int idetape_init_read(ide_drive_t *drive)
 {
        idetape_tape_t *tape = drive->driver_data;
        int bytes_read;
@@ -1979,13 +1889,6 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages)
                }
        }
 
-       if (tape->nr_pending_stages >= 3 * max_stages / 4) {
-               tape->measure_insert_time = 1;
-               tape->insert_time = jiffies;
-               tape->insert_size = 0;
-               tape->insert_speed = 0;
-       }
-
        return 0;
 }
 
@@ -2003,7 +1906,7 @@ static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks)
        if (test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags))
                return 0;
 
-       idetape_init_read(drive, tape->max_stages);
+       idetape_init_read(drive);
 
        return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks,
                                     tape->merge_stage->bh);
@@ -2079,11 +1982,10 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd,
                if (copy_from_user(&config, argp, sizeof(config)))
                        return -EFAULT;
                tape->best_dsc_rw_freq = config.dsc_rw_frequency;
-               tape->max_stages = config.nr_stages;
                break;
        case 0x0350:
                config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq;
-               config.nr_stages = tape->max_stages;
+               config.nr_stages = 1;
                if (copy_to_user(argp, &config, sizeof(config)))
                        return -EFAULT;
                break;
@@ -2175,7 +2077,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
                            (count % tape->blk_size) == 0)
                                tape->user_bs_factor = count / tape->blk_size;
        }
-       rc = idetape_init_read(drive, tape->max_stages);
+       rc = idetape_init_read(drive);
        if (rc < 0)
                return rc;
        if (count == 0)
@@ -2793,18 +2695,6 @@ static void idetape_add_settings(ide_drive_t *drive)
 
        ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff,
                        1, 2, (u16 *)&tape->caps[16], NULL);
-       ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff,
-                       tape->stage_size / 1024, 1, &tape->min_pipeline, NULL);
-       ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff,
-                       tape->stage_size / 1024, 1, &tape->max_stages, NULL);
-       ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff,
-                       tape->stage_size / 1024, 1, &tape->max_pipeline, NULL);
-       ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0,
-                       0xffff, tape->stage_size / 1024, 1, &tape->nr_stages,
-                       NULL);
-       ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0,
-                       0xffff, tape->stage_size / 1024, 1,
-                       &tape->nr_pending_stages, NULL);
        ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff,
                        1, 1, (u16 *)&tape->caps[14], NULL);
        ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1,
@@ -2836,11 +2726,10 @@ static inline void idetape_add_settings(ide_drive_t *drive) { ; }
  */
 static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
 {
-       unsigned long t1, tmid, tn, t;
+       unsigned long t;
        int speed;
        int stage_size;
        u8 gcw[2];
-       struct sysinfo si;
        u16 *ctl = (u16 *)&tape->caps[12];
 
        spin_lock_init(&tape->lock);
@@ -2865,10 +2754,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
        if (((gcw[0] & 0x60) >> 5) == 1)
                set_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags);
 
-       tape->min_pipeline = 10;
-       tape->max_pipeline = 10;
-       tape->max_stages   = 10;
-
        idetape_get_inquiry_results(drive);
        idetape_get_mode_sense_results(drive);
        ide_tape_get_bsize_from_bdesc(drive);
@@ -2886,36 +2771,10 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
                tape->excess_bh_size = PAGE_SIZE - stage_size % PAGE_SIZE;
        }
 
-       /* Select the "best" DSC read/write polling freq and pipeline size. */
+       /* select the "best" DSC read/write polling freq */
        speed = max(*(u16 *)&tape->caps[14], *(u16 *)&tape->caps[8]);
 
-       tape->max_stages = speed * 1000 * 10 / tape->stage_size;
-
-       /* Limit memory use for pipeline to 10% of physical memory */
-       si_meminfo(&si);
-       if (tape->max_stages * tape->stage_size >
-                       si.totalram * si.mem_unit / 10)
-               tape->max_stages =
-                       si.totalram * si.mem_unit / (10 * tape->stage_size);
-
-       tape->max_stages   = min(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES);
-       tape->min_pipeline = min(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES);
-       tape->max_pipeline =
-               min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES);
-       if (tape->max_stages == 0) {
-               tape->max_stages   = 1;
-               tape->min_pipeline = 1;
-               tape->max_pipeline = 1;
-       }
-
-       t1 = (tape->stage_size * HZ) / (speed * 1000);
-       tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125);
-       tn = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000);
-
-       if (tape->max_stages)
-               t = tn;
-       else
-               t = t1;
+       t = (IDETAPE_FIFO_THRESHOLD * tape->stage_size * HZ) / (speed * 1000);
 
        /*
         * Ensure that the number we got makes sense; limit it within
@@ -2925,11 +2784,10 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
                                min_t(unsigned long, t, IDETAPE_DSC_RW_MAX),
                                IDETAPE_DSC_RW_MIN);
        printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, "
-               "%dkB pipeline, %lums tDSC%s\n",
+               "%lums tDSC%s\n",
                drive->name, tape->name, *(u16 *)&tape->caps[14],
                (*(u16 *)&tape->caps[16] * 512) / tape->stage_size,
                tape->stage_size / 1024,
-               tape->max_stages * tape->stage_size / 1024,
                tape->best_dsc_rw_freq * 1000 / HZ,
                drive->using_dma ? ", DMA":"");
 
@@ -2953,7 +2811,7 @@ static void ide_tape_release(struct kref *kref)
        ide_drive_t *drive = tape->drive;
        struct gendisk *g = tape->disk;
 
-       BUG_ON(tape->first_stage != NULL || tape->merge_stage_size);
+       BUG_ON(tape->merge_stage_size);
 
        drive->dsc_overlap = 0;
        drive->driver_data = NULL;