Skip to contentSkip to conversation

Add an array that describes which opcodes are supported by the RDWR and SHEEPDOG backends.

PATCH ronnie sahlberg 4 participants 12 messages Oct 16, 2013 – Nov 7, 2013 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

ping?

Quoted 201 lines · Ronnie Sahlberg

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
usr/bs.c +8 -0
index 636f53b..5299498 100644
@@ -463,3 +463,11 @@ int bs_thread_cmd_submit(struct scsi_cmd *cmd)
 
        return 0;
 }
+
+void bs_create_opcode_map(unsigned char *map, unsigned char *opcodes, int num)
+{
+       int i;
+
+       for (i = 0; i < num; i++)
+               map[opcodes[i]] = 1;
+}
usr/bs_rdwr.c +51 -0
index 47d2d99..6a88205 100644
@@ -412,6 +412,8 @@ static void bs_rdwr_exit(struct scsi_lu *lu)
        bs_thread_close(info);
 }
 
+static char bs_ops_supported[256];
+
 static struct backingstore_template rdwr_bst = {
        .bs_name                = "rdwr",
        .bs_datasize            = sizeof(struct bs_thread_info),
@@ -421,9 +423,58 @@ static struct backingstore_template rdwr_bst = {
        .bs_exit                = bs_rdwr_exit,
        .bs_cmd_submit          = bs_thread_cmd_submit,
        .bs_oflags_supported    = O_SYNC | O_DIRECT,
+       .bs_ops_supported       = bs_ops_supported,
 };
 
 __attribute__((constructor)) static void bs_rdwr_constructor(void)
 {
+       static char opcodes[] = {
+               ALLOW_MEDIUM_REMOVAL,
+               COMPARE_AND_WRITE,
+               FORMAT_UNIT,
+               INQUIRY,
+               MAINT_PROTOCOL_IN,
+               MODE_SELECT,
+               MODE_SELECT_10,
+               MODE_SENSE,
+               MODE_SENSE_10,
+               ORWRITE_16,
+               PERSISTENT_RESERVE_IN,
+               PERSISTENT_RESERVE_OUT,
+               PRE_FETCH_10,
+               PRE_FETCH_16,
+               READ_10,
+               READ_12,
+               READ_16,
+               READ_6,
+               READ_CAPACITY,
+               RELEASE,
+               REPORT_LUNS,
+               REQUEST_SENSE,
+               RESERVE,
+               SEND_DIAGNOSTIC,
+               SERVICE_ACTION_IN,
+               START_STOP,
+               SYNCHRONIZE_CACHE,
+               SYNCHRONIZE_CACHE_16,
+               TEST_UNIT_READY,
+               UNMAP,
+               VERIFY_10,
+               VERIFY_12,
+               VERIFY_16,
+               WRITE_10,
+               WRITE_12,
+               WRITE_16,
+               WRITE_6,
+               WRITE_SAME,
+               WRITE_SAME_16,
+               WRITE_VERIFY,
+               WRITE_VERIFY_12,
+               WRITE_VERIFY_16
+       };
+
+       bs_create_opcode_map(bs_ops_supported, &opcodes[0],
+               sizeof(opcodes) / sizeof(opcodes[0]));
+
        register_backingstore_template(&rdwr_bst);
 }
usr/bs_sheepdog.c +38 -0
index 4b5a951..3099b58 100644
@@ -1017,6 +1017,8 @@ static void bs_sheepdog_exit(struct scsi_lu *lu)
        }
 }
 
