aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorBadari Pulavarty <pbadari@us.ibm.com>2006-10-01 02:28:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 03:39:28 -0400
commit027445c37282bc1ed26add45e573ad2d3e4860a5 (patch)
tree93eab101a938ffebaea64703033c8649df4d73f0 /fs/nfs
parent9ea0f9499d15c49df23e7aac4332d830c40e12d0 (diff)
[PATCH] Vectorize aio_read/aio_write fileop methods
This patch vectorizes aio_read() and aio_write() methods to prepare for collapsing all aio & vectored operations into one interface - which is aio_read()/aio_write(). Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Michael Holzheu <HOLZHEU@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/direct.c26
-rw-r--r--fs/nfs/file.c34
2 files changed, 38 insertions, 22 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 377839bed172..9f7f8b9ea1e2 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -707,8 +707,8 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz
707/** 707/**
708 * nfs_file_direct_read - file direct read operation for NFS files 708 * nfs_file_direct_read - file direct read operation for NFS files
709 * @iocb: target I/O control block 709 * @iocb: target I/O control block
710 * @buf: user's buffer into which to read data 710 * @iov: vector of user buffers into which to read data
711 * @count: number of bytes to read 711 * @nr_segs: size of iov vector
712 * @pos: byte offset in file where reading starts 712 * @pos: byte offset in file where reading starts
713 * 713 *
714 * We use this function for direct reads instead of calling 714 * We use this function for direct reads instead of calling
@@ -725,17 +725,24 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz
725 * client must read the updated atime from the server back into its 725 * client must read the updated atime from the server back into its
726 * cache. 726 * cache.
727 */ 727 */
728ssize_t nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos) 728ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov,
729 unsigned long nr_segs, loff_t pos)
729{ 730{
730 ssize_t retval = -EINVAL; 731 ssize_t retval = -EINVAL;
731 struct file *file = iocb->ki_filp; 732 struct file *file = iocb->ki_filp;
732 struct address_space *mapping = file->f_mapping; 733 struct address_space *mapping = file->f_mapping;
734 /* XXX: temporary */
735 const char __user *buf = iov[0].iov_base;
736 size_t count = iov[0].iov_len;
733 737
734 dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n", 738 dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n",
735 file->f_dentry->d_parent->d_name.name, 739 file->f_dentry->d_parent->d_name.name,
736 file->f_dentry->d_name.name, 740 file->f_dentry->d_name.name,
737 (unsigned long) count, (long long) pos); 741 (unsigned long) count, (long long) pos);
738 742
743 if (nr_segs != 1)
744 return -EINVAL;
745
739 if (count < 0) 746 if (count < 0)
740 goto out; 747 goto out;
741 retval = -EFAULT; 748 retval = -EFAULT;
@@ -760,8 +767,8 @@ out:
760/** 767/**
761 * nfs_file_direct_write - file direct write operation for NFS files 768 * nfs_file_direct_write - file direct write operation for NFS files
762 * @iocb: target I/O control block 769 * @iocb: target I/O control block
763 * @buf: user's buffer from which to write data 770 * @iov: vector of user buffers from which to write data
764 * @count: number of bytes to write 771 * @nr_segs: size of iov vector
765 * @pos: byte offset in file where writing starts 772 * @pos: byte offset in file where writing starts
766 * 773 *
767 * We use this function for direct writes instead of calling 774 * We use this function for direct writes instead of calling
@@ -782,17 +789,24 @@ out:
782 * Note that O_APPEND is not supported for NFS direct writes, as there 789 * Note that O_APPEND is not supported for NFS direct writes, as there
783 * is no atomic O_APPEND write facility in the NFS protocol. 790 * is no atomic O_APPEND write facility in the NFS protocol.
784 */ 791 */
785ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos) 792ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
793 unsigned long nr_segs, loff_t pos)
786{ 794{
787 ssize_t retval; 795 ssize_t retval;
788 struct file *file = iocb->ki_filp; 796 struct file *file = iocb->ki_filp;
789 struct address_space *mapping = file->f_mapping; 797 struct address_space *mapping = file->f_mapping;
798 /* XXX: temporary */
799 const char __user *buf = iov[0].iov_base;
800 size_t count = iov[0].iov_len;
790 801
791 dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n", 802 dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n",
792 file->f_dentry->d_parent->d_name.name, 803 file->f_dentry->d_parent->d_name.name,
793 file->f_dentry->d_name.name, 804 file->f_dentry->d_name.name,
794 (unsigned long) count, (long long) pos); 805 (unsigned long) count, (long long) pos);
795 806
807 if (nr_segs != 1)
808 return -EINVAL;
809
796 retval = generic_write_checks(file, &pos, &count, 0); 810 retval = generic_write_checks(file, &pos, &count, 0);
797 if (retval) 811 if (retval)
798 goto out; 812 goto out;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index be997d649127..cc93865cea93 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -41,8 +41,10 @@ static int nfs_file_release(struct inode *, struct file *);
41static loff_t nfs_file_llseek(struct file *file, loff_t offset, int origin); 41static loff_t nfs_file_llseek(struct file *file, loff_t offset, int origin);
42static int nfs_file_mmap(struct file *, struct vm_area_struct *); 42static int nfs_file_mmap(struct file *, struct vm_area_struct *);
43static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *); 43static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
44static ssize_t nfs_file_read(struct kiocb *, char __user *, size_t, loff_t); 44static ssize_t nfs_file_read(struct kiocb *, const struct iovec *iov,
45static ssize_t nfs_file_write(struct kiocb *, const char __user *, size_t, loff_t); 45 unsigned long nr_segs, loff_t pos);
46static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov,
47 unsigned long nr_segs, loff_t pos);
46static int nfs_file_flush(struct file *, fl_owner_t id); 48static int nfs_file_flush(struct file *, fl_owner_t id);
47static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); 49static int nfs_fsync(struct file *, struct dentry *dentry, int datasync);
48static int nfs_check_flags(int flags); 50static int nfs_check_flags(int flags);
@@ -53,8 +55,8 @@ const struct file_operations nfs_file_operations = {
53 .llseek = nfs_file_llseek, 55 .llseek = nfs_file_llseek,
54 .read = do_sync_read, 56 .read = do_sync_read,
55 .write = do_sync_write, 57 .write = do_sync_write,
56 .aio_read = nfs_file_read, 58 .aio_read = nfs_file_read,
57 .aio_write = nfs_file_write, 59 .aio_write = nfs_file_write,
58 .mmap = nfs_file_mmap, 60 .mmap = nfs_file_mmap,
59 .open = nfs_file_open, 61 .open = nfs_file_open,
60 .flush = nfs_file_flush, 62 .flush = nfs_file_flush,
@@ -196,15 +198,17 @@ nfs_file_flush(struct file *file, fl_owner_t id)
196} 198}
197 199
198static ssize_t 200static ssize_t
199nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos) 201nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
202 unsigned long nr_segs, loff_t pos)
200{ 203{
201 struct dentry * dentry = iocb->ki_filp->f_dentry; 204 struct dentry * dentry = iocb->ki_filp->f_dentry;
202 struct inode * inode = dentry->d_inode; 205 struct inode * inode = dentry->d_inode;
203 ssize_t result; 206 ssize_t result;
207 size_t count = iov_length(iov, nr_segs);
204 208
205#ifdef CONFIG_NFS_DIRECTIO 209#ifdef CONFIG_NFS_DIRECTIO
206 if (iocb->ki_filp->f_flags & O_DIRECT) 210 if (iocb->ki_filp->f_flags & O_DIRECT)
207 return nfs_file_direct_read(iocb, buf, count, pos); 211 return nfs_file_direct_read(iocb, iov, nr_segs, pos);
208#endif 212#endif
209 213
210 dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", 214 dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n",
@@ -214,7 +218,7 @@ nfs_file_read(struct kiocb *iocb, char __user * buf, size_t count, loff_t pos)
214 result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); 218 result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
215 nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count); 219 nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, count);
216 if (!result) 220 if (!result)
217 result = generic_file_aio_read(iocb, buf, count, pos); 221 result = generic_file_aio_read(iocb, iov, nr_segs, pos);
218 return result; 222 return result;
219} 223}
220 224
@@ -336,24 +340,22 @@ const struct address_space_operations nfs_file_aops = {
336#endif 340#endif
337}; 341};
338 342
339/* 343static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
340 * Write to a file (through the page cache). 344 unsigned long nr_segs, loff_t pos)
341 */
342static ssize_t
343nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos)
344{ 345{
345 struct dentry * dentry = iocb->ki_filp->f_dentry; 346 struct dentry * dentry = iocb->ki_filp->f_dentry;
346 struct inode * inode = dentry->d_inode; 347 struct inode * inode = dentry->d_inode;
347 ssize_t result; 348 ssize_t result;
349 size_t count = iov_length(iov, nr_segs);
348 350
349#ifdef CONFIG_NFS_DIRECTIO 351#ifdef CONFIG_NFS_DIRECTIO
350 if (iocb->ki_filp->f_flags & O_DIRECT) 352 if (iocb->ki_filp->f_flags & O_DIRECT)
351 return nfs_file_direct_write(iocb, buf, count, pos); 353 return nfs_file_direct_write(iocb, iov, nr_segs, pos);
352#endif 354#endif
353 355
354 dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%lu)\n", 356 dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%Ld)\n",
355 dentry->d_parent->d_name.name, dentry->d_name.name, 357 dentry->d_parent->d_name.name, dentry->d_name.name,
356 inode->i_ino, (unsigned long) count, (unsigned long) pos); 358 inode->i_ino, (unsigned long) count, (long long) pos);
357 359
358 result = -EBUSY; 360 result = -EBUSY;
359 if (IS_SWAPFILE(inode)) 361 if (IS_SWAPFILE(inode))
@@ -372,7 +374,7 @@ nfs_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t
372 goto out; 374 goto out;
373 375
374 nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); 376 nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
375 result = generic_file_aio_write(iocb, buf, count, pos); 377 result = generic_file_aio_write(iocb, iov, nr_segs, pos);
376out: 378out:
377 return result; 379 return result;
378 380