Re: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 25, 2014 at 5:36 AM, 严正 <zyan@xxxxxxxxxx> wrote:
> updated patch
>
>
> From 1f7963731ccbd2cd0f19d4f357c915e23d702d60 Mon Sep 17 00:00:00 2001
> From: "Yan, Zheng" <zyan@xxxxxxxxxx>
> Date: Wed, 12 Nov 2014 14:00:43 +0800
> Subject: [PATCH 01/12] libceph: add SETXATTR/CMPXATTR osd operations support
>
> Signed-off-by: Yan, Zheng <zyan@xxxxxxxxxx>
> ---
>  include/linux/ceph/osd_client.h | 10 +++++++++
>  net/ceph/osd_client.c           | 47 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+)
>
> diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
> index 03aeb27..bcf9c21 100644
> --- a/include/linux/ceph/osd_client.h
> +++ b/include/linux/ceph/osd_client.h
> @@ -87,6 +87,13 @@ struct ceph_osd_req_op {
>                         struct ceph_osd_data osd_data;
>                 } extent;
>                 struct {
> +                       __le32 name_len;
> +                       __le32 value_len;
> +                       __u8 cmp_op;       /* CEPH_OSD_CMPXATTR_OP_* */
> +                       __u8 cmp_mode;     /* CEPH_OSD_CMPXATTR_MODE_* */
> +                       struct ceph_osd_data osd_data;
> +               } xattr;
> +               struct {
>                         const char *class_name;
>                         const char *method_name;
>                         struct ceph_osd_data request_info;
> @@ -295,6 +302,9 @@ extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
>  extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req,
>                                         unsigned int which, u16 opcode,
>                                         const char *class, const char *method);
> +extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which,
> +                                u16 opcode, const char *name, const void *value,
> +                                size_t size, u8 cmp_op, u8 cmp_mode);
>  extern void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
>                                         unsigned int which, u16 opcode,
>                                         u64 cookie, u64 version, int flag);
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index 1f6c405..489c830 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -292,6 +292,10 @@ static void osd_req_op_data_release(struct ceph_osd_request *osd_req,
>                 ceph_osd_data_release(&op->cls.request_data);
>                 ceph_osd_data_release(&op->cls.response_data);
>                 break;
> +       case CEPH_OSD_OP_SETXATTR:
> +       case CEPH_OSD_OP_CMPXATTR:
> +               ceph_osd_data_release(&op->xattr.osd_data);
> +               break;
>         default:
>                 break;
>         }
> @@ -545,6 +549,39 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
>  }
>  EXPORT_SYMBOL(osd_req_op_cls_init);
>
> +int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which,
> +                         u16 opcode, const char *name, const void *value,
> +                         size_t size, u8 cmp_op, u8 cmp_mode)
> +{
> +       struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which, opcode);
> +       struct ceph_pagelist *pagelist;
> +       size_t payload_len;
> +
> +       BUG_ON(opcode != CEPH_OSD_OP_SETXATTR && opcode != CEPH_OSD_OP_CMPXATTR);
> +
> +       pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS);
> +       if (!pagelist)
> +               return -ENOMEM;
> +
> +       ceph_pagelist_init(pagelist);
> +
> +       payload_len = strlen(name);
> +       op->xattr.name_len = payload_len;
> +       ceph_pagelist_append(pagelist, name, payload_len);
> +
> +       op->xattr.value_len = size;
> +       ceph_pagelist_append(pagelist, value, size);
> +       payload_len += size;
> +
> +       op->xattr.cmp_op = cmp_op;
> +       op->xattr.cmp_mode = cmp_mode;
> +
> +       ceph_osd_data_pagelist_init(&op->xattr.osd_data, pagelist);
> +       op->payload_len = payload_len;
> +       return 0;
> +}
> +EXPORT_SYMBOL(osd_req_op_xattr_init);
> +
>  void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
>                                 unsigned int which, u16 opcode,
>                                 u64 cookie, u64 version, int flag)
> @@ -676,6 +713,16 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,
>                 dst->alloc_hint.expected_write_size =
>                     cpu_to_le64(src->alloc_hint.expected_write_size);
>                 break;
> +       case CEPH_OSD_OP_SETXATTR:
> +       case CEPH_OSD_OP_CMPXATTR:
> +               dst->xattr.name_len = cpu_to_le32(src->xattr.name_len);
> +               dst->xattr.value_len = cpu_to_le32(src->xattr.value_len);
> +               dst->xattr.cmp_op = src->xattr.cmp_op;
> +               dst->xattr.cmp_mode = src->xattr.cmp_mode;
> +               osd_data = &src->xattr.osd_data;
> +               ceph_osdc_msg_data_add(req->r_request, osd_data);
> +               request_data_len = osd_data->pagelist->length;
> +               break;
>         default:
>                 pr_err("unsupported osd opcode %s\n",
>                         ceph_osd_op_name(src->op));

I see you've also added osd_req_op_data_release() hunk.

Reviewed-by: Ilya Dryomov <idryomov@xxxxxxxxxx>

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux