]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/cls/user/cls_user_client.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / cls / user / cls_user_client.cc
index c77075dcb24a72c1ceefb5adf936ac6aacf2b6b4..b74f55b48b2fd493795b71920a154dbfc40956a2 100644 (file)
@@ -1,4 +1,4 @@
-// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
 #include <errno.h>
@@ -6,9 +6,15 @@
 #include "cls/user/cls_user_client.h"
 #include "include/rados/librados.hpp"
 
+using std::list;
+using std::string;
 
-using namespace librados;
+using ceph::bufferlist;
+using ceph::real_clock;
 
+using librados::IoCtx;
+using librados::ObjectOperationCompletion;
+using librados::ObjectReadOperation;
 
 void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_bucket_entry>& entries, bool add)
 {
@@ -17,7 +23,7 @@ void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_buck
   call.entries = entries;
   call.add = add;
   call.time = real_clock::now();
-  ::encode(call, in);
+  encode(call, in);
   op.exec("user", "set_buckets_info", in);
 }
 
@@ -26,7 +32,7 @@ void cls_user_complete_stats_sync(librados::ObjectWriteOperation& op)
   bufferlist in;
   cls_user_complete_stats_sync_op call;
   call.time = real_clock::now();
-  ::encode(call, in);
+  encode(call, in);
   op.exec("user", "complete_stats_sync", in);
 }
 
@@ -35,7 +41,7 @@ void cls_user_remove_bucket(librados::ObjectWriteOperation& op, const cls_user_b
   bufferlist in;
   cls_user_remove_bucket_op call;
   call.bucket = bucket;
-  ::encode(call, in);
+  encode(call, in);
   op.exec("user", "remove_bucket", in);
 }
 
@@ -51,15 +57,15 @@ public:
     if (r >= 0) {
       cls_user_list_buckets_ret ret;
       try {
-        bufferlist::iterator iter = outbl.begin();
-        ::decode(ret, iter);
+        auto iter = outbl.cbegin();
+        decode(ret, iter);
         if (entries)
          *entries = ret.entries;
         if (truncated)
           *truncated = ret.truncated;
         if (marker)
           *marker = ret.marker;
-      } catch (buffer::error& err) {
+      } catch (ceph::buffer::error& err) {
         r = -EIO;
       }
     }
@@ -84,7 +90,7 @@ void cls_user_bucket_list(librados::ObjectReadOperation& op,
   call.end_marker = end_marker;
   call.max_entries = max_entries;
 
-  ::encode(call, inbl);
+  encode(call, inbl);
 
   op.exec("user", "list_buckets", inbl, new ClsUserListCtx(&entries, out_marker, truncated, pret));
 }
@@ -104,11 +110,11 @@ public:
     if (r >= 0) {
       cls_user_get_header_ret ret;
       try {
-        bufferlist::iterator iter = outbl.begin();
-        ::decode(ret, iter);
+        auto iter = outbl.cbegin();
+        decode(ret, iter);
         if (header)
          *header = ret.header;
-      } catch (buffer::error& err) {
+      } catch (ceph::buffer::error& err) {
         r = -EIO;
       }
       if (ret_ctx) {
@@ -127,19 +133,28 @@ void cls_user_get_header(librados::ObjectReadOperation& op,
   bufferlist inbl;
   cls_user_get_header_op call;
 
-  ::encode(call, inbl);
+  encode(call, inbl);
 
   op.exec("user", "get_header", inbl, new ClsUserGetHeaderCtx(header, NULL, pret));
 }
 
+void cls_user_reset_stats(librados::ObjectWriteOperation &op)
+{
+  bufferlist inbl;
+  cls_user_reset_stats_op call;
+  call.time = real_clock::now();
+  encode(call, inbl);
+  op.exec("user", "reset_user_stats", inbl);
+}
+
 int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx)
 {
   bufferlist in, out;
   cls_user_get_header_op call;
-  ::encode(call, in);
+  encode(call, in);
   ObjectReadOperation op;
   op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx, NULL)); /* no need to pass pret, as we'll call ctx->handle_response() with correct error */
-  AioCompletion *c = librados::Rados::aio_create_completion(NULL, NULL, NULL);
+  auto c = librados::Rados::aio_create_completion(nullptr, nullptr);
   int r = io_ctx.aio_operate(oid, c, &op, NULL);
   c->release();
   if (r < 0)