From: Jens Axboe <axboe@kernel.dk>
To: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: [PATCH] block: convert the debugfs interface to read/write iterators
Date: Tue, 9 Apr 2024 09:00:22 -0600 [thread overview]
Message-ID: <dc58cf1e-cfbc-4771-80b8-4dfdf5d7f0d1@kernel.dk> (raw)
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
next reply other threads:[~2024-04-09 15:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240410192515epcas5p1360a731616fca3841c892be310afb109@epcas5p1.samsung.com>
2024-04-09 15:00 ` Jens Axboe [this message]
2024-04-09 21:36 ` [PATCH] block: convert the debugfs interface to read/write iterators Bart Van Assche
2024-04-10 19:18 ` Nitesh Shetty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc58cf1e-cfbc-4771-80b8-4dfdf5d7f0d1@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox