SMC fixes
PATCH 1/1 SMC fixes
List, Tomo,
We need a proper whitelist for which opcodes are valid for SMC devices. The following patch adds a trivial backing store template for smc with a corresponding opcode whitelist. With this patch we can access the smc device with mtx again.
Ronnie Sahlberg (1):
SMC: add a smc backend template with an opcode whitelist
usr/bs_rdwr.c | 33 +++++++++++++++++++++++++++++++++ usr/scsi.h | 1 + usr/smc.c | 9 +++++++++ 3 files changed, 43 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.3.1
PATCH 1/1 SMC: add a smc backend template with an opcode whitelist
SMC is not working properly since we do not yet initialize a proper SMC backend to tell it which opcodes are valid and which are not. With this change SMC works again and we can create a jukebox that mtx can communicate with correctly.
--- usr/bs_rdwr.c | 33 +++++++++++++++++++++++++++++++++ usr/scsi.h | 1 + usr/smc.c | 9 +++++++++ 3 files changed, 43 insertions(+), 0 deletions(-)
usr/bs_rdwr.c +33 -0
@@ -434,6 +434,17 @@ static struct backingstore_template mmc_bst = { .bs_oflags_supported = O_SYNC | O_DIRECT, }; +static struct backingstore_template smc_bst = { + .bs_name ="smc" , + .bs_datasize =sizeof (struct bs_thread_info ), + .bs_open = bs_rdwr_open, + .bs_close = bs_rdwr_close, + .bs_init = bs_rdwr_init, + .bs_exit = bs_rdwr_exit, + .bs_cmd_submit = bs_thread_cmd_submit, + .bs_oflags_supported =O_SYNC |O_DIRECT , +}; + __attribute__((constructor))static void bs_rdwr_constructor (void ) {unsigned char sbc_opcodes[] = {
@@ -519,4 +530,26 @@ __attribute__((constructor)) static void bs_rdwr_constructor(void) };bs_create_opcode_map (&mmc_bst, mmc_opcodes,ARRAY_SIZE (mmc_opcodes));register_backingstore_template (&mmc_bst); + +unsigned char smc_opcodes[] = { +INITIALIZE_ELEMENT_STATUS , +INITIALIZE_ELEMENT_STATUS_WITH_RANGE , +INQUIRY , +MAINT_PROTOCOL_IN , +MODE_SELECT , +MODE_SELECT_10 , +MODE_SENSE , +MODE_SENSE_10 , +MOVE_MEDIUM , +PERSISTENT_RESERVE_IN , +PERSISTENT_RESERVE_OUT , +REQUEST_SENSE , +TEST_UNIT_READY , +READ_ELEMENT_STATUS , +RELEASE , +REPORT_LUNS , +RESERVE , + }; +bs_create_opcode_map (&smc_bst, smc_opcodes,ARRAY_SIZE (smc_opcodes)); +register_backingstore_template (&smc_bst); }
usr/scsi.h +1 -0
@@ -50,6 +50,7 @@#define SYNCHRONIZE_CACHE 0x35#define LOCK_UNLOCK_CACHE 0x36#define READ_DEFECT_DATA 0x37 +#define INITIALIZE_ELEMENT_STATUS_WITH_RANGE 0x37#define MEDIUM_SCAN 0x38#define COMPARE 0x39#define COPY_VERIFY 0x3a
usr/smc.c +9 -0
@@ -493,6 +493,7 @@ sense:static tgtadm_err smc_lu_init (struct scsi_lu *lu) { +struct backingstore_template *bst;struct smc_info *smc;tgtadm_err adm_err;
@@ -505,6 +506,14 @@ static tgtadm_err smc_lu_init(struct scsi_lu *lu)if (spc_lu_init (lu))return TGTADM_NOMEM ; +/* SMC devices always use smc backingstore */ + bst =get_backingstore_template ("smc" ); +if (!bst) { +eprintf ("failed to find bstype, smc\n" ); +return TGTADM_INVALID_REQUEST ; + } + lu->bst = bst; +strncpy (lu->attrs.product_id,"VIRTUAL-CHANGER" ,sizeof (lu->attrs.product_id)); lu->attrs.version_desc[0 ] =0x0480 ;/* SMC-3 no version claimed */
Signature · 1 line
1.7.3.1
FUJITA Tomonori
AppliedRe: [PATCH] SMC: add a smc backend template with an opcode whitelist
Quoted 11 lines · On Mon, 8 Sep 2014 19:53:09 -0700 Ronnie Sahlberg <[email protected]>…
SMC is not working properly since we do not yet initialize a proper SMC backend to tell it which opcodes are valid and which are not. With this change SMC works again and we can create a jukebox that mtx can communicate with correctly.
Signed-off-by Ronnie Sahlberg <[email protected]>--- usr/bs_rdwr.c | 33 +++++++++++++++++++++++++++++++++ usr/scsi.h | 1 + usr/smc.c | 9 +++++++++ 3 files changed, 43 insertions(+), 0 deletions(-)
Applied, thanks!
ping?
Quoted 19 lines · Ronnie Sahlberg
List, Tomo,
We need a proper whitelist for which opcodes are valid for SMC devices. The following patch adds a trivial backing store template for smc with a corresponding opcode whitelist. With this patch we can access the smc device with mtx again.
Ronnie Sahlberg (1):
SMC: add a smc backend template with an opcode whitelistusr/bs_rdwr.c | 33 +++++++++++++++++++++++++++++++++ usr/scsi.h | 1 + usr/smc.c | 9 +++++++++ 3 files changed, 43 insertions(+), 0 deletions(-)--
1.7.3.1