+static char bs_ops_supported[256];
+
 static struct backingstore_template sheepdog_bst = {
        .bs_name                = "sheepdog",
        .bs_datasize            =
@@ -1026,9 +1028,45 @@ static struct backingstore_template sheepdog_bst = {
        .bs_init                = bs_sheepdog_init,
        .bs_exit                = bs_sheepdog_exit,
        .bs_cmd_submit          = bs_thread_cmd_submit,
+       .bs_ops_supported       = bs_ops_supported,
 };
 
 __attribute__((constructor)) static void __constructor(void)
 {
+       static char opcodes[] = {
+               ALLOW_MEDIUM_REMOVAL,
+               FORMAT_UNIT,
+               INQUIRY,
+               MAINT_PROTOCOL_IN,
+               MODE_SELECT,
+               MODE_SELECT_10,
+               MODE_SENSE,
+               MODE_SENSE_10,
+               PERSISTENT_RESERVE_IN,
+               PERSISTENT_RESERVE_OUT,
+               READ_10,
+               READ_12,
+               READ_16,
+               READ_6,
+               READ_CAPACITY,
+               RELEASE,
+               REPORT_LUNS,
+               REQUEST_SENSE,
+               RESERVE,
+               SEND_DIAGNOSTIC,
+               SERVICE_ACTION_IN,
+               START_STOP,
+               SYNCHRONIZE_CACHE,
+               SYNCHRONIZE_CACHE_16,
+               TEST_UNIT_READY,
+               WRITE_10,
+               WRITE_12,
+               WRITE_16,
+               WRITE_6
+       };
+
+       bs_create_opcode_map(bs_ops_supported, &opcodes[0],
+               sizeof(opcodes) / sizeof(opcodes[0]));
+
        register_backingstore_template(&sheepdog_bst);
 }
usr/scsi.c +6 -0
index 2636a5c..bce5ae0 100644
@@ -492,6 +492,12 @@ int scsi_cmd_perform(int host_no, struct scsi_cmd *cmd)
        if (spc_access_check(cmd))
                return SAM_STAT_RESERVATION_CONFLICT;
 
+       if (cmd->dev->bst->bs_ops_supported
+       && !cmd->dev->bst->bs_ops_supported[op]) {
+               sense_data_build(cmd, ILLEGAL_REQUEST, ASC_INVALID_OP_CODE);
+               return SAM_STAT_CHECK_CONDITION;
+       }
+
        return cmd->dev->dev_type_template.ops[op].cmd_perform(host_no, cmd);
 }
 
usr/tgtd.h +1 -1
index 484e6e9..70f6306 100644
@@ -165,6 +165,7 @@ struct backingstore_template {
        void (*bs_exit)(struct scsi_lu *dev);
        int (*bs_cmd_submit)(struct scsi_cmd *cmd);
        int bs_oflags_supported;
+       const char *bs_ops_supported;
 
        struct list_head backingstore_siblings;
 };
--

1.7.3.1

#3 lore raw
In reply to a message not in the archive

Hi Ronnie,

At Sat, 12 Oct 2013 07:38:59 -0700,

Quoted 14 lines · Ronnie Sahlberg

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 9 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)

Thanks a lot for the change! This patch looks good to me. I'll try to implement these missing opcode in bs_sheepdog.c, but it will take time and your solution is a great help.

Thanks,
Hitoshi

#4 lore raw
In reply to a message not in the archive

ping?

Quoted 201 lines · Ronnie Sahlberg

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
usr/bs.c +8 -0
index 636f53b..5299498 100644
@@ -463,3 +463,11 @@ int bs_thread_cmd_submit(struct scsi_cmd *cmd)
 
        return 0;
 }
+
+void bs_create_opcode_map(unsigned char *map, unsigned char *opcodes, int num)
+{
+       int i;
+
+       for (i = 0; i < num; i++)
+               map[opcodes[i]] = 1;
+}
usr/bs_rdwr.c +51 -0
index 47d2d99..6a88205 100644
@@ -412,6 +412,8 @@ static void bs_rdwr_exit(struct scsi_lu *lu)
        bs_thread_close(info);
 }
 
+static char bs_ops_supported[256];
+
 static struct backingstore_template rdwr_bst = {
        .bs_name                = "rdwr",
        .bs_datasize            = sizeof(struct bs_thread_info),
@@ -421,9 +423,58 @@ static struct backingstore_template rdwr_bst = {
        .bs_exit                = bs_rdwr_exit,
        .bs_cmd_submit          = bs_thread_cmd_submit,
        .bs_oflags_supported    = O_SYNC | O_DIRECT,
+       .bs_ops_supported       = bs_ops_supported,
 };
 
 __attribute__((constructor)) static void bs_rdwr_constructor(void)
 {
+       static char opcodes[] = {
+               ALLOW_MEDIUM_REMOVAL,
+               COMPARE_AND_WRITE,
+               FORMAT_UNIT,
+               INQUIRY,
+               MAINT_PROTOCOL_IN,
+               MODE_SELECT,
+               MODE_SELECT_10,
+               MODE_SENSE,
+               MODE_SENSE_10,
+               ORWRITE_16,
+               PERSISTENT_RESERVE_IN,
+               PERSISTENT_RESERVE_OUT,
+               PRE_FETCH_10,
+               PRE_FETCH_16,
+               READ_10,
+               READ_12,
+               READ_16,
+               READ_6,
+               READ_CAPACITY,
+               RELEASE,
+               REPORT_LUNS,
+               REQUEST_SENSE,
+               RESERVE,
+               SEND_DIAGNOSTIC,
+               SERVICE_ACTION_IN,
+               START_STOP,
+               SYNCHRONIZE_CACHE,
+               SYNCHRONIZE_CACHE_16,
+               TEST_UNIT_READY,
+               UNMAP,
+               VERIFY_10,
+               VERIFY_12,
+               VERIFY_16,
+               WRITE_10,
+               WRITE_12,
+               WRITE_16,
+               WRITE_6,
+               WRITE_SAME,
+               WRITE_SAME_16,
+               WRITE_VERIFY,
+               WRITE_VERIFY_12,
+               WRITE_VERIFY_16
+       };
+
+       bs_create_opcode_map(bs_ops_supported, &opcodes[0],
+               sizeof(opcodes) / sizeof(opcodes[0]));
+
        register_backingstore_template(&rdwr_bst);
 }
usr/bs_sheepdog.c +38 -0
index 4b5a951..3099b58 100644
@@ -1017,6 +1017,8 @@ static void bs_sheepdog_exit(struct scsi_lu *lu)
        }
 }
 
+static char bs_ops_supported[256];
+
 static struct backingstore_template sheepdog_bst = {
        .bs_name                = "sheepdog",
        .bs_datasize            =
@@ -1026,9 +1028,45 @@ static struct backingstore_template sheepdog_bst = {
        .bs_init                = bs_sheepdog_init,
        .bs_exit                = bs_sheepdog_exit,
        .bs_cmd_submit          = bs_thread_cmd_submit,
+       .bs_ops_supported       = bs_ops_supported,
 };
 
 __attribute__((constructor)) static void __constructor(void)
 {
+       static char opcodes[] = {
+               ALLOW_MEDIUM_REMOVAL,
+               FORMAT_UNIT,
+               INQUIRY,
+               MAINT_PROTOCOL_IN,
+               MODE_SELECT,
+               MODE_SELECT_10,
+               MODE_SENSE,
+               MODE_SENSE_10,
+               PERSISTENT_RESERVE_IN,
+               PERSISTENT_RESERVE_OUT,
+               READ_10,
+               READ_12,
+               READ_16,
+               READ_6,
+               READ_CAPACITY,
+               RELEASE,
+               REPORT_LUNS,
+               REQUEST_SENSE,
+               RESERVE,
+               SEND_DIAGNOSTIC,
+               SERVICE_ACTION_IN,
+               START_STOP,
+               SYNCHRONIZE_CACHE,
+               SYNCHRONIZE_CACHE_16,
+               TEST_UNIT_READY,
+               WRITE_10,
+               WRITE_12,
+               WRITE_16,
+               WRITE_6
+       };
+
+       bs_create_opcode_map(bs_ops_supported, &opcodes[0],
+               sizeof(opcodes) / sizeof(opcodes[0]));
+
        register_backingstore_template(&sheepdog_bst);
 }
usr/scsi.c +6 -0
index 2636a5c..bce5ae0 100644
@@ -492,6 +492,12 @@ int scsi_cmd_perform(int host_no, struct scsi_cmd *cmd)
        if (spc_access_check(cmd))
                return SAM_STAT_RESERVATION_CONFLICT;
 
+       if (cmd->dev->bst->bs_ops_supported
+       && !cmd->dev->bst->bs_ops_supported[op]) {
+               sense_data_build(cmd, ILLEGAL_REQUEST, ASC_INVALID_OP_CODE);
+               return SAM_STAT_CHECK_CONDITION;
+       }
+
        return cmd->dev->dev_type_template.ops[op].cmd_perform(host_no, cmd);
 }
 
