提交 40ff2c3b 编写于 作者: S Sebastian Andrzej Siewior 提交者: Nicholas Bellinger

target/file: Fix 32-bit highmem breakage for SGL -> iovec mapping

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: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 0ff87549
......@@ -236,7 +236,7 @@ static int fd_do_readv(struct se_cmd *cmd, struct scatterlist *sgl,
for_each_sg(sgl, sg, sgl_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();
......@@ -244,6 +244,8 @@ static int fd_do_readv(struct se_cmd *cmd, struct scatterlist *sgl,
ret = vfs_readv(fd, &iov[0], sgl_nents, &pos);
set_fs(old_fs);
for_each_sg(sgl, sg, sgl_nents, i)
kunmap(sg_page(sg));
kfree(iov);
/*
* Return zeros and GOOD status even if the READ did not return
......@@ -288,7 +290,7 @@ static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl,
for_each_sg(sgl, sg, sgl_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();
......@@ -296,6 +298,9 @@ static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl,
ret = vfs_writev(fd, &iov[0], sgl_nents, &pos);
set_fs(old_fs);
for_each_sg(sgl, sg, sgl_nents, i)
kunmap(sg_page(sg));
kfree(iov);
if (ret < 0 || ret != cmd->data_length) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册