[PATCH 197/437] scsi: scsi_debug: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 12:23:34 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
drivers/scsi/scsi_debug.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index acf0592d63da..0ce291a5e8fa 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1022,19 +1022,19 @@ static int sdebug_error_open(struct inode *inode, struct file *file)
return single_open(file, sdebug_error_show, inode->i_private);
}

-static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,
- size_t count, loff_t *ppos)
+static ssize_t sdebug_error_write(struct kiocb *iocb, struct iov_iter *from)
{
char *buf;
unsigned int inject_type;
struct sdebug_err_inject *inject;
- struct scsi_device *sdev = (struct scsi_device *)file->f_inode->i_private;
+ struct scsi_device *sdev = iocb->ki_filp->f_inode->i_private;
+ size_t count = iov_iter_count(from);

buf = kzalloc(count + 1, GFP_KERNEL);
if (!buf)
return -ENOMEM;

- if (copy_from_user(buf, ubuf, count)) {
+ if (!copy_from_iter_full(buf, count, from)) {
kfree(buf);
return -EFAULT;
}
@@ -1095,8 +1095,8 @@ static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,

static const struct file_operations sdebug_error_fops = {
.open = sdebug_error_open,
- .read = seq_read,
- .write = sdebug_error_write,
+ .read_iter = seq_read_iter,
+ .write_iter = sdebug_error_write,
.release = single_release,
};

@@ -1117,17 +1117,17 @@ static int sdebug_target_reset_fail_open(struct inode *inode, struct file *file)
return single_open(file, sdebug_target_reset_fail_show, inode->i_private);
}

-static ssize_t sdebug_target_reset_fail_write(struct file *file,
- const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t sdebug_target_reset_fail_write(struct kiocb *iocb,
+ struct iov_iter *from)
{
int ret;
- struct scsi_target *starget =
- (struct scsi_target *)file->f_inode->i_private;
+ struct scsi_target *starget = iocb->ki_filp->f_inode->i_private;
struct sdebug_target_info *targetip =
(struct sdebug_target_info *)starget->hostdata;
+ size_t count = iov_iter_count(from);

if (targetip) {
- ret = kstrtobool_from_user(ubuf, count, &targetip->reset_fail);
+ ret = kstrtobool_from_iter(from, count, &targetip->reset_fail);
return ret < 0 ? ret : count;
}
return -ENODEV;
@@ -1135,8 +1135,8 @@ static ssize_t sdebug_target_reset_fail_write(struct file *file,

static const struct file_operations sdebug_target_reset_fail_fops = {
.open = sdebug_target_reset_fail_open,
- .read = seq_read,
- .write = sdebug_target_reset_fail_write,
+ .read_iter = seq_read_iter,
+ .write_iter = sdebug_target_reset_fail_write,
.release = single_release,
};

--
2.43.0