[sheepdog] [PATCH v3 2/3] sheep: make push_cache_object() queue a local gateway request
Yunkai Zhang
yunkai.me at gmail.com
Thu Jun 28 14:14:12 CEST 2012
On Wed, Jun 27, 2012 at 11:07 AM, levin li <levin108 at gmail.com> wrote:
> From: levin li <xingke.lwp at taobao.com>
>
> The same reason as write/read/remove_object(), push_cache_object()
> also needs a retrying machanism like gateway, so we also queue a
> local gateway request instead of directly calling forward_write_obj_req().
>
> Signed-off-by: levin li <xingke.lwp at taobao.com>
> ---
> sheep/gateway.c | 3 ++-
> sheep/object_cache.c | 24 ++++++++----------------
> 2 files changed, 10 insertions(+), 17 deletions(-)
>
> diff --git a/sheep/gateway.c b/sheep/gateway.c
> index 42f028a..18ab926 100644
> --- a/sheep/gateway.c
> +++ b/sheep/gateway.c
> @@ -216,7 +216,8 @@ void do_gateway_request(struct work *work)
> dprintf("%x, %" PRIx64" , %u\n",
> req->rq.opcode, req->rq.obj.oid, req->rq.epoch);
>
> - if (!sys->enable_write_cache || bypass_object_cache(req)) {
> + if (!sys->enable_write_cache || req->local ||
> + bypass_object_cache(req)) {
> if (req->rq.flags & SD_FLAG_CMD_WRITE)
> ret = forward_write_obj_req(req);
> else
> diff --git a/sheep/object_cache.c b/sheep/object_cache.c
> index 1854a77..e538cda 100644
> --- a/sheep/object_cache.c
> +++ b/sheep/object_cache.c
> @@ -552,8 +552,7 @@ static uint64_t idx_to_oid(uint32_t vid, uint32_t idx)
> static int push_cache_object(struct vnode_info *vnode_info, uint32_t vid,
> uint32_t idx, uint64_t bmap, int create)
> {
> - struct request fake_req;
> - struct sd_req *hdr = &fake_req.rq;
> + struct sd_req hdr;
> void *buf;
> off_t offset;
> unsigned data_length;
> @@ -568,8 +567,6 @@ static int push_cache_object(struct vnode_info *vnode_info, uint32_t vid,
> return SD_RES_SUCCESS;
> }
>
> - memset(&fake_req, 0, sizeof(fake_req));
> -
> first_bit = ffsll(bmap) - 1;
> last_bit = fls64(bmap) - 1;
>
> @@ -595,20 +592,15 @@ static int push_cache_object(struct vnode_info *vnode_info, uint32_t vid,
> if (ret != SD_RES_SUCCESS)
> goto out;
>
> - hdr->opcode = create ? SD_OP_CREATE_AND_WRITE_OBJ : SD_OP_WRITE_OBJ;
> - hdr->flags = SD_FLAG_CMD_WRITE;
> - hdr->data_length = data_length;
> - hdr->epoch = sys_epoch();
> -
> - hdr->obj.oid = oid;
> - hdr->obj.offset = offset;
> - hdr->obj.copies = sys->nr_copies;
> + memset(&hdr, 0, sizeof(hdr));
> + hdr.opcode = create ? SD_OP_CREATE_AND_WRITE_OBJ : SD_OP_WRITE_OBJ;
> + hdr.flags = SD_FLAG_CMD_WRITE;
>
> - fake_req.data = buf;
> - fake_req.op = get_sd_op(hdr->opcode);
> - fake_req.vnodes = vnode_info;
> + hdr.obj.oid = oid;
> + hdr.obj.offset = offset;
> + hdr.obj.copies = sys->nr_copies;
>
> - ret = forward_write_obj_req(&fake_req);
> + ret = exec_local_req(&hdr, buf, data_length);
sys->outstanding_data_size would be updated in alloc_local_request()
which was called in exec_local_req(), this will be a race.
> if (ret != SD_RES_SUCCESS)
> eprintf("failed to push object %x\n", ret);
>
> --
> 1.7.10
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog
--
Yunkai Zhang
Work at Taobao
More information about the sheepdog
mailing list