aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.c
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2008-04-27 09:38:34 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-27 09:38:34 -0400
commit01a63aebe4dcfcbe983c40a475e4650a4ae614de (patch)
tree3526df2545f33a26f26efbe2bf8433af52ffd001 /drivers/ide/ide-tape.c
parentd9df937af4f980883d94276000e5af399438e1a9 (diff)
ide-tape: mv tape->merge_stage_size tape->merge_bh_size
This is the size of the merge buffer. Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r--drivers/ide/ide-tape.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 00b7e0cb8b1a..0b8765c22d7a 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -310,7 +310,8 @@ typedef struct ide_tape_obj {
310 /* Data buffer size chosen based on the tape's recommendation */ 310 /* Data buffer size chosen based on the tape's recommendation */
311 int buffer_size; 311 int buffer_size;
312 idetape_stage_t *merge_stage; 312 idetape_stage_t *merge_stage;
313 int merge_stage_size; 313 /* size of the merge buffer */
314 int merge_bh_size;
314 struct idetape_bh *bh; 315 struct idetape_bh *bh;
315 char *b_data; 316 char *b_data;
316 int b_count; 317 int b_count;
@@ -1649,7 +1650,7 @@ static void __ide_tape_discard_merge_buffer(ide_drive_t *drive)
1649 return; 1650 return;
1650 1651
1651 clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags); 1652 clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags);
1652 tape->merge_stage_size = 0; 1653 tape->merge_bh_size = 0;
1653 if (tape->merge_stage != NULL) { 1654 if (tape->merge_stage != NULL) {
1654 ide_tape_kfree_buffer(tape->merge_stage); 1655 ide_tape_kfree_buffer(tape->merge_stage);
1655 tape->merge_stage = NULL; 1656 tape->merge_stage = NULL;
@@ -1790,17 +1791,17 @@ static void ide_tape_flush_merge_buffer(ide_drive_t *drive)
1790 " but we are not writing.\n"); 1791 " but we are not writing.\n");
1791 return; 1792 return;
1792 } 1793 }
1793 if (tape->merge_stage_size > tape->buffer_size) { 1794 if (tape->merge_bh_size > tape->buffer_size) {
1794 printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n"); 1795 printk(KERN_ERR "ide-tape: bug: merge_buffer too big\n");
1795 tape->merge_stage_size = tape->buffer_size; 1796 tape->merge_bh_size = tape->buffer_size;
1796 } 1797 }
1797 if (tape->merge_stage_size) { 1798 if (tape->merge_bh_size) {
1798 blocks = tape->merge_stage_size / tape->blk_size; 1799 blocks = tape->merge_bh_size / tape->blk_size;
1799 if (tape->merge_stage_size % tape->blk_size) { 1800 if (tape->merge_bh_size % tape->blk_size) {
1800 unsigned int i; 1801 unsigned int i;
1801 1802
1802 blocks++; 1803 blocks++;
1803 i = tape->blk_size - tape->merge_stage_size % 1804 i = tape->blk_size - tape->merge_bh_size %
1804 tape->blk_size; 1805 tape->blk_size;
1805 bh = tape->bh->b_reqnext; 1806 bh = tape->bh->b_reqnext;
1806 while (bh) { 1807 while (bh) {
@@ -1824,7 +1825,7 @@ static void ide_tape_flush_merge_buffer(ide_drive_t *drive)
1824 } 1825 }
1825 } 1826 }
1826 (void) idetape_add_chrdev_write_request(drive, blocks); 1827 (void) idetape_add_chrdev_write_request(drive, blocks);
1827 tape->merge_stage_size = 0; 1828 tape->merge_bh_size = 0;
1828 } 1829 }
1829 if (tape->merge_stage != NULL) { 1830 if (tape->merge_stage != NULL) {
1830 ide_tape_kfree_buffer(tape->merge_stage); 1831 ide_tape_kfree_buffer(tape->merge_stage);
@@ -1844,10 +1845,10 @@ static int idetape_init_read(ide_drive_t *drive)
1844 ide_tape_flush_merge_buffer(drive); 1845 ide_tape_flush_merge_buffer(drive);
1845 idetape_flush_tape_buffers(drive); 1846 idetape_flush_tape_buffers(drive);
1846 } 1847 }
1847 if (tape->merge_stage || tape->merge_stage_size) { 1848 if (tape->merge_stage || tape->merge_bh_size) {
1848 printk(KERN_ERR "ide-tape: merge_stage_size should be" 1849 printk(KERN_ERR "ide-tape: merge_bh_size should be"
1849 " 0 now\n"); 1850 " 0 now\n");
1850 tape->merge_stage_size = 0; 1851 tape->merge_bh_size = 0;
1851 } 1852 }
1852 tape->merge_stage = ide_tape_kmalloc_buffer(tape, 0, 0); 1853 tape->merge_stage = ide_tape_kmalloc_buffer(tape, 0, 0);
1853 if (!tape->merge_stage) 1854 if (!tape->merge_stage)
@@ -1993,7 +1994,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
1993 } 1994 }
1994 1995
1995 if (tape->chrdev_dir == IDETAPE_DIR_READ) { 1996 if (tape->chrdev_dir == IDETAPE_DIR_READ) {
1996 tape->merge_stage_size = 0; 1997 tape->merge_bh_size = 0;
1997 if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) 1998 if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags))
1998 ++count; 1999 ++count;
1999 ide_tape_discard_merge_buffer(drive, 0); 2000 ide_tape_discard_merge_buffer(drive, 0);
@@ -2063,13 +2064,13 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
2063 return rc; 2064 return rc;
2064 if (count == 0) 2065 if (count == 0)
2065 return (0); 2066 return (0);
2066 if (tape->merge_stage_size) { 2067 if (tape->merge_bh_size) {
2067 actually_read = min((unsigned int)(tape->merge_stage_size), 2068 actually_read = min((unsigned int)(tape->merge_bh_size),
2068 (unsigned int)count); 2069 (unsigned int)count);
2069 if (idetape_copy_stage_to_user(tape, buf, actually_read)) 2070 if (idetape_copy_stage_to_user(tape, buf, actually_read))
2070 ret = -EFAULT; 2071 ret = -EFAULT;
2071 buf += actually_read; 2072 buf += actually_read;
2072 tape->merge_stage_size -= actually_read; 2073 tape->merge_bh_size -= actually_read;
2073 count -= actually_read; 2074 count -= actually_read;
2074 } 2075 }
2075 while (count >= tape->buffer_size) { 2076 while (count >= tape->buffer_size) {
@@ -2090,7 +2091,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
2090 if (idetape_copy_stage_to_user(tape, buf, temp)) 2091 if (idetape_copy_stage_to_user(tape, buf, temp))
2091 ret = -EFAULT; 2092 ret = -EFAULT;
2092 actually_read += temp; 2093 actually_read += temp;
2093 tape->merge_stage_size = bytes_read-temp; 2094 tape->merge_bh_size = bytes_read-temp;
2094 } 2095 }
2095finish: 2096finish:
2096 if (!actually_read && test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) { 2097 if (!actually_read && test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) {
@@ -2122,10 +2123,10 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
2122 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { 2123 if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
2123 if (tape->chrdev_dir == IDETAPE_DIR_READ) 2124 if (tape->chrdev_dir == IDETAPE_DIR_READ)
2124 ide_tape_discard_merge_buffer(drive, 1); 2125 ide_tape_discard_merge_buffer(drive, 1);
2125 if (tape->merge_stage || tape->merge_stage_size) { 2126 if (tape->merge_stage || tape->merge_bh_size) {
2126 printk(KERN_ERR "ide-tape: merge_stage_size " 2127 printk(KERN_ERR "ide-tape: merge_bh_size "
2127 "should be 0 now\n"); 2128 "should be 0 now\n");
2128 tape->merge_stage_size = 0; 2129 tape->merge_bh_size = 0;
2129 } 2130 }
2130 tape->merge_stage = ide_tape_kmalloc_buffer(tape, 0, 0); 2131 tape->merge_stage = ide_tape_kmalloc_buffer(tape, 0, 0);
2131 if (!tape->merge_stage) 2132 if (!tape->merge_stage)
@@ -2153,23 +2154,23 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
2153 } 2154 }
2154 if (count == 0) 2155 if (count == 0)
2155 return (0); 2156 return (0);
2156 if (tape->merge_stage_size) { 2157 if (tape->merge_bh_size) {
2157 if (tape->merge_stage_size >= tape->buffer_size) { 2158 if (tape->merge_bh_size >= tape->buffer_size) {
2158 printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); 2159 printk(KERN_ERR "ide-tape: bug: merge buf too big\n");
2159 tape->merge_stage_size = 0; 2160 tape->merge_bh_size = 0;
2160 } 2161 }
2161 actually_written = min((unsigned int) 2162 actually_written = min((unsigned int)
2162 (tape->buffer_size - tape->merge_stage_size), 2163 (tape->buffer_size - tape->merge_bh_size),
2163 (unsigned int)count); 2164 (unsigned int)count);
2164 if (idetape_copy_stage_from_user(tape, buf, actually_written)) 2165 if (idetape_copy_stage_from_user(tape, buf, actually_written))
2165 ret = -EFAULT; 2166 ret = -EFAULT;
2166 buf += actually_written; 2167 buf += actually_written;
2167 tape->merge_stage_size += actually_written; 2168 tape->merge_bh_size += actually_written;
2168 count -= actually_written; 2169 count -= actually_written;
2169 2170
2170 if (tape->merge_stage_size == tape->buffer_size) { 2171 if (tape->merge_bh_size == tape->buffer_size) {
2171 ssize_t retval; 2172 ssize_t retval;
2172 tape->merge_stage_size = 0; 2173 tape->merge_bh_size = 0;
2173 retval = idetape_add_chrdev_write_request(drive, ctl); 2174 retval = idetape_add_chrdev_write_request(drive, ctl);
2174 if (retval <= 0) 2175 if (retval <= 0)
2175 return (retval); 2176 return (retval);
@@ -2190,7 +2191,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
2190 actually_written += count; 2191 actually_written += count;
2191 if (idetape_copy_stage_from_user(tape, buf, count)) 2192 if (idetape_copy_stage_from_user(tape, buf, count))
2192 ret = -EFAULT; 2193 ret = -EFAULT;
2193 tape->merge_stage_size += count; 2194 tape->merge_bh_size += count;
2194 } 2195 }
2195 return ret ? ret : actually_written; 2196 return ret ? ret : actually_written;
2196} 2197}
@@ -2361,7 +2362,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
2361 idetape_flush_tape_buffers(drive); 2362 idetape_flush_tape_buffers(drive);
2362 } 2363 }
2363 if (cmd == MTIOCGET || cmd == MTIOCPOS) { 2364 if (cmd == MTIOCGET || cmd == MTIOCPOS) {
2364 block_offset = tape->merge_stage_size / 2365 block_offset = tape->merge_bh_size /
2365 (tape->blk_size * tape->user_bs_factor); 2366 (tape->blk_size * tape->user_bs_factor);
2366 position = idetape_read_position(drive); 2367 position = idetape_read_position(drive);
2367 if (position < 0) 2368 if (position < 0)
@@ -2790,7 +2791,7 @@ static void ide_tape_release(struct kref *kref)
2790 ide_drive_t *drive = tape->drive; 2791 ide_drive_t *drive = tape->drive;
2791 struct gendisk *g = tape->disk; 2792 struct gendisk *g = tape->disk;
2792 2793
2793 BUG_ON(tape->merge_stage_size); 2794 BUG_ON(tape->merge_bh_size);
2794 2795
2795 drive->dsc_overlap = 0; 2796 drive->dsc_overlap = 0;
2796 drive->driver_data = NULL; 2797 drive->driver_data = NULL;