block: convert the debugfs interface to read/write iterators
Jens Axboe
maintainerPATCH 1/1 block: convert the debugfs interface to read/write iterators
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 <[email protected]>
---
This is part of a larger series that intends to fully kill the old read/write interface.
block/blk-mq-debugfs.c +10 -10
@@ -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, };
block/blk-mq-debugfs.h +1 -1
@@ -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; };
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
Convert the block debugfs interface to use read/write iterators rather than the older style ->read()/->write().
Reviewed-by Bart Van Assche <[email protected]>
Quoted 7 lines · Jens Axboe
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 <[email protected]>
Reviewed-by Nitesh Shetty <[email protected]>