[PATCH 044/437] ocfs2: convert to read/write iterators

From: Jens Axboe
Date: Thu Apr 11 2024 - 11:49:21 EST


Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
fs/ocfs2/cluster/heartbeat.c | 15 ++++++++-------
fs/ocfs2/dlm/dlmdebug.c | 16 +++++++++-------
fs/ocfs2/stack_user.c | 6 ++++--
fs/ocfs2/super.c | 15 ++++++++-------
4 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 1bde1281d514..6baff47a3a08 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1350,12 +1350,14 @@ static int o2hb_debug_release(struct inode *inode, struct file *file)
return 0;
}

-static ssize_t o2hb_debug_read(struct file *file, char __user *buf,
- size_t nbytes, loff_t *ppos)
+static ssize_t o2hb_debug_read(struct kiocb *iocb, struct iov_iter *to)
{
- return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
- i_size_read(file->f_mapping->host));
+ struct file *file = iocb->ki_filp;
+
+ return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+ i_size_read(file->f_mapping->host), to);
}
+
#else
static int o2hb_debug_open(struct inode *inode, struct file *file)
{
@@ -1365,8 +1367,7 @@ static int o2hb_debug_release(struct inode *inode, struct file *file)
{
return 0;
}
-static ssize_t o2hb_debug_read(struct file *file, char __user *buf,
- size_t nbytes, loff_t *ppos)
+static ssize_t o2hb_debug_read(struct kiocb *iocb, struct iov_iter *to)
{
return 0;
}
@@ -1375,7 +1376,7 @@ static ssize_t o2hb_debug_read(struct file *file, char __user *buf,
static const struct file_operations o2hb_debug_fops = {
.open = o2hb_debug_open,
.release = o2hb_debug_release,
- .read = o2hb_debug_read,
+ .read_iter = o2hb_debug_read,
.llseek = generic_file_llseek,
};

diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index cd4857d5a44a..bad07f55bbf6 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -336,12 +336,14 @@ static int debug_release(struct inode *inode, struct file *file)
return 0;
}

-static ssize_t debug_read(struct file *file, char __user *buf,
- size_t nbytes, loff_t *ppos)
+static ssize_t debug_read(struct kiocb *iocb, struct iov_iter *to)
{
- return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
- i_size_read(file->f_mapping->host));
+ struct file *file = iocb->ki_filp;
+
+ return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+ i_size_read(file->f_mapping->host), to);
}
+
/* end - util funcs */

/* begin - purge list funcs */
@@ -395,7 +397,7 @@ static int debug_purgelist_open(struct inode *inode, struct file *file)
static const struct file_operations debug_purgelist_fops = {
.open = debug_purgelist_open,
.release = debug_release,
- .read = debug_read,
+ .read_iter = debug_read,
.llseek = generic_file_llseek,
};
/* end - purge list funcs */
@@ -452,7 +454,7 @@ static int debug_mle_open(struct inode *inode, struct file *file)
static const struct file_operations debug_mle_fops = {
.open = debug_mle_open,
.release = debug_release,
- .read = debug_read,
+ .read_iter = debug_read,
.llseek = generic_file_llseek,
};

@@ -843,7 +845,7 @@ static int debug_state_open(struct inode *inode, struct file *file)
static const struct file_operations debug_state_fops = {
.open = debug_state_open,
.release = debug_release,
- .read = debug_read,
+ .read_iter = debug_read,
.llseek = generic_file_llseek,
};
/* end - debug state funcs */
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index c11406cd87a8..360fb8f35e43 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -534,6 +534,7 @@ static ssize_t ocfs2_control_write(struct file *file,

return ret;
}
+FOPS_WRITE_ITER_HELPER(ocfs2_control_write);

/*
* This is a naive version. If we ever have a new protocol, we'll expand
@@ -556,6 +557,7 @@ static ssize_t ocfs2_control_read(struct file *file,

return ret;
}
+FOPS_READ_ITER_HELPER(ocfs2_control_read);

static int ocfs2_control_release(struct inode *inode, struct file *file)
{
@@ -616,8 +618,8 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
static const struct file_operations ocfs2_control_fops = {
.open = ocfs2_control_open,
.release = ocfs2_control_release,
- .read = ocfs2_control_read,
- .write = ocfs2_control_write,
+ .read_iter = ocfs2_control_read_iter,
+ .write_iter = ocfs2_control_write_iter,
.owner = THIS_MODULE,
.llseek = default_llseek,
};
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 8aabaed2c1cb..6f7107ecd6c6 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -360,12 +360,14 @@ static int ocfs2_debug_release(struct inode *inode, struct file *file)
return 0;
}

-static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
- size_t nbytes, loff_t *ppos)
+static ssize_t ocfs2_debug_read(struct kiocb *iocb, struct iov_iter *to)
{
- return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
- i_size_read(file->f_mapping->host));
+ struct file *file = iocb->ki_filp;
+
+ return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+ i_size_read(file->f_mapping->host), to);
}
+
#else
static int ocfs2_osb_debug_open(struct inode *inode, struct file *file)
{
@@ -375,8 +377,7 @@ static int ocfs2_debug_release(struct inode *inode, struct file *file)
{
return 0;
}
-static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
- size_t nbytes, loff_t *ppos)
+static ssize_t ocfs2_debug_read(struct kiocb *iocb, struct iov_iter *to)
{
return 0;
}
@@ -385,7 +386,7 @@ static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
static const struct file_operations ocfs2_osb_debug_fops = {
.open = ocfs2_osb_debug_open,
.release = ocfs2_debug_release,
- .read = ocfs2_debug_read,
+ .read_iter = ocfs2_debug_read,
.llseek = generic_file_llseek,
};

--
2.43.0