diff options
| author | Andy Grover <agrover@redhat.com> | 2016-02-25 18:14:32 -0500 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-03-11 00:48:55 -0500 |
| commit | 03a68b44faff1b3eef5424952044747c9c555f0e (patch) | |
| tree | 4a1e59d4735b892ff4f41ef1bffe3be29060bbe3 /drivers/target/target_core_tpg.c | |
| parent | 07b6319687026bdac90a0bb9eeb0509f1ff27179 (diff) | |
target: Remove enum transport_lunflags_table
se_dev_entry.lun_flags and se_lun.lun_access are only used for keeping
track of read-write vs. read-only state. Since this is an either/or thing
we can represent it as bool, and remove the unneeded enum
transport_lunflags_table, which is left over from when there were more
flags.
Change code that uses this enum to just use true/false, and make it clear
through variable and param names that true means read-only, false means
read-write.
Signed-off-by: Andy Grover <agrover@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_tpg.c')
| -rw-r--r-- | drivers/target/target_core_tpg.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 3608b1b5ecf7..ddf046080dc3 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
| @@ -121,7 +121,7 @@ void core_tpg_add_node_to_devs( | |||
| 121 | struct se_portal_group *tpg, | 121 | struct se_portal_group *tpg, |
| 122 | struct se_lun *lun_orig) | 122 | struct se_lun *lun_orig) |
| 123 | { | 123 | { |
| 124 | u32 lun_access = 0; | 124 | bool lun_access_ro = true; |
| 125 | struct se_lun *lun; | 125 | struct se_lun *lun; |
| 126 | struct se_device *dev; | 126 | struct se_device *dev; |
| 127 | 127 | ||
| @@ -137,27 +137,26 @@ void core_tpg_add_node_to_devs( | |||
| 137 | * demo_mode_write_protect is ON, or READ_ONLY; | 137 | * demo_mode_write_protect is ON, or READ_ONLY; |
| 138 | */ | 138 | */ |
| 139 | if (!tpg->se_tpg_tfo->tpg_check_demo_mode_write_protect(tpg)) { | 139 | if (!tpg->se_tpg_tfo->tpg_check_demo_mode_write_protect(tpg)) { |
| 140 | lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; | 140 | lun_access_ro = false; |
| 141 | } else { | 141 | } else { |
| 142 | /* | 142 | /* |
| 143 | * Allow only optical drives to issue R/W in default RO | 143 | * Allow only optical drives to issue R/W in default RO |
| 144 | * demo mode. | 144 | * demo mode. |
| 145 | */ | 145 | */ |
| 146 | if (dev->transport->get_device_type(dev) == TYPE_DISK) | 146 | if (dev->transport->get_device_type(dev) == TYPE_DISK) |
| 147 | lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; | 147 | lun_access_ro = true; |
| 148 | else | 148 | else |
| 149 | lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; | 149 | lun_access_ro = false; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | pr_debug("TARGET_CORE[%s]->TPG[%u]_LUN[%llu] - Adding %s" | 152 | pr_debug("TARGET_CORE[%s]->TPG[%u]_LUN[%llu] - Adding %s" |
| 153 | " access for LUN in Demo Mode\n", | 153 | " access for LUN in Demo Mode\n", |
| 154 | tpg->se_tpg_tfo->get_fabric_name(), | 154 | tpg->se_tpg_tfo->get_fabric_name(), |
| 155 | tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, | 155 | tpg->se_tpg_tfo->tpg_get_tag(tpg), lun->unpacked_lun, |
| 156 | (lun_access == TRANSPORT_LUNFLAGS_READ_WRITE) ? | 156 | lun_access_ro ? "READ-ONLY" : "READ-WRITE"); |
| 157 | "READ-WRITE" : "READ-ONLY"); | ||
| 158 | 157 | ||
| 159 | core_enable_device_list_for_node(lun, NULL, lun->unpacked_lun, | 158 | core_enable_device_list_for_node(lun, NULL, lun->unpacked_lun, |
| 160 | lun_access, acl, tpg); | 159 | lun_access_ro, acl, tpg); |
| 161 | /* | 160 | /* |
| 162 | * Check to see if there are any existing persistent reservation | 161 | * Check to see if there are any existing persistent reservation |
| 163 | * APTPL pre-registrations that need to be enabled for this dynamic | 162 | * APTPL pre-registrations that need to be enabled for this dynamic |
| @@ -522,7 +521,7 @@ int core_tpg_register( | |||
| 522 | return PTR_ERR(se_tpg->tpg_virt_lun0); | 521 | return PTR_ERR(se_tpg->tpg_virt_lun0); |
| 523 | 522 | ||
| 524 | ret = core_tpg_add_lun(se_tpg, se_tpg->tpg_virt_lun0, | 523 | ret = core_tpg_add_lun(se_tpg, se_tpg->tpg_virt_lun0, |
| 525 | TRANSPORT_LUNFLAGS_READ_ONLY, g_lun0_dev); | 524 | true, g_lun0_dev); |
| 526 | if (ret < 0) { | 525 | if (ret < 0) { |
| 527 | kfree(se_tpg->tpg_virt_lun0); | 526 | kfree(se_tpg->tpg_virt_lun0); |
| 528 | return ret; | 527 | return ret; |
| @@ -616,7 +615,7 @@ struct se_lun *core_tpg_alloc_lun( | |||
| 616 | int core_tpg_add_lun( | 615 | int core_tpg_add_lun( |
| 617 | struct se_portal_group *tpg, | 616 | struct se_portal_group *tpg, |
| 618 | struct se_lun *lun, | 617 | struct se_lun *lun, |
| 619 | u32 lun_access, | 618 | bool lun_access_ro, |
| 620 | struct se_device *dev) | 619 | struct se_device *dev) |
| 621 | { | 620 | { |
| 622 | int ret; | 621 | int ret; |
| @@ -644,9 +643,9 @@ int core_tpg_add_lun( | |||
| 644 | spin_unlock(&dev->se_port_lock); | 643 | spin_unlock(&dev->se_port_lock); |
| 645 | 644 | ||
| 646 | if (dev->dev_flags & DF_READ_ONLY) | 645 | if (dev->dev_flags & DF_READ_ONLY) |
| 647 | lun->lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; | 646 | lun->lun_access_ro = true; |
| 648 | else | 647 | else |
| 649 | lun->lun_access = lun_access; | 648 | lun->lun_access_ro = lun_access_ro; |
| 650 | if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) | 649 | if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) |
| 651 | hlist_add_head_rcu(&lun->link, &tpg->tpg_lun_hlist); | 650 | hlist_add_head_rcu(&lun->link, &tpg->tpg_lun_hlist); |
| 652 | mutex_unlock(&tpg->tpg_lun_mutex); | 651 | mutex_unlock(&tpg->tpg_lun_mutex); |
