]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
9p: move readn meta-function from client to fs layer
authorEric Van Hensbergen <ericvh@gmail.com>
Tue, 14 Oct 2008 01:36:16 +0000 (20:36 -0500)
committerEric Van Hensbergen <ericvh@gmail.com>
Fri, 17 Oct 2008 16:04:43 +0000 (11:04 -0500)
There are a couple of methods in the client code which aren't actually
wire operations.  To keep things organized cleaner, these operations are
being moved to the fs layer.

This patch moves the readn meta-function (which executes multiple wire
reads until a buffer is full) to the fs layer.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
fs/9p/v9fs.c
fs/9p/v9fs_vfs.h
fs/9p/vfs_addr.c
fs/9p/vfs_file.c
include/net/9p/client.h
net/9p/client.c

index b6b85cf01e0d4fd4df98d1c28b8b7b14b6155636..24eb01087b6d63313404dff82b4f192177189342 100644 (file)
@@ -234,7 +234,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
        if (!v9ses->clnt->dotu)
                v9ses->flags &= ~V9FS_EXTENDED;
 
-       v9ses->maxdata = v9ses->clnt->msize;
+       v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ;
 
        /* for legacy mode, fall back to V9FS_ACCESS_ANY */
        if (!v9fs_extended(v9ses) &&
index 57997fa14e69d4260fc5b9a990e030355a321963..046cff377f1016741e6db4f0c29f5e109060e2e5 100644 (file)
@@ -52,3 +52,5 @@ int v9fs_file_open(struct inode *inode, struct file *file);
 void v9fs_inode2stat(struct inode *inode, struct p9_stat *stat);
 void v9fs_dentry_release(struct dentry *);
 int v9fs_uflags2omode(int uflags, int extended);
+
+ssize_t v9fs_file_readn(struct file *, char *, char __user *, u32, u64);
index 97d3aed57983905f7caa660ce9474b7dc734d8e6..6fcb1e7095cfe0a97255170656d76e3fe8ed9a30 100644 (file)
@@ -38,7 +38,6 @@
 
 #include "v9fs.h"
 #include "v9fs_vfs.h"
-#include "fid.h"
 
 /**
  * v9fs_vfs_readpage - read an entire page in from 9P
@@ -53,14 +52,12 @@ static int v9fs_vfs_readpage(struct file *filp, struct page *page)
        int retval;
        loff_t offset;
        char *buffer;
-       struct p9_fid *fid;
 
        P9_DPRINTK(P9_DEBUG_VFS, "\n");
-       fid = filp->private_data;
        buffer = kmap(page);
        offset = page_offset(page);
 
-       retval = p9_client_readn(fid, buffer, offset, PAGE_CACHE_SIZE);
+       retval = v9fs_file_readn(filp, buffer, NULL, offset, PAGE_CACHE_SIZE);
        if (retval < 0)
                goto done;
 
index 3819a195de8f027745880b2866d465e62444a910..4d6d7657fb759ee4ed5bada670ba740ec327d527 100644 (file)
@@ -120,23 +120,72 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
 }
 
 /**
- * v9fs_file_read - read from a file
+ * v9fs_file_readn - read from a file
  * @filp: file pointer to read
  * @data: data buffer to read data into
+ * @udata: user data buffer to read data into
  * @count: size of buffer
  * @offset: offset at which to read data
  *
  */
+
+ssize_t
+v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
+              u64 offset)
+{
+       int n, total;
+       struct p9_fid *fid = filp->private_data;
+
+       P9_DPRINTK(P9_DEBUG_9P, "fid %d offset %llu count %d\n", fid->fid,
+                                       (long long unsigned) offset, count);
+
+       n = 0;
+       total = 0;
+       do {
+               n = p9_client_read(fid, data, udata, offset, count);
+               if (n <= 0)
+                       break;
+
+               if (data)
+                       data += n;
+               if (udata)
+                       udata += n;
+
+               offset += n;
+               count -= n;
+               total += n;
+       } while (count > 0 && n == (fid->clnt->msize - P9_IOHDRSZ));
+
+       if (n < 0)
+               total = n;
+
+       return total;
+}
+
+/**
+ * v9fs_file_read - read from a file
+ * @filp: file pointer to read
+ * @udata: user data buffer to read data into
+ * @count: size of buffer
+ * @offset: offset at which to read data
+ *
+ */
+
 static ssize_t
-v9fs_file_read(struct file *filp, char __user * data, size_t count,
+v9fs_file_read(struct file *filp, char __user *udata, size_t count,
               loff_t * offset)
 {
        int ret;
        struct p9_fid *fid;
 
-       P9_DPRINTK(P9_DEBUG_VFS, "\n");
+       P9_DPRINTK(P9_DEBUG_VFS, "count %d offset %lld\n", count, *offset);
        fid = filp->private_data;
-       ret = p9_client_read(fid, NULL, data, *offset, count);
+
+       if (count > (fid->clnt->msize - P9_IOHDRSZ))
+               ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
+       else
+               ret = p9_client_read(fid, NULL, udata, *offset, count);
+
        if (ret > 0)
                *offset += ret;
 
index c70a0f0b448d1477bba1a1996c4ceb9e14495a9a..bb8b0ede132d565b41a059d3812a356667bb3ff7 100644 (file)
@@ -203,7 +203,6 @@ int p9_client_clunk(struct p9_fid *fid);
 int p9_client_remove(struct p9_fid *fid);
 int p9_client_read(struct p9_fid *fid, char *data, char __user *udata,
                                                        u64 offset, u32 count);
-int p9_client_readn(struct p9_fid *fid, char *data, u64 offset, u32 count);
 int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
                                                        u64 offset, u32 count);
 struct p9_stat *p9_client_stat(struct p9_fid *fid);
index 5fc3aa1eb39b3eeeed0d2f676c610c4c61c0b66e..d5ea042eabb079512b5c883f8735c16554f9b384 100644 (file)
@@ -1150,32 +1150,6 @@ error:
 }
 EXPORT_SYMBOL(p9_client_write);
 
-int p9_client_readn(struct p9_fid *fid, char *data, u64 offset, u32 count)
-{
-       int n, total;
-
-       P9_DPRINTK(P9_DEBUG_9P, "fid %d offset %llu count %d\n", fid->fid,
-                                       (long long unsigned) offset, count);
-       n = 0;
-       total = 0;
-       while (count) {
-               n = p9_client_read(fid, data, NULL, offset, count);
-               if (n <= 0)
-                       break;
-
-               data += n;
-               offset += n;
-               count -= n;
-               total += n;
-       }
-
-       if (n < 0)
-               total = n;
-
-       return total;
-}
-EXPORT_SYMBOL(p9_client_readn);
-
 static struct p9_stat *p9_clone_stat(struct p9_stat *st, int dotu)
 {
        int n;