aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-11-12 12:16:47 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-11-26 16:32:35 -0500
commit19f737879cc623c3aa73e655465faa3bff121768 (patch)
tree12b96a6b345892592260ce55aadb7528ef3e516f /fs/nfs/direct.c
parent014313a9d66272ed37b9ebd64c3f30b596a4c8e1 (diff)
downloadkernel_samsung_tuna-19f737879cc623c3aa73e655465faa3bff121768.zip
kernel_samsung_tuna-19f737879cc623c3aa73e655465faa3bff121768.tar.gz
kernel_samsung_tuna-19f737879cc623c3aa73e655465faa3bff121768.tar.bz2
NFS: Introduce iovec I/O helpers to fs/nfs/direct.c
Add helpers that iterate over multi-segment iovecs. These will be used to support multi-segment scatter/gather direct I/O in a later patch. Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index afcab00..e30d928 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -355,6 +355,41 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo
return result < 0 ? (ssize_t) result : -EFAULT;
}
+static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
+ const struct iovec *iov,
+ unsigned long nr_segs,
+ loff_t pos)
+{
+ ssize_t result = -EINVAL;
+ size_t requested_bytes = 0;
+ unsigned long seg;
+
+ get_dreq(dreq);
+
+ for (seg = 0; seg < nr_segs; seg++) {
+ const struct iovec *vec = &iov[seg];
+ result = nfs_direct_read_schedule(dreq,
+ (unsigned long)vec->iov_base,
+ vec->iov_len, pos);
+ if (result < 0)
+ break;
+ requested_bytes += result;
+ if ((size_t)result < vec->iov_len)
+ break;
+ pos += vec->iov_len;
+ }
+
+ if (put_dreq(dreq))
+ nfs_direct_complete(dreq);
+
+ if (requested_bytes != 0)
+ return 0;
+
+ if (result < 0)
+ return result;
+ return -EIO;
+}
+
static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t pos)
{
ssize_t result = 0;
@@ -697,6 +732,42 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l
return result < 0 ? (ssize_t) result : -EFAULT;
}
+static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
+ const struct iovec *iov,
+ unsigned long nr_segs,
+ loff_t pos, int sync)
+{
+ ssize_t result = 0;
+ size_t requested_bytes = 0;
+ unsigned long seg;
+
+ get_dreq(dreq);
+
+ for (seg = 0; seg < nr_segs; seg++) {
+ const struct iovec *vec = &iov[seg];
+ result = nfs_direct_write_schedule(dreq,
+ (unsigned long)vec->iov_base,
+ vec->iov_len,
+ pos, sync);
+ if (result < 0)
+ break;
+ requested_bytes += result;
+ if ((size_t)result < vec->iov_len)
+ break;
+ pos += vec->iov_len;
+ }
+
+ if (put_dreq(dreq))
+ nfs_direct_write_complete(dreq, dreq->inode);
+
+ if (requested_bytes != 0)
+ return 0;
+
+ if (result < 0)
+ return result;
+ return -EIO;
+}
+
static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t pos)
{
ssize_t result = 0;