[Sheepdog] [PATCH v2 3/3] sheep: use do_process_work() to handle io request
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Tue Nov 22 07:51:36 CET 2011
At Mon, 21 Nov 2011 20:11:23 +0800,
Liu Yuan wrote:
>
> From: Liu Yuan <tailai.ly at taobao.com>
>
> Since we already have a low level framework to handle requests, let's use
> it to handle io requests too.
>
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
> sheep/ops.c | 4 +++
> sheep/sheep_priv.h | 5 ++++
> sheep/store.c | 63 ++++++++++++++++++++++++---------------------------
> 3 files changed, 39 insertions(+), 33 deletions(-)
>
> diff --git a/sheep/ops.c b/sheep/ops.c
> index 9287c71..fd836c1 100644
> --- a/sheep/ops.c
> +++ b/sheep/ops.c
> @@ -476,18 +476,22 @@ static struct sd_op_template sd_ops[] = {
> /* I/O operations */
> [SD_OP_CREATE_AND_WRITE_OBJ] = {
> .type = SD_OP_TYPE_IO,
> + .process_work = store_create_and_write_obj,
> },
>
> [SD_OP_READ_OBJ] = {
> .type = SD_OP_TYPE_IO,
> + .process_work = store_read_obj,
> },
>
> [SD_OP_WRITE_OBJ] = {
> .type = SD_OP_TYPE_IO,
> + .process_work = store_write_obj,
> },
>
> [SD_OP_REMOVE_OBJ] = {
> .type = SD_OP_TYPE_IO,
> + .process_work = store_remove_obj,
> },
> };
>
> diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
> index cfc497d..618267e 100644
> --- a/sheep/sheep_priv.h
> +++ b/sheep/sheep_priv.h
> @@ -233,6 +233,11 @@ int get_cluster_copies(uint8_t *copies);
> int set_cluster_flags(uint16_t flags);
> int get_cluster_flags(uint16_t *flags);
>
> +int store_create_and_write_obj(const struct sd_req *, struct sd_rsp *, void *);
> +int store_write_obj(const struct sd_req *, struct sd_rsp *, void *);
> +int store_read_obj(const struct sd_req *, struct sd_rsp *, void *);
> +int store_remove_obj(const struct sd_req *, struct sd_rsp *, void *);
> +
> #define NR_GW_WORKER_THREAD 4
> #define NR_IO_WORKER_THREAD 4
>
> diff --git a/sheep/store.c b/sheep/store.c
> index bcb97ba..9c2739f 100644
> --- a/sheep/store.c
> +++ b/sheep/store.c
> @@ -491,6 +491,7 @@ int write_object_local(uint64_t oid, char *data, unsigned int datalen,
> hdr->offset = offset;
> hdr->data_length = datalen;
> req->data = data;
> + req->op = get_sd_op(hdr->opcode);
>
> ret = do_local_io(req, epoch);
>
> @@ -521,6 +522,7 @@ int read_object_local(uint64_t oid, char *data, unsigned int datalen,
> hdr->offset = offset;
> hdr->data_length = datalen;
> req->data = data;
> + req->op = get_sd_op(hdr->opcode);
>
> ret = do_local_io(req, epoch);
>
We need to set req->op in fix_object_recovery(), too:
- store.c:726
Set get_sd_op(SD_OP_READ_OBJ) before calling do_cluster_read()
- store.c:735
Set get_sd_op(SD_OP_WRITE_OBJ) before calling do_cluster_write()
- store.c:743
Recover the original req->op before exiting fix_object_recovery().
Thanks,
Kazutaka
More information about the sheepdog
mailing list