summaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_transport.c
diff options
context:
space:
mode:
authorroland@purestorage.com2012-01-05 00:59:58 +0100
committerNicholas Bellinger2012-01-18 09:29:57 +0100
commit9db9da332250dbe662995703a4dcdd692112f0c3 (patch)
treebec92f208f928e41e84cc03ff9687e35eda6a062 /drivers/target/target_core_transport.c
parenttarget: Allow PERSISTENT RESERVE IN for non-reservation holder (diff)
downloadkernel-qcow2-linux-9db9da332250dbe662995703a4dcdd692112f0c3.tar.gz
kernel-qcow2-linux-9db9da332250dbe662995703a4dcdd692112f0c3.tar.xz
kernel-qcow2-linux-9db9da332250dbe662995703a4dcdd692112f0c3.zip
target: Don't zero pages used for data buffers
Doing alloc_page(GFP_KERNEL | __GFP_ZERO) to get pages used for data buffers wastes a lot of CPU clearing pages that will be quickly be overwritten by the actual data. However, for emulated control commands such as INQUIRY and so on, the code does assume that the buffer is zeroed. To avoid this CPU overhead, skip the __GFP_ZERO for commands that are actually moving data, ie cmds that have SCF_SCSI_DATA_SG_IO_CDB set. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_transport.c')
-rw-r--r--drivers/target/target_core_transport.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index d3ddd1361949..289bc0f125f9 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -3516,6 +3516,7 @@ transport_generic_get_mem(struct se_cmd *cmd)
u32 length = cmd->data_length;
unsigned int nents;
struct page *page;
+ gfp_t zero_flag;
int i = 0;
nents = DIV_ROUND_UP(length, PAGE_SIZE);
@@ -3526,9 +3527,11 @@ transport_generic_get_mem(struct se_cmd *cmd)
cmd->t_data_nents = nents;
sg_init_table(cmd->t_data_sg, nents);
+ zero_flag = cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB ? 0 : __GFP_ZERO;
+
while (length) {
u32 page_len = min_t(u32, length, PAGE_SIZE);
- page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+ page = alloc_page(GFP_KERNEL | zero_flag);
if (!page)
goto out;