Skip to content

Commit 13bb08f

Browse files
manu0401Atsushi Abe
authored andcommitted
Make ltotape thread-safe
The ltotape driver uses a thread-shared ltotape_scsi_io_type structure that contains fields involved in SCSI operations: cdb, cdb_length, data, data_length, data_direction, actual_data_length, sensedata, sense_length, timeout_ms. As a result the driver is not re-entrant, while libltfs expects it to be. We fix that situation by adding a wrapper layer that copies the ltotape_scsi_io_type structure to the stack when doing SCSI operations, so that the offending fields are not shared among threads anymore.
1 parent e9f031c commit 13bb08f

File tree

6 files changed

+2028
-150
lines changed

6 files changed

+2028
-150
lines changed

src/tape_drivers/linux/ltotape/ltotape.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,14 +3228,14 @@ const char *tape_dev_get_message_bundle_name (void **message_data)
32283228
return "driver_ltotape";
32293229
}
32303230

3231-
#ifdef IBM_LTFS_BUILD
3232-
#include "ltotape_compat.c"
3233-
#endif
32343231

32353232
/**
32363233
* Finally declare the set of operations defined by this backend
32373234
* and provide a function to access the structure:
32383235
*/
3236+
#ifdef IBM_LTFS_BUILD
3237+
#include "ltotape_compat.c"
3238+
#else
32393239
struct tape_ops ltotape_drive_handler ={
32403240
.open = ltotape_open,
32413241
.reopen = ltotape_reopen,
@@ -3254,9 +3254,7 @@ struct tape_ops ltotape_drive_handler ={
32543254
.erase = ltotape_erase,
32553255
.load = ltotape_load,
32563256
.unload = ltotape_unload,
3257-
#ifndef IBM_LTFS_BUILD
32583257
.loadunload = ltotape_ext_loadunload,
3259-
#endif
32603258
.readpos = ltotape_readposition,
32613259
.setcap = ltotape_setcap,
32623260
.format = ltotape_format,
@@ -3271,9 +3269,7 @@ struct tape_ops ltotape_drive_handler ={
32713269
.read_attribute = ltotape_read_attribute,
32723270
.write_attribute = ltotape_write_attribute,
32733271
.allow_overwrite = ltotape_allow_overwrite,
3274-
#ifndef IBM_LTFS_BUILD
32753272
.report_density = ltotape_report_density,
3276-
#endif
32773273
.set_compression = ltotape_set_compression,
32783274
.set_default = ltotape_set_default,
32793275
.get_cartridge_health = ltotape_get_cartridge_health,
@@ -3289,23 +3285,13 @@ struct tape_ops ltotape_drive_handler ={
32893285
.default_device_name = ltotape_default_device_name,
32903286
.set_key = ltotape_set_key,
32913287
.get_keyalias = ltotape_get_keyalias,
3292-
#ifdef IBM_LTFS_BUILD
3293-
.takedump_drive = _ltotape_takedump_drive,
3294-
.is_mountable = _ltotape_is_mountable,
3295-
#else
32963288
.takedump_drive = ltotape_takedump_drive,
32973289
.is_mountable = ltotape_is_mountable,
32983290
.update_mam_attr = ltotape_update_mam_attr,
3299-
#endif
33003291
.get_worm_status = ltotape_get_worm_status,
3301-
#ifdef IBM_LTFS_BUILD
3302-
.get_serialnumber = ltotape_get_serialnumber,
3303-
.set_profiler = ltotape_set_profiler,
3304-
.get_block_in_buffer = ltotape_get_block_in_buffer,
3305-
.is_readonly = ltotape_is_readonly,
3306-
#endif
33073292

33083293
};
3294+
#endif
33093295

33103296
struct tape_ops *tape_dev_get_ops (void)
33113297
{

0 commit comments

Comments
 (0)