* [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache
@ 2013-01-14 6:01 Liu Yuan
2013-01-14 6:01 ` [Qemu-devel] [PATCH 2/2] sheepdog: clean up sd_aio_setup() Liu Yuan
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Liu Yuan @ 2013-01-14 6:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, MORITA Kazutaka
From: Liu Yuan <tailai.ly@taobao.com>
This will reduce sockfds connected to the sheep server to one, which simply the
future hacks.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
block/sheepdog.c | 64 +++++++++++++++++++++++-------------------------------
1 file changed, 27 insertions(+), 37 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 462c4b2..4e38670 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -266,6 +266,7 @@ typedef struct AIOReq {
enum AIOCBState {
AIOCB_WRITE_UDATA,
AIOCB_READ_UDATA,
+ AIOCB_FLUSH_CACHE,
};
struct SheepdogAIOCB {
@@ -299,7 +300,6 @@ typedef struct BDRVSheepdogState {
char *addr;
char *port;
int fd;
- int flush_fd;
CoMutex lock;
Coroutine *co_send;
@@ -736,6 +736,13 @@ static void coroutine_fn aio_read_response(void *opaque)
goto out;
}
break;
+ case AIOCB_FLUSH_CACHE:
+ if (rsp.result == SD_RES_INVALID_PARMS) {
+ dprintf("disable cache since the server doesn't support it\n");
+ s->cache_flags = SD_FLAG_CMD_DIRECT;
+ rsp.result = SD_RES_SUCCESS;
+ }
+ break;
}
if (rsp.result != SD_RES_SUCCESS) {
@@ -964,7 +971,10 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
memset(&hdr, 0, sizeof(hdr));
- if (aiocb_type == AIOCB_READ_UDATA) {
+ if (aiocb_type == AIOCB_FLUSH_CACHE) {
+ wlen = 0;
+ hdr.opcode = SD_OP_FLUSH_VDI;
+ } else if (aiocb_type == AIOCB_READ_UDATA) {
wlen = 0;
hdr.opcode = SD_OP_READ_OBJ;
hdr.flags = flags;
@@ -1127,15 +1137,6 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
s->cache_flags = SD_FLAG_CMD_DIRECT;
}
- if (s->cache_flags == SD_FLAG_CMD_CACHE) {
- s->flush_fd = connect_to_sdog(s->addr, s->port);
- if (s->flush_fd < 0) {
- error_report("failed to connect");
- ret = s->flush_fd;
- goto out;
- }
- }
-
if (snapid || tag[0] != '\0') {
dprintf("%" PRIx32 " snapshot inode was open.\n", vid);
s->is_snapshot = true;
@@ -1397,9 +1398,6 @@ static void sd_close(BlockDriverState *bs)
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL);
closesocket(s->fd);
- if (s->cache_flags) {
- closesocket(s->flush_fd);
- }
g_free(s->addr);
}
@@ -1711,39 +1709,31 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
{
BDRVSheepdogState *s = bs->opaque;
- SheepdogObjReq hdr = { 0 };
- SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;
- SheepdogInode *inode = &s->inode;
+ SheepdogAIOCB *acb;
+ AIOReq *aio_req;
int ret;
- unsigned int wlen = 0, rlen = 0;
if (s->cache_flags != SD_FLAG_CMD_CACHE) {
return 0;
}
- hdr.opcode = SD_OP_FLUSH_VDI;
- hdr.oid = vid_to_vdi_oid(inode->vdi_id);
+ acb = sd_aio_setup(bs, NULL, 0, 0, NULL, NULL);
+ acb->aiocb_type = AIOCB_FLUSH_CACHE;
+ acb->aio_done_func = sd_finish_aiocb;
- ret = do_req(s->flush_fd, (SheepdogReq *)&hdr, NULL, &wlen, &rlen);
- if (ret) {
- error_report("failed to send a request to the sheep");
+ aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
+ 0, 0, 0, 0, 0);
+ QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
+ ret = add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type);
+ if (ret < 0) {
+ error_report("add_aio_request is failed");
+ free_aio_req(s, aio_req);
+ qemu_aio_release(acb);
return ret;
}
- if (rsp->result == SD_RES_INVALID_PARMS) {
- dprintf("disable write cache since the server doesn't support it\n");
-
- s->cache_flags = SD_FLAG_CMD_DIRECT;
- closesocket(s->flush_fd);
- return 0;
- }
-
- if (rsp->result != SD_RES_SUCCESS) {
- error_report("%s", sd_strerror(rsp->result));
- return -EIO;
- }
-
- return 0;
+ qemu_coroutine_yield();
+ return acb->ret;
}
static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 2/2] sheepdog: clean up sd_aio_setup()
2013-01-14 6:01 [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Liu Yuan
@ 2013-01-14 6:01 ` Liu Yuan
2013-01-15 7:21 ` [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Stefan Hajnoczi
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Liu Yuan @ 2013-01-14 6:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, MORITA Kazutaka
From: Liu Yuan <tailai.ly@taobao.com>
The last two parameters of sd_aio_setup() are never used, so remove them.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
block/sheepdog.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 4e38670..db33f58 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -427,12 +427,11 @@ static const AIOCBInfo sd_aiocb_info = {
};
static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov,
- int64_t sector_num, int nb_sectors,
- BlockDriverCompletionFunc *cb, void *opaque)
+ int64_t sector_num, int nb_sectors)
{
SheepdogAIOCB *acb;
- acb = qemu_aio_get(&sd_aiocb_info, bs, cb, opaque);
+ acb = qemu_aio_get(&sd_aiocb_info, bs, NULL, NULL);
acb->qiov = qiov;
@@ -1670,7 +1669,7 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
bs->total_sectors = sector_num + nb_sectors;
}
- acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors, NULL, NULL);
+ acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
acb->aio_done_func = sd_write_done;
acb->aiocb_type = AIOCB_WRITE_UDATA;
@@ -1691,7 +1690,7 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
SheepdogAIOCB *acb;
int ret;
- acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors, NULL, NULL);
+ acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
acb->aiocb_type = AIOCB_READ_UDATA;
acb->aio_done_func = sd_finish_aiocb;
@@ -1717,7 +1716,7 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
return 0;
}
- acb = sd_aio_setup(bs, NULL, 0, 0, NULL, NULL);
+ acb = sd_aio_setup(bs, NULL, 0, 0);
acb->aiocb_type = AIOCB_FLUSH_CACHE;
acb->aio_done_func = sd_finish_aiocb;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache
2013-01-14 6:01 [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Liu Yuan
2013-01-14 6:01 ` [Qemu-devel] [PATCH 2/2] sheepdog: clean up sd_aio_setup() Liu Yuan
@ 2013-01-15 7:21 ` Stefan Hajnoczi
2013-01-15 8:15 ` MORITA Kazutaka
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2013-01-15 7:21 UTC (permalink / raw)
To: Liu Yuan; +Cc: Kevin Wolf, MORITA Kazutaka, qemu-devel, Stefan Hajnoczi
On Mon, Jan 14, 2013 at 02:01:02PM +0800, Liu Yuan wrote:
> From: Liu Yuan <tailai.ly@taobao.com>
>
> This will reduce sockfds connected to the sheep server to one, which simply the
> future hacks.
>
> Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
> ---
> block/sheepdog.c | 64 +++++++++++++++++++++++-------------------------------
> 1 file changed, 27 insertions(+), 37 deletions(-)
This series looks fine to me but I'd like to give Kazutaka a chance to
review.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache
2013-01-14 6:01 [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Liu Yuan
2013-01-14 6:01 ` [Qemu-devel] [PATCH 2/2] sheepdog: clean up sd_aio_setup() Liu Yuan
2013-01-15 7:21 ` [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Stefan Hajnoczi
@ 2013-01-15 8:15 ` MORITA Kazutaka
2013-01-15 8:21 ` [Qemu-devel] [PATCH v2] " Liu Yuan
2013-01-15 8:28 ` [Qemu-devel] [PATCH v3] " Liu Yuan
4 siblings, 0 replies; 9+ messages in thread
From: MORITA Kazutaka @ 2013-01-15 8:15 UTC (permalink / raw)
To: Liu Yuan; +Cc: Kevin Wolf, MORITA Kazutaka, qemu-devel, Stefan Hajnoczi
At Mon, 14 Jan 2013 14:01:02 +0800,
Liu Yuan wrote:
>
> @@ -964,7 +971,10 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
>
> memset(&hdr, 0, sizeof(hdr));
>
> - if (aiocb_type == AIOCB_READ_UDATA) {
> + if (aiocb_type == AIOCB_FLUSH_CACHE) {
> + wlen = 0;
> + hdr.opcode = SD_OP_FLUSH_VDI;
> + } else if (aiocb_type == AIOCB_READ_UDATA) {
> wlen = 0;
> hdr.opcode = SD_OP_READ_OBJ;
> hdr.flags = flags;
I think it's better to use a switch statement here.
The other parts look good to me.
Thanks,
Kazutaka
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v2] sheepdog: multiplex the rw FD to flush cache
2013-01-14 6:01 [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Liu Yuan
` (2 preceding siblings ...)
2013-01-15 8:15 ` MORITA Kazutaka
@ 2013-01-15 8:21 ` Liu Yuan
2013-01-15 8:28 ` [Qemu-devel] [PATCH v3] " Liu Yuan
4 siblings, 0 replies; 9+ messages in thread
From: Liu Yuan @ 2013-01-15 8:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, MORITA Kazutaka
From: Liu Yuan <tailai.ly@taobao.com>
This will reduce sockfds connected to the sheep server to one, which simply the
future hacks.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
v2: use switch case in add_aio_request
block/sheepdog.c | 86 ++++++++++++++++++++++++++----------------------------
1 file changed, 41 insertions(+), 45 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 462c4b2..3caa872 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -266,6 +266,7 @@ typedef struct AIOReq {
enum AIOCBState {
AIOCB_WRITE_UDATA,
AIOCB_READ_UDATA,
+ AIOCB_FLUSH_CACHE,
};
struct SheepdogAIOCB {
@@ -299,7 +300,6 @@ typedef struct BDRVSheepdogState {
char *addr;
char *port;
int fd;
- int flush_fd;
CoMutex lock;
Coroutine *co_send;
@@ -736,6 +736,13 @@ static void coroutine_fn aio_read_response(void *opaque)
goto out;
}
break;
+ case AIOCB_FLUSH_CACHE:
+ if (rsp.result == SD_RES_INVALID_PARMS) {
+ dprintf("disable cache since the server doesn't support it\n");
+ s->cache_flags = SD_FLAG_CMD_DIRECT;
+ rsp.result = SD_RES_SUCCESS;
+ }
+ break;
}
if (rsp.result != SD_RES_SUCCESS) {
@@ -964,18 +971,27 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
memset(&hdr, 0, sizeof(hdr));
- if (aiocb_type == AIOCB_READ_UDATA) {
+ switch (aiocb_type) {
+ case AIOCB_FLUSH_CACHE:
+ wlen = 0;
+ hdr.opcode = SD_OP_FLUSH_VDI;
+ break;
+ case AIOCB_READ_UDATA:
wlen = 0;
hdr.opcode = SD_OP_READ_OBJ;
hdr.flags = flags;
- } else if (create) {
- wlen = datalen;
- hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
- hdr.flags = SD_FLAG_CMD_WRITE | flags;
- } else {
- wlen = datalen;
- hdr.opcode = SD_OP_WRITE_OBJ;
- hdr.flags = SD_FLAG_CMD_WRITE | flags;
+ break;
+ case AIOCB_WRITE_UDATA:
+ if (create) {
+ wlen = datalen;
+ hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
+ hdr.flags = SD_FLAG_CMD_WRITE | flags;
+ } else {
+ wlen = datalen;
+ hdr.opcode = SD_OP_WRITE_OBJ;
+ hdr.flags = SD_FLAG_CMD_WRITE | flags;
+ }
+ break;
}
if (s->cache_flags) {
@@ -1127,15 +1143,6 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
s->cache_flags = SD_FLAG_CMD_DIRECT;
}
- if (s->cache_flags == SD_FLAG_CMD_CACHE) {
- s->flush_fd = connect_to_sdog(s->addr, s->port);
- if (s->flush_fd < 0) {
- error_report("failed to connect");
- ret = s->flush_fd;
- goto out;
- }
- }
-
if (snapid || tag[0] != '\0') {
dprintf("%" PRIx32 " snapshot inode was open.\n", vid);
s->is_snapshot = true;
@@ -1397,9 +1404,6 @@ static void sd_close(BlockDriverState *bs)
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL);
closesocket(s->fd);
- if (s->cache_flags) {
- closesocket(s->flush_fd);
- }
g_free(s->addr);
}
@@ -1711,39 +1715,31 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
{
BDRVSheepdogState *s = bs->opaque;
- SheepdogObjReq hdr = { 0 };
- SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;
- SheepdogInode *inode = &s->inode;
+ SheepdogAIOCB *acb;
+ AIOReq *aio_req;
int ret;
- unsigned int wlen = 0, rlen = 0;
if (s->cache_flags != SD_FLAG_CMD_CACHE) {
return 0;
}
- hdr.opcode = SD_OP_FLUSH_VDI;
- hdr.oid = vid_to_vdi_oid(inode->vdi_id);
+ acb = sd_aio_setup(bs, NULL, 0, 0, NULL, NULL);
+ acb->aiocb_type = AIOCB_FLUSH_CACHE;
+ acb->aio_done_func = sd_finish_aiocb;
- ret = do_req(s->flush_fd, (SheepdogReq *)&hdr, NULL, &wlen, &rlen);
- if (ret) {
- error_report("failed to send a request to the sheep");
+ aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
+ 0, 0, 0, 0, 0);
+ QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
+ ret = add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type);
+ if (ret < 0) {
+ error_report("add_aio_request is failed");
+ free_aio_req(s, aio_req);
+ qemu_aio_release(acb);
return ret;
}
- if (rsp->result == SD_RES_INVALID_PARMS) {
- dprintf("disable write cache since the server doesn't support it\n");
-
- s->cache_flags = SD_FLAG_CMD_DIRECT;
- closesocket(s->flush_fd);
- return 0;
- }
-
- if (rsp->result != SD_RES_SUCCESS) {
- error_report("%s", sd_strerror(rsp->result));
- return -EIO;
- }
-
- return 0;
+ qemu_coroutine_yield();
+ return acb->ret;
}
static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3] sheepdog: multiplex the rw FD to flush cache
2013-01-14 6:01 [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Liu Yuan
` (3 preceding siblings ...)
2013-01-15 8:21 ` [Qemu-devel] [PATCH v2] " Liu Yuan
@ 2013-01-15 8:28 ` Liu Yuan
2013-01-15 10:20 ` Stefan Hajnoczi
4 siblings, 1 reply; 9+ messages in thread
From: Liu Yuan @ 2013-01-15 8:28 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, MORITA Kazutaka
From: Liu Yuan <tailai.ly@taobao.com>
This will reduce sockfds connected to the sheep server to one, which simply the
future hacks.
Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
v3: fix gcc warning in add_aio_request()
block/sheepdog.c | 82 ++++++++++++++++++++++++------------------------------
1 file changed, 37 insertions(+), 45 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 462c4b2..1cbfe53 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -266,6 +266,7 @@ typedef struct AIOReq {
enum AIOCBState {
AIOCB_WRITE_UDATA,
AIOCB_READ_UDATA,
+ AIOCB_FLUSH_CACHE,
};
struct SheepdogAIOCB {
@@ -299,7 +300,6 @@ typedef struct BDRVSheepdogState {
char *addr;
char *port;
int fd;
- int flush_fd;
CoMutex lock;
Coroutine *co_send;
@@ -736,6 +736,13 @@ static void coroutine_fn aio_read_response(void *opaque)
goto out;
}
break;
+ case AIOCB_FLUSH_CACHE:
+ if (rsp.result == SD_RES_INVALID_PARMS) {
+ dprintf("disable cache since the server doesn't support it\n");
+ s->cache_flags = SD_FLAG_CMD_DIRECT;
+ rsp.result = SD_RES_SUCCESS;
+ }
+ break;
}
if (rsp.result != SD_RES_SUCCESS) {
@@ -950,7 +957,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
{
int nr_copies = s->inode.nr_copies;
SheepdogObjReq hdr;
- unsigned int wlen;
+ unsigned int wlen = 0;
int ret;
uint64_t oid = aio_req->oid;
unsigned int datalen = aio_req->data_len;
@@ -964,18 +971,23 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
memset(&hdr, 0, sizeof(hdr));
- if (aiocb_type == AIOCB_READ_UDATA) {
- wlen = 0;
+ switch (aiocb_type) {
+ case AIOCB_FLUSH_CACHE:
+ hdr.opcode = SD_OP_FLUSH_VDI;
+ break;
+ case AIOCB_READ_UDATA:
hdr.opcode = SD_OP_READ_OBJ;
hdr.flags = flags;
- } else if (create) {
- wlen = datalen;
- hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
- hdr.flags = SD_FLAG_CMD_WRITE | flags;
- } else {
+ break;
+ case AIOCB_WRITE_UDATA:
+ if (create) {
+ hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ;
+ } else {
+ hdr.opcode = SD_OP_WRITE_OBJ;
+ }
wlen = datalen;
- hdr.opcode = SD_OP_WRITE_OBJ;
hdr.flags = SD_FLAG_CMD_WRITE | flags;
+ break;
}
if (s->cache_flags) {
@@ -1127,15 +1139,6 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
s->cache_flags = SD_FLAG_CMD_DIRECT;
}
- if (s->cache_flags == SD_FLAG_CMD_CACHE) {
- s->flush_fd = connect_to_sdog(s->addr, s->port);
- if (s->flush_fd < 0) {
- error_report("failed to connect");
- ret = s->flush_fd;
- goto out;
- }
- }
-
if (snapid || tag[0] != '\0') {
dprintf("%" PRIx32 " snapshot inode was open.\n", vid);
s->is_snapshot = true;
@@ -1397,9 +1400,6 @@ static void sd_close(BlockDriverState *bs)
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL);
closesocket(s->fd);
- if (s->cache_flags) {
- closesocket(s->flush_fd);
- }
g_free(s->addr);
}
@@ -1711,39 +1711,31 @@ static coroutine_fn int sd_co_readv(BlockDriverState *bs, int64_t sector_num,
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
{
BDRVSheepdogState *s = bs->opaque;
- SheepdogObjReq hdr = { 0 };
- SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr;
- SheepdogInode *inode = &s->inode;
+ SheepdogAIOCB *acb;
+ AIOReq *aio_req;
int ret;
- unsigned int wlen = 0, rlen = 0;
if (s->cache_flags != SD_FLAG_CMD_CACHE) {
return 0;
}
- hdr.opcode = SD_OP_FLUSH_VDI;
- hdr.oid = vid_to_vdi_oid(inode->vdi_id);
+ acb = sd_aio_setup(bs, NULL, 0, 0, NULL, NULL);
+ acb->aiocb_type = AIOCB_FLUSH_CACHE;
+ acb->aio_done_func = sd_finish_aiocb;
- ret = do_req(s->flush_fd, (SheepdogReq *)&hdr, NULL, &wlen, &rlen);
- if (ret) {
- error_report("failed to send a request to the sheep");
+ aio_req = alloc_aio_req(s, acb, vid_to_vdi_oid(s->inode.vdi_id),
+ 0, 0, 0, 0, 0);
+ QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
+ ret = add_aio_request(s, aio_req, NULL, 0, false, acb->aiocb_type);
+ if (ret < 0) {
+ error_report("add_aio_request is failed");
+ free_aio_req(s, aio_req);
+ qemu_aio_release(acb);
return ret;
}
- if (rsp->result == SD_RES_INVALID_PARMS) {
- dprintf("disable write cache since the server doesn't support it\n");
-
- s->cache_flags = SD_FLAG_CMD_DIRECT;
- closesocket(s->flush_fd);
- return 0;
- }
-
- if (rsp->result != SD_RES_SUCCESS) {
- error_report("%s", sd_strerror(rsp->result));
- return -EIO;
- }
-
- return 0;
+ qemu_coroutine_yield();
+ return acb->ret;
}
static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3] sheepdog: multiplex the rw FD to flush cache
2013-01-15 8:28 ` [Qemu-devel] [PATCH v3] " Liu Yuan
@ 2013-01-15 10:20 ` Stefan Hajnoczi
2013-01-15 10:28 ` Liu Yuan
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Hajnoczi @ 2013-01-15 10:20 UTC (permalink / raw)
To: Liu Yuan; +Cc: Kevin Wolf, qemu-devel, MORITA Kazutaka
On Tue, Jan 15, 2013 at 04:28:55PM +0800, Liu Yuan wrote:
> From: Liu Yuan <tailai.ly@taobao.com>
>
> This will reduce sockfds connected to the sheep server to one, which simply the
> future hacks.
>
> Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
> ---
> v3: fix gcc warning in add_aio_request()
>
> block/sheepdog.c | 82 ++++++++++++++++++++++++------------------------------
> 1 file changed, 37 insertions(+), 45 deletions(-)
Please remember to run scripts/checkpatch.pl before posting patches. I
fixed up a tab character that snuck into this patch.
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3] sheepdog: multiplex the rw FD to flush cache
2013-01-15 10:20 ` Stefan Hajnoczi
@ 2013-01-15 10:28 ` Liu Yuan
2013-01-15 12:43 ` Stefan Hajnoczi
0 siblings, 1 reply; 9+ messages in thread
From: Liu Yuan @ 2013-01-15 10:28 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel, MORITA Kazutaka
On 01/15/2013 06:20 PM, Stefan Hajnoczi wrote:
> Please remember to run scripts/checkpatch.pl before posting patches. I
> fixed up a tab character that snuck into this patch.
>
Ah, Okay, it was in a hasty.
> Thanks, applied to my block tree:
> https://github.com/stefanha/qemu/commits/block
Seems that lost Patch 2/2?
Thanks,
Yuan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3] sheepdog: multiplex the rw FD to flush cache
2013-01-15 10:28 ` Liu Yuan
@ 2013-01-15 12:43 ` Stefan Hajnoczi
0 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2013-01-15 12:43 UTC (permalink / raw)
To: Liu Yuan; +Cc: Kevin Wolf, qemu-devel, MORITA Kazutaka
On Tue, Jan 15, 2013 at 06:28:24PM +0800, Liu Yuan wrote:
> On 01/15/2013 06:20 PM, Stefan Hajnoczi wrote:
> > Please remember to run scripts/checkpatch.pl before posting patches. I
> > fixed up a tab character that snuck into this patch.
> >
>
> Ah, Okay, it was in a hasty.
>
> > Thanks, applied to my block tree:
> > https://github.com/stefanha/qemu/commits/block
>
> Seems that lost Patch 2/2?
Thanks for pointing this out, 2/2 is now merged.
I suggest sending patch series with a cover letter in the future.
Resend the whole vN+1 series when you make a change. This reduces the
chance that I or other maintainers miss patches.
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-01-15 12:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-14 6:01 [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Liu Yuan
2013-01-14 6:01 ` [Qemu-devel] [PATCH 2/2] sheepdog: clean up sd_aio_setup() Liu Yuan
2013-01-15 7:21 ` [Qemu-devel] [PATCH 1/2] sheepdog: multiplex the rw FD to flush cache Stefan Hajnoczi
2013-01-15 8:15 ` MORITA Kazutaka
2013-01-15 8:21 ` [Qemu-devel] [PATCH v2] " Liu Yuan
2013-01-15 8:28 ` [Qemu-devel] [PATCH v3] " Liu Yuan
2013-01-15 10:20 ` Stefan Hajnoczi
2013-01-15 10:28 ` Liu Yuan
2013-01-15 12:43 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).