usr/tgtd.h +1 -1
index 484e6e9..70f6306 100644
@@ -165,6 +165,7 @@ struct backingstore_template {
        void (*bs_exit)(struct scsi_lu *dev);
        int (*bs_cmd_submit)(struct scsi_cmd *cmd);
        int bs_oflags_supported;
+       const char *bs_ops_supported;
 
        struct list_head backingstore_siblings;
 };
--

1.7.3.1

#5 lore raw
In reply to a message not in the archive
Quoted 13 lines · On Sat, 12 Oct 2013 07:38:59 -0700 Ronnie Sahlberg <[email protected]>…

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 8 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)

Why backend store's bs_cmd_submit cannot return a proper error and sbr_rc returns that error to an initiator?

#6 lore raw
Quoted 25 lines · FUJITA Tomonori
Quoted 13 lines · On Sat, 12 Oct 2013 07:38:59 -0700 Ronnie Sahlberg <[email protected]>…

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 8 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
Quoted 2 lines

Why backend store's bs_cmd_submit cannot return a proper error and sbr_rc returns that error to an initiator?

It could, but this way it is more explicit which opcodes are available, and a simple compare of the array between opcodes makes it easy for non-bs_rdwr backend developers to see the delta between their backend and rdwr.

A second reason is for a followup patch.
The followup patch will use this array so that it can prune which opcodes to report back for the REPORT_SUPPORTED_OPCODE opcode. So that when you issue that command to a sheepdog LUN you get a pruned list back that only lists the opcodes that sheepdog supports.

regards
ronnie sahlberg

#7 lore raw

Ping?

We need something like an array like this so that we can also update REPORT_SUPPORTED_OPCODES correctly
and have this opcode only return the opcodes that the particular backend supports.

Quoted 45 lines · ronnie sahlberg
Quoted 25 lines · FUJITA Tomonori
Quoted 13 lines · On Sat, 12 Oct 2013 07:38:59 -0700 Ronnie Sahlberg <[email protected]>…

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 8 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
Quoted 2 lines

Why backend store's bs_cmd_submit cannot return a proper error and sbr_rc returns that error to an initiator?

It could, but this way it is more explicit which opcodes are available, and a simple compare of the array between opcodes makes it easy for non-bs_rdwr backend developers to see the delta between their backend and rdwr.

A second reason is for a followup patch.
The followup patch will use this array so that it can prune which opcodes to report back for the REPORT_SUPPORTED_OPCODE opcode. So that when you issue that command to a sheepdog LUN you get a pruned list back that only lists the opcodes that sheepdog supports.

regards
ronnie sahlberg

#8 lore raw
In reply to ronnie sahlberg
Quoted 36 lines · On Wed, 30 Oct 2013 18:44:19 -0700 ronnie sahlberg <[email protected]>…
Quoted 25 lines · FUJITA Tomonori
Quoted 13 lines · On Sat, 12 Oct 2013 07:38:59 -0700 Ronnie Sahlberg <[email protected]>…

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 8 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
Quoted 2 lines

Why backend store's bs_cmd_submit cannot return a proper error and sbr_rc returns that error to an initiator?

It could, but this way it is more explicit which opcodes are available, and a simple compare of the array between opcodes makes it easy for non-bs_rdwr backend developers to see the delta between their backend and rdwr.

Quoted 5 lines

A second reason is for a followup patch.
The followup patch will use this array so that it can prune which opcodes to report back for the REPORT_SUPPORTED_OPCODE opcode. So that when you issue that command to a sheepdog LUN you get a pruned list back that only lists the opcodes that sheepdog supports.

I see, thanks. Using the bitmaps is simpler than the array of char if you calculate delta and such?

#9 lore raw
Quoted 39 lines · FUJITA Tomonori
Quoted 36 lines · On Wed, 30 Oct 2013 18:44:19 -0700 ronnie sahlberg <[email protected]>…
Quoted 25 lines · FUJITA Tomonori
Quoted 13 lines · On Sat, 12 Oct 2013 07:38:59 -0700 Ronnie Sahlberg <[email protected]>…

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 8 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
Quoted 2 lines

Why backend store's bs_cmd_submit cannot return a proper error and sbr_rc returns that error to an initiator?

It could, but this way it is more explicit which opcodes are available, and a simple compare of the array between opcodes makes it easy for non-bs_rdwr backend developers to see the delta between their backend and rdwr.

Quoted 8 lines
Quoted 5 lines

A second reason is for a followup patch.
The followup patch will use this array so that it can prune which opcodes to report back for the REPORT_SUPPORTED_OPCODE opcode. So that when you issue that command to a sheepdog LUN you get a pruned list back that only lists the opcodes that sheepdog supports.

I see, thanks. Using the bitmaps is simpler than the array of char if you calculate delta and such?

I think using the array with opcode names is simpler for a human to comparing when reading the sourcecode.

I had a bitmap of 32 bytes, one bit for each opcode, and I also
tried using an array of 256 bytes, one byte 0/1 for each opcode but it was horrible to read from a human standpoint.

When reading the code and the bitmap/array it was very difficult to see which opcodes were supported and which were not
by just looking at the bits.
It was also errorprone and I did several mistakes when building the bitmap manually.

This approach uses an array of opcodes, making it really easy for a human to see which opcodes are supported and which are not. Then I call bs_create_opcode_map() to convert this array into a byte-array to make it efficient for tgtd to check if the opcodes are supported or not.

#10 lore raw
Quoted 58 lines · On Thu, 7 Nov 2013 08:42:43 -0800 ronnie sahlberg <[email protected]>…
Quoted 39 lines · FUJITA Tomonori
Quoted 36 lines · On Wed, 30 Oct 2013 18:44:19 -0700 ronnie sahlberg <[email protected]>…
Quoted 25 lines · FUJITA Tomonori
Quoted 13 lines · On Sat, 12 Oct 2013 07:38:59 -0700 Ronnie Sahlberg <[email protected]>…

While RDWR supports all SBC opcodes that TGTD implement SHEEPDOG only supports a subset and lacks the following opcodes:
WRITE_VERIFY10/12/16 VERIFY10/12/16 PREFETCH10/16 WRITE_SAME10/16 UNMAP and ORWRITE

This allows backends to specify which opcodes it is prepared to process and which commands should fail with invalid op code
and allows SHEEPDOG backed LUNs to respond with INVALID_OP_CODE correctly.

This is most useful for block devices where we have several different backens and where some backends only support a subset of the commands

Quoted 8 lines
---
 usr/bs.c          |    8 ++++++++
 usr/bs_rdwr.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/bs_sheepdog.c |   38 ++++++++++++++++++++++++++++++++++++++
 usr/scsi.c        |    6 ++++++
 usr/tgtd.h        |    1 +
 5 files changed, 104 insertions(+), 0 deletions(-)
Quoted 2 lines

Why backend store's bs_cmd_submit cannot return a proper error and sbr_rc returns that error to an initiator?

It could, but this way it is more explicit which opcodes are available, and a simple compare of the array between opcodes makes it easy for non-bs_rdwr backend developers to see the delta between their backend and rdwr.

Quoted 8 lines
Quoted 5 lines

A second reason is for a followup patch.
The followup patch will use this array so that it can prune which opcodes to report back for the REPORT_SUPPORTED_OPCODE opcode. So that when you issue that command to a sheepdog LUN you get a pruned list back that only lists the opcodes that sheepdog supports.

I see, thanks. Using the bitmaps is simpler than the array of char if you calculate delta and such?

I think using the array with opcode names is simpler for a human to comparing when reading the sourcecode.

I had a bitmap of 32 bytes, one bit for each opcode, and I also
tried using an array of 256 bytes, one byte 0/1 for each opcode but it was horrible to read from a human standpoint.

Quoted 5 lines

When reading the code and the bitmap/array it was very difficult to see which opcodes were supported and which were not
by just looking at the bits.
It was also errorprone and I did several mistakes when building the bitmap manually.

Why you built it manually? You can do something like

set_bit(WRITE_6, bitmap_addr);

