diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-12-05 12:08:29 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-06-11 12:04:21 -0700 |
commit | 82b9ccd651eb90f28b4336554d82ea0ab9067c63 (patch) | |
tree | 297a05c4eaff132a27645ef59f35f9736321fdb7 /drivers | |
parent | 2b102fcef6a89e1bc0b7116125a82b3b03d57d89 (diff) |
target/file: Fix 32-bit highmem breakage for SGL -> iovec mapping
commit 40ff2c3b3da35dd3a00ac6722056a59b4b3f2caf upstream.
This patch changes vectored file I/O to use kmap + kunmap when mapping
incoming SGL memory -> struct iovec in order to properly support 32-bit
highmem configurations. This is because an extra bounce buffer may be
required when processing scatterlist pages allocated with GFP_KERNEL.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
[bwh: Backported to 3.2: use task->task_sg{,_nents} for iteration]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Rui Xiang <rui.xiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/target/target_core_file.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index a251efd783d..f44459a2a7c 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -299,7 +299,7 @@ static int fd_do_readv(struct se_task *task) for_each_sg(task->task_sg, sg, task->task_sg_nents, i) { iov[i].iov_len = sg->length; - iov[i].iov_base = sg_virt(sg); + iov[i].iov_base = kmap(sg_page(sg)) + sg->offset; } old_fs = get_fs(); @@ -307,6 +307,8 @@ static int fd_do_readv(struct se_task *task) ret = vfs_readv(fd, &iov[0], task->task_sg_nents, &pos); set_fs(old_fs); + for_each_sg(task->task_sg, sg, task->task_sg_nents, i) + kunmap(sg_page(sg)); kfree(iov); /* * Return zeros and GOOD status even if the READ did not return @@ -352,7 +354,7 @@ static int fd_do_writev(struct se_task *task) for_each_sg(task->task_sg, sg, task->task_sg_nents, i) { iov[i].iov_len = sg->length; - iov[i].iov_base = sg_virt(sg); + iov[i].iov_base = kmap(sg_page(sg)) + sg->offset; } old_fs = get_fs(); @@ -360,6 +362,9 @@ static int fd_do_writev(struct se_task *task) ret = vfs_writev(fd, &iov[0], task->task_sg_nents, &pos); set_fs(old_fs); + for_each_sg(task->task_sg, sg, task->task_sg_nents, i) + kunmap(sg_page(sg)); + kfree(iov); if (ret < 0 || ret != task->task_size) { |