| 45 | } |
| 46 | |
| 47 | static int cls_queue_enqueue(cls_method_context_t hctx, bufferlist *in, bufferlist *out) |
| 48 | { |
| 49 | auto iter = in->cbegin(); |
| 50 | cls_queue_enqueue_op op; |
| 51 | try { |
| 52 | decode(op, iter); |
| 53 | } catch (ceph::buffer::error& err) { |
| 54 | CLS_LOG(1, "ERROR: cls_queue_enqueue: failed to decode input data \n"); |
| 55 | return -EINVAL; |
| 56 | } |
| 57 | |
| 58 | cls_queue_head head; |
| 59 | auto ret = queue_read_head(hctx, head); |
| 60 | if (ret < 0) { |
| 61 | return ret; |
| 62 | } |
| 63 | |
| 64 | ret = queue_enqueue(hctx, op, head); |
| 65 | if (ret < 0) { |
| 66 | return ret; |
| 67 | } |
| 68 | |
| 69 | //Write back head |
| 70 | return queue_write_head(hctx, head); |
| 71 | } |
| 72 | |
| 73 | static int cls_queue_list_entries(cls_method_context_t hctx, bufferlist *in, bufferlist *out) |
| 74 | { |