?

As usual, you can steal bitmap functions from Linux kernel.

Quoted 10 lines

This approach uses an array of opcodes, making it really easy for a human to see which opcodes are supported and which are not. Then I call bs_create_opcode_map() to convert this array into a byte-array to make it efficient for tgtd to check if the opcodes are supported or not.
--
To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
Quoted 18 lines
Quoted 12 lines
Quoted 3 lines

I see, thanks. Using the bitmaps is simpler than the array of char if you calculate delta and such?

I think using the array with opcode names is simpler for a human to comparing when reading the sourcecode.

I had a bitmap of 32 bytes, one bit for each opcode, and I also
tried using an array of 256 bytes, one byte 0/1 for each opcode but it was horrible to read from a human standpoint.

Quoted 5 lines

When reading the code and the bitmap/array it was very difficult to see which opcodes were supported and which were not
by just looking at the bits.
It was also errorprone and I did several mistakes when building the bitmap manually.

Quoted 7 lines

Why you built it manually? You can do something like

set_bit(WRITE_6, bitmap_addr);

?

As usual, you can steal bitmap functions from Linux kernel.

Is it worth it to mess around with bits when chars are easily manipulated? Sure, it's 8x the data, but it's much easier to dump, examine in debuggers, etc., and it's 256 bytes; hardly worthy of notice. Bitmaps are a pain in general.

#12 lore raw
Quoted 24 lines · On Thu, 07 Nov 2013 13:46:36 -0800 Dan Mick <[email protected]> wrote:
Quoted 24 lines
Quoted 12 lines
Quoted 3 lines

I see, thanks. Using the bitmaps is simpler than the array of char if you calculate delta and such?

I think using the array with opcode names is simpler for a human to comparing when reading the sourcecode.

I had a bitmap of 32 bytes, one bit for each opcode, and I also
tried using an array of 256 bytes, one byte 0/1 for each opcode but it was horrible to read from a human standpoint.

Quoted 5 lines

When reading the code and the bitmap/array it was very difficult to see which opcodes were supported and which were not
by just looking at the bits.
It was also errorprone and I did several mistakes when building the bitmap manually.

Why you built it manually? You can do something like

set_bit(WRITE_6, bitmap_addr);

?

Quoted 7 lines
Quoted 1 line

As usual, you can steal bitmap functions from Linux kernel.

Is it worth it to mess around with bits when chars are easily manipulated? Sure, it's 8x the data, but it's much easier to dump, examine in debuggers, etc., and it's 256 bytes; hardly worthy of notice.
Bitmaps are a pain in general.

Most of us (kernel people) are familar with bitmap ops rather than functions that we would invent. That's my point.

#13 lore raw
Quoted 29 lines · FUJITA Tomonori
Quoted 26 lines · On Thu, 07 Nov 2013 13:46:36 -0800 Dan Mick <[email protected]> wrote:
Quoted 25 lines
Quoted 12 lines
Quoted 3 lines

I see, thanks. Using the bitmaps is simpler than the array of char if you calculate delta and such?

I think using the array with opcode names is simpler for a human to comparing when reading the sourcecode.

I had a bitmap of 32 bytes, one bit for each opcode, and I also
tried using an array of 256 bytes, one byte 0/1 for each opcode but it was horrible to read from a human standpoint.

Quoted 5 lines

When reading the code and the bitmap/array it was very difficult to see which opcodes were supported and which were not
by just looking at the bits.
It was also errorprone and I did several mistakes when building the bitmap manually.

Why you built it manually? You can do something like

set_bit(WRITE_6, bitmap_addr);

?

As usual, you can steal bitmap functions from Linux kernel.

Quoted 9 lines
Quoted 5 lines

Is it worth it to mess around with bits when chars are easily manipulated? Sure, it's 8x the data, but it's much easier to dump, examine in debuggers, etc., and it's 256 bytes; hardly worthy of notice.
Bitmaps are a pain in general.

Most of us (kernel people) are familar with bitmap ops rather than functions that we would invent. That's my point.

Sure, I get that; I just mean it's not worth it for the space savings when the usability hit is there, IMO. But it's a matter of opinion.