diff options
author | M. Mohan Kumar <mohan@in.ibm.com> | 2010-06-04 07:59:07 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-08-02 15:25:06 -0400 |
commit | 97e8442b0971ea6be9a495b3d03402985cfe5d6a (patch) | |
tree | 2afd94c5c1afc34c65a28f45baa08a811479f1f0 /fs/9p | |
parent | cff6b8a9b81b404e8ce0257b26007c3afe625212 (diff) |
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: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r-- | fs/9p/vfs_file.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 2bedc6c94fc2..2d686ec322a0 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -139,7 +139,7 @@ ssize_t | |||
139 | v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, | 139 | v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, |
140 | u64 offset) | 140 | u64 offset) |
141 | { | 141 | { |
142 | int n, total; | 142 | int n, total, size; |
143 | struct p9_fid *fid = filp->private_data; | 143 | struct p9_fid *fid = filp->private_data; |
144 | 144 | ||
145 | P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid, | 145 | 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 | 147 | ||
148 | n = 0; | 148 | n = 0; |
149 | total = 0; | 149 | total = 0; |
150 | size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ; | ||
150 | do { | 151 | do { |
151 | n = p9_client_read(fid, data, udata, offset, count); | 152 | n = p9_client_read(fid, data, udata, offset, count); |
152 | if (n <= 0) | 153 | if (n <= 0) |
@@ -160,7 +161,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count, | |||
160 | offset += n; | 161 | offset += n; |
161 | count -= n; | 162 | count -= n; |
162 | total += n; | 163 | total += n; |
163 | } while (count > 0 && n == (fid->clnt->msize - P9_IOHDRSZ)); | 164 | } while (count > 0 && n == size); |
164 | 165 | ||
165 | if (n < 0) | 166 | if (n < 0) |
166 | total = n; | 167 | total = n; |
@@ -183,11 +184,13 @@ v9fs_file_read(struct file *filp, char __user *udata, size_t count, | |||
183 | { | 184 | { |
184 | int ret; | 185 | int ret; |
185 | struct p9_fid *fid; | 186 | struct p9_fid *fid; |
187 | size_t size; | ||
186 | 188 | ||
187 | P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset); | 189 | P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset); |
188 | fid = filp->private_data; | 190 | fid = filp->private_data; |
189 | 191 | ||
190 | if (count > (fid->clnt->msize - P9_IOHDRSZ)) | 192 | size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ; |
193 | if (count > size) | ||
191 | ret = v9fs_file_readn(filp, NULL, udata, count, *offset); | 194 | ret = v9fs_file_readn(filp, NULL, udata, count, *offset); |
192 | else | 195 | else |
193 | ret = p9_client_read(fid, NULL, udata, *offset, count); | 196 | ret = p9_client_read(fid, NULL, udata, *offset, count); |
@@ -224,9 +227,7 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
224 | fid = filp->private_data; | 227 | fid = filp->private_data; |
225 | clnt = fid->clnt; | 228 | clnt = fid->clnt; |
226 | 229 | ||
227 | rsize = fid->iounit; | 230 | rsize = fid->iounit ? fid->iounit : clnt->msize - P9_IOHDRSZ; |
228 | if (!rsize || rsize > clnt->msize-P9_IOHDRSZ) | ||
229 | rsize = clnt->msize - P9_IOHDRSZ; | ||
230 | 231 | ||
231 | do { | 232 | do { |
232 | if (count < rsize) | 233 | if (count < rsize) |