|
@@ -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;
|
|
|
|