* parameters as the client sees them - it would be silly to mention
* in each one that they take an input and an output bufferlist.
*/
-#include "include/int_types.h"
#include "include/types.h"
#include <algorithm>
-#include <cstring>
-#include <cstdlib>
#include <errno.h>
-#include <iostream>
-#include <map>
#include <sstream>
-#include <vector>
#include "common/bit_vector.hpp"
#include "common/errno.h"
bufferlist featuresbl;
bufferlist object_prefixbl;
bufferlist snap_seqbl;
+ bufferlist create_timestampbl;
uint64_t snap_seq = 0;
+ utime_t create_timestamp = ceph_clock_now();
::encode(size, sizebl);
::encode(order, orderbl);
::encode(features, featuresbl);
::encode(object_prefix, object_prefixbl);
::encode(snap_seq, snap_seqbl);
+ ::encode(create_timestamp, create_timestampbl);
map<string, bufferlist> omap_vals;
omap_vals["size"] = sizebl;
omap_vals["features"] = featuresbl;
omap_vals["object_prefix"] = object_prefixbl;
omap_vals["snap_seq"] = snap_seqbl;
+ omap_vals["create_timestamp"] = create_timestampbl;
if (features & RBD_FEATURE_DATA_POOL) {
if (data_pool_id == -1) {
return 0;
}
+int get_create_timestamp(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+{
+ CLS_LOG(20, "get_create_timestamp");
+
+ utime_t timestamp;
+ bufferlist bl;
+ int r = cls_cxx_map_get_val(hctx, "create_timestamp", &bl);
+ if (r < 0) {
+ if (r != -ENOENT) {
+ CLS_ERR("error reading create_timestamp: %s", cpp_strerror(r).c_str());
+ return r;
+ }
+ } else {
+ try {
+ bufferlist::iterator it = bl.begin();
+ ::decode(timestamp, it);
+ } catch (const buffer::error &err) {
+ CLS_ERR("could not decode create_timestamp");
+ return -EIO;
+ }
+ }
+
+ ::encode(timestamp, *out);
+ return 0;
+}
+
/**
* get the image flags
*
cls_method_handle_t h_set_protection_status;
cls_method_handle_t h_get_stripe_unit_count;
cls_method_handle_t h_set_stripe_unit_count;
+ cls_method_handle_t h_get_create_timestamp;
cls_method_handle_t h_get_flags;
cls_method_handle_t h_set_flags;
cls_method_handle_t h_remove_parent;
cls_register_cxx_method(h_class, "set_stripe_unit_count",
CLS_METHOD_RD | CLS_METHOD_WR,
set_stripe_unit_count, &h_set_stripe_unit_count);
+ cls_register_cxx_method(h_class, "get_create_timestamp",
+ CLS_METHOD_RD,
+ get_create_timestamp, &h_get_create_timestamp);
cls_register_cxx_method(h_class, "get_flags",
CLS_METHOD_RD,
get_flags, &h_get_flags);