Commit f9773229 authored by Christof Schmitt's avatar Christof Schmitt Committed by James Bottomley

[SCSI] zfcp: Use common FC kmem_cache for GPN_FT request

Switch the allocation of the GPN_FT request data to the FC kmem_cache
and remove the zfcp_gpn kmem_cache.
Signed-off-by: default avatarChristof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: default avatarSteffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent fcf7e614
...@@ -122,11 +122,6 @@ static int __init zfcp_module_init(void) ...@@ -122,11 +122,6 @@ static int __init zfcp_module_init(void)
{ {
int retval = -ENOMEM; int retval = -ENOMEM;
zfcp_data.gpn_ft_cache = zfcp_cache_hw_align("zfcp_gpn",
sizeof(struct zfcp_fc_gpn_ft_req));
if (!zfcp_data.gpn_ft_cache)
goto out;
zfcp_data.qtcb_cache = zfcp_cache_hw_align("zfcp_qtcb", zfcp_data.qtcb_cache = zfcp_cache_hw_align("zfcp_qtcb",
sizeof(struct fsf_qtcb)); sizeof(struct fsf_qtcb));
if (!zfcp_data.qtcb_cache) if (!zfcp_data.qtcb_cache)
...@@ -171,8 +166,6 @@ static int __init zfcp_module_init(void) ...@@ -171,8 +166,6 @@ static int __init zfcp_module_init(void)
out_fc_cache: out_fc_cache:
kmem_cache_destroy(zfcp_data.qtcb_cache); kmem_cache_destroy(zfcp_data.qtcb_cache);
out_qtcb_cache: out_qtcb_cache:
kmem_cache_destroy(zfcp_data.gpn_ft_cache);
out:
return retval; return retval;
} }
...@@ -185,7 +178,6 @@ static void __exit zfcp_module_exit(void) ...@@ -185,7 +178,6 @@ static void __exit zfcp_module_exit(void)
fc_release_transport(zfcp_data.scsi_transport_template); fc_release_transport(zfcp_data.scsi_transport_template);
kmem_cache_destroy(zfcp_fc_req_cache); kmem_cache_destroy(zfcp_fc_req_cache);
kmem_cache_destroy(zfcp_data.qtcb_cache); kmem_cache_destroy(zfcp_data.qtcb_cache);
kmem_cache_destroy(zfcp_data.gpn_ft_cache);
} }
module_exit(zfcp_module_exit); module_exit(zfcp_module_exit);
......
...@@ -317,7 +317,6 @@ struct zfcp_fsf_req { ...@@ -317,7 +317,6 @@ struct zfcp_fsf_req {
struct zfcp_data { struct zfcp_data {
struct scsi_host_template scsi_host_template; struct scsi_host_template scsi_host_template;
struct scsi_transport_template *scsi_transport_template; struct scsi_transport_template *scsi_transport_template;
struct kmem_cache *gpn_ft_cache;
struct kmem_cache *qtcb_cache; struct kmem_cache *qtcb_cache;
}; };
......
...@@ -528,68 +528,42 @@ void zfcp_fc_test_link(struct zfcp_port *port) ...@@ -528,68 +528,42 @@ void zfcp_fc_test_link(struct zfcp_port *port)
put_device(&port->dev); put_device(&port->dev);
} }
static void zfcp_free_sg_env(struct zfcp_fc_gpn_ft *gpn_ft, int buf_num) static struct zfcp_fc_req *zfcp_alloc_sg_env(int buf_num)
{ {
struct scatterlist *sg = &gpn_ft->sg_req; struct zfcp_fc_req *fc_req;
kmem_cache_free(zfcp_data.gpn_ft_cache, sg_virt(sg));
zfcp_sg_free_table(gpn_ft->sg_resp, buf_num);
kfree(gpn_ft);
}
static struct zfcp_fc_gpn_ft *zfcp_alloc_sg_env(int buf_num)
{
struct zfcp_fc_gpn_ft *gpn_ft;
struct zfcp_fc_gpn_ft_req *req;
gpn_ft = kzalloc(sizeof(*gpn_ft), GFP_KERNEL); fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_KERNEL);
if (!gpn_ft) if (!fc_req)
return NULL; return NULL;
req = kmem_cache_zalloc(zfcp_data.gpn_ft_cache, GFP_KERNEL); if (zfcp_sg_setup_table(&fc_req->sg_rsp, buf_num)) {
if (!req) { kmem_cache_free(zfcp_fc_req_cache, fc_req);
kfree(gpn_ft); return NULL;
gpn_ft = NULL;
goto out;
} }
sg_init_one(&gpn_ft->sg_req, req, sizeof(*req));
if (zfcp_sg_setup_table(gpn_ft->sg_resp, buf_num)) { sg_init_one(&fc_req->sg_req, &fc_req->u.gpn_ft.req,
zfcp_free_sg_env(gpn_ft, buf_num); sizeof(struct zfcp_fc_gpn_ft_req));
gpn_ft = NULL;
}
out:
return gpn_ft;
}
return fc_req;
}
static int zfcp_fc_send_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, static int zfcp_fc_send_gpn_ft(struct zfcp_fc_req *fc_req,
struct zfcp_adapter *adapter, int max_bytes) struct zfcp_adapter *adapter, int max_bytes)
{ {
struct zfcp_fsf_ct_els *ct = &gpn_ft->ct; struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els;
struct zfcp_fc_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req); struct zfcp_fc_gpn_ft_req *req = &fc_req->u.gpn_ft.req;
DECLARE_COMPLETION_ONSTACK(completion); DECLARE_COMPLETION_ONSTACK(completion);
int ret; int ret;
/* prepare CT IU for GPN_FT */ zfcp_fc_ct_ns_init(&req->ct_hdr, FC_NS_GPN_FT, max_bytes);
req->ct_hdr.ct_rev = FC_CT_REV;
req->ct_hdr.ct_fs_type = FC_FST_DIR;
req->ct_hdr.ct_fs_subtype = FC_NS_SUBTYPE;
req->ct_hdr.ct_options = 0;
req->ct_hdr.ct_cmd = FC_NS_GPN_FT;
req->ct_hdr.ct_mr_size = max_bytes / 4;
req->gpn_ft.fn_domain_id_scope = 0;
req->gpn_ft.fn_area_id_scope = 0;
req->gpn_ft.fn_fc4_type = FC_TYPE_FCP; req->gpn_ft.fn_fc4_type = FC_TYPE_FCP;
/* prepare zfcp_send_ct */ ct_els->handler = zfcp_fc_complete;
ct->handler = zfcp_fc_complete; ct_els->handler_data = &completion;
ct->handler_data = &completion; ct_els->req = &fc_req->sg_req;
ct->req = &gpn_ft->sg_req; ct_els->resp = &fc_req->sg_rsp;
ct->resp = gpn_ft->sg_resp;
ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct, NULL, ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL,
ZFCP_FC_CTELS_TMO); ZFCP_FC_CTELS_TMO);
if (!ret) if (!ret)
wait_for_completion(&completion); wait_for_completion(&completion);
...@@ -610,11 +584,11 @@ static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh) ...@@ -610,11 +584,11 @@ static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh)
list_move_tail(&port->list, lh); list_move_tail(&port->list, lh);
} }
static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_req *fc_req,
struct zfcp_adapter *adapter, int max_entries) struct zfcp_adapter *adapter, int max_entries)
{ {
struct zfcp_fsf_ct_els *ct = &gpn_ft->ct; struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els;
struct scatterlist *sg = gpn_ft->sg_resp; struct scatterlist *sg = &fc_req->sg_rsp;
struct fc_ct_hdr *hdr = sg_virt(sg); struct fc_ct_hdr *hdr = sg_virt(sg);
struct fc_gpn_ft_resp *acc = sg_virt(sg); struct fc_gpn_ft_resp *acc = sg_virt(sg);
struct zfcp_port *port, *tmp; struct zfcp_port *port, *tmp;
...@@ -623,7 +597,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, ...@@ -623,7 +597,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft,
u32 d_id; u32 d_id;
int ret = 0, x, last = 0; int ret = 0, x, last = 0;
if (ct->status) if (ct_els->status)
return -EIO; return -EIO;
if (hdr->ct_cmd != FC_FS_ACC) { if (hdr->ct_cmd != FC_FS_ACC) {
...@@ -687,7 +661,7 @@ void zfcp_fc_scan_ports(struct work_struct *work) ...@@ -687,7 +661,7 @@ void zfcp_fc_scan_ports(struct work_struct *work)
struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter,
scan_work); scan_work);
int ret, i; int ret, i;
struct zfcp_fc_gpn_ft *gpn_ft; struct zfcp_fc_req *fc_req;
int chain, max_entries, buf_num, max_bytes; int chain, max_entries, buf_num, max_bytes;
chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS;
...@@ -702,21 +676,22 @@ void zfcp_fc_scan_ports(struct work_struct *work) ...@@ -702,21 +676,22 @@ void zfcp_fc_scan_ports(struct work_struct *work)
if (zfcp_fc_wka_port_get(&adapter->gs->ds)) if (zfcp_fc_wka_port_get(&adapter->gs->ds))
return; return;
gpn_ft = zfcp_alloc_sg_env(buf_num); fc_req = zfcp_alloc_sg_env(buf_num);
if (!gpn_ft) if (!fc_req)
goto out; goto out;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
ret = zfcp_fc_send_gpn_ft(gpn_ft, adapter, max_bytes); ret = zfcp_fc_send_gpn_ft(fc_req, adapter, max_bytes);
if (!ret) { if (!ret) {
ret = zfcp_fc_eval_gpn_ft(gpn_ft, adapter, max_entries); ret = zfcp_fc_eval_gpn_ft(fc_req, adapter, max_entries);
if (ret == -EAGAIN) if (ret == -EAGAIN)
ssleep(1); ssleep(1);
else else
break; break;
} }
} }
zfcp_free_sg_env(gpn_ft, buf_num); zfcp_sg_free_table(&fc_req->sg_rsp, buf_num);
kmem_cache_free(zfcp_fc_req_cache, fc_req);
out: out:
zfcp_fc_wka_port_put(&adapter->gs->ds); zfcp_fc_wka_port_put(&adapter->gs->ds);
} }
......
...@@ -83,28 +83,6 @@ struct zfcp_fc_gpn_ft_req { ...@@ -83,28 +83,6 @@ struct zfcp_fc_gpn_ft_req {
struct fc_ns_gid_ft gpn_ft; struct fc_ns_gid_ft gpn_ft;
} __packed; } __packed;
/**
* struct zfcp_fc_gpn_ft_resp - container for ct header plus gpn_ft response
* @ct_hdr: FC GS common transport header
* @gpn_ft: Array of gpn_ft response data to fill one memory page
*/
struct zfcp_fc_gpn_ft_resp {
struct fc_ct_hdr ct_hdr;
struct fc_gpn_ft_resp gpn_ft[ZFCP_FC_GPN_FT_ENT_PAGE];
} __packed;
/**
* struct zfcp_fc_gpn_ft - zfcp data for gpn_ft request
* @ct: data passed to zfcp_fsf for issuing fsf request
* @sg_req: scatter list entry for gpn_ft request
* @sg_resp: scatter list entries for gpn_ft responses (per memory page)
*/
struct zfcp_fc_gpn_ft {
struct zfcp_fsf_ct_els ct;
struct scatterlist sg_req;
struct scatterlist sg_resp[ZFCP_FC_GPN_FT_NUM_BUFS];
};
/** /**
* struct zfcp_fc_req - Container for FC ELS and CT requests sent from zfcp * struct zfcp_fc_req - Container for FC ELS and CT requests sent from zfcp
* @ct_els: data required for issuing fsf command * @ct_els: data required for issuing fsf command
...@@ -125,6 +103,10 @@ struct zfcp_fc_req { ...@@ -125,6 +103,10 @@ struct zfcp_fc_req {
struct zfcp_fc_gid_pn_req req; struct zfcp_fc_gid_pn_req req;
struct zfcp_fc_gid_pn_rsp rsp; struct zfcp_fc_gid_pn_rsp rsp;
} gid_pn; } gid_pn;
struct {
struct scatterlist sg_rsp2[ZFCP_FC_GPN_FT_NUM_BUFS - 1];
struct zfcp_fc_gpn_ft_req req;
} gpn_ft;
} u; } u;
}; };
......
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