[PATCH 049/437] fuse: convert to read/write iterators

Jens Axboe posted 437 patches 1 year, 8 months ago
[PATCH 049/437] fuse: convert to read/write iterators
Posted by Jens Axboe 1 year, 8 months ago
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/fuse/control.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 97ac994ff78f..0ca1d1f418c3 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -31,37 +31,36 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file)
 	return fc;
 }
 
-static ssize_t fuse_conn_abort_write(struct file *file, const char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t fuse_conn_abort_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
+	struct fuse_conn *fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (fc) {
 		if (fc->abort_err)
 			fc->aborted = true;
 		fuse_abort_conn(fc);
 		fuse_conn_put(fc);
 	}
-	return count;
+	return iov_iter_count(from);
 }
 
-static ssize_t fuse_conn_waiting_read(struct file *file, char __user *buf,
-				      size_t len, loff_t *ppos)
+static ssize_t fuse_conn_waiting_read_iter(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
 	char tmp[32];
 	size_t size;
 
-	if (!*ppos) {
+	if (!iocb->ki_pos) {
 		long value;
-		struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
+		struct fuse_conn *fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 		if (!fc)
 			return 0;
 
 		value = atomic_read(&fc->num_waiting);
-		file->private_data = (void *)value;
+		iocb->ki_filp->private_data = (void *)value;
 		fuse_conn_put(fc);
 	}
-	size = sprintf(tmp, "%ld\n", (long)file->private_data);
-	return simple_read_from_buffer(buf, len, ppos, tmp, size);
+	size = sprintf(tmp, "%ld\n", (long)iocb->ki_filp->private_data);
+	return simple_copy_to_iter(tmp, &iocb->ki_pos, size, to);
 }
 
 static ssize_t fuse_conn_limit_read(struct file *file, char __user *buf,
@@ -115,6 +114,7 @@ static ssize_t fuse_conn_max_background_read(struct file *file,
 
 	return fuse_conn_limit_read(file, buf, len, ppos, val);
 }
+FOPS_READ_ITER_HELPER(fuse_conn_max_background_read);
 
 static ssize_t fuse_conn_max_background_write(struct file *file,
 					      const char __user *buf,
@@ -140,6 +140,7 @@ static ssize_t fuse_conn_max_background_write(struct file *file,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(fuse_conn_max_background_write);
 
 static ssize_t fuse_conn_congestion_threshold_read(struct file *file,
 						   char __user *buf, size_t len,
@@ -179,30 +180,31 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
 out:
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(fuse_conn_congestion_threshold_write);
 
 static const struct file_operations fuse_ctl_abort_ops = {
 	.open = nonseekable_open,
-	.write = fuse_conn_abort_write,
+	.write_iter = fuse_conn_abort_write,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_ctl_waiting_ops = {
 	.open = nonseekable_open,
-	.read = fuse_conn_waiting_read,
+	.read_iter = fuse_conn_waiting_read_iter,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_max_background_ops = {
 	.open = nonseekable_open,
-	.read = fuse_conn_max_background_read,
-	.write = fuse_conn_max_background_write,
+	.read_iter = fuse_conn_max_background_read_iter,
+	.write_iter = fuse_conn_max_background_write_iter,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_congestion_threshold_ops = {
 	.open = nonseekable_open,
 	.read = fuse_conn_congestion_threshold_read,
-	.write = fuse_conn_congestion_threshold_write,
+	.write_iter = fuse_conn_congestion_threshold_write_iter,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0