mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 15:31:14 +07:00
target: Fall back to vzalloc upon ->sess_cmd_map kzalloc failure
This patch changes transport_alloc_session_tags() to fall back to use vzalloc when kzalloc fails for big tag_num that end up generating larger order allocations. Also use is_vmalloc_addr() in transport_alloc_session_tags() failure path, and normal transport_free_session() path to determine when vfree() needs to be called instead of kfree(). v2 changes: - Use __GFP_NOWARN | __GFP_REPEAT for sess_cmd_map kzalloc (mst) Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Asias He <asias@redhat.com> Cc: Kent Overstreet <kmo@daterainc.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
4a47d3a1ff
commit
8c7f6e9b33
@ -236,17 +236,24 @@ int transport_alloc_session_tags(struct se_session *se_sess,
|
||||
{
|
||||
int rc;
|
||||
|
||||
se_sess->sess_cmd_map = kzalloc(tag_num * tag_size, GFP_KERNEL);
|
||||
se_sess->sess_cmd_map = kzalloc(tag_num * tag_size,
|
||||
GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
|
||||
if (!se_sess->sess_cmd_map) {
|
||||
pr_err("Unable to allocate se_sess->sess_cmd_map\n");
|
||||
return -ENOMEM;
|
||||
se_sess->sess_cmd_map = vzalloc(tag_num * tag_size);
|
||||
if (!se_sess->sess_cmd_map) {
|
||||
pr_err("Unable to allocate se_sess->sess_cmd_map\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
rc = percpu_ida_init(&se_sess->sess_tag_pool, tag_num);
|
||||
if (rc < 0) {
|
||||
pr_err("Unable to init se_sess->sess_tag_pool,"
|
||||
" tag_num: %u\n", tag_num);
|
||||
kfree(se_sess->sess_cmd_map);
|
||||
if (is_vmalloc_addr(se_sess->sess_cmd_map))
|
||||
vfree(se_sess->sess_cmd_map);
|
||||
else
|
||||
kfree(se_sess->sess_cmd_map);
|
||||
se_sess->sess_cmd_map = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -412,7 +419,10 @@ void transport_free_session(struct se_session *se_sess)
|
||||
{
|
||||
if (se_sess->sess_cmd_map) {
|
||||
percpu_ida_destroy(&se_sess->sess_tag_pool);
|
||||
kfree(se_sess->sess_cmd_map);
|
||||
if (is_vmalloc_addr(se_sess->sess_cmd_map))
|
||||
vfree(se_sess->sess_cmd_map);
|
||||
else
|
||||
kfree(se_sess->sess_cmd_map);
|
||||
}
|
||||
kmem_cache_free(se_sess_cache, se_sess);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user