[sheepdog] [PATCH 08/10] sheep: set SD_FLAG_CMD_WRITE in sd_init_req
Liu Yuan
namei.unix at gmail.com
Wed Oct 16 05:34:35 CEST 2013
On Wed, Oct 16, 2013 at 03:17:06AM +0900, MORITA Kazutaka wrote:
> At Tue, 15 Oct 2013 22:36:41 +0800,
> Liu Yuan wrote:
> >
> > It is easy to forget to set SD_FLAG_CMD_WRITE for write and create and hard
> > to debug, so set it directly in sd_init_req().
> >
> > Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> > ---
> > dog/common.c | 1 -
> > include/sheep.h | 2 ++
> > sheep/gateway.c | 1 -
> > sheep/object_cache.c | 3 ---
> > sheep/store.c | 3 ---
> > 5 files changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/dog/common.c b/dog/common.c
> > index a2fb945..b70080e 100644
> > --- a/dog/common.c
> > +++ b/dog/common.c
> > @@ -100,7 +100,6 @@ int sd_write_object(uint64_t oid, uint64_t cow_oid, void *data,
> > sd_init_req(&hdr, SD_OP_WRITE_OBJ);
> >
> > hdr.data_length = datalen;
> > - hdr.flags = flags | SD_FLAG_CMD_WRITE;
> > if (cow_oid)
> > hdr.flags |= SD_FLAG_CMD_COW;
> > if (direct)
> > diff --git a/include/sheep.h b/include/sheep.h
> > index 293e057..f93026f 100644
> > --- a/include/sheep.h
> > +++ b/include/sheep.h
> > @@ -54,6 +54,8 @@ static inline void sd_init_req(struct sd_req *req, uint8_t opcode)
> > memset(req, 0, sizeof(*req));
> > req->opcode = opcode;
> > req->proto_ver = opcode < 0x80 ? SD_PROTO_VER : SD_SHEEP_PROTO_VER;
> > + if (opcode == SD_OP_CREATE_AND_WRITE_OBJ || opcode == SD_OP_WRITE_OBJ)
> > + req->flags = SD_FLAG_CMD_WRITE;
>
> I'm against dealing only these two opcodes as special cases. I think
> of adding more general check to detect this kind of error in sheep
> code.
Okay, I'll drop this patch.
Thanks
Yuan
More information about the sheepdog
mailing list