Skip to content

Commit 28da74c

Browse files
hoeppnerjhcahca
authored andcommitted
s390/tape: Remove special block id handling
For real 3490 tape models a logical block was composed of a direction bit (wrap), a segment number, a format mode, and a logical block number. This is represented in a 4byte identifier. The Virtual Tape Server (VTS) emulates 3490 tape devices and uses a stripped block id format where bit 0-9 of the 4byte identifier are always 0. Bit 10-31 represent the logical block number. All tapes use the 3480-2 XF format, which was defined via TAPE34XX_FMT_3480_2_XF but never used. There is also no special handling required anymore as this is the only format being used. Since VTS doesn't require any special handling of block ids and format, corresponding code is removed. Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com> Reviewed-by: Jens Remus <jremus@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent effcf3d commit 28da74c

2 files changed

Lines changed: 2 additions & 202 deletions

File tree

drivers/s390/char/tape.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ struct tape_device {
186186

187187
/* Device discipline information. */
188188
struct tape_discipline * discipline;
189-
void * discdata;
190189

191190
/* Generic status flags */
192191
long tape_generic_status;

drivers/s390/char/tape_34xx.c

Lines changed: 2 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,11 @@
2828
debug_info_t *TAPE_DBF_AREA = NULL;
2929
EXPORT_SYMBOL(TAPE_DBF_AREA);
3030

31-
#define TAPE34XX_FMT_3480 0
32-
#define TAPE34XX_FMT_3480_2_XF 1
33-
#define TAPE34XX_FMT_3480_XF 2
34-
3531
struct tape_34xx_block_id {
36-
unsigned int wrap : 1;
37-
unsigned int segment : 7;
38-
unsigned int format : 2;
32+
unsigned int unused : 10;
3933
unsigned int block : 22;
4034
};
4135

42-
/*
43-
* A list of block ID's is used to faster seek blocks.
44-
*/
45-
struct tape_34xx_sbid {
46-
struct list_head list;
47-
struct tape_34xx_block_id bid;
48-
};
49-
50-
static void tape_34xx_delete_sbid_from(struct tape_device *, int);
51-
5236
/*
5337
* Medium sense for 34xx tapes. There is no 'real' medium sense call.
5438
* So we just do a normal sense.
@@ -175,19 +159,6 @@ static inline int
175159
tape_34xx_done(struct tape_request *request)
176160
{
177161
DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
178-
179-
switch (request->op) {
180-
case TO_DSE:
181-
case TO_RUN:
182-
case TO_WRI:
183-
case TO_WTM:
184-
case TO_ASSIGN:
185-
case TO_UNASSIGN:
186-
tape_34xx_delete_sbid_from(request->device, 0);
187-
break;
188-
default:
189-
;
190-
}
191162
return TAPE_IO_SUCCESS;
192163
}
193164

@@ -224,7 +195,6 @@ tape_34xx_unsolicited_irq(struct tape_device *device, struct irb *irb)
224195
if (irb->scsw.cmd.dstat == 0x85) { /* READY */
225196
/* A medium was inserted in the drive. */
226197
DBF_EVENT(6, "xuud med\n");
227-
tape_34xx_delete_sbid_from(device, 0);
228198
tape_34xx_schedule_work(device, TO_MSEN);
229199
} else {
230200
DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
@@ -356,7 +326,6 @@ tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
356326
*/
357327
case TO_LBL:
358328
/* Block could not be located. */
359-
tape_34xx_delete_sbid_from(device, 0);
360329
return tape_34xx_erp_failed(request, -EIO);
361330

362331
case TO_RFO:
@@ -543,7 +512,6 @@ tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
543512
*/
544513
dev_warn (&device->cdev->dev, "The tape unit failed to load"
545514
" the cartridge\n");
546-
tape_34xx_delete_sbid_from(device, 0);
547515
return tape_34xx_erp_failed(request, -EIO);
548516
case 0x34:
549517
/*
@@ -601,7 +569,6 @@ tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
601569
/* Manual rewind or unload. This causes an I/O error. */
602570
dev_warn (&device->cdev->dev, "The tape medium has been "
603571
"rewound or unloaded manually\n");
604-
tape_34xx_delete_sbid_from(device, 0);
605572
return tape_34xx_erp_failed(request, -EIO);
606573
case 0x42:
607574
/*
@@ -613,7 +580,6 @@ tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
613580
return tape_34xx_erp_retry(request);
614581
case 0x43:
615582
/* Drive not ready. */
616-
tape_34xx_delete_sbid_from(device, 0);
617583
tape_med_state_set(device, MS_UNLOADED);
618584
/* Some commands commands are successful even in this case */
619585
if (sense[1] & SENSE_DRIVE_ONLINE) {
@@ -653,7 +619,6 @@ tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
653619
/* Volume fenced. CU reports volume integrity is lost. */
654620
dev_warn (&device->cdev->dev, "The control unit has fenced "
655621
"access to the tape volume\n");
656-
tape_34xx_delete_sbid_from(device, 0);
657622
return tape_34xx_erp_failed(request, -EIO);
658623
case 0x48:
659624
/* Log sense data and retry request. */
@@ -725,7 +690,6 @@ tape_34xx_unit_check(struct tape_device *device, struct tape_request *request,
725690
/* End of Volume complete. Rewind unload completed ok. */
726691
if (request->op == TO_RUN) {
727692
tape_med_state_set(device, MS_UNLOADED);
728-
tape_34xx_delete_sbid_from(device, 0);
729693
return tape_34xx_erp_succeeded(request);
730694
}
731695
return tape_34xx_erp_bug(device, request, irb, sense[3]);
@@ -835,183 +799,24 @@ tape_34xx_irq(struct tape_device *device, struct tape_request *request,
835799
return TAPE_IO_STOP;
836800
}
837801

838-
static inline void
839-
tape_34xx_append_new_sbid(struct tape_34xx_block_id bid, struct list_head *l)
840-
{
841-
struct tape_34xx_sbid * new_sbid;
842-
843-
new_sbid = kmalloc(sizeof(*new_sbid), GFP_ATOMIC);
844-
if (!new_sbid)
845-
return;
846-
847-
new_sbid->bid = bid;
848-
list_add(&new_sbid->list, l);
849-
}
850-
851-
/*
852-
* Build up the search block ID list. The block ID consists of a logical
853-
* block number and a hardware specific part. The hardware specific part
854-
* helps the tape drive to speed up searching for a specific block.
855-
*/
856-
static void
857-
tape_34xx_add_sbid(struct tape_device *device, struct tape_34xx_block_id bid)
858-
{
859-
struct list_head * sbid_list;
860-
struct tape_34xx_sbid * sbid;
861-
struct list_head * l;
862-
863-
/*
864-
* immediately return if there is no list at all or the block to add
865-
* is located in segment 1 of wrap 0 because this position is used
866-
* if no hardware position data is supplied.
867-
*/
868-
sbid_list = (struct list_head *) device->discdata;
869-
if (!sbid_list || (bid.segment < 2 && bid.wrap == 0))
870-
return;
871-
872-
/*
873-
* Search the position where to insert the new entry. Hardware
874-
* acceleration uses only the segment and wrap number. So we
875-
* need only one entry for a specific wrap/segment combination.
876-
* If there is a block with a lower number but the same hard-
877-
* ware position data we just update the block number in the
878-
* existing entry.
879-
*/
880-
list_for_each(l, sbid_list) {
881-
sbid = list_entry(l, struct tape_34xx_sbid, list);
882-
883-
if (
884-
(sbid->bid.segment == bid.segment) &&
885-
(sbid->bid.wrap == bid.wrap)
886-
) {
887-
if (bid.block < sbid->bid.block)
888-
sbid->bid = bid;
889-
else return;
890-
break;
891-
}
892-
893-
/* Sort in according to logical block number. */
894-
if (bid.block < sbid->bid.block) {
895-
tape_34xx_append_new_sbid(bid, l->prev);
896-
break;
897-
}
898-
}
899-
/* List empty or new block bigger than last entry. */
900-
if (l == sbid_list)
901-
tape_34xx_append_new_sbid(bid, l->prev);
902-
903-
DBF_LH(4, "Current list is:\n");
904-
list_for_each(l, sbid_list) {
905-
sbid = list_entry(l, struct tape_34xx_sbid, list);
906-
DBF_LH(4, "%d:%03d@%05d\n",
907-
sbid->bid.wrap,
908-
sbid->bid.segment,
909-
sbid->bid.block
910-
);
911-
}
912-
}
913-
914-
/*
915-
* Delete all entries from the search block ID list that belong to tape blocks
916-
* equal or higher than the given number.
917-
*/
918-
static void
919-
tape_34xx_delete_sbid_from(struct tape_device *device, int from)
920-
{
921-
struct list_head * sbid_list;
922-
struct tape_34xx_sbid * sbid;
923-
struct list_head * l;
924-
struct list_head * n;
925-
926-
sbid_list = (struct list_head *) device->discdata;
927-
if (!sbid_list)
928-
return;
929-
930-
list_for_each_safe(l, n, sbid_list) {
931-
sbid = list_entry(l, struct tape_34xx_sbid, list);
932-
if (sbid->bid.block >= from) {
933-
DBF_LH(4, "Delete sbid %d:%03d@%05d\n",
934-
sbid->bid.wrap,
935-
sbid->bid.segment,
936-
sbid->bid.block
937-
);
938-
list_del(l);
939-
kfree(sbid);
940-
}
941-
}
942-
}
943-
944-
/*
945-
* Merge hardware position data into a block id.
946-
*/
947-
static void
948-
tape_34xx_merge_sbid(
949-
struct tape_device * device,
950-
struct tape_34xx_block_id * bid
951-
) {
952-
struct tape_34xx_sbid * sbid;
953-
struct tape_34xx_sbid * sbid_to_use;
954-
struct list_head * sbid_list;
955-
struct list_head * l;
956-
957-
sbid_list = (struct list_head *) device->discdata;
958-
bid->wrap = 0;
959-
bid->segment = 1;
960-
961-
if (!sbid_list || list_empty(sbid_list))
962-
return;
963-
964-
sbid_to_use = NULL;
965-
list_for_each(l, sbid_list) {
966-
sbid = list_entry(l, struct tape_34xx_sbid, list);
967-
968-
if (sbid->bid.block >= bid->block)
969-
break;
970-
sbid_to_use = sbid;
971-
}
972-
if (sbid_to_use) {
973-
bid->wrap = sbid_to_use->bid.wrap;
974-
bid->segment = sbid_to_use->bid.segment;
975-
DBF_LH(4, "Use %d:%03d@%05d for %05d\n",
976-
sbid_to_use->bid.wrap,
977-
sbid_to_use->bid.segment,
978-
sbid_to_use->bid.block,
979-
bid->block
980-
);
981-
}
982-
}
983-
984802
static int
985803
tape_34xx_setup_device(struct tape_device * device)
986804
{
987-
int rc;
988-
struct list_head * discdata;
805+
int rc;
989806

990807
DBF_EVENT(6, "34xx device setup\n");
991808
if ((rc = tape_std_assign(device)) == 0) {
992809
if ((rc = tape_34xx_medium_sense(device)) != 0) {
993810
DBF_LH(3, "34xx medium sense returned %d\n", rc);
994811
}
995812
}
996-
discdata = kmalloc(sizeof(struct list_head), GFP_KERNEL);
997-
if (discdata) {
998-
INIT_LIST_HEAD(discdata);
999-
device->discdata = discdata;
1000-
}
1001-
1002813
return rc;
1003814
}
1004815

1005816
static void
1006817
tape_34xx_cleanup_device(struct tape_device *device)
1007818
{
1008819
tape_std_unassign(device);
1009-
1010-
if (device->discdata) {
1011-
tape_34xx_delete_sbid_from(device, 0);
1012-
kfree(device->discdata);
1013-
device->discdata = NULL;
1014-
}
1015820
}
1016821

1017822

@@ -1031,7 +836,6 @@ tape_34xx_mttell(struct tape_device *device, int mt_count)
1031836
if (rc)
1032837
return rc;
1033838

1034-
tape_34xx_add_sbid(device, block_id.cbid);
1035839
return block_id.cbid.block;
1036840
}
1037841

@@ -1055,10 +859,7 @@ tape_34xx_mtseek(struct tape_device *device, int mt_count)
1055859
/* setup ccws */
1056860
request->op = TO_LBL;
1057861
bid = (struct tape_34xx_block_id *) request->cpdata;
1058-
bid->format = (*device->modeset_byte & 0x08) ?
1059-
TAPE34XX_FMT_3480_XF : TAPE34XX_FMT_3480;
1060862
bid->block = mt_count;
1061-
tape_34xx_merge_sbid(device, bid);
1062863

1063864
tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
1064865
tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);

0 commit comments

Comments
 (0)