Fix fd_do_rw error (rhbz 1218882)
This commit is contained in:
parent
3fb93d9892
commit
aee0909293
|
@ -0,0 +1,70 @@
|
|||
From 6b9a44d0939ca6235c72b811bd55b462d6a0a553 Mon Sep 17 00:00:00 2001
|
||||
From: Christoph Hellwig <hch@lst.de>
|
||||
Date: Sun, 22 Feb 2015 08:48:41 -0800
|
||||
Subject: [PATCH] target: use vfs_iter_read/write in fd_do_rw
|
||||
|
||||
Signed-off-by: Christoph Hellwig <hch@lst.de>
|
||||
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
|
||||
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
|
||||
---
|
||||
drivers/target/target_core_file.c | 31 ++++++++++++++-----------------
|
||||
1 file changed, 14 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
|
||||
index 44620fb..ea6e14e 100644
|
||||
--- a/drivers/target/target_core_file.c
|
||||
+++ b/drivers/target/target_core_file.c
|
||||
@@ -331,36 +331,33 @@ static int fd_do_rw(struct se_cmd *cmd, struct scatterlist *sgl,
|
||||
struct fd_dev *dev = FD_DEV(se_dev);
|
||||
struct file *fd = dev->fd_file;
|
||||
struct scatterlist *sg;
|
||||
- struct iovec *iov;
|
||||
- mm_segment_t old_fs;
|
||||
+ struct iov_iter iter;
|
||||
+ struct bio_vec *bvec;
|
||||
+ ssize_t len = 0;
|
||||
loff_t pos = (cmd->t_task_lba * se_dev->dev_attrib.block_size);
|
||||
int ret = 0, i;
|
||||
|
||||
- iov = kzalloc(sizeof(struct iovec) * sgl_nents, GFP_KERNEL);
|
||||
- if (!iov) {
|
||||
+ bvec = kcalloc(sgl_nents, sizeof(struct bio_vec), GFP_KERNEL);
|
||||
+ if (!bvec) {
|
||||
pr_err("Unable to allocate fd_do_readv iov[]\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for_each_sg(sgl, sg, sgl_nents, i) {
|
||||
- iov[i].iov_len = sg->length;
|
||||
- iov[i].iov_base = kmap(sg_page(sg)) + sg->offset;
|
||||
- }
|
||||
+ bvec[i].bv_page = sg_page(sg);
|
||||
+ bvec[i].bv_len = sg->length;
|
||||
+ bvec[i].bv_offset = sg->offset;
|
||||
|
||||
- old_fs = get_fs();
|
||||
- set_fs(get_ds());
|
||||
+ len += sg->length;
|
||||
+ }
|
||||
|
||||
+ iov_iter_bvec(&iter, ITER_BVEC, bvec, sgl_nents, len);
|
||||
if (is_write)
|
||||
- ret = vfs_writev(fd, &iov[0], sgl_nents, &pos);
|
||||
+ ret = vfs_iter_write(fd, &iter, &pos);
|
||||
else
|
||||
- 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));
|
||||
+ ret = vfs_iter_read(fd, &iter, &pos);
|
||||
|
||||
- kfree(iov);
|
||||
+ kfree(bvec);
|
||||
|
||||
if (is_write) {
|
||||
if (ret < 0 || ret != cmd->data_length) {
|
||||
--
|
||||
2.4.1
|
||||
|
|
@ -685,6 +685,9 @@ Patch26214: acpi_video-Add-enable_native_backlight-quirk-for-Mac.patch
|
|||
#rhbz 1225563
|
||||
Patch26215: HID-lenovo-set-INPUT_PROP_POINTING_STICK.patch
|
||||
|
||||
#rhbz 1218882
|
||||
Patch26216: 0001-target-use-vfs_iter_read-write-in-fd_do_rw.patch
|
||||
|
||||
# END OF PATCH DEFINITIONS
|
||||
|
||||
%endif
|
||||
|
@ -1473,6 +1476,9 @@ ApplyPatch acpi_video-Add-enable_native_backlight-quirk-for-Mac.patch
|
|||
#rhbz 1225563
|
||||
ApplyPatch HID-lenovo-set-INPUT_PROP_POINTING_STICK.patch
|
||||
|
||||
#rhbz 1218882
|
||||
ApplyPatch 0001-target-use-vfs_iter_read-write-in-fd_do_rw.patch
|
||||
|
||||
# END OF PATCH APPLICATIONS
|
||||
|
||||
%endif
|
||||
|
@ -2332,6 +2338,9 @@ fi
|
|||
# ||----w |
|
||||
# || ||
|
||||
%changelog
|
||||
* Tue Jun 02 2015 Laura Abbott <labbott@fedoraproject.org>
|
||||
- Fix fd_do_rw error (rhbz 1218882)
|
||||
|
||||
* Tue Jun 02 2015 Josh Boyer <jwboyer@fedoraproject.org>
|
||||
- Fix middle button issues on external Lenovo keyboards (rhbz 1225563)
|
||||
|
||||
|
|
Loading…
Reference in New Issue