• Home
  • Raw
  • Download

Lines Matching refs:STp

235 	struct scsi_tape *STp = NULL;  in scsi_tape_get()  local
240 STp = idr_find(&st_index_idr, dev); in scsi_tape_get()
241 if (!STp) goto out; in scsi_tape_get()
243 kref_get(&STp->kref); in scsi_tape_get()
245 if (!STp->device) in scsi_tape_get()
248 if (scsi_device_get(STp->device)) in scsi_tape_get()
254 kref_put(&STp->kref, scsi_tape_release); in scsi_tape_get()
255 STp = NULL; in scsi_tape_get()
259 return STp; in scsi_tape_get()
262 static void scsi_tape_put(struct scsi_tape *STp) in scsi_tape_put() argument
264 struct scsi_device *sdev = STp->device; in scsi_tape_put()
267 kref_put(&STp->kref, scsi_tape_release); in scsi_tape_put()
342 static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) in st_chk_result() argument
347 char *name = tape_name(STp); in st_chk_result()
353 cmdstatp = &STp->buffer->cmdstat; in st_chk_result()
357 scode = STp->buffer->cmdstat.sense_hdr.sense_key; in st_chk_result()
390 STp->cln_mode >= EXTENDED_SENSE_START) { /* Only fixed format sense */ in st_chk_result()
391 if (STp->cln_sense_value) in st_chk_result()
392 STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] & in st_chk_result()
393 STp->cln_sense_mask) == STp->cln_sense_value); in st_chk_result()
395 STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] & in st_chk_result()
396 STp->cln_sense_mask) != 0); in st_chk_result()
400 STp->cleaning_req = 1; /* ASC and ASCQ => cleaning requested */ in st_chk_result()
402 STp->pos_unknown |= STp->device->was_reset; in st_chk_result()
411 STp->recover_count++; in st_chk_result()
412 STp->recover_reg++; in st_chk_result()
423 STp->recover_count); in st_chk_result()
459 struct scsi_tape *STp = SRpnt->stp; in st_scsi_execute_end() local
462 STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors; in st_scsi_execute_end()
463 STp->buffer->cmdstat.residual = req->resid_len; in st_scsi_execute_end()
519 st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd, in st_do_scsi() argument
523 struct rq_map_data *mdata = &STp->buffer->map_data; in st_do_scsi()
527 if (!do_wait && ((STp->buffer)->last_SRpnt)) { in st_do_scsi()
529 tape_name(STp)); in st_do_scsi()
531 (STp->buffer)->syscall_result = (-EINTR); in st_do_scsi()
533 (STp->buffer)->syscall_result = (-EBUSY); in st_do_scsi()
538 SRpnt = st_allocate_request(STp); in st_do_scsi()
546 (STp->buffer)->last_SRpnt = SRpnt; in st_do_scsi()
548 waiting = &STp->wait; in st_do_scsi()
552 if (STp->buffer->do_dio) { in st_do_scsi()
554 mdata->nr_entries = STp->buffer->sg_segs; in st_do_scsi()
555 mdata->pages = STp->buffer->mapped_pages; in st_do_scsi()
557 mdata->page_order = STp->buffer->reserved_page_order; in st_do_scsi()
560 mdata->pages = STp->buffer->reserved_pages; in st_do_scsi()
565 STp->buffer->cmdstat.have_sense = 0; in st_do_scsi()
566 STp->buffer->syscall_result = 0; in st_do_scsi()
572 (STp->buffer)->syscall_result = (-EBUSY); in st_do_scsi()
573 (STp->buffer)->last_SRpnt = NULL; in st_do_scsi()
577 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); in st_do_scsi()
588 static int write_behind_check(struct scsi_tape * STp) in write_behind_check() argument
596 STbuffer = STp->buffer; in write_behind_check()
601 if (STp->write_pending) in write_behind_check()
602 STp->nbr_waits++; in write_behind_check()
604 STp->nbr_finished++; in write_behind_check()
607 wait_for_completion(&(STp->wait)); in write_behind_check()
612 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); in write_behind_check()
616 STps = &(STp->ps[STp->partition]); in write_behind_check()
618 if (STp->block_size == 0) in write_behind_check()
621 STps->drv_block += STbuffer->writing / STp->block_size; in write_behind_check()
643 tape_name(STp), STbuffer->cmdstat.midlevel_result, retval);) /* end DEB */ in write_behind_check()
651 static int cross_eof(struct scsi_tape * STp, int forward) in cross_eof() argument
666 tape_name(STp), forward ? "forward" : "backward")); in cross_eof()
668 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, in cross_eof()
669 STp->device->request_queue->rq_timeout, in cross_eof()
672 return (STp->buffer)->syscall_result; in cross_eof()
677 if ((STp->buffer)->cmdstat.midlevel_result != 0) in cross_eof()
679 tape_name(STp), forward ? "forward" : "backward"); in cross_eof()
681 return (STp->buffer)->syscall_result; in cross_eof()
686 static int st_flush_write_buffer(struct scsi_tape * STp) in st_flush_write_buffer() argument
694 result = write_behind_check(STp); in st_flush_write_buffer()
699 if (STp->dirty == 1) { in st_flush_write_buffer()
701 transfer = STp->buffer->buffer_bytes; in st_flush_write_buffer()
703 tape_name(STp), transfer)); in st_flush_write_buffer()
708 blks = transfer / STp->block_size; in st_flush_write_buffer()
713 SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE, in st_flush_write_buffer()
714 STp->device->request_queue->rq_timeout, in st_flush_write_buffer()
717 return (STp->buffer)->syscall_result; in st_flush_write_buffer()
719 STps = &(STp->ps[STp->partition]); in st_flush_write_buffer()
720 if ((STp->buffer)->syscall_result != 0) { in st_flush_write_buffer()
721 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_flush_write_buffer()
729 STp->dirty = 0; in st_flush_write_buffer()
730 (STp->buffer)->buffer_bytes = 0; in st_flush_write_buffer()
736 tape_name(STp)); in st_flush_write_buffer()
743 STp->dirty = 0; in st_flush_write_buffer()
744 (STp->buffer)->buffer_bytes = 0; in st_flush_write_buffer()
755 static int flush_buffer(struct scsi_tape *STp, int seek_next) in flush_buffer() argument
761 STbuffer = STp->buffer; in flush_buffer()
767 if (STp->pos_unknown) in flush_buffer()
770 if (STp->ready != ST_READY) in flush_buffer()
772 STps = &(STp->ps[STp->partition]); in flush_buffer()
774 return st_flush_write_buffer(STp); in flush_buffer()
776 if (STp->block_size == 0) in flush_buffer()
779 backspace = ((STp->buffer)->buffer_bytes + in flush_buffer()
780 (STp->buffer)->read_pointer) / STp->block_size - in flush_buffer()
781 ((STp->buffer)->read_pointer + STp->block_size - 1) / in flush_buffer()
782 STp->block_size; in flush_buffer()
783 (STp->buffer)->buffer_bytes = 0; in flush_buffer()
784 (STp->buffer)->read_pointer = 0; in flush_buffer()
788 result = cross_eof(STp, 0); /* Back over the EOF hit */ in flush_buffer()
798 result = st_int_ioctl(STp, MTBSR, backspace); in flush_buffer()
810 static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm) in set_mode_densblk() argument
814 char *name = tape_name(STp); in set_mode_densblk()
816 if (!STp->density_changed && in set_mode_densblk()
818 STm->default_density != STp->density) { in set_mode_densblk()
822 arg = STp->density; in set_mode_densblk()
824 if (!STp->blksize_changed && in set_mode_densblk()
826 STm->default_blksize != STp->block_size) { in set_mode_densblk()
830 arg |= STp->block_size; in set_mode_densblk()
832 st_int_ioctl(STp, SET_DENS_AND_BLK, arg)) { in set_mode_densblk()
844 static int do_door_lock(struct scsi_tape * STp, int do_lock) in do_door_lock() argument
847 DEB(char *name = tape_name(STp);) in do_door_lock()
853 retval = scsi_ioctl(STp->device, cmd, NULL); in do_door_lock()
855 STp->door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED; in do_door_lock()
858 STp->door_locked = ST_LOCK_FAILS; in do_door_lock()
865 static void reset_state(struct scsi_tape *STp) in reset_state() argument
870 STp->pos_unknown = 0; in reset_state()
872 STps = &(STp->ps[i]); in reset_state()
880 if (STp->can_partitions) { in reset_state()
881 STp->partition = find_partition(STp); in reset_state()
882 if (STp->partition < 0) in reset_state()
883 STp->partition = 0; in reset_state()
884 STp->new_partition = STp->partition; in reset_state()
897 static int test_ready(struct scsi_tape *STp, int do_wait) in test_ready() argument
903 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in test_ready()
910 SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, in test_ready()
911 STp->long_timeout, MAX_READY_RETRIES, 1); in test_ready()
914 retval = (STp->buffer)->syscall_result; in test_ready()
944 if ((STp->device)->scsi_level >= SCSI_2 && in test_ready()
954 retval = (STp->buffer)->syscall_result; in test_ready()
971 static int check_tape(struct scsi_tape *STp, struct file *filp) in check_tape() argument
979 char *name = tape_name(STp); in check_tape()
983 STp->ready = ST_READY; in check_tape()
985 if (mode != STp->current_mode) { in check_tape()
987 name, STp->current_mode, mode)); in check_tape()
989 STp->current_mode = mode; in check_tape()
991 STm = &(STp->modes[STp->current_mode]); in check_tape()
993 saved_cleaning = STp->cleaning_req; in check_tape()
994 STp->cleaning_req = 0; in check_tape()
997 retval = test_ready(STp, do_wait); in check_tape()
1003 STp->pos_unknown = 0; in check_tape()
1004 STp->partition = STp->new_partition = 0; in check_tape()
1005 if (STp->can_partitions) in check_tape()
1006 STp->nbr_partitions = 1; /* This guess will be updated later in check_tape()
1009 STps = &(STp->ps[i]); in check_tape()
1020 STp->cleaning_req |= saved_cleaning; in check_tape()
1024 STp->ready = ST_NO_TAPE; in check_tape()
1026 STp->ready = ST_NOT_READY; in check_tape()
1028 STp->density = 0; /* Clear the erroneous "residue" */ in check_tape()
1029 STp->write_prot = 0; in check_tape()
1030 STp->block_size = 0; in check_tape()
1031 STp->ps[0].drv_file = STp->ps[0].drv_block = (-1); in check_tape()
1032 STp->partition = STp->new_partition = 0; in check_tape()
1033 STp->door_locked = ST_UNLOCKED; in check_tape()
1038 if (STp->omit_blklims) in check_tape()
1039 STp->min_block = STp->max_block = (-1); in check_tape()
1044 SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE, in check_tape()
1045 STp->device->request_queue->rq_timeout, in check_tape()
1048 retval = (STp->buffer)->syscall_result; in check_tape()
1052 if (!SRpnt->result && !STp->buffer->cmdstat.have_sense) { in check_tape()
1053 STp->max_block = ((STp->buffer)->b_data[1] << 16) | in check_tape()
1054 ((STp->buffer)->b_data[2] << 8) | (STp->buffer)->b_data[3]; in check_tape()
1055 STp->min_block = ((STp->buffer)->b_data[4] << 8) | in check_tape()
1056 (STp->buffer)->b_data[5]; in check_tape()
1057 if ( DEB( debugging || ) !STp->inited) in check_tape()
1060 STp->min_block, STp->max_block); in check_tape()
1062 STp->min_block = STp->max_block = (-1); in check_tape()
1072 SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE, in check_tape()
1073 STp->device->request_queue->rq_timeout, in check_tape()
1076 retval = (STp->buffer)->syscall_result; in check_tape()
1080 if ((STp->buffer)->syscall_result != 0) { in check_tape()
1082 STp->block_size = ST_DEFAULT_BLOCK; /* Educated guess (?) */ in check_tape()
1083 (STp->buffer)->syscall_result = 0; /* Prevent error propagation */ in check_tape()
1084 STp->drv_write_prot = 0; in check_tape()
1089 (STp->buffer)->b_data[0], (STp->buffer)->b_data[1], in check_tape()
1090 (STp->buffer)->b_data[2], (STp->buffer)->b_data[3])); in check_tape()
1092 if ((STp->buffer)->b_data[3] >= 8) { in check_tape()
1093 STp->drv_buffer = ((STp->buffer)->b_data[2] >> 4) & 7; in check_tape()
1094 STp->density = (STp->buffer)->b_data[4]; in check_tape()
1095 STp->block_size = (STp->buffer)->b_data[9] * 65536 + in check_tape()
1096 (STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[11]; in check_tape()
1099 name, STp->density, (STp->buffer)->b_data[5] * 65536 + in check_tape()
1100 (STp->buffer)->b_data[6] * 256 + (STp->buffer)->b_data[7], in check_tape()
1101 STp->drv_buffer)); in check_tape()
1103 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; in check_tape()
1104 if (!STp->drv_buffer && STp->immediate_filemark) { in check_tape()
1108 STp->immediate_filemark = 0; in check_tape()
1113 STp->inited = 1; in check_tape()
1115 if (STp->block_size > 0) in check_tape()
1116 (STp->buffer)->buffer_blocks = in check_tape()
1117 (STp->buffer)->buffer_size / STp->block_size; in check_tape()
1119 (STp->buffer)->buffer_blocks = 1; in check_tape()
1120 (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0; in check_tape()
1124 STp->block_size, (STp->buffer)->buffer_size, in check_tape()
1125 (STp->buffer)->buffer_blocks)); in check_tape()
1127 if (STp->drv_write_prot) { in check_tape()
1128 STp->write_prot = 1; in check_tape()
1140 if (STp->can_partitions && STp->nbr_partitions < 1) { in check_tape()
1146 if ((STp->partition = find_partition(STp)) < 0) { in check_tape()
1147 retval = STp->partition; in check_tape()
1150 STp->new_partition = STp->partition; in check_tape()
1151 STp->nbr_partitions = 1; /* This guess will be updated when necessary */ in check_tape()
1155 STp->density_changed = STp->blksize_changed = 0; in check_tape()
1156 STp->compression_changed = 0; in check_tape()
1158 (retval = set_mode_densblk(STp, STm)) < 0) in check_tape()
1161 if (STp->default_drvbuffer != 0xff) { in check_tape()
1162 if (st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer)) in check_tape()
1165 name, STp->default_drvbuffer); in check_tape()
1182 struct scsi_tape *STp; in st_open() local
1194 if (!(STp = scsi_tape_get(dev))) { in st_open()
1198 filp->private_data = STp; in st_open()
1199 name = tape_name(STp); in st_open()
1202 if (STp->in_use) { in st_open()
1204 scsi_tape_put(STp); in st_open()
1209 STp->in_use = 1; in st_open()
1211 STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0; in st_open()
1213 if (scsi_autopm_get_device(STp->device) < 0) { in st_open()
1218 if (!scsi_block_when_processing_errors(STp->device)) { in st_open()
1224 if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) { in st_open()
1231 (STp->buffer)->cleared = 0; in st_open()
1232 (STp->buffer)->writing = 0; in st_open()
1233 (STp->buffer)->syscall_result = 0; in st_open()
1235 STp->write_prot = ((filp->f_flags & O_ACCMODE) == O_RDONLY); in st_open()
1237 STp->dirty = 0; in st_open()
1239 STps = &(STp->ps[i]); in st_open()
1242 STp->try_dio_now = STp->try_dio; in st_open()
1243 STp->recover_count = 0; in st_open()
1244 DEB( STp->nbr_waits = STp->nbr_finished = 0; in st_open()
1245 STp->nbr_requests = STp->nbr_dio = STp->nbr_pages = 0; ) in st_open()
1247 retval = check_tape(STp, filp); in st_open()
1252 if (STp->ready == NO_TAPE) in st_open()
1261 normalize_buffer(STp->buffer); in st_open()
1263 STp->in_use = 0; in st_open()
1265 scsi_tape_put(STp); in st_open()
1267 scsi_autopm_put_device(STp->device); in st_open()
1279 struct scsi_tape *STp = filp->private_data; in st_flush() local
1280 struct st_modedef *STm = &(STp->modes[STp->current_mode]); in st_flush()
1281 struct st_partstat *STps = &(STp->ps[STp->partition]); in st_flush()
1282 char *name = tape_name(STp); in st_flush()
1287 if (STps->rw == ST_WRITING && !STp->pos_unknown) { in st_flush()
1288 result = st_flush_write_buffer(STp); in st_flush()
1293 if (STp->can_partitions && in st_flush()
1294 (result2 = switch_partition(STp)) < 0) { in st_flush()
1302 DEBC( if (STp->nbr_requests) in st_flush()
1304 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages)); in st_flush()
1306 if (STps->rw == ST_WRITING && !STp->pos_unknown) { in st_flush()
1307 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_flush()
1310 name, STp->nbr_waits, STp->nbr_finished); in st_flush()
1315 if (STp->immediate_filemark) in st_flush()
1317 cmd[4] = 1 + STp->two_fm; in st_flush()
1319 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, in st_flush()
1320 STp->device->request_queue->rq_timeout, in st_flush()
1323 result = (STp->buffer)->syscall_result; in st_flush()
1327 if (STp->buffer->syscall_result == 0 || in st_flush()
1339 if (STp->two_fm) in st_flush()
1340 cross_eof(STp, 0); in st_flush()
1353 } else if (!STp->rew_at_close) { in st_flush()
1354 STps = &(STp->ps[STp->partition]); in st_flush()
1356 if (STp->can_bsr) in st_flush()
1357 result = flush_buffer(STp, 0); in st_flush()
1359 result = cross_eof(STp, 0); in st_flush()
1369 !(result = cross_eof(STp, 1))) || in st_flush()
1379 if (STp->rew_at_close) { in st_flush()
1380 result2 = st_int_ioctl(STp, MTREW, 1); in st_flush()
1393 struct scsi_tape *STp = filp->private_data; in st_release() local
1395 if (STp->door_locked == ST_LOCKED_AUTO) in st_release()
1396 do_door_lock(STp, 0); in st_release()
1398 normalize_buffer(STp->buffer); in st_release()
1400 STp->in_use = 0; in st_release()
1402 scsi_autopm_put_device(STp->device); in st_release()
1403 scsi_tape_put(STp); in st_release()
1409 static ssize_t rw_checks(struct scsi_tape *STp, struct file *filp, size_t count) in rw_checks() argument
1419 if (!scsi_block_when_processing_errors(STp->device)) { in rw_checks()
1424 if (STp->ready != ST_READY) { in rw_checks()
1425 if (STp->ready == ST_NO_TAPE) in rw_checks()
1432 if (! STp->modes[STp->current_mode].defined) { in rw_checks()
1442 if (STp->pos_unknown) { in rw_checks()
1451 if (!STp->in_use) { in rw_checks()
1452 printk(ST_DEB_MSG "%s: Incorrect device.\n", tape_name(STp)); in rw_checks()
1457 if (STp->can_partitions && in rw_checks()
1458 (retval = switch_partition(STp)) < 0) in rw_checks()
1461 if (STp->block_size == 0 && STp->max_block > 0 && in rw_checks()
1462 (count < STp->min_block || count > STp->max_block)) { in rw_checks()
1467 if (STp->do_auto_lock && STp->door_locked == ST_UNLOCKED && in rw_checks()
1468 !do_door_lock(STp, 1)) in rw_checks()
1469 STp->door_locked = ST_LOCKED_AUTO; in rw_checks()
1476 static int setup_buffering(struct scsi_tape *STp, const char __user *buf, in setup_buffering() argument
1480 struct st_buffer *STbp = STp->buffer; in setup_buffering()
1483 i = STp->try_dio_now && try_rdio; in setup_buffering()
1485 i = STp->try_dio_now && try_wdio; in setup_buffering()
1488 STp->device->request_queue)) == 0) { in setup_buffering()
1500 STp->nbr_dio++; in setup_buffering()
1501 STp->nbr_pages += STbp->do_dio; in setup_buffering()
1506 DEB( STp->nbr_requests++; ) in setup_buffering()
1509 if (STp->block_size) in setup_buffering()
1510 bufsize = STp->block_size > st_fixed_buffer_size ? in setup_buffering()
1511 STp->block_size : st_fixed_buffer_size; in setup_buffering()
1516 if (is_read && STp->sili && !STbp->cleared) in setup_buffering()
1521 !enlarge_buffer(STbp, bufsize, STp->restr_dma)) { in setup_buffering()
1523 tape_name(STp), bufsize); in setup_buffering()
1527 if (STp->block_size) in setup_buffering()
1528 STbp->buffer_blocks = bufsize / STp->block_size; in setup_buffering()
1537 static void release_buffering(struct scsi_tape *STp, int is_read) in release_buffering() argument
1541 STbp = STp->buffer; in release_buffering()
1562 struct scsi_tape *STp = filp->private_data; in st_write() local
1566 char *name = tape_name(STp); in st_write()
1568 if (mutex_lock_interruptible(&STp->lock)) in st_write()
1571 retval = rw_checks(STp, filp, count); in st_write()
1576 if (STp->block_size != 0 && (count % STp->block_size) != 0) { in st_write()
1583 STm = &(STp->modes[STp->current_mode]); in st_write()
1584 STps = &(STp->ps[STp->partition]); in st_write()
1586 if (STp->write_prot) { in st_write()
1593 retval = flush_buffer(STp, 0); in st_write()
1599 if ((retval = set_mode_densblk(STp, STm)) < 0) in st_write()
1602 !(STp->compression_changed)) { in st_write()
1603 if (st_compression(STp, (STm->default_compression == ST_YES))) { in st_write()
1614 STbp = STp->buffer; in st_write()
1615 i = write_behind_check(STp); in st_write()
1635 if (STp->block_size != 0 && in st_write()
1643 retval = setup_buffering(STp, buf, count, 0); in st_write()
1651 cmd[1] = (STp->block_size != 0); in st_write()
1662 if (STp->block_size == 0) in st_write()
1665 do_count = STbp->buffer_blocks * STp->block_size - in st_write()
1680 async_write = STp->block_size == 0 && !STbp->do_dio && in st_write()
1683 if (STp->block_size != 0 && STm->do_buffer_writes && in st_write()
1684 !(STp->try_dio_now && try_wdio) && STps->eof < ST_EOM_OK && in st_write()
1686 STp->dirty = 1; in st_write()
1693 if (STp->block_size == 0) in st_write()
1700 blks /= STp->block_size; in st_write()
1701 transfer = blks * STp->block_size; in st_write()
1707 SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE, in st_write()
1708 STp->device->request_queue->rq_timeout, in st_write()
1716 STp->dirty = !(STbp->writing == in st_write()
1719 DEB( STp->write_pending = 1; ) in st_write()
1724 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_write()
1731 else if (STp->block_size == 0 && in st_write()
1736 if (STp->block_size != 0) in st_write()
1737 undone *= STp->block_size; in st_write()
1743 if (STp->block_size) in st_write()
1744 blks = (transfer - undone) / STp->block_size; in st_write()
1750 if (STp->block_size == 0 || in st_write()
1761 move_buffer_data(STp->buffer, transfer - undone); in st_write()
1765 STp->block_size; in st_write()
1770 name, STp->buffer->buffer_bytes)); in st_write()
1795 if (STp->block_size == 0) in st_write()
1802 STp->dirty = 0; in st_write()
1820 release_buffering(STp, 0); in st_write()
1821 mutex_unlock(&STp->lock); in st_write()
1832 static long read_tape(struct scsi_tape *STp, long count, in read_tape() argument
1842 char *name = tape_name(STp); in read_tape()
1847 STm = &(STp->modes[STp->current_mode]); in read_tape()
1848 STps = &(STp->ps[STp->partition]); in read_tape()
1851 STbp = STp->buffer; in read_tape()
1853 if (STp->block_size == 0) in read_tape()
1856 if (!(STp->try_dio_now && try_rdio) && STm->do_read_ahead) { in read_tape()
1857 blks = (STp->buffer)->buffer_blocks; in read_tape()
1858 bytes = blks * STp->block_size; in read_tape()
1861 if (!STbp->do_dio && bytes > (STp->buffer)->buffer_size) in read_tape()
1862 bytes = (STp->buffer)->buffer_size; in read_tape()
1863 blks = bytes / STp->block_size; in read_tape()
1864 bytes = blks * STp->block_size; in read_tape()
1870 cmd[1] = (STp->block_size != 0); in read_tape()
1871 if (!cmd[1] && STp->sili) in read_tape()
1878 SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, in read_tape()
1879 STp->device->request_queue->rq_timeout, in read_tape()
1881 release_buffering(STp, 1); in read_tape()
1891 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in read_tape()
1911 if (STp->block_size == 0 && in read_tape()
1916 if (STp->block_size == 0) { in read_tape()
1935 st_int_ioctl(STp, MTBSR, 1); in read_tape()
1940 STp->block_size; in read_tape()
1946 if (st_int_ioctl(STp, MTBSR, 1)) in read_tape()
1954 if (STp->block_size == 0) in read_tape()
1958 bytes - transfer * STp->block_size; in read_tape()
1967 if (STp->block_size == 0) in read_tape()
1971 bytes - transfer * STp->block_size; in read_tape()
2004 if (STp->sili) /* In fixed block mode residual is always zero here */ in read_tape()
2005 STbp->buffer_bytes -= STp->buffer->cmdstat.residual; in read_tape()
2009 if (STp->block_size == 0) in read_tape()
2012 STps->drv_block += STbp->buffer_bytes / STp->block_size; in read_tape()
2027 struct scsi_tape *STp = filp->private_data; in st_read() local
2030 struct st_buffer *STbp = STp->buffer; in st_read()
2031 DEB( char *name = tape_name(STp); ) in st_read()
2033 if (mutex_lock_interruptible(&STp->lock)) in st_read()
2036 retval = rw_checks(STp, filp, count); in st_read()
2040 STm = &(STp->modes[STp->current_mode]); in st_read()
2041 if (STp->block_size != 0 && (count % STp->block_size) != 0) { in st_read()
2046 STp->try_dio_now = 0; /* Direct i/o can't handle split blocks */ in st_read()
2049 STps = &(STp->ps[STp->partition]); in st_read()
2051 retval = flush_buffer(STp, 0); in st_read()
2062 retval = setup_buffering(STp, buf, count, 1); in st_read()
2098 special = read_tape(STp, count - total, &SRpnt); in st_read()
2127 if (STp->block_size == 0) in st_read()
2157 release_buffering(STp, 1); in st_read()
2160 mutex_unlock(&STp->lock); in st_read()
2169 static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm, char *name) in DEB() argument
2174 name, STp->current_mode, STm->do_buffer_writes, STm->do_async_writes, in DEB()
2178 name, STp->can_bsr, STp->two_fm, STp->fast_mteom, STp->do_auto_lock); in DEB()
2181 name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, in DEB()
2182 STp->scsi2_logical); in DEB()
2185 name, STm->sysv, STp->immediate, STp->sili, in DEB()
2186 STp->immediate_filemark); in DEB()
2194 static int st_set_options(struct scsi_tape *STp, long options)
2199 char *name = tape_name(STp);
2202 STm = &(STp->modes[STp->current_mode]);
2205 memcpy(STm, &(STp->modes[0]), sizeof(struct st_modedef));
2210 name, STp->current_mode));
2219 STp->two_fm = (options & MT_ST_TWO_FM) != 0;
2220 STp->fast_mteom = (options & MT_ST_FAST_MTEOM) != 0;
2221 STp->do_auto_lock = (options & MT_ST_AUTO_LOCK) != 0;
2222 STp->can_bsr = (options & MT_ST_CAN_BSR) != 0;
2223 STp->omit_blklims = (options & MT_ST_NO_BLKLIMS) != 0;
2224 if ((STp->device)->scsi_level >= SCSI_2)
2225 STp->can_partitions = (options & MT_ST_CAN_PARTITIONS) != 0;
2226 STp->scsi2_logical = (options & MT_ST_SCSI2LOGICAL) != 0;
2227 STp->immediate = (options & MT_ST_NOWAIT) != 0;
2228 STp->immediate_filemark = (options & MT_ST_NOWAIT_EOF) != 0;
2230 STp->sili = (options & MT_ST_SILI) != 0;
2232 st_log_options(STp, STm, name); )
2244 STp->two_fm = value;
2246 STp->fast_mteom = value;
2248 STp->do_auto_lock = value;
2250 STp->can_bsr = value;
2252 STp->omit_blklims = value;
2253 if ((STp->device)->scsi_level >= SCSI_2 &&
2255 STp->can_partitions = value;
2257 STp->scsi2_logical = value;
2259 STp->immediate = value;
2261 STp->immediate_filemark = value;
2265 STp->sili = value;
2269 st_log_options(STp, STm, name); )
2281 if (STp->ready == ST_READY) {
2282 STp->blksize_changed = 0;
2283 set_mode_densblk(STp, STm);
2289 STp->long_timeout = (value & ~MT_ST_SET_LONG_TIMEOUT) * HZ;
2293 blk_queue_rq_timeout(STp->device->request_queue,
2304 STp->cln_mode = value;
2305 STp->cln_sense_mask = (options >> 8) & 0xff;
2306 STp->cln_sense_value = (options >> 16) & 0xff;
2309 name, value, STp->cln_sense_mask, STp->cln_sense_value);
2322 if (STp->ready == ST_READY) {
2323 STp->density_changed = 0;
2324 set_mode_densblk(STp, STm);
2329 STp->default_drvbuffer = 0xff;
2333 STp->default_drvbuffer = value & 7;
2336 name, STp->default_drvbuffer));
2337 if (STp->ready == ST_READY)
2338 st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer);
2347 STp->c_algo = (value & 0xff00) >> 8;
2349 name, STp->c_algo));
2355 if (STp->ready == ST_READY) {
2356 STp->compression_changed = 0;
2357 st_compression(STp, (STm->default_compression == ST_YES));
2390 static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) in read_mode_page() argument
2402 SRpnt = st_do_scsi(NULL, STp, cmd, cmd[4], DMA_FROM_DEVICE, in read_mode_page()
2403 STp->device->request_queue->rq_timeout, 0, 1); in read_mode_page()
2405 return (STp->buffer)->syscall_result; in read_mode_page()
2409 return STp->buffer->syscall_result; in read_mode_page()
2415 static int write_mode_page(struct scsi_tape *STp, int page, int slow) in write_mode_page() argument
2425 pgo = MODE_HEADER_LENGTH + (STp->buffer)->b_data[MH_OFF_BDESCS_LENGTH]; in write_mode_page()
2426 cmd[4] = pgo + (STp->buffer)->b_data[pgo + MP_OFF_PAGE_LENGTH] + 2; in write_mode_page()
2429 (STp->buffer)->b_data[MH_OFF_DATA_LENGTH] = 0; in write_mode_page()
2430 (STp->buffer)->b_data[MH_OFF_MEDIUM_TYPE] = 0; in write_mode_page()
2431 (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP; in write_mode_page()
2432 (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; in write_mode_page()
2435 STp->long_timeout : STp->device->request_queue->rq_timeout; in write_mode_page()
2436 SRpnt = st_do_scsi(NULL, STp, cmd, cmd[4], DMA_TO_DEVICE, in write_mode_page()
2439 return (STp->buffer)->syscall_result; in write_mode_page()
2443 return STp->buffer->syscall_result; in write_mode_page()
2464 static int st_compression(struct scsi_tape * STp, int state) in st_compression() argument
2468 unsigned char *b_data = (STp->buffer)->b_data; in st_compression()
2469 DEB( char *name = tape_name(STp); ) in st_compression()
2471 if (STp->ready != ST_READY) in st_compression()
2475 retval = read_mode_page(STp, COMPRESSION_PAGE, 0); in st_compression()
2495 if (STp->c_algo != 0) in st_compression()
2496 b_data[mpoffs + CP_OFF_C_ALGO] = STp->c_algo; in st_compression()
2500 if (STp->c_algo != 0) in st_compression()
2504 retval = write_mode_page(STp, COMPRESSION_PAGE, 0); in st_compression()
2512 STp->compression_changed = 1; in st_compression()
2518 static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code) in do_load_unload() argument
2521 DEB( char *name = tape_name(STp); ) in do_load_unload()
2526 if (STp->ready != ST_READY && !load_code) { in do_load_unload()
2527 if (STp->ready == ST_NO_TAPE) in do_load_unload()
2547 if (STp->immediate) { in do_load_unload()
2549 timeout = STp->device->request_queue->rq_timeout; in do_load_unload()
2552 timeout = STp->long_timeout; in do_load_unload()
2561 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, in do_load_unload()
2564 return (STp->buffer)->syscall_result; in do_load_unload()
2566 retval = (STp->buffer)->syscall_result; in do_load_unload()
2572 STp->rew_at_close = 0; in do_load_unload()
2573 STp->ready = ST_NO_TAPE; in do_load_unload()
2576 STp->rew_at_close = STp->autorew_dev; in do_load_unload()
2577 retval = check_tape(STp, filp); in do_load_unload()
2583 STps = &(STp->ps[STp->partition]); in do_load_unload()
2608 static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned long arg) in st_int_ioctl() argument
2619 char *name = tape_name(STp); in st_int_ioctl()
2621 WARN_ON(STp->buffer->do_dio != 0); in st_int_ioctl()
2622 if (STp->ready != ST_READY) { in st_int_ioctl()
2623 if (STp->ready == ST_NO_TAPE) in st_int_ioctl()
2628 timeout = STp->long_timeout; in st_int_ioctl()
2629 STps = &(STp->ps[STp->partition]); in st_int_ioctl()
2716 if (STp->write_prot) in st_int_ioctl()
2722 (cmd_in == MTWEOF && STp->immediate_filemark)) in st_int_ioctl()
2727 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2743 if (STp->immediate) { in st_int_ioctl()
2745 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2756 if (STp->immediate) { in st_int_ioctl()
2758 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2765 if (!STp->fast_mteom) { in st_int_ioctl()
2767 ioctl_result = st_int_ioctl(STp, MTFSF, 0x7fffff); in st_int_ioctl()
2785 if (STp->write_prot) in st_int_ioctl()
2789 if (STp->immediate) { in st_int_ioctl()
2791 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2794 timeout = STp->long_timeout * 8; in st_int_ioctl()
2804 if (STp->dirty || (STp->buffer)->buffer_bytes != 0) in st_int_ioctl()
2808 STp->max_block > 0 && in st_int_ioctl()
2809 ((arg & MT_ST_BLKSIZE_MASK) < STp->min_block || in st_int_ioctl()
2810 (arg & MT_ST_BLKSIZE_MASK) > STp->max_block)) { in st_int_ioctl()
2815 if ((STp->use_pf & USE_PF)) in st_int_ioctl()
2820 memset((STp->buffer)->b_data, 0, 12); in st_int_ioctl()
2822 (STp->buffer)->b_data[2] = (arg & 7) << 4; in st_int_ioctl()
2824 (STp->buffer)->b_data[2] = in st_int_ioctl()
2825 STp->drv_buffer << 4; in st_int_ioctl()
2826 (STp->buffer)->b_data[3] = 8; /* block descriptor length */ in st_int_ioctl()
2828 (STp->buffer)->b_data[4] = arg; in st_int_ioctl()
2829 STp->density_changed = 1; /* At least we tried ;-) */ in st_int_ioctl()
2831 (STp->buffer)->b_data[4] = arg >> 24; in st_int_ioctl()
2833 (STp->buffer)->b_data[4] = STp->density; in st_int_ioctl()
2837 STp->blksize_changed = 1; /* At least we tried ;-) */ in st_int_ioctl()
2839 ltmp = STp->block_size; in st_int_ioctl()
2840 (STp->buffer)->b_data[9] = (ltmp >> 16); in st_int_ioctl()
2841 (STp->buffer)->b_data[10] = (ltmp >> 8); in st_int_ioctl()
2842 (STp->buffer)->b_data[11] = ltmp; in st_int_ioctl()
2843 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2848 (STp->buffer)->b_data[9] * 65536 + in st_int_ioctl()
2849 (STp->buffer)->b_data[10] * 256 + in st_int_ioctl()
2850 (STp->buffer)->b_data[11]); in st_int_ioctl()
2854 (STp->buffer)->b_data[4]); in st_int_ioctl()
2858 ((STp->buffer)->b_data[2] >> 4) & 7); in st_int_ioctl()
2865 SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction, in st_int_ioctl()
2868 return (STp->buffer)->syscall_result; in st_int_ioctl()
2870 ioctl_result = (STp->buffer)->syscall_result; in st_int_ioctl()
2880 ioctl_result = st_int_ioctl(STp, MTFSF, 1); in st_int_ioctl()
2882 ioctl_result = st_int_ioctl(STp, MTBSF, 1); in st_int_ioctl()
2885 STp->block_size = arg & MT_ST_BLKSIZE_MASK; in st_int_ioctl()
2886 if (STp->block_size != 0) { in st_int_ioctl()
2887 (STp->buffer)->buffer_blocks = in st_int_ioctl()
2888 (STp->buffer)->buffer_size / STp->block_size; in st_int_ioctl()
2890 (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0; in st_int_ioctl()
2892 STp->density = arg >> MT_ST_DENSITY_SHIFT; in st_int_ioctl()
2894 STp->drv_buffer = (arg & 7); in st_int_ioctl()
2896 STp->density = arg; in st_int_ioctl()
2909 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_int_ioctl()
2984 !(STp->use_pf & PF_TESTED)) { in st_int_ioctl()
2987 STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED; in st_int_ioctl()
2990 return st_int_ioctl(STp, cmd_in, arg); in st_int_ioctl()
3009 static int get_location(struct scsi_tape *STp, unsigned int *block, int *partition, in get_location() argument
3015 DEB( char *name = tape_name(STp); ) in get_location()
3017 if (STp->ready != ST_READY) in get_location()
3021 if ((STp->device)->scsi_level < SCSI_2) { in get_location()
3026 if (!logical && !STp->scsi2_logical) in get_location()
3029 SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE, in get_location()
3030 STp->device->request_queue->rq_timeout, in get_location()
3033 return (STp->buffer)->syscall_result; in get_location()
3035 if ((STp->buffer)->syscall_result != 0 || in get_location()
3036 (STp->device->scsi_level >= SCSI_2 && in get_location()
3037 ((STp->buffer)->b_data[0] & 4) != 0)) { in get_location()
3043 if ((STp->device)->scsi_level < SCSI_2) { in get_location()
3044 *block = ((STp->buffer)->b_data[0] << 16) in get_location()
3045 + ((STp->buffer)->b_data[1] << 8) in get_location()
3046 + (STp->buffer)->b_data[2]; in get_location()
3049 *block = ((STp->buffer)->b_data[4] << 24) in get_location()
3050 + ((STp->buffer)->b_data[5] << 16) in get_location()
3051 + ((STp->buffer)->b_data[6] << 8) in get_location()
3052 + (STp->buffer)->b_data[7]; in get_location()
3053 *partition = (STp->buffer)->b_data[1]; in get_location()
3054 if (((STp->buffer)->b_data[0] & 0x80) && in get_location()
3055 (STp->buffer)->b_data[1] == 0) /* BOP of partition 0 */ in get_location()
3056 STp->ps[0].drv_block = STp->ps[0].drv_file = 0; in get_location()
3070 static int set_location(struct scsi_tape *STp, unsigned int block, int partition, in set_location() argument
3079 DEB( char *name = tape_name(STp); ) in set_location()
3081 if (STp->ready != ST_READY) in set_location()
3083 timeout = STp->long_timeout; in set_location()
3084 STps = &(STp->ps[STp->partition]); in set_location()
3092 if ((!STp->can_partitions && partition != 0) || in set_location()
3095 if (partition != STp->partition) { in set_location()
3096 if (get_location(STp, &blk, &p, 1)) in set_location()
3103 name, blk, STp->partition)); in set_location()
3108 if ((STp->device)->scsi_level < SCSI_2) { in set_location()
3120 if (!logical && !STp->scsi2_logical) in set_location()
3122 if (STp->partition != partition) { in set_location()
3127 name, STp->partition, partition)); in set_location()
3130 if (STp->immediate) { in set_location()
3132 timeout = STp->device->request_queue->rq_timeout; in set_location()
3135 SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE, in set_location()
3138 return (STp->buffer)->syscall_result; in set_location()
3142 if ((STp->buffer)->syscall_result != 0) { in set_location()
3144 if (STp->can_partitions && in set_location()
3145 (STp->device)->scsi_level >= SCSI_2 && in set_location()
3146 (p = find_partition(STp)) >= 0) in set_location()
3147 STp->partition = p; in set_location()
3149 if (STp->can_partitions) { in set_location()
3150 STp->partition = partition; in set_location()
3151 STps = &(STp->ps[partition]); in set_location()
3173 static int find_partition(struct scsi_tape *STp) in find_partition() argument
3178 if ((i = get_location(STp, &block, &partition, 1)) < 0) in find_partition()
3187 static int switch_partition(struct scsi_tape *STp) in switch_partition() argument
3191 if (STp->partition == STp->new_partition) in switch_partition()
3193 STps = &(STp->ps[STp->new_partition]); in switch_partition()
3196 return set_location(STp, STps->last_block_visited, STp->new_partition, 1); in switch_partition()
3215 static int nbr_partitions(struct scsi_tape *STp) in nbr_partitions() argument
3218 DEB( char *name = tape_name(STp); ) in nbr_partitions()
3220 if (STp->ready != ST_READY) in nbr_partitions()
3223 result = read_mode_page(STp, PART_PAGE, 1); in nbr_partitions()
3230 result = (STp->buffer)->b_data[MODE_HEADER_LENGTH + in nbr_partitions()
3258 static int partition_tape(struct scsi_tape *STp, int size) in partition_tape() argument
3260 char *name = tape_name(STp); in partition_tape()
3265 result = read_mode_page(STp, PART_PAGE, 0); in partition_tape()
3271 bp = (STp->buffer)->b_data; in partition_tape()
3308 result = write_mode_page(STp, PART_PAGE, 1); in partition_tape()
3325 struct scsi_tape *STp = file->private_data; in st_ioctl() local
3328 char *name = tape_name(STp); in st_ioctl()
3331 if (mutex_lock_interruptible(&STp->lock)) in st_ioctl()
3335 if (debugging && !STp->in_use) { in st_ioctl()
3341 STm = &(STp->modes[STp->current_mode]); in st_ioctl()
3342 STps = &(STp->ps[STp->partition]); in st_ioctl()
3350 retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, in st_ioctl()
3352 if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV) in st_ioctl()
3386 if (!STp->pos_unknown) { in st_ioctl()
3404 i = !STp->can_partitions || in st_ioctl()
3405 (STp->new_partition != STp->partition); in st_ioctl()
3414 i = flush_buffer(STp, i); in st_ioctl()
3423 i = st_int_ioctl(STp, MTWEOF, 1); in st_ioctl()
3448 reset_state(STp); in st_ioctl()
3450 STp->device->was_reset = 0; in st_ioctl()
3458 if (mtc.mt_op == MTOFFL && STp->door_locked != ST_UNLOCKED) in st_ioctl()
3459 do_door_lock(STp, 0); /* Ignore result! */ in st_ioctl()
3463 retval = st_set_options(STp, mtc.mt_count); in st_ioctl()
3468 if (!STp->can_partitions || in st_ioctl()
3473 if (mtc.mt_count >= STp->nbr_partitions && in st_ioctl()
3474 (STp->nbr_partitions = nbr_partitions(STp)) < 0) { in st_ioctl()
3478 if (mtc.mt_count >= STp->nbr_partitions) { in st_ioctl()
3482 STp->new_partition = mtc.mt_count; in st_ioctl()
3488 if (!STp->can_partitions) { in st_ioctl()
3492 if ((i = st_int_ioctl(STp, MTREW, 0)) < 0 || in st_ioctl()
3493 (i = partition_tape(STp, mtc.mt_count)) < 0) { in st_ioctl()
3498 STp->ps[i].rw = ST_IDLE; in st_ioctl()
3499 STp->ps[i].at_sm = 0; in st_ioctl()
3500 STp->ps[i].last_block_valid = 0; in st_ioctl()
3502 STp->partition = STp->new_partition = 0; in st_ioctl()
3503 STp->nbr_partitions = 1; /* Bad guess ?-) */ in st_ioctl()
3510 i = set_location(STp, mtc.mt_count, STp->new_partition, 0); in st_ioctl()
3511 if (!STp->can_partitions) in st_ioctl()
3512 STp->ps[0].rw = ST_IDLE; in st_ioctl()
3518 retval = do_load_unload(STp, file, 0); in st_ioctl()
3523 retval = do_load_unload(STp, file, max(1, mtc.mt_count)); in st_ioctl()
3528 retval = do_door_lock(STp, (mtc.mt_op == MTLOCK)); in st_ioctl()
3532 if (STp->can_partitions && STp->ready == ST_READY && in st_ioctl()
3533 (i = switch_partition(STp)) < 0) { in st_ioctl()
3539 retval = st_compression(STp, (mtc.mt_count & 1)); in st_ioctl()
3541 retval = st_int_ioctl(STp, mtc.mt_op, mtc.mt_count); in st_ioctl()
3549 if ((i = flush_buffer(STp, 0)) < 0) { in st_ioctl()
3553 if (STp->can_partitions && in st_ioctl()
3554 (i = switch_partition(STp)) < 0) { in st_ioctl()
3567 mt_status.mt_type = STp->tape_type; in st_ioctl()
3569 ((STp->block_size << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK) | in st_ioctl()
3570 ((STp->density << MT_ST_DENSITY_SHIFT) & MT_ST_DENSITY_MASK); in st_ioctl()
3573 if (STp->block_size != 0) { in st_ioctl()
3576 (STp->buffer)->buffer_bytes / STp->block_size; in st_ioctl()
3579 ((STp->buffer)->buffer_bytes + in st_ioctl()
3580 STp->block_size - 1) / STp->block_size; in st_ioctl()
3584 if (STp->drv_write_prot) in st_ioctl()
3592 mt_status.mt_erreg = (STp->recover_reg << MT_ST_SOFTERR_SHIFT); in st_ioctl()
3593 mt_status.mt_resid = STp->partition; in st_ioctl()
3598 if (STp->density == 1) in st_ioctl()
3600 else if (STp->density == 2) in st_ioctl()
3602 else if (STp->density == 3) in st_ioctl()
3604 if (STp->ready == ST_READY) in st_ioctl()
3606 if (STp->ready == ST_NO_TAPE) in st_ioctl()
3611 (STm->do_buffer_writes && STp->block_size != 0) || in st_ioctl()
3612 STp->drv_buffer != 0) in st_ioctl()
3614 if (STp->cleaning_req) in st_ioctl()
3623 STp->recover_reg = 0; /* Clear after read */ in st_ioctl()
3633 if ((i = get_location(STp, &blk, &bt, 0)) < 0) { in st_ioctl()
3643 mutex_unlock(&STp->lock); in st_ioctl()
3655 i = scsi_cmd_ioctl(STp->disk->queue, STp->disk, in st_ioctl()
3661 retval = scsi_ioctl(STp->device, cmd_in, p); in st_ioctl()
3663 STp->rew_at_close = 0; in st_ioctl()
3664 STp->ready = ST_NO_TAPE; in st_ioctl()
3669 mutex_unlock(&STp->lock); in st_ioctl()
3676 struct scsi_tape *STp = file->private_data; in st_compat_ioctl() local
3677 struct scsi_device *sdev = STp->device; in st_compat_ioctl()
4452 struct scsi_tape *STp = STm->tape; in options_show() local
4460 options |= STp->two_fm ? MT_ST_TWO_FM : 0; in options_show()
4461 options |= STp->fast_mteom ? MT_ST_FAST_MTEOM : 0; in options_show()
4463 options |= STp->can_bsr ? MT_ST_CAN_BSR : 0; in options_show()
4464 options |= STp->omit_blklims ? MT_ST_NO_BLKLIMS : 0; in options_show()
4465 options |= STp->can_partitions ? MT_ST_CAN_PARTITIONS : 0; in options_show()
4466 options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0; in options_show()
4468 options |= STp->immediate ? MT_ST_NOWAIT : 0; in options_show()
4469 options |= STp->immediate_filemark ? MT_ST_NOWAIT_EOF : 0; in options_show()
4470 options |= STp->sili ? MT_ST_SILI : 0; in options_show()