* [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations
@ 2010-06-01 14:17 M. Mohan Kumar
2010-06-01 14:17 ` [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write M. Mohan Kumar
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: M. Mohan Kumar @ 2010-06-01 14:17 UTC (permalink / raw)
To: qemu-devel, v9fs-developer
Compute iounit based on the host filesystem block size and pass it to
client with open/create response. Also return iounit as statfs's f_bsize
for optimal block size transfers.
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
---
hw/virtio-9p.c | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
hw/virtio-9p.h | 3 +++
2 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index f087122..4357f1f 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1,4 +1,4 @@
-/*
+ /*
* Virtio 9p backend
*
* Copyright IBM, Corp. 2010
@@ -269,6 +269,11 @@ static int v9fs_do_fsync(V9fsState *s, int fd)
return s->ops->fsync(&s->ctx, fd);
}
+static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
+{
+ return s->ops->statfs(&s->ctx, path->data, stbuf);
+}
+
static void v9fs_string_init(V9fsString *str)
{
str->data = NULL;
@@ -1035,11 +1040,10 @@ static void v9fs_fix_path(V9fsString *dst, V9fsString *src, int len)
static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
{
- int32_t msize;
V9fsString version;
size_t offset = 7;
- pdu_unmarshal(pdu, offset, "ds", &msize, &version);
+ pdu_unmarshal(pdu, offset, "ds", &s->msize, &version);
if (!strcmp(version.data, "9P2000.u")) {
s->proto_version = V9FS_PROTO_2000U;
@@ -1049,7 +1053,7 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
v9fs_string_sprintf(&version, "unknown");
}
- offset += pdu_marshal(pdu, offset, "ds", msize, &version);
+ offset += pdu_marshal(pdu, offset, "ds", s->msize, &version);
complete_pdu(s, pdu, offset);
v9fs_string_free(&version);
@@ -1304,6 +1308,20 @@ out:
v9fs_walk_complete(s, vs, err);
}
+static int32_t get_iounit(V9fsState *s, V9fsString *name)
+{
+ struct statfs stbuf;
+ int32_t iounit = 0;
+
+
+ if (!v9fs_do_statfs(s, name, &stbuf)) {
+ iounit = stbuf.f_bsize;
+ iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize;
+ }
+
+ return iounit;
+}
+
static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
{
if (vs->fidp->dir == NULL) {
@@ -1321,12 +1339,15 @@ out:
static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
{
+ int32_t iounit;
+
if (vs->fidp->fd == -1) {
err = -errno;
goto out;
}
- vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
+ iounit = get_iounit(s, &vs->fidp->path);
+ vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, iounit);
err = vs->offset;
out:
complete_pdu(s, vs->pdu, err);
@@ -1800,11 +1821,16 @@ out:
static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
{
+ int32_t iounit;
+
+ iounit = get_iounit(s, &vs->fidp->path);
+
if (err == 0) {
v9fs_string_copy(&vs->fidp->path, &vs->fullname);
stat_to_qid(&vs->stbuf, &vs->qid);
- vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
+ vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid,
+ iounit);
err = vs->offset;
}
@@ -2295,23 +2321,25 @@ out:
qemu_free(vs);
}
-static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
-{
- return s->ops->statfs(&s->ctx, path->data, stbuf);
-}
-
static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
{
+ int32_t bsize_factor;
+
if (err) {
err = -errno;
goto out;
}
+ bsize_factor = (s->msize - P9_IOHDRSZ)/vs->stbuf.f_bsize;
+ if (!bsize_factor) {
+ bsize_factor = 1;
+ }
vs->v9statfs.f_type = vs->stbuf.f_type;
vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
- vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
- vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
- vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
+ vs->v9statfs.f_bsize *= bsize_factor;
+ vs->v9statfs.f_blocks = vs->stbuf.f_blocks/bsize_factor;
+ vs->v9statfs.f_bfree = vs->stbuf.f_bfree/bsize_factor;
+ vs->v9statfs.f_bavail = vs->stbuf.f_bavail/bsize_factor;
vs->v9statfs.f_files = vs->stbuf.f_files;
vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
vs->v9statfs.fsid_val = (unsigned int) vs->stbuf.f_fsid.__val[0] |
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 6b3d4a4..9264163 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -72,6 +72,8 @@ enum p9_proto_version {
#define P9_NOFID (u32)(~0)
#define P9_MAXWELEM 16
+#define P9_IOHDRSZ 24
+
typedef struct V9fsPDU V9fsPDU;
struct V9fsPDU
@@ -156,6 +158,7 @@ typedef struct V9fsState
uint8_t *tag;
size_t config_size;
enum p9_proto_version proto_version;
+ int32_t msize;
} V9fsState;
typedef struct V9fsCreateState {
--
1.6.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write
2010-06-01 14:17 [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations M. Mohan Kumar
@ 2010-06-01 14:17 ` M. Mohan Kumar
2010-06-04 7:07 ` Sripathi Kodi
2010-06-02 11:47 ` [Qemu-devel] Re: [V9fs-developer] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations Aneesh Kumar K. V
2010-06-04 6:51 ` [Qemu-devel] " Sripathi Kodi
2 siblings, 1 reply; 6+ messages in thread
From: M. Mohan Kumar @ 2010-06-01 14:17 UTC (permalink / raw)
To: qemu-devel, v9fs-developer
Change the v9fs_file_readn function to limit the maximum transfer size
based on the iounit instead of 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>
---
fs/9p/vfs_file.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 25b300e..b8c0891 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -160,7 +160,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
offset += n;
count -= n;
total += n;
- } while (count > 0 && n == (fid->clnt->msize - P9_IOHDRSZ));
+ } while (count > 0 && n == fid->iounit);
if (n < 0)
total = n;
@@ -187,11 +187,7 @@ v9fs_file_read(struct file *filp, char __user *udata, size_t count,
P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset);
fid = filp->private_data;
- 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);
-
+ ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
if (ret > 0)
*offset += ret;
@@ -225,8 +221,6 @@ v9fs_file_write(struct file *filp, const char __user * data,
clnt = fid->clnt;
rsize = fid->iounit;
- if (!rsize || rsize > clnt->msize-P9_IOHDRSZ)
- rsize = clnt->msize - P9_IOHDRSZ;
do {
if (count < rsize)
--
1.6.6.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [V9fs-developer] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations
2010-06-01 14:17 [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations M. Mohan Kumar
2010-06-01 14:17 ` [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write M. Mohan Kumar
@ 2010-06-02 11:47 ` Aneesh Kumar K. V
2010-06-04 6:51 ` [Qemu-devel] " Sripathi Kodi
2 siblings, 0 replies; 6+ messages in thread
From: Aneesh Kumar K. V @ 2010-06-02 11:47 UTC (permalink / raw)
To: M. Mohan Kumar, qemu-devel, v9fs-developer
On Tue, 1 Jun 2010 19:47:14 +0530, "M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Compute iounit based on the host filesystem block size and pass it to
> client with open/create response. Also return iounit as statfs's f_bsize
> for optimal block size transfers.
>
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> ---
> hw/virtio-9p.c | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
> hw/virtio-9p.h | 3 +++
> 2 files changed, 45 insertions(+), 14 deletions(-)
>
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index f087122..4357f1f 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -1,4 +1,4 @@
> -/*
> + /*
why ?
> * Virtio 9p backend
> *
> * Copyright IBM, Corp. 2010
> @@ -269,6 +269,11 @@ static int v9fs_do_fsync(V9fsState *s, int fd)
> return s->ops->fsync(&s->ctx, fd);
> }
>
> +static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
> +{
> + return s->ops->statfs(&s->ctx, path->data, stbuf);
> +}
> +
> static void v9fs_string_init(V9fsString *str)
> {
> str->data = NULL;
> @@ -1035,11 +1040,10 @@ static void v9fs_fix_path(V9fsString *dst, V9fsString *src, int len)
>
> static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
> {
> - int32_t msize;
> V9fsString version;
> size_t offset = 7;
>
> - pdu_unmarshal(pdu, offset, "ds", &msize, &version);
> + pdu_unmarshal(pdu, offset, "ds", &s->msize, &version);
>
> if (!strcmp(version.data, "9P2000.u")) {
> s->proto_version = V9FS_PROTO_2000U;
> @@ -1049,7 +1053,7 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
> v9fs_string_sprintf(&version, "unknown");
> }
>
> - offset += pdu_marshal(pdu, offset, "ds", msize, &version);
> + offset += pdu_marshal(pdu, offset, "ds", s->msize, &version);
> complete_pdu(s, pdu, offset);
>
> v9fs_string_free(&version);
> @@ -1304,6 +1308,20 @@ out:
> v9fs_walk_complete(s, vs, err);
> }
>
> +static int32_t get_iounit(V9fsState *s, V9fsString *name)
> +{
> + struct statfs stbuf;
> + int32_t iounit = 0;
> +
> +
> + if (!v9fs_do_statfs(s, name, &stbuf)) {
> + iounit = stbuf.f_bsize;
> + iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize;
> + }
> +
Add a comment here explaining why we do the above math.
> + return iounit;
> +}
> +
> static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
> {
> if (vs->fidp->dir == NULL) {
> @@ -1321,12 +1339,15 @@ out:
>
> static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
> {
> + int32_t iounit;
> +
> if (vs->fidp->fd == -1) {
> err = -errno;
> goto out;
> }
>
> - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
> + iounit = get_iounit(s, &vs->fidp->path);
> + vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid,
> iounit);
We may later want to track this per exported mount point and to
get_iounit only once per exported mount point.
> err = vs->offset;
> out:
> complete_pdu(s, vs->pdu, err);
> @@ -1800,11 +1821,16 @@ out:
>
> static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
> {
> + int32_t iounit;
> +
> + iounit = get_iounit(s, &vs->fidp->path);
> +
> if (err == 0) {
> v9fs_string_copy(&vs->fidp->path, &vs->fullname);
> stat_to_qid(&vs->stbuf, &vs->qid);
>
> - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
> + vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid,
> + iounit);
>
> err = vs->offset;
> }
> @@ -2295,23 +2321,25 @@ out:
> qemu_free(vs);
> }
>
> -static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
> -{
> - return s->ops->statfs(&s->ctx, path->data, stbuf);
> -}
> -
> static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
> {
> + int32_t bsize_factor;
> +
> if (err) {
> err = -errno;
> goto out;
> }
>
> + bsize_factor = (s->msize - P9_IOHDRSZ)/vs->stbuf.f_bsize;
> + if (!bsize_factor) {
> + bsize_factor = 1;
> + }
> vs->v9statfs.f_type = vs->stbuf.f_type;
> vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
> - vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
> - vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
> - vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
> + vs->v9statfs.f_bsize *= bsize_factor;
> + vs->v9statfs.f_blocks = vs->stbuf.f_blocks/bsize_factor;
> + vs->v9statfs.f_bfree = vs->stbuf.f_bfree/bsize_factor;
> + vs->v9statfs.f_bavail = vs->stbuf.f_bavail/bsize_factor;
Add a comment around whey we are doing this.
> vs->v9statfs.f_files = vs->stbuf.f_files;
> vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
> vs->v9statfs.fsid_val = (unsigned int)
> vs->stbuf.f_fsid.__val[0] |
> diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
> index 6b3d4a4..9264163 100644
> --- a/hw/virtio-9p.h
> +++ b/hw/virtio-9p.h
> @@ -72,6 +72,8 @@ enum p9_proto_version {
> #define P9_NOFID (u32)(~0)
> #define P9_MAXWELEM 16
>
> +#define P9_IOHDRSZ 24
Add a comment how size 24 is arrived.
> +
> typedef struct V9fsPDU V9fsPDU;
>
> struct V9fsPDU
> @@ -156,6 +158,7 @@ typedef struct V9fsState
> uint8_t *tag;
> size_t config_size;
> enum p9_proto_version proto_version;
> + int32_t msize;
> } V9fsState;
>
> typedef struct V9fsCreateState {
> --
-aneesh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations
2010-06-01 14:17 [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations M. Mohan Kumar
2010-06-01 14:17 ` [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write M. Mohan Kumar
2010-06-02 11:47 ` [Qemu-devel] Re: [V9fs-developer] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations Aneesh Kumar K. V
@ 2010-06-04 6:51 ` Sripathi Kodi
2010-06-06 19:48 ` Venkateswararao Jujjuri (JV)
2 siblings, 1 reply; 6+ messages in thread
From: Sripathi Kodi @ 2010-06-04 6:51 UTC (permalink / raw)
To: M. Mohan Kumar; +Cc: v9fs-developer, qemu-devel
On Tue, 1 Jun 2010 19:47:14 +0530
"M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Compute iounit based on the host filesystem block size and pass it to
> client with open/create response. Also return iounit as statfs's f_bsize
> for optimal block size transfers.
>
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> ---
> hw/virtio-9p.c | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
> hw/virtio-9p.h | 3 +++
> 2 files changed, 45 insertions(+), 14 deletions(-)
>
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index f087122..4357f1f 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -1,4 +1,4 @@
> -/*
> + /*
> * Virtio 9p backend
> *
> * Copyright IBM, Corp. 2010
> @@ -269,6 +269,11 @@ static int v9fs_do_fsync(V9fsState *s, int fd)
> return s->ops->fsync(&s->ctx, fd);
> }
>
> +static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
> +{
> + return s->ops->statfs(&s->ctx, path->data, stbuf);
> +}
> +
> static void v9fs_string_init(V9fsString *str)
> {
> str->data = NULL;
> @@ -1035,11 +1040,10 @@ static void v9fs_fix_path(V9fsString *dst, V9fsString *src, int len)
>
> static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
> {
> - int32_t msize;
> V9fsString version;
> size_t offset = 7;
>
> - pdu_unmarshal(pdu, offset, "ds", &msize, &version);
> + pdu_unmarshal(pdu, offset, "ds", &s->msize, &version);
>
> if (!strcmp(version.data, "9P2000.u")) {
> s->proto_version = V9FS_PROTO_2000U;
> @@ -1049,7 +1053,7 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
> v9fs_string_sprintf(&version, "unknown");
> }
>
> - offset += pdu_marshal(pdu, offset, "ds", msize, &version);
> + offset += pdu_marshal(pdu, offset, "ds", s->msize, &version);
> complete_pdu(s, pdu, offset);
>
> v9fs_string_free(&version);
> @@ -1304,6 +1308,20 @@ out:
> v9fs_walk_complete(s, vs, err);
> }
>
> +static int32_t get_iounit(V9fsState *s, V9fsString *name)
> +{
> + struct statfs stbuf;
> + int32_t iounit = 0;
> +
> +
> + if (!v9fs_do_statfs(s, name, &stbuf)) {
> + iounit = stbuf.f_bsize;
> + iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize;
If (s->msize - P9_IOHDRSZ) is less than stbuf.f_bsize iounit becomes
zero. See below.
> + }
> +
> + return iounit;
> +}
> +
> static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
> {
> if (vs->fidp->dir == NULL) {
> @@ -1321,12 +1339,15 @@ out:
>
> static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
> {
> + int32_t iounit;
> +
> if (vs->fidp->fd == -1) {
> err = -errno;
> goto out;
> }
>
> - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
> + iounit = get_iounit(s, &vs->fidp->path);
> + vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, iounit);
> err = vs->offset;
> out:
> complete_pdu(s, vs->pdu, err);
> @@ -1800,11 +1821,16 @@ out:
>
> static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
> {
> + int32_t iounit;
> +
> + iounit = get_iounit(s, &vs->fidp->path);
> +
> if (err == 0) {
> v9fs_string_copy(&vs->fidp->path, &vs->fullname);
> stat_to_qid(&vs->stbuf, &vs->qid);
>
> - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
> + vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid,
> + iounit);
>
> err = vs->offset;
> }
> @@ -2295,23 +2321,25 @@ out:
> qemu_free(vs);
> }
>
> -static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
> -{
> - return s->ops->statfs(&s->ctx, path->data, stbuf);
> -}
> -
> static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
> {
> + int32_t bsize_factor;
> +
> if (err) {
> err = -errno;
> goto out;
> }
>
> + bsize_factor = (s->msize - P9_IOHDRSZ)/vs->stbuf.f_bsize;
> + if (!bsize_factor) {
> + bsize_factor = 1;
> + }
Again, if (s->msize - P9_IOHDRSZ) is less than stbuf.f_bsize
bsize_factor becomes zero. The following divisions become divide by
zero!
Thanks,
Sripathi.
> vs->v9statfs.f_type = vs->stbuf.f_type;
> vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
> - vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
> - vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
> - vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
> + vs->v9statfs.f_bsize *= bsize_factor;
> + vs->v9statfs.f_blocks = vs->stbuf.f_blocks/bsize_factor;
> + vs->v9statfs.f_bfree = vs->stbuf.f_bfree/bsize_factor;
> + vs->v9statfs.f_bavail = vs->stbuf.f_bavail/bsize_factor;
> vs->v9statfs.f_files = vs->stbuf.f_files;
> vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
> vs->v9statfs.fsid_val = (unsigned int) vs->stbuf.f_fsid.__val[0] |
> diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
> index 6b3d4a4..9264163 100644
> --- a/hw/virtio-9p.h
> +++ b/hw/virtio-9p.h
> @@ -72,6 +72,8 @@ enum p9_proto_version {
> #define P9_NOFID (u32)(~0)
> #define P9_MAXWELEM 16
>
> +#define P9_IOHDRSZ 24
> +
> typedef struct V9fsPDU V9fsPDU;
>
> struct V9fsPDU
> @@ -156,6 +158,7 @@ typedef struct V9fsState
> uint8_t *tag;
> size_t config_size;
> enum p9_proto_version proto_version;
> + int32_t msize;
> } V9fsState;
>
> typedef struct V9fsCreateState {
> --
> 1.6.6.1
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write
2010-06-01 14:17 ` [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write M. Mohan Kumar
@ 2010-06-04 7:07 ` Sripathi Kodi
0 siblings, 0 replies; 6+ messages in thread
From: Sripathi Kodi @ 2010-06-04 7:07 UTC (permalink / raw)
To: M. Mohan Kumar; +Cc: v9fs-developer, qemu-devel
On Tue, 1 Jun 2010 19:47:49 +0530
"M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Change the v9fs_file_readn function to limit the maximum transfer size
> based on the iounit instead of 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>
> ---
> fs/9p/vfs_file.c | 10 ++--------
> 1 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
> index 25b300e..b8c0891 100644
> --- a/fs/9p/vfs_file.c
> +++ b/fs/9p/vfs_file.c
> @@ -160,7 +160,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
> offset += n;
> count -= n;
> total += n;
> - } while (count > 0 && n == (fid->clnt->msize - P9_IOHDRSZ));
> + } while (count > 0 && n == fid->iounit);
If fid->iounit is zero this will go wrong. With the current version of
your server side patch, fid->iounit can be zero, right?
>
> if (n < 0)
> total = n;
> @@ -187,11 +187,7 @@ v9fs_file_read(struct file *filp, char __user *udata, size_t count,
> P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset);
> fid = filp->private_data;
>
> - 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);
> -
> + ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
> if (ret > 0)
> *offset += ret;
>
> @@ -225,8 +221,6 @@ v9fs_file_write(struct file *filp, const char __user * data,
> clnt = fid->clnt;
>
> rsize = fid->iounit;
> - if (!rsize || rsize > clnt->msize-P9_IOHDRSZ)
> - rsize = clnt->msize - P9_IOHDRSZ;
This will be needed if fid->iounit = 0
Thanks,
Sripathi.
>
> do {
> if (count < rsize)
> --
> 1.6.6.1
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations
2010-06-04 6:51 ` [Qemu-devel] " Sripathi Kodi
@ 2010-06-06 19:48 ` Venkateswararao Jujjuri (JV)
0 siblings, 0 replies; 6+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2010-06-06 19:48 UTC (permalink / raw)
To: Sripathi Kodi; +Cc: v9fs-developer, M. Mohan Kumar, qemu-devel
Sripathi Kodi wrote:
> On Tue, 1 Jun 2010 19:47:14 +0530
> "M. Mohan Kumar" <mohan@in.ibm.com> wrote:
>
>> Compute iounit based on the host filesystem block size and pass it to
>> client with open/create response. Also return iounit as statfs's f_bsize
>> for optimal block size transfers.
>>
>> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
>> ---
>> hw/virtio-9p.c | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
>> hw/virtio-9p.h | 3 +++
>> 2 files changed, 45 insertions(+), 14 deletions(-)
>>
>> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
>> index f087122..4357f1f 100644
>> --- a/hw/virtio-9p.c
>> +++ b/hw/virtio-9p.c
>> @@ -1,4 +1,4 @@
>> -/*
>> + /*
>> * Virtio 9p backend
>> *
>> * Copyright IBM, Corp. 2010
>> @@ -269,6 +269,11 @@ static int v9fs_do_fsync(V9fsState *s, int fd)
>> return s->ops->fsync(&s->ctx, fd);
>> }
>>
>> +static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
>> +{
>> + return s->ops->statfs(&s->ctx, path->data, stbuf);
>> +}
>> +
>> static void v9fs_string_init(V9fsString *str)
>> {
>> str->data = NULL;
>> @@ -1035,11 +1040,10 @@ static void v9fs_fix_path(V9fsString *dst, V9fsString *src, int len)
>>
>> static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
>> {
>> - int32_t msize;
>> V9fsString version;
>> size_t offset = 7;
>>
>> - pdu_unmarshal(pdu, offset, "ds", &msize, &version);
>> + pdu_unmarshal(pdu, offset, "ds", &s->msize, &version);
>>
>> if (!strcmp(version.data, "9P2000.u")) {
>> s->proto_version = V9FS_PROTO_2000U;
>> @@ -1049,7 +1053,7 @@ static void v9fs_version(V9fsState *s, V9fsPDU *pdu)
>> v9fs_string_sprintf(&version, "unknown");
>> }
>>
>> - offset += pdu_marshal(pdu, offset, "ds", msize, &version);
>> + offset += pdu_marshal(pdu, offset, "ds", s->msize, &version);
>> complete_pdu(s, pdu, offset);
>>
>> v9fs_string_free(&version);
>> @@ -1304,6 +1308,20 @@ out:
>> v9fs_walk_complete(s, vs, err);
>> }
>>
>> +static int32_t get_iounit(V9fsState *s, V9fsString *name)
>> +{
>> + struct statfs stbuf;
>> + int32_t iounit = 0;
>> +
>> +
>> + if (!v9fs_do_statfs(s, name, &stbuf)) {
>> + iounit = stbuf.f_bsize;
>> + iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize;
>
> If (s->msize - P9_IOHDRSZ) is less than stbuf.f_bsize iounit becomes
> zero. See below.
>
>> + }
>> +
>> + return iounit;
>> +}
>> +
>> static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
>> {
>> if (vs->fidp->dir == NULL) {
>> @@ -1321,12 +1339,15 @@ out:
>>
>> static void v9fs_open_post_open(V9fsState *s, V9fsOpenState *vs, int err)
>> {
>> + int32_t iounit;
>> +
>> if (vs->fidp->fd == -1) {
>> err = -errno;
>> goto out;
>> }
>>
>> - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
>> + iounit = get_iounit(s, &vs->fidp->path);
>> + vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, iounit);
>> err = vs->offset;
>> out:
>> complete_pdu(s, vs->pdu, err);
>> @@ -1800,11 +1821,16 @@ out:
>>
>> static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
>> {
>> + int32_t iounit;
>> +
>> + iounit = get_iounit(s, &vs->fidp->path);
>> +
>> if (err == 0) {
>> v9fs_string_copy(&vs->fidp->path, &vs->fullname);
>> stat_to_qid(&vs->stbuf, &vs->qid);
>>
>> - vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid, 0);
>> + vs->offset += pdu_marshal(vs->pdu, vs->offset, "Qd", &vs->qid,
>> + iounit);
>>
>> err = vs->offset;
>> }
>> @@ -2295,23 +2321,25 @@ out:
>> qemu_free(vs);
>> }
>>
>> -static int v9fs_do_statfs(V9fsState *s, V9fsString *path, struct statfs *stbuf)
>> -{
>> - return s->ops->statfs(&s->ctx, path->data, stbuf);
>> -}
>> -
>> static void v9fs_statfs_post_statfs(V9fsState *s, V9fsStatfsState *vs, int err)
>> {
>> + int32_t bsize_factor;
>> +
>> if (err) {
>> err = -errno;
>> goto out;
>> }
>>
>> + bsize_factor = (s->msize - P9_IOHDRSZ)/vs->stbuf.f_bsize;
>> + if (!bsize_factor) {
>> + bsize_factor = 1;
>> + }
>
> Again, if (s->msize - P9_IOHDRSZ) is less than stbuf.f_bsize
> bsize_factor becomes zero. The following divisions become divide by
> zero!
Yes, I think we should leave iounit alone return it with open/create and handle it
as per the 9P protocol..and return whatever the fileserver gives for stat and satatfs.
- JV
>
> Thanks,
> Sripathi.
>
>> vs->v9statfs.f_type = vs->stbuf.f_type;
>> vs->v9statfs.f_bsize = vs->stbuf.f_bsize;
>> - vs->v9statfs.f_blocks = vs->stbuf.f_blocks;
>> - vs->v9statfs.f_bfree = vs->stbuf.f_bfree;
>> - vs->v9statfs.f_bavail = vs->stbuf.f_bavail;
>> + vs->v9statfs.f_bsize *= bsize_factor;
>> + vs->v9statfs.f_blocks = vs->stbuf.f_blocks/bsize_factor;
>> + vs->v9statfs.f_bfree = vs->stbuf.f_bfree/bsize_factor;
>> + vs->v9statfs.f_bavail = vs->stbuf.f_bavail/bsize_factor;
>> vs->v9statfs.f_files = vs->stbuf.f_files;
>> vs->v9statfs.f_ffree = vs->stbuf.f_ffree;
>> vs->v9statfs.fsid_val = (unsigned int) vs->stbuf.f_fsid.__val[0] |
>> diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
>> index 6b3d4a4..9264163 100644
>> --- a/hw/virtio-9p.h
>> +++ b/hw/virtio-9p.h
>> @@ -72,6 +72,8 @@ enum p9_proto_version {
>> #define P9_NOFID (u32)(~0)
>> #define P9_MAXWELEM 16
>>
>> +#define P9_IOHDRSZ 24
>> +
>> typedef struct V9fsPDU V9fsPDU;
>>
>> struct V9fsPDU
>> @@ -156,6 +158,7 @@ typedef struct V9fsState
>> uint8_t *tag;
>> size_t config_size;
>> enum p9_proto_version proto_version;
>> + int32_t msize;
>> } V9fsState;
>>
>> typedef struct V9fsCreateState {
>> --
>> 1.6.6.1
>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-06 19:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-01 14:17 [Qemu-devel] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations M. Mohan Kumar
2010-06-01 14:17 ` [Qemu-devel] 9p: [RFC] [PATCH 02/02] Make use of iounit for read/write M. Mohan Kumar
2010-06-04 7:07 ` Sripathi Kodi
2010-06-02 11:47 ` [Qemu-devel] Re: [V9fs-developer] qemu:virtio-9p: [RFC] [PATCH 01/02] Send iounit to client for read/write operations Aneesh Kumar K. V
2010-06-04 6:51 ` [Qemu-devel] " Sripathi Kodi
2010-06-06 19:48 ` Venkateswararao Jujjuri (JV)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.