Messages in this thread Patch in this message | | | From | "Jason A. Donenfeld" <> | Subject | [PATCH] fs: prefer read_iter over read and write_iter over write | Date | Fri, 20 May 2022 15:51:03 +0200 |
| |
Most kernel code prefers read_iter over read and write_iter over write, yet the read function pointer is tested first. Reverse these so that the iter function is always used first.
Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> --- fs/read_write.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c index e643aec2b0ef..78a81aa5fa76 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -476,10 +476,10 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) if (count > MAX_RW_COUNT) count = MAX_RW_COUNT; - if (file->f_op->read) - ret = file->f_op->read(file, buf, count, pos); - else if (file->f_op->read_iter) + if (file->f_op->read_iter) ret = new_sync_read(file, buf, count, pos); + else if (file->f_op->read) + ret = file->f_op->read(file, buf, count, pos); else ret = -EINVAL; if (ret > 0) { @@ -585,10 +585,10 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_ if (count > MAX_RW_COUNT) count = MAX_RW_COUNT; file_start_write(file); - if (file->f_op->write) - ret = file->f_op->write(file, buf, count, pos); - else if (file->f_op->write_iter) + if (file->f_op->write_iter) ret = new_sync_write(file, buf, count, pos); + else if (file->f_op->write) + ret = file->f_op->write(file, buf, count, pos); else ret = -EINVAL; if (ret > 0) { -- 2.35.1
| |