Commit 97e8442b authored by M. Mohan Kumar's avatar M. Mohan Kumar Committed by Eric Van Hensbergen

9p: Make use of iounit for read/write

Change the v9fs_file_readn function to limit the maximum transfer size
based on the iounit or msize.

Also remove the redundant check for limiting the transfer size in
v9fs_file_write. This check is done by p9_client_write.
Signed-off-by: default avatarM. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent cff6b8a9
...@@ -139,7 +139,7 @@ ssize_t ...@@ -139,7 +139,7 @@ ssize_t
v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
u64 offset) u64 offset)
{ {
int n, total; int n, total, size;
struct p9_fid *fid = filp->private_data; struct p9_fid *fid = filp->private_data;
P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid, P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid,
...@@ -147,6 +147,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, ...@@ -147,6 +147,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
n = 0; n = 0;
total = 0; total = 0;
size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
do { do {
n = p9_client_read(fid, data, udata, offset, count); n = p9_client_read(fid, data, udata, offset, count);
if (n <= 0) if (n <= 0)
...@@ -160,7 +161,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, ...@@ -160,7 +161,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
offset += n; offset += n;
count -= n; count -= n;
total += n; total += n;
} while (count > 0 && n == (fid->clnt->msize - P9_IOHDRSZ)); } while (count > 0 && n == size);
if (n < 0) if (n < 0)
total = n; total = n;
...@@ -183,11 +184,13 @@ v9fs_file_read(struct file *filp, char __user *udata, size_t count, ...@@ -183,11 +184,13 @@ v9fs_file_read(struct file *filp, char __user *udata, size_t count,
{ {
int ret; int ret;
struct p9_fid *fid; struct p9_fid *fid;
size_t size;
P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset); P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset);
fid = filp->private_data; fid = filp->private_data;
if (count > (fid->clnt->msize - P9_IOHDRSZ)) size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
if (count > size)
ret = v9fs_file_readn(filp, NULL, udata, count, *offset); ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
else else
ret = p9_client_read(fid, NULL, udata, *offset, count); ret = p9_client_read(fid, NULL, udata, *offset, count);
...@@ -224,9 +227,7 @@ v9fs_file_write(struct file *filp, const char __user * data, ...@@ -224,9 +227,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
fid = filp->private_data; fid = filp->private_data;
clnt = fid->clnt; clnt = fid->clnt;
rsize = fid->iounit; rsize = fid->iounit ? fid->iounit : clnt->msize - P9_IOHDRSZ;
if (!rsize || rsize > clnt->msize-P9_IOHDRSZ)
rsize = clnt->msize - P9_IOHDRSZ;
do { do {
if (count < rsize) if (count < rsize)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment