Lines Matching defs:aSRpnt
183 static int osst_int_ioctl(struct osst_tape *STp, struct osst_request ** aSRpnt,
186 static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int frame, int skip);
188 static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt);
190 static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request ** aSRpnt);
192 static int osst_write_error_recovery(struct osst_tape * STp, struct osst_request ** aSRpnt, int pending);
749 static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt,
768 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
769 *aSRpnt = SRpnt;
791 *aSRpnt = SRpnt;
796 osst_write_error_recovery(STp, aSRpnt, 0) ) {
814 static int osst_wait_for_medium(struct osst_tape * STp, struct osst_request ** aSRpnt, unsigned timeout)
829 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
830 *aSRpnt = SRpnt;
849 *aSRpnt = SRpnt;
869 static int osst_position_tape_and_confirm(struct osst_tape * STp, struct osst_request ** aSRpnt, int frame)
873 osst_wait_ready(STp, aSRpnt, 15 * 60, 0); /* TODO - can this catch a write error? */
874 retval = osst_set_frame_position(STp, aSRpnt, frame, 0);
876 osst_wait_ready(STp, aSRpnt, 15 * 60, OSST_WAIT_POSITION_COMPLETE);
877 return (osst_get_frame_position(STp, aSRpnt));
883 static int osst_flush_drive_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt)
899 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
900 *aSRpnt = SRpnt;
908 result = osst_write_error_recovery(STp, aSRpnt, 0);
910 result |= osst_wait_ready(STp, aSRpnt, 5 * 60, delay);
917 static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int curr, int minlast, int to)
930 result = osst_get_frame_position(STp, aSRpnt);
932 if ((result = osst_write_error_recovery(STp, aSRpnt, 0)) == 0)
972 static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int writing)
990 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout,
998 retval = osst_write_error_recovery(STp, aSRpnt, 0);
1020 (*aSRpnt)->sense[ 2] & 0x0f,
1021 (*aSRpnt)->sense[12],
1022 (*aSRpnt)->sense[13]);
1030 static int osst_read_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int timeout)
1041 if (osst_wait_frame (STp, aSRpnt, STp->first_frame_position, 0, timeout))
1042 retval = osst_recover_wait_frame(STp, aSRpnt, 0);
1053 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, OS_FRAME_SIZE, DMA_FROM_DEVICE,
1055 *aSRpnt = SRpnt;
1101 static int osst_initiate_read(struct osst_tape * STp, struct osst_request ** aSRpnt)
1112 osst_flush_write_buffer(STp, aSRpnt);
1113 osst_flush_drive_buffer(STp, aSRpnt);
1129 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
1130 *aSRpnt = SRpnt;
1138 static int osst_get_logical_frame(struct osst_tape * STp, struct osst_request ** aSRpnt,
1166 osst_set_frame_position(STp, aSRpnt, STp->read_error_frame, 0);
1181 if ( osst_initiate_read(STp, aSRpnt)
1182 || ( (!STp->frame_in_buffer) && osst_read_frame(STp, aSRpnt, 30) ) ) {
1185 position = osst_get_frame_position(STp, aSRpnt);
1200 osst_set_frame_position(STp, aSRpnt, position, 0);
1221 position = osst_get_frame_position(STp, aSRpnt)
1233 osst_set_frame_position(STp, aSRpnt, position, 0);
1239 if (osst_get_frame_position(STp, aSRpnt) == 0xbaf) {
1243 osst_set_frame_position(STp, aSRpnt, 0xbb8, 0);
1267 static int osst_seek_logical_blk(struct osst_tape * STp, struct osst_request ** aSRpnt, int logical_blk_num)
1301 osst_set_frame_position(STp, aSRpnt, ppos_estimate, 0);
1302 if (osst_get_logical_frame(STp, aSRpnt, frame_seq_estimate, 1) >= 0) {
1348 if (osst_get_logical_frame(STp, aSRpnt, -1, 1) < 0)
1376 static int osst_get_sector(struct osst_tape * STp, struct osst_request ** aSRpnt)
1399 sector = osst_get_frame_position(STp, aSRpnt);
1406 static int osst_seek_sector(struct osst_tape * STp, struct osst_request ** aSRpnt, int sector)
1422 return (osst_set_frame_position(STp, aSRpnt, frame, 0));
1424 r = osst_set_frame_position(STp, aSRpnt, offset?frame:frame-1, 0);
1427 r = osst_get_logical_frame(STp, aSRpnt, -1, 1);
1430 if (osst_get_frame_position(STp, aSRpnt) != (offset?frame+1:frame)) return (-EIO);
1469 static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst_request ** aSRpnt,
1472 struct osst_request * SRpnt = * aSRpnt;
1516 *aSRpnt = SRpnt;
1526 *aSRpnt = SRpnt;
1527 osst_get_frame_position(STp, aSRpnt);
1550 osst_set_frame_position(STp, aSRpnt, new_frame + i, 0);
1551 osst_wait_ready(STp, aSRpnt, 60, OSST_WAIT_POSITION_COMPLETE);
1552 osst_get_frame_position(STp, aSRpnt);
1553 SRpnt = * aSRpnt;
1632 *aSRpnt = SRpnt;
1649 osst_get_frame_position(STp, aSRpnt);
1667 static int osst_reposition_and_retry(struct osst_tape * STp, struct osst_request ** aSRpnt,
1693 osst_set_frame_position(STp, aSRpnt, frame + skip, 1);
1698 if (osst_get_frame_position(STp, aSRpnt) < 0) { /* additional write error */
1718 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, OS_FRAME_SIZE, DMA_TO_DEVICE,
1720 *aSRpnt = SRpnt;
1770 static int osst_write_error_recovery(struct osst_tape * STp, struct osst_request ** aSRpnt, int pending)
1772 struct osst_request * SRpnt = * aSRpnt;
1799 osst_get_frame_position(STp, aSRpnt);
1812 retval = osst_reposition_and_retry(STp, aSRpnt, frame, skip, pending);
1814 retval = osst_read_back_buffer_and_rewrite(STp, aSRpnt, frame, skip, pending);
1822 osst_set_frame_position(STp, aSRpnt, frame + STp->cur_frames + pending, 0);
1827 retval = osst_read_back_buffer_and_rewrite(STp, aSRpnt, frame, 1, pending);
1831 osst_set_frame_position(STp, aSRpnt, frame + STp->cur_frames + pending, 0);
1833 osst_get_frame_position(STp, aSRpnt);
1849 static int osst_space_over_filemarks_backward(struct osst_tape * STp, struct osst_request ** aSRpnt,
1859 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
1891 osst_position_tape_and_confirm(STp, aSRpnt, last_mark_ppos);
1892 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
1918 osst_position_tape_and_confirm(STp, aSRpnt, last_mark_ppos);
1920 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
1948 static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct osst_request ** aSRpnt,
1957 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
1964 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
2002 static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct osst_request ** aSRpnt,
2012 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
2048 return osst_space_over_filemarks_forward_slow(STp, aSRpnt, mt_op, mt_count);
2050 osst_position_tape_and_confirm(STp, aSRpnt, next_mark_ppos);
2051 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
2088 return osst_space_over_filemarks_forward_slow(STp, aSRpnt, mt_op, mt_count);
2090 osst_position_tape_and_confirm(STp, aSRpnt, STp->first_mark_ppos);
2091 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
2105 if (osst_space_over_filemarks_backward(STp, aSRpnt, MTBSF, 1) < 0)
2117 return osst_space_over_filemarks_forward_slow(STp, aSRpnt, mt_op, mt_count - cnt);
2122 osst_position_tape_and_confirm(STp, aSRpnt, next_mark_ppos);
2124 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
2153 static void osst_set_retries(struct osst_tape * STp, struct osst_request ** aSRpnt, int retries)
2156 struct osst_request * SRpnt = * aSRpnt;
2177 *aSRpnt = SRpnt;
2185 static int osst_write_filemark(struct osst_tape * STp, struct osst_request ** aSRpnt)
2202 result = osst_flush_write_buffer(STp, aSRpnt);
2203 result |= osst_flush_drive_buffer(STp, aSRpnt);
2213 static int osst_write_eod(struct osst_tape * STp, struct osst_request ** aSRpnt)
2230 result = osst_flush_write_buffer(STp, aSRpnt);
2231 result |= osst_flush_drive_buffer(STp, aSRpnt);
2236 static int osst_write_filler(struct osst_tape * STp, struct osst_request ** aSRpnt, int where, int count)
2243 osst_wait_ready(STp, aSRpnt, 60 * 5, 0);
2244 osst_set_frame_position(STp, aSRpnt, where, 0);
2250 if (osst_flush_write_buffer(STp, aSRpnt)) {
2258 return osst_flush_drive_buffer(STp, aSRpnt);
2261 static int __osst_write_header(struct osst_tape * STp, struct osst_request ** aSRpnt, int where, int count)
2269 osst_wait_ready(STp, aSRpnt, 60 * 5, 0);
2270 osst_set_frame_position(STp, aSRpnt, where, 0);
2276 if (osst_flush_write_buffer(STp, aSRpnt)) {
2281 result = osst_flush_drive_buffer(STp, aSRpnt);
2288 static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRpnt, int locate_eod)
2340 result = __osst_write_header(STp, aSRpnt, 0xbae, 5);
2342 osst_write_filler(STp, aSRpnt, 0xbb3, 5);
2343 result &= __osst_write_header(STp, aSRpnt, 5, 5);
2349 osst_set_frame_position(STp, aSRpnt, STp->eod_frame_ppos, 0);
2362 static int osst_reset_header(struct osst_tape * STp, struct osst_request ** aSRpnt)
2372 return osst_write_header(STp, aSRpnt, 1);
2375 static int __osst_analyze_headers(struct osst_tape * STp, struct osst_request ** aSRpnt, int ppos)
2388 if (osst_set_frame_position(STp, aSRpnt, ppos, 0))
2390 osst_wait_ready(STp, aSRpnt, 60 * 15, 0);
2391 if (osst_initiate_read (STp, aSRpnt)) {
2396 if (osst_read_frame(STp, aSRpnt, 180)) {
2552 static int osst_analyze_headers(struct osst_tape * STp, struct osst_request ** aSRpnt)
2559 position = osst_get_frame_position(STp, aSRpnt);
2581 if (__osst_analyze_headers(STp, aSRpnt, ppos))
2588 if (__osst_analyze_headers(STp, aSRpnt, ppos))
2594 osst_set_frame_position(STp, aSRpnt, 10, 0);
2601 osst_set_frame_position(STp, aSRpnt, position, 0);
2607 static int osst_verify_position(struct osst_tape * STp, struct osst_request ** aSRpnt)
2621 osst_set_frame_position(STp, aSRpnt, frame_position - 1, 0);
2622 if (osst_get_logical_frame(STp, aSRpnt, -1, 0) < 0) {
2649 osst_set_frame_position(STp, aSRpnt, frame_position - 1, 0);
2683 static int osst_configure_onstream(struct osst_tape *STp, struct osst_request ** aSRpnt)
2687 struct osst_request * SRpnt = * aSRpnt;
2723 *aSRpnt = SRpnt;
2754 *aSRpnt = SRpnt;
2766 osst_set_retries(STp, aSRpnt, 0);
2767 SRpnt = * aSRpnt;
2794 *aSRpnt = SRpnt;
2809 *aSRpnt = SRpnt;
2829 *aSRpnt = SRpnt;
2854 static int cross_eof(struct osst_tape *STp, struct osst_request ** aSRpnt, int forward)
2867 result = osst_space_over_filemarks_forward_slow(STp, aSRpnt, MTFSF, 1);
2871 result = osst_seek_logical_blk(STp, aSRpnt, STp->logical_blk_num - 1);
2883 static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt)
2902 SRpnt = osst_do_scsi(*aSRpnt, STp, scmd, 20, DMA_FROM_DEVICE,
2908 *aSRpnt = SRpnt;
2967 static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int ppos, int skip)
3001 SRpnt = osst_do_scsi(*aSRpnt, STp, scmd, 0, DMA_NONE, STp->long_timeout,
3005 *aSRpnt = SRpnt;
3015 osst_wait_ready(STp, aSRpnt, 5 * 60, OSST_WAIT_POSITION_COMPLETE);
3025 static int osst_write_trailer(struct osst_tape *STp, struct osst_request ** aSRpnt, int leave_at_EOT)
3032 result = osst_flush_drive_buffer(STp, aSRpnt);
3034 result = osst_write_filemark(STp, aSRpnt);
3041 result = osst_write_eod(STp, aSRpnt);
3042 osst_write_header(STp, aSRpnt, leave_at_EOT);
3053 static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request ** aSRpnt)
3058 struct osst_request * SRpnt = *aSRpnt;
3066 "%s:D: aSRpnt points to osst_request that write_behind_check will release -- cleared\n", name);
3068 *aSRpnt = SRpnt = NULL;
3072 "%s:D: aSRpnt does not point to osst_request that write_behind_check will release -- strange\n", name);
3101 if (osst_wait_frame (STp, aSRpnt, STp->first_frame_position, -50, 120))
3102 result = osst_recover_wait_frame(STp, aSRpnt, 1);
3140 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, transfer, DMA_TO_DEVICE,
3142 *aSRpnt = SRpnt;
3161 if (osst_write_error_recovery(STp, aSRpnt, 1)) {
3183 static int osst_flush_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt, int seek_next)
3204 return osst_flush_write_buffer(STp, aSRpnt);
3223 result = cross_eof(STp, aSRpnt, 0); /* Back over the EOF hit */
3233 result = osst_seek_logical_blk(STp, aSRpnt, STp->logical_blk_num - backspace);
3245 static int osst_write_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int synchronous)
3258 if (osst_flush_drive_buffer(STp, aSRpnt) < 0) {
3262 if (osst_get_frame_position(STp, aSRpnt) < 0xbb8) {
3266 osst_position_tape_and_confirm(STp, aSRpnt, 0xbb8);
3271 if (osst_wait_frame (STp, aSRpnt, STp->first_frame_position, -48, 120))
3272 if (osst_recover_wait_frame(STp, aSRpnt, 1))
3297 SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, OS_FRAME_SIZE, DMA_TO_DEVICE, STp->timeout,
3301 *aSRpnt = SRpnt;
3315 if (osst_write_error_recovery(STp, aSRpnt, 1))
4056 static int osst_int_ioctl(struct osst_tape * STp, struct osst_request ** aSRpnt,
4064 struct osst_request * SRpnt = * aSRpnt;
4435 *aSRpnt = SRpnt;