[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 5/9] sheepdog: reload inode outside of resend_aio
From: |
MORITA Kazutaka |
Subject: |
[Qemu-devel] [PATCH v2 5/9] sheepdog: reload inode outside of resend_aioreq |
Date: |
Wed, 24 Jul 2013 16:56:29 +0900 |
This prepares for using resend_aioreq() after reconnecting to the
sheepdog server.
Signed-off-by: MORITA Kazutaka <address@hidden>
---
block/sheepdog.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index f25c7df..cde887b 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -222,6 +222,11 @@ static inline uint64_t data_oid_to_idx(uint64_t oid)
return oid & (MAX_DATA_OBJS - 1);
}
+static inline uint32_t oid_to_vid(uint64_t oid)
+{
+ return (oid & ~VDI_BIT) >> VDI_SPACE_SHIFT;
+}
+
static inline uint64_t vid_to_vdi_oid(uint32_t vid)
{
return VDI_BIT | ((uint64_t)vid << VDI_SPACE_SHIFT);
@@ -607,7 +612,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState
*s, AIOReq *aio_req,
struct iovec *iov, int niov, bool create,
enum AIOCBState aiocb_type);
static int coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req);
-
+static int reload_inode(BDRVSheepdogState *s, uint32_t snapid, const char
*tag);
static AIOReq *find_pending_req(BDRVSheepdogState *s, uint64_t oid)
{
@@ -755,6 +760,19 @@ static void coroutine_fn aio_read_response(void *opaque)
case SD_RES_SUCCESS:
break;
case SD_RES_READONLY:
+ if (s->inode.vdi_id == oid_to_vid(aio_req->oid)) {
+ ret = reload_inode(s, 0, "");
+ if (ret < 0) {
+ goto out;
+ }
+ }
+
+ if (is_data_obj(aio_req->oid)) {
+ aio_req->oid = vid_to_data_oid(s->inode.vdi_id,
+ data_oid_to_idx(aio_req->oid));
+ } else {
+ aio_req->oid = vid_to_vdi_oid(s->inode.vdi_id);
+ }
ret = resend_aioreq(s, aio_req);
if (ret == SD_RES_SUCCESS) {
goto out;
@@ -1202,19 +1220,6 @@ static int coroutine_fn resend_aioreq(BDRVSheepdogState
*s, AIOReq *aio_req)
{
SheepdogAIOCB *acb = aio_req->aiocb;
bool create = false;
- int ret;
-
- ret = reload_inode(s, 0, "");
- if (ret < 0) {
- return ret;
- }
-
- if (is_data_obj(aio_req->oid)) {
- aio_req->oid = vid_to_data_oid(s->inode.vdi_id,
- data_oid_to_idx(aio_req->oid));
- } else {
- aio_req->oid = vid_to_vdi_oid(s->inode.vdi_id);
- }
/* check whether this request becomes a CoW one */
if (acb->aiocb_type == AIOCB_WRITE_UDATA && is_data_obj(aio_req->oid)) {
--
1.8.1.3.566.gaa39828
- [Qemu-devel] [PATCH v2 0/9] sheepdog: reconnect server after connection failure, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 4/9] sheepdog: handle vdi objects in resend_aio_req, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 2/9] iov: handle EOF in iov_send_recv, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 1/9] ignore SIGPIPE in qemu-img and qemu-io, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 3/9] sheepdog: check return values of qemu_co_recv/send correctly, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 7/9] sheepdog: try to reconnect to sheepdog after network error, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 5/9] sheepdog: reload inode outside of resend_aioreq,
MORITA Kazutaka <=
- [Qemu-devel] [PATCH v2 6/9] coroutine: add co_aio_sleep_ns() to allow sleep in block drivers, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 8/9] sheepdog: make add_aio_request and send_aioreq void functions, MORITA Kazutaka, 2013/07/24
- [Qemu-devel] [PATCH v2 9/9] sheepdog: cancel aio requests if possible, MORITA Kazutaka, 2013/07/24
- Re: [Qemu-devel] [sheepdog] [PATCH v2 0/9] sheepdog: reconnect server after connection failure, Liu Yuan, 2013/07/24
- Re: [Qemu-devel] [sheepdog] [PATCH v2 0/9] sheepdog: reconnect server after connection failure, MORITA Kazutaka, 2013/07/24
- Re: [Qemu-devel] [sheepdog] [PATCH v2 0/9] sheepdog: reconnect server after connection failure, Liu Yuan, 2013/07/24
- Re: [Qemu-devel] [sheepdog] [PATCH v2 0/9] sheepdog: reconnect server after connection failure, Liu Yuan, 2013/07/24
- Re: [Qemu-devel] [PATCH v2 0/9] sheepdog: reconnect server after connection failure, Liu Yuan, 2013/07/25
- [Qemu-devel] [PATCH 1/2] sheepdog: correct signedness of comparison, Liu Yuan, 2013/07/25
- [Qemu-devel] [PATCH 2/2] sheepdog: put aio request into failed list when failing to send request, Liu Yuan, 2013/07/25