aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2014-11-12 01:00:43 -0500
committerIlya Dryomov <idryomov@redhat.com>2014-12-17 12:09:51 -0500
commitd74b50bed037794135cb5a4e7418ad71d9848ce1 (patch)
tree6f202861df8a6d21fd6ddb7c8823e49c744a2970 /net/ceph
parent7e868b6eff21edb59eb6a723dfd18761476ddb46 (diff)
libceph: add SETXATTR/CMPXATTR osd operations support
Signed-off-by: Yan, Zheng <zyan@redhat.com> Reviewed-by: Ilya Dryomov <idryomov@redhat.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/osd_client.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 1f6c4055adaf..2b0555b36e4d 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,
292 ceph_osd_data_release(&op->cls.request_data); 292 ceph_osd_data_release(&op->cls.request_data);
293 ceph_osd_data_release(&op->cls.response_data); 293 ceph_osd_data_release(&op->cls.response_data);
294 break; 294 break;
295 case CEPH_OSD_OP_SETXATTR:
296 case CEPH_OSD_OP_CMPXATTR:
297 ceph_osd_data_release(&op->xattr.osd_data);
298 break;
295 default: 299 default:
296 break; 300 break;
297 } 301 }
@@ -545,6 +549,39 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
545} 549}
546EXPORT_SYMBOL(osd_req_op_cls_init); 550EXPORT_SYMBOL(osd_req_op_cls_init);
547 551
552int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which,
553 u16 opcode, const char *name, const void *value,
554 size_t size, u8 cmp_op, u8 cmp_mode)
555{
556 struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which, opcode);
557 struct ceph_pagelist *pagelist;
558 size_t payload_len;
559
560 BUG_ON(opcode != CEPH_OSD_OP_SETXATTR && opcode != CEPH_OSD_OP_CMPXATTR);
561
562 pagelist = kmalloc(sizeof(*pagelist), GFP_NOFS);
563 if (!pagelist)
564 return -ENOMEM;
565
566 ceph_pagelist_init(pagelist);
567
568 payload_len = strlen(name);
569 op->xattr.name_len = payload_len;
570 ceph_pagelist_append(pagelist, name, payload_len);
571
572 op->xattr.value_len = size;
573 ceph_pagelist_append(pagelist, value, size);
574 payload_len += size;
575
576 op->xattr.cmp_op = cmp_op;
577 op->xattr.cmp_mode = cmp_mode;
578
579 ceph_osd_data_pagelist_init(&op->xattr.osd_data, pagelist);
580 op->payload_len = payload_len;
581 return 0;
582}
583EXPORT_SYMBOL(osd_req_op_xattr_init);
584
548void osd_req_op_watch_init(struct ceph_osd_request *osd_req, 585void osd_req_op_watch_init(struct ceph_osd_request *osd_req,
549 unsigned int which, u16 opcode, 586 unsigned int which, u16 opcode,
550 u64 cookie, u64 version, int flag) 587 u64 cookie, u64 version, int flag)
@@ -676,6 +713,16 @@ static u64 osd_req_encode_op(struct ceph_osd_request *req,
676 dst->alloc_hint.expected_write_size = 713 dst->alloc_hint.expected_write_size =
677 cpu_to_le64(src->alloc_hint.expected_write_size); 714 cpu_to_le64(src->alloc_hint.expected_write_size);
678 break; 715 break;
716 case CEPH_OSD_OP_SETXATTR:
717 case CEPH_OSD_OP_CMPXATTR:
718 dst->xattr.name_len = cpu_to_le32(src->xattr.name_len);
719 dst->xattr.value_len = cpu_to_le32(src->xattr.value_len);
720 dst->xattr.cmp_op = src->xattr.cmp_op;
721 dst->xattr.cmp_mode = src->xattr.cmp_mode;
722 osd_data = &src->xattr.osd_data;
723 ceph_osdc_msg_data_add(req->r_request, osd_data);
724 request_data_len = osd_data->pagelist->length;
725 break;
679 default: 726 default:
680 pr_err("unsupported osd opcode %s\n", 727 pr_err("unsupported osd opcode %s\n",
681 ceph_osd_op_name(src->op)); 728 ceph_osd_op_name(src->op));