aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-05-07 19:18:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-07 21:38:28 -0400
commit162934de51e0271f6e2955075735656ea5092ea9 (patch)
tree7a843e340e0241f66acb83e906ee6ee6152b1355 /drivers/char
parent41003a7bcfed1255032e1e7c7b487e505b22e298 (diff)
char: add aio_{read,write} to /dev/{null,zero}
These are handy for measuring the cost of the aio infrastructure with operations that do very little and complete immediately. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: Kent Overstreet <koverstreet@google.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Jens Axboe <axboe@kernel.dk> Cc: Asai Thambi S P <asamymuthupa@micron.com> Cc: Selvan Mani <smani@micron.com> Cc: Sam Bradshaw <sbradshaw@micron.com> Acked-by: Jeff Moyer <jmoyer@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Benjamin LaHaise <bcrl@kvack.org> Reviewed-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/mem.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 2c644afbcdd4..e49265f18f86 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -627,6 +627,18 @@ static ssize_t write_null(struct file *file, const char __user *buf,
627 return count; 627 return count;
628} 628}
629 629
630static ssize_t aio_read_null(struct kiocb *iocb, const struct iovec *iov,
631 unsigned long nr_segs, loff_t pos)
632{
633 return 0;
634}
635
636static ssize_t aio_write_null(struct kiocb *iocb, const struct iovec *iov,
637 unsigned long nr_segs, loff_t pos)
638{
639 return iov_length(iov, nr_segs);
640}
641
630static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf, 642static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf,
631 struct splice_desc *sd) 643 struct splice_desc *sd)
632{ 644{
@@ -670,6 +682,24 @@ static ssize_t read_zero(struct file *file, char __user *buf,
670 return written ? written : -EFAULT; 682 return written ? written : -EFAULT;
671} 683}
672 684
685static ssize_t aio_read_zero(struct kiocb *iocb, const struct iovec *iov,
686 unsigned long nr_segs, loff_t pos)
687{
688 size_t written = 0;
689 unsigned long i;
690 ssize_t ret;
691
692 for (i = 0; i < nr_segs; i++) {
693 ret = read_zero(iocb->ki_filp, iov[i].iov_base, iov[i].iov_len,
694 &pos);
695 if (ret < 0)
696 break;
697 written += ret;
698 }
699
700 return written ? written : -EFAULT;
701}
702
673static int mmap_zero(struct file *file, struct vm_area_struct *vma) 703static int mmap_zero(struct file *file, struct vm_area_struct *vma)
674{ 704{
675#ifndef CONFIG_MMU 705#ifndef CONFIG_MMU
@@ -738,6 +768,7 @@ static int open_port(struct inode *inode, struct file *filp)
738#define full_lseek null_lseek 768#define full_lseek null_lseek
739#define write_zero write_null 769#define write_zero write_null
740#define read_full read_zero 770#define read_full read_zero
771#define aio_write_zero aio_write_null
741#define open_mem open_port 772#define open_mem open_port
742#define open_kmem open_mem 773#define open_kmem open_mem
743#define open_oldmem open_mem 774#define open_oldmem open_mem
@@ -766,6 +797,8 @@ static const struct file_operations null_fops = {
766 .llseek = null_lseek, 797 .llseek = null_lseek,
767 .read = read_null, 798 .read = read_null,
768 .write = write_null, 799 .write = write_null,
800 .aio_read = aio_read_null,
801 .aio_write = aio_write_null,
769 .splice_write = splice_write_null, 802 .splice_write = splice_write_null,
770}; 803};
771 804
@@ -782,6 +815,8 @@ static const struct file_operations zero_fops = {
782 .llseek = zero_lseek, 815 .llseek = zero_lseek,
783 .read = read_zero, 816 .read = read_zero,
784 .write = write_zero, 817 .write = write_zero,
818 .aio_read = aio_read_zero,
819 .aio_write = aio_write_zero,
785 .mmap = mmap_zero, 820 .mmap = mmap_zero,
786}; 821};
787 822