Skip to content

Commit ee74462

Browse files
Christof SchmittJames Bottomley
authored andcommitted
[SCSI] zfcp: Improve ELS ADISC handling
Introduce kmem_cache for ELS ADISC data to guarantee the required hardware alignment and free the allocated memory in case the send failes. Reviewed-by: Swen Schillig <[email protected]> Signed-off-by: Christof Schmitt <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 7c7dc19 commit ee74462

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

drivers/s390/scsi/zfcp_aux.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ static int __init zfcp_module_init(void)
179179
if (!zfcp_data.gid_pn_cache)
180180
goto out_gid_cache;
181181

182+
zfcp_data.adisc_cache = zfcp_cache_hw_align("zfcp_adisc",
183+
sizeof(struct zfcp_fc_els_adisc));
184+
if (!zfcp_data.adisc_cache)
185+
goto out_adisc_cache;
186+
182187
zfcp_data.scsi_transport_template =
183188
fc_attach_transport(&zfcp_transport_functions);
184189
if (!zfcp_data.scsi_transport_template)
@@ -206,6 +211,8 @@ static int __init zfcp_module_init(void)
206211
out_misc:
207212
fc_release_transport(zfcp_data.scsi_transport_template);
208213
out_transport:
214+
kmem_cache_destroy(zfcp_data.adisc_cache);
215+
out_adisc_cache:
209216
kmem_cache_destroy(zfcp_data.gid_pn_cache);
210217
out_gid_cache:
211218
kmem_cache_destroy(zfcp_data.sr_buffer_cache);
@@ -224,6 +231,7 @@ static void __exit zfcp_module_exit(void)
224231
ccw_driver_unregister(&zfcp_ccw_driver);
225232
misc_deregister(&zfcp_cfdc_misc);
226233
fc_release_transport(zfcp_data.scsi_transport_template);
234+
kmem_cache_destroy(zfcp_data.adisc_cache);
227235
kmem_cache_destroy(zfcp_data.gid_pn_cache);
228236
kmem_cache_destroy(zfcp_data.sr_buffer_cache);
229237
kmem_cache_destroy(zfcp_data.qtcb_cache);

drivers/s390/scsi/zfcp_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ struct zfcp_data {
347347
struct kmem_cache *qtcb_cache;
348348
struct kmem_cache *sr_buffer_cache;
349349
struct kmem_cache *gid_pn_cache;
350+
struct kmem_cache *adisc_cache;
350351
};
351352

352353
/********************** ZFCP SPECIFIC DEFINES ********************************/

drivers/s390/scsi/zfcp_fc.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,16 @@ static void zfcp_fc_adisc_handler(void *data)
389389
out:
390390
atomic_clear_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status);
391391
put_device(&port->sysfs_device);
392-
kfree(adisc);
392+
kmem_cache_free(zfcp_data.adisc_cache, adisc);
393393
}
394394

395395
static int zfcp_fc_adisc(struct zfcp_port *port)
396396
{
397397
struct zfcp_fc_els_adisc *adisc;
398398
struct zfcp_adapter *adapter = port->adapter;
399+
int ret;
399400

400-
adisc = kzalloc(sizeof(struct zfcp_fc_els_adisc), GFP_ATOMIC);
401+
adisc = kmem_cache_alloc(zfcp_data.adisc_cache, GFP_ATOMIC);
401402
if (!adisc)
402403
return -ENOMEM;
403404

@@ -420,7 +421,11 @@ static int zfcp_fc_adisc(struct zfcp_port *port)
420421
hton24(adisc->adisc_req.adisc_port_id,
421422
fc_host_port_id(adapter->scsi_host));
422423

423-
return zfcp_fsf_send_els(adapter, port->d_id, &adisc->els);
424+
ret = zfcp_fsf_send_els(adapter, port->d_id, &adisc->els);
425+
if (ret)
426+
kmem_cache_free(zfcp_data.adisc_cache, adisc);
427+
428+
return ret;
424429
}
425430

426431
void zfcp_fc_link_test_work(struct work_struct *work)

0 commit comments

Comments
 (0)