diff options
| author | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-03-22 23:42:19 -0400 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-06-01 03:23:46 -0400 |
| commit | 29a05deebf6c2e3010934fb78ee65cab3d329470 (patch) | |
| tree | 5b91d971e31c45919ef212513104350877807c3c /include/target | |
| parent | d2c27f0d0b7eb18f40b9b1a0d793c8ba074e5c23 (diff) | |
target: Convert se_node_acl->device_list[] to RCU hlist
This patch converts se_node_acl->device_list[] table for mappedluns
to modern RCU hlist_head usage in order to support an arbitrary number
of node_acl lun mappings.
It converts transport_lookup_*_lun() fast-path code to use RCU read path
primitives when looking up se_dev_entry. It adds a new hlist_head at
se_node_acl->lun_entry_hlist for this purpose.
For transport_lookup_cmd_lun() code, it works with existing per-cpu
se_lun->lun_ref when associating se_cmd with se_lun + se_device.
Also, go ahead and update core_create_device_list_for_node() +
core_free_device_list_for_node() to use ->lun_entry_hlist.
It also converts se_dev_entry->pr_ref_count access to use modern
struct kref counting, and updates core_disable_device_list_for_node()
to kref_put() and block on se_deve->pr_comp waiting for outstanding PR
special-case PR references to drop, then invoke kfree_rcu() to wait
for the RCU grace period to complete before releasing memory.
So now that se_node_acl->lun_entry_hlist fast path access uses RCU
protected pointers, go ahead and convert remaining non-fast path
RCU updater code using ->lun_entry_lock to struct mutex to allow
callers to block while walking se_node_acl->lun_entry_hlist.
Finally drop the left-over core_clear_initiator_node_from_tpg() that
originally cleared lun_access during se_node_acl shutdown, as post
RCU conversion it now becomes duplicated logic.
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'include/target')
| -rw-r--r-- | include/target/target_core_backend.h | 2 | ||||
| -rw-r--r-- | include/target/target_core_base.h | 27 |
2 files changed, 16 insertions, 13 deletions
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 47fafec556f8..80d9e486e33e 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h | |||
| @@ -101,7 +101,7 @@ int target_alloc_sgl(struct scatterlist **, unsigned int *, u32, bool); | |||
| 101 | sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *, | 101 | sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *, |
| 102 | struct scatterlist *, u32, struct scatterlist *, u32); | 102 | struct scatterlist *, u32, struct scatterlist *, u32); |
| 103 | 103 | ||
| 104 | void array_free(void *array, int n); | 104 | bool target_lun_is_rdonly(struct se_cmd *); |
| 105 | 105 | ||
| 106 | /* From target_core_configfs.c to setup default backend config_item_types */ | 106 | /* From target_core_configfs.c to setup default backend config_item_types */ |
| 107 | void target_core_setup_sub_cits(struct se_subsystem_api *); | 107 | void target_core_setup_sub_cits(struct se_subsystem_api *); |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 042a73464966..b518523cba7b 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
| @@ -160,10 +160,8 @@ enum se_cmd_flags_table { | |||
| 160 | 160 | ||
| 161 | /* struct se_dev_entry->lun_flags and struct se_lun->lun_access */ | 161 | /* struct se_dev_entry->lun_flags and struct se_lun->lun_access */ |
| 162 | enum transport_lunflags_table { | 162 | enum transport_lunflags_table { |
| 163 | TRANSPORT_LUNFLAGS_NO_ACCESS = 0x00, | 163 | TRANSPORT_LUNFLAGS_READ_ONLY = 0x01, |
| 164 | TRANSPORT_LUNFLAGS_INITIATOR_ACCESS = 0x01, | 164 | TRANSPORT_LUNFLAGS_READ_WRITE = 0x02, |
| 165 | TRANSPORT_LUNFLAGS_READ_ONLY = 0x02, | ||
| 166 | TRANSPORT_LUNFLAGS_READ_WRITE = 0x04, | ||
| 167 | }; | 165 | }; |
| 168 | 166 | ||
| 169 | /* | 167 | /* |
| @@ -584,10 +582,10 @@ struct se_node_acl { | |||
| 584 | char acl_tag[MAX_ACL_TAG_SIZE]; | 582 | char acl_tag[MAX_ACL_TAG_SIZE]; |
| 585 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ | 583 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ |
| 586 | atomic_t acl_pr_ref_count; | 584 | atomic_t acl_pr_ref_count; |
| 587 | struct se_dev_entry **device_list; | 585 | struct hlist_head lun_entry_hlist; |
| 588 | struct se_session *nacl_sess; | 586 | struct se_session *nacl_sess; |
| 589 | struct se_portal_group *se_tpg; | 587 | struct se_portal_group *se_tpg; |
| 590 | spinlock_t device_list_lock; | 588 | struct mutex lun_entry_mutex; |
| 591 | spinlock_t nacl_sess_lock; | 589 | spinlock_t nacl_sess_lock; |
| 592 | struct config_group acl_group; | 590 | struct config_group acl_group; |
| 593 | struct config_group acl_attrib_group; | 591 | struct config_group acl_attrib_group; |
| @@ -644,20 +642,23 @@ struct se_dev_entry { | |||
| 644 | /* See transport_lunflags_table */ | 642 | /* See transport_lunflags_table */ |
| 645 | u32 lun_flags; | 643 | u32 lun_flags; |
| 646 | u32 mapped_lun; | 644 | u32 mapped_lun; |
| 647 | u32 total_cmds; | ||
| 648 | u64 pr_res_key; | 645 | u64 pr_res_key; |
| 649 | u64 creation_time; | 646 | u64 creation_time; |
| 650 | u32 attach_count; | 647 | u32 attach_count; |
| 651 | u64 read_bytes; | 648 | atomic_long_t total_cmds; |
| 652 | u64 write_bytes; | 649 | atomic_long_t read_bytes; |
| 650 | atomic_long_t write_bytes; | ||
| 653 | atomic_t ua_count; | 651 | atomic_t ua_count; |
| 654 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ | 652 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ |
| 655 | atomic_t pr_ref_count; | 653 | struct kref pr_kref; |
| 656 | struct se_lun_acl *se_lun_acl; | 654 | struct completion pr_comp; |
| 655 | struct se_lun_acl __rcu *se_lun_acl; | ||
| 657 | spinlock_t ua_lock; | 656 | spinlock_t ua_lock; |
| 658 | struct se_lun *se_lun; | 657 | struct se_lun __rcu *se_lun; |
| 659 | struct list_head alua_port_list; | 658 | struct list_head alua_port_list; |
| 660 | struct list_head ua_list; | 659 | struct list_head ua_list; |
| 660 | struct hlist_node link; | ||
| 661 | struct rcu_head rcu_head; | ||
| 661 | }; | 662 | }; |
| 662 | 663 | ||
| 663 | struct se_dev_attrib { | 664 | struct se_dev_attrib { |
| @@ -703,6 +704,7 @@ struct se_port_stat_grps { | |||
| 703 | }; | 704 | }; |
| 704 | 705 | ||
| 705 | struct se_lun { | 706 | struct se_lun { |
| 707 | u16 lun_rtpi; | ||
| 706 | #define SE_LUN_LINK_MAGIC 0xffff7771 | 708 | #define SE_LUN_LINK_MAGIC 0xffff7771 |
| 707 | u32 lun_link_magic; | 709 | u32 lun_link_magic; |
| 708 | /* See transport_lun_status_table */ | 710 | /* See transport_lun_status_table */ |
| @@ -710,6 +712,7 @@ struct se_lun { | |||
| 710 | u32 lun_access; | 712 | u32 lun_access; |
| 711 | u32 lun_flags; | 713 | u32 lun_flags; |
| 712 | u32 unpacked_lun; | 714 | u32 unpacked_lun; |
| 715 | u32 lun_index; | ||
| 713 | atomic_t lun_acl_count; | 716 | atomic_t lun_acl_count; |
| 714 | spinlock_t lun_acl_lock; | 717 | spinlock_t lun_acl_lock; |
| 715 | spinlock_t lun_sep_lock; | 718 | spinlock_t lun_sep_lock; |
