diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-02-27 22:05:33 -0800 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-04-07 23:26:09 -0700 |
commit | 9ef5466ee2f0599caf8d84203d36e581c6fc7035 (patch) | |
tree | 03317fe25e4c27bb98664fec6ebd8e340bde2676 /drivers/target/target_core_sbc.c | |
parent | 38b57f82f66dfb21ebe321d71c84c0e3469980c4 (diff) | |
download | linux-9ef5466ee2f0599caf8d84203d36e581c6fc7035.tar.bz2 |
target: Update SPC/SBC emulation for sess_prot_type
This patch updates standard INQUIRY, INQUIRY EVPD=0x86, READ_CAPACITY_16
and control mode pages to use se_sess->sess_prot_type when determing which
type of T10-PI related feature bits can be exposed.
This is required for fabric sessions supporting T10-PI metadata to
backend devices that don't have protection enabled.
Reviewed-by: Martin Petersen <martin.petersen@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Doug Gilbert <dgilbert@interlog.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_sbc.c')
-rw-r--r-- | drivers/target/target_core_sbc.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 9efd1fd985ee..67bc1886f004 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -93,6 +93,8 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) { struct se_device *dev = cmd->se_dev; struct se_session *sess = cmd->se_sess; + int pi_prot_type = dev->dev_attrib.pi_prot_type; + unsigned char *rbuf; unsigned char buf[32]; unsigned long long blocks = dev->transport->get_blocks(dev); @@ -114,8 +116,15 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) * Set P_TYPE and PROT_EN bits for DIF support */ if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) { - if (dev->dev_attrib.pi_prot_type) - buf[12] = (dev->dev_attrib.pi_prot_type - 1) << 1 | 0x1; + /* + * Only override a device's pi_prot_type if no T10-PI is + * available, and sess_prot_type has been explicitly enabled. + */ + if (!pi_prot_type) + pi_prot_type = sess->sess_prot_type; + + if (pi_prot_type) + buf[12] = (pi_prot_type - 1) << 1 | 0x1; } if (dev->transport->get_lbppbe) |