* [PATCH] block: convert the debugfs interface to read/write iterators
@ 2024-04-09 15:00 ` Jens Axboe
2024-04-09 21:36 ` Bart Van Assche
2024-04-10 19:18 ` Nitesh Shetty
0 siblings, 2 replies; 3+ messages in thread
From: Jens Axboe @ 2024-04-09 15:00 UTC (permalink / raw)
To: linux-block@vger.kernel.org
Convert the block debugfs interface to use read/write iterators rather
than the older style ->read()/->write().
No intended functional changes in this patch.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
This is part of a larger series that intends to fully kill the old
read/write interface.
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 94668e72ab09..a9fa3d7311ac 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -119,9 +119,10 @@ static int queue_state_show(void *data, struct seq_file *m)
return 0;
}
-static ssize_t queue_state_write(void *data, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t queue_state_write(void *data, struct kiocb *iocb,
+ struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
struct request_queue *q = data;
char opbuf[16] = { }, *op;
@@ -137,7 +138,7 @@ static ssize_t queue_state_write(void *data, const char __user *buf,
goto inval;
}
- if (copy_from_user(opbuf, buf, count))
+ if (!copy_from_iter_full(opbuf, count, from))
return -EFAULT;
op = strstrip(opbuf);
if (strcmp(op, "run") == 0) {
@@ -540,12 +541,11 @@ static int blk_mq_debugfs_show(struct seq_file *m, void *v)
return attr->show(data, m);
}
-static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t blk_mq_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct seq_file *m = file->private_data;
+ struct seq_file *m = iocb->ki_filp->private_data;
const struct blk_mq_debugfs_attr *attr = m->private;
- void *data = d_inode(file->f_path.dentry->d_parent)->i_private;
+ void *data = d_inode(iocb->ki_filp->f_path.dentry->d_parent)->i_private;
/*
* Attributes that only implement .seq_ops are read-only and 'attr' is
@@ -554,7 +554,7 @@ static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf,
if (attr == data || !attr->write)
return -EPERM;
- return attr->write(data, buf, count, ppos);
+ return attr->write(data, iocb, from);
}
static int blk_mq_debugfs_open(struct inode *inode, struct file *file)
@@ -591,8 +591,8 @@ static int blk_mq_debugfs_release(struct inode *inode, struct file *file)
static const struct file_operations blk_mq_debugfs_fops = {
.open = blk_mq_debugfs_open,
- .read = seq_read,
- .write = blk_mq_debugfs_write,
+ .read_iter = seq_read_iter,
+ .write_iter = blk_mq_debugfs_write,
.llseek = seq_lseek,
.release = blk_mq_debugfs_release,
};
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 9c7d4b6117d4..22c65e5ff430 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -12,7 +12,7 @@ struct blk_mq_debugfs_attr {
const char *name;
umode_t mode;
int (*show)(void *, struct seq_file *);
- ssize_t (*write)(void *, const char __user *, size_t, loff_t *);
+ ssize_t (*write)(void *, struct kiocb *, struct iov_iter *);
/* Set either .show or .seq_ops. */
const struct seq_operations *seq_ops;
};
--
Jens Axboe
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: convert the debugfs interface to read/write iterators
2024-04-09 15:00 ` [PATCH] block: convert the debugfs interface to read/write iterators Jens Axboe
@ 2024-04-09 21:36 ` Bart Van Assche
2024-04-10 19:18 ` Nitesh Shetty
1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2024-04-09 21:36 UTC (permalink / raw)
To: Jens Axboe, linux-block@vger.kernel.org
On 4/9/24 08:00, Jens Axboe wrote:
> Convert the block debugfs interface to use read/write iterators rather
> than the older style ->read()/->write().
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: convert the debugfs interface to read/write iterators
2024-04-09 15:00 ` [PATCH] block: convert the debugfs interface to read/write iterators Jens Axboe
2024-04-09 21:36 ` Bart Van Assche
@ 2024-04-10 19:18 ` Nitesh Shetty
1 sibling, 0 replies; 3+ messages in thread
From: Nitesh Shetty @ 2024-04-10 19:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
On 09/04/24 09:00AM, Jens Axboe wrote:
>Convert the block debugfs interface to use read/write iterators rather
>than the older style ->read()/->write().
>
>No intended functional changes in this patch.
>
>Signed-off-by: Jens Axboe <axboe@kernel.dk>
>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-10 19:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240410192515epcas5p1360a731616fca3841c892be310afb109@epcas5p1.samsung.com>
2024-04-09 15:00 ` [PATCH] block: convert the debugfs interface to read/write iterators Jens Axboe
2024-04-09 21:36 ` Bart Van Assche
2024-04-10 19:18 ` Nitesh Shetty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox