diff options
author | Nicholas Bellinger <nab@daterainc.com> | 2013-08-17 17:27:56 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-09-09 17:29:21 -0400 |
commit | d703ce2f7f4de20c03d71c22a9d5e3708798047b (patch) | |
tree | f06be5be02dc43ae0a7c34eacd986238005a003b /drivers/target | |
parent | 3aee26b4ae91048c933dc622f00b7bb01f7f0ff1 (diff) |
iscsi/iser-target: Convert to command priv_size usage
This command converts iscsi/isert-target to use allocations based on
iscsit_transport->priv_size within iscsit_allocate_cmd(), instead of
using an embedded isert_cmd->iscsi_cmd.
This includes removing iscsit_transport->alloc_cmd() usage, along
with updating isert-target code to use iscsit_priv_cmd().
Also, remove left-over iscsit_transport->release_cmd() usage for
direct calls to iscsit_release_cmd(), and drop the now unused
lio_cmd_cache and isert_cmd_cache.
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Cc: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Nicholas Bellinger <nab@daterainc.com>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 16 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target.h | 1 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 2 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_core.h | 1 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_util.c | 20 |
5 files changed, 7 insertions, 33 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 1dff3e01f92c..da6bbfe4f26d 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -63,7 +63,6 @@ spinlock_t sess_idr_lock; | |||
63 | 63 | ||
64 | struct iscsit_global *iscsit_global; | 64 | struct iscsit_global *iscsit_global; |
65 | 65 | ||
66 | struct kmem_cache *lio_cmd_cache; | ||
67 | struct kmem_cache *lio_qr_cache; | 66 | struct kmem_cache *lio_qr_cache; |
68 | struct kmem_cache *lio_dr_cache; | 67 | struct kmem_cache *lio_dr_cache; |
69 | struct kmem_cache *lio_ooo_cache; | 68 | struct kmem_cache *lio_ooo_cache; |
@@ -500,7 +499,6 @@ static struct iscsit_transport iscsi_target_transport = { | |||
500 | .iscsit_setup_np = iscsit_setup_np, | 499 | .iscsit_setup_np = iscsit_setup_np, |
501 | .iscsit_accept_np = iscsit_accept_np, | 500 | .iscsit_accept_np = iscsit_accept_np, |
502 | .iscsit_free_np = iscsit_free_np, | 501 | .iscsit_free_np = iscsit_free_np, |
503 | .iscsit_alloc_cmd = iscsit_alloc_cmd, | ||
504 | .iscsit_get_login_rx = iscsit_get_login_rx, | 502 | .iscsit_get_login_rx = iscsit_get_login_rx, |
505 | .iscsit_put_login_tx = iscsit_put_login_tx, | 503 | .iscsit_put_login_tx = iscsit_put_login_tx, |
506 | .iscsit_get_dataout = iscsit_build_r2ts_for_cmd, | 504 | .iscsit_get_dataout = iscsit_build_r2ts_for_cmd, |
@@ -541,22 +539,13 @@ static int __init iscsi_target_init_module(void) | |||
541 | goto ts_out1; | 539 | goto ts_out1; |
542 | } | 540 | } |
543 | 541 | ||
544 | lio_cmd_cache = kmem_cache_create("lio_cmd_cache", | ||
545 | sizeof(struct iscsi_cmd), __alignof__(struct iscsi_cmd), | ||
546 | 0, NULL); | ||
547 | if (!lio_cmd_cache) { | ||
548 | pr_err("Unable to kmem_cache_create() for" | ||
549 | " lio_cmd_cache\n"); | ||
550 | goto ts_out2; | ||
551 | } | ||
552 | |||
553 | lio_qr_cache = kmem_cache_create("lio_qr_cache", | 542 | lio_qr_cache = kmem_cache_create("lio_qr_cache", |
554 | sizeof(struct iscsi_queue_req), | 543 | sizeof(struct iscsi_queue_req), |
555 | __alignof__(struct iscsi_queue_req), 0, NULL); | 544 | __alignof__(struct iscsi_queue_req), 0, NULL); |
556 | if (!lio_qr_cache) { | 545 | if (!lio_qr_cache) { |
557 | pr_err("nable to kmem_cache_create() for" | 546 | pr_err("nable to kmem_cache_create() for" |
558 | " lio_qr_cache\n"); | 547 | " lio_qr_cache\n"); |
559 | goto cmd_out; | 548 | goto ts_out2; |
560 | } | 549 | } |
561 | 550 | ||
562 | lio_dr_cache = kmem_cache_create("lio_dr_cache", | 551 | lio_dr_cache = kmem_cache_create("lio_dr_cache", |
@@ -600,8 +589,6 @@ dr_out: | |||
600 | kmem_cache_destroy(lio_dr_cache); | 589 | kmem_cache_destroy(lio_dr_cache); |
601 | qr_out: | 590 | qr_out: |
602 | kmem_cache_destroy(lio_qr_cache); | 591 | kmem_cache_destroy(lio_qr_cache); |
603 | cmd_out: | ||
604 | kmem_cache_destroy(lio_cmd_cache); | ||
605 | ts_out2: | 592 | ts_out2: |
606 | iscsi_deallocate_thread_sets(); | 593 | iscsi_deallocate_thread_sets(); |
607 | ts_out1: | 594 | ts_out1: |
@@ -619,7 +606,6 @@ static void __exit iscsi_target_cleanup_module(void) | |||
619 | iscsi_thread_set_free(); | 606 | iscsi_thread_set_free(); |
620 | iscsit_release_discovery_tpg(); | 607 | iscsit_release_discovery_tpg(); |
621 | iscsit_unregister_transport(&iscsi_target_transport); | 608 | iscsit_unregister_transport(&iscsi_target_transport); |
622 | kmem_cache_destroy(lio_cmd_cache); | ||
623 | kmem_cache_destroy(lio_qr_cache); | 609 | kmem_cache_destroy(lio_qr_cache); |
624 | kmem_cache_destroy(lio_dr_cache); | 610 | kmem_cache_destroy(lio_dr_cache); |
625 | kmem_cache_destroy(lio_ooo_cache); | 611 | kmem_cache_destroy(lio_ooo_cache); |
diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index f82f6273526e..e936d56fb523 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h | |||
@@ -39,7 +39,6 @@ extern struct target_fabric_configfs *lio_target_fabric_configfs; | |||
39 | 39 | ||
40 | extern struct kmem_cache *lio_dr_cache; | 40 | extern struct kmem_cache *lio_dr_cache; |
41 | extern struct kmem_cache *lio_ooo_cache; | 41 | extern struct kmem_cache *lio_ooo_cache; |
42 | extern struct kmem_cache *lio_cmd_cache; | ||
43 | extern struct kmem_cache *lio_qr_cache; | 42 | extern struct kmem_cache *lio_qr_cache; |
44 | extern struct kmem_cache *lio_r2t_cache; | 43 | extern struct kmem_cache *lio_r2t_cache; |
45 | 44 | ||
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index ddfa32c3f564..116114ffaa8b 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -1925,7 +1925,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd) | |||
1925 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1925 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
1926 | 1926 | ||
1927 | pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); | 1927 | pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); |
1928 | cmd->release_cmd(cmd); | 1928 | iscsit_release_cmd(cmd); |
1929 | } | 1929 | } |
1930 | 1930 | ||
1931 | /* End functions for target_core_fabric_ops */ | 1931 | /* End functions for target_core_fabric_ops */ |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 089a0e915da8..129b7d77c7cb 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
@@ -489,7 +489,6 @@ struct iscsi_cmd { | |||
489 | u32 first_data_sg_off; | 489 | u32 first_data_sg_off; |
490 | u32 kmapped_nents; | 490 | u32 kmapped_nents; |
491 | sense_reason_t sense_reason; | 491 | sense_reason_t sense_reason; |
492 | void (*release_cmd)(struct iscsi_cmd *); | ||
493 | } ____cacheline_aligned; | 492 | } ____cacheline_aligned; |
494 | 493 | ||
495 | struct iscsi_tmr_req { | 494 | struct iscsi_tmr_req { |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 1df06d5e4e01..5784cad16be1 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -149,18 +149,6 @@ void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd) | |||
149 | spin_unlock_bh(&cmd->r2t_lock); | 149 | spin_unlock_bh(&cmd->r2t_lock); |
150 | } | 150 | } |
151 | 151 | ||
152 | struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) | ||
153 | { | ||
154 | struct iscsi_cmd *cmd; | ||
155 | |||
156 | cmd = kmem_cache_zalloc(lio_cmd_cache, gfp_mask); | ||
157 | if (!cmd) | ||
158 | return NULL; | ||
159 | |||
160 | cmd->release_cmd = &iscsit_release_cmd; | ||
161 | return cmd; | ||
162 | } | ||
163 | |||
164 | /* | 152 | /* |
165 | * May be called from software interrupt (timer) context for allocating | 153 | * May be called from software interrupt (timer) context for allocating |
166 | * iSCSI NopINs. | 154 | * iSCSI NopINs. |
@@ -168,8 +156,9 @@ struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) | |||
168 | struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) | 156 | struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask) |
169 | { | 157 | { |
170 | struct iscsi_cmd *cmd; | 158 | struct iscsi_cmd *cmd; |
159 | int priv_size = conn->conn_transport->priv_size; | ||
171 | 160 | ||
172 | cmd = conn->conn_transport->iscsit_alloc_cmd(conn, gfp_mask); | 161 | cmd = kzalloc(sizeof(struct iscsi_cmd) + priv_size, gfp_mask); |
173 | if (!cmd) { | 162 | if (!cmd) { |
174 | pr_err("Unable to allocate memory for struct iscsi_cmd.\n"); | 163 | pr_err("Unable to allocate memory for struct iscsi_cmd.\n"); |
175 | return NULL; | 164 | return NULL; |
@@ -696,8 +685,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) | |||
696 | kfree(cmd->iov_data); | 685 | kfree(cmd->iov_data); |
697 | kfree(cmd->text_in_ptr); | 686 | kfree(cmd->text_in_ptr); |
698 | 687 | ||
699 | kmem_cache_free(lio_cmd_cache, cmd); | 688 | kfree(cmd); |
700 | } | 689 | } |
690 | EXPORT_SYMBOL(iscsit_release_cmd); | ||
701 | 691 | ||
702 | static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, | 692 | static void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, |
703 | bool check_queues) | 693 | bool check_queues) |
@@ -761,7 +751,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) | |||
761 | /* Fall-through */ | 751 | /* Fall-through */ |
762 | default: | 752 | default: |
763 | __iscsit_free_cmd(cmd, false, shutdown); | 753 | __iscsit_free_cmd(cmd, false, shutdown); |
764 | cmd->release_cmd(cmd); | 754 | iscsit_release_cmd(cmd); |
765 | break; | 755 | break; |
766 | } | 756 | } |
767 | } | 757 | } |