Commit eeeb9522 authored by Nicholas Bellinger's avatar Nicholas Bellinger

target: Propigate backend read-only to core_tpg_add_lun

This patch adds a DF_READ_ONLY flag that is used by IBLOCK to
signal when a backend has been set to read-only mode, in order
to propigate read-only status up to core_tpg_add_lun() for all
future LUN fabric exports.

With this is place, existing emulation for reporting read-only
in spc_emulate_modesense() and normal transport_lookup_cmd_lun()
TCM_WRITE_PROTECTED status checking just works as expected.
Reported-by: default avatarJoeue Deng <joeue404@gmail.com>
Reported-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 3ccd6e83
...@@ -105,6 +105,8 @@ static int iblock_configure_device(struct se_device *dev) ...@@ -105,6 +105,8 @@ static int iblock_configure_device(struct se_device *dev)
mode = FMODE_READ|FMODE_EXCL; mode = FMODE_READ|FMODE_EXCL;
if (!ib_dev->ibd_readonly) if (!ib_dev->ibd_readonly)
mode |= FMODE_WRITE; mode |= FMODE_WRITE;
else
dev->dev_flags |= DF_READ_ONLY;
bd = blkdev_get_by_path(ib_dev->ibd_udev_path, mode, ib_dev); bd = blkdev_get_by_path(ib_dev->ibd_udev_path, mode, ib_dev);
if (IS_ERR(bd)) { if (IS_ERR(bd)) {
......
...@@ -668,6 +668,9 @@ int core_tpg_add_lun( ...@@ -668,6 +668,9 @@ int core_tpg_add_lun(
list_add_tail(&lun->lun_dev_link, &dev->dev_sep_list); list_add_tail(&lun->lun_dev_link, &dev->dev_sep_list);
spin_unlock(&dev->se_port_lock); spin_unlock(&dev->se_port_lock);
if (dev->dev_flags & DF_READ_ONLY)
lun->lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
else
lun->lun_access = lun_access; lun->lun_access = lun_access;
if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE))
hlist_add_head_rcu(&lun->link, &tpg->tpg_lun_hlist); hlist_add_head_rcu(&lun->link, &tpg->tpg_lun_hlist);
......
...@@ -730,6 +730,7 @@ struct se_device { ...@@ -730,6 +730,7 @@ struct se_device {
#define DF_EMULATED_VPD_UNIT_SERIAL 0x00000004 #define DF_EMULATED_VPD_UNIT_SERIAL 0x00000004
#define DF_USING_UDEV_PATH 0x00000008 #define DF_USING_UDEV_PATH 0x00000008
#define DF_USING_ALIAS 0x00000010 #define DF_USING_ALIAS 0x00000010
#define DF_READ_ONLY 0x00000020
/* Physical device queue depth */ /* Physical device queue depth */
u32 queue_depth; u32 queue_depth;
/* Used for SPC-2 reservations enforce of ISIDs */ /* Used for SPC-2 reservations enforce of ISIDs */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment