summaryrefslogtreecommitdiffstats
path: root/src/cls/refcount/cls_refcount_client.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/cls/refcount/cls_refcount_client.h
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cls/refcount/cls_refcount_client.h')
-rw-r--r--src/cls/refcount/cls_refcount_client.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cls/refcount/cls_refcount_client.h b/src/cls/refcount/cls_refcount_client.h
new file mode 100644
index 000000000..73a23a7ee
--- /dev/null
+++ b/src/cls/refcount/cls_refcount_client.h
@@ -0,0 +1,41 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_CLS_REFCOUNT_CLIENT_H
+#define CEPH_CLS_REFCOUNT_CLIENT_H
+
+#include "include/rados/librados_fwd.hpp"
+#include "include/types.h"
+
+/*
+ * refcount objclass
+ *
+ * The refcount objclass implements a refcounting scheme that allows having multiple references
+ * to a single rados object. The canonical way to use it is to add a reference and to remove a
+ * reference using a specific tag. This way we ensure that refcounting operations are idempotent,
+ * that is, a single client can only increase/decrease the refcount once using a single tag, so
+ * any replay of operations (implicit or explicit) is possible.
+ *
+ * So, the regular usage would be to create an object, to increase the refcount. Then, when
+ * wanting to have another reference to it, increase the refcount using a different tag. When
+ * removing a reference it is required to drop the refcount (using the same tag that was used
+ * for that reference). When the refcount drops to zero, the object is removed automaticfally.
+ *
+ * In order to maintain backwards compatibility with objects that were created without having
+ * their refcount increased, the implicit_ref was added. Any object that was created without
+ * having it's refcount increased (explicitly) is having an implicit refcount of 1. Since
+ * we don't have a tag for this refcount, we consider this tag as a wildcard. So if the refcount
+ * is being decreased by an unknown tag and we still have one wildcard tag, we'll accept it
+ * as the relevant tag, and the refcount will be decreased.
+ */
+
+void cls_refcount_get(librados::ObjectWriteOperation& op, const std::string& tag, bool implicit_ref = false);
+void cls_refcount_put(librados::ObjectWriteOperation& op, const std::string& tag, bool implicit_ref = false);
+void cls_refcount_set(librados::ObjectWriteOperation& op, std::list<std::string>& refs);
+// these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw.
+// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec()
+#ifndef CLS_CLIENT_HIDE_IOCTX
+int cls_refcount_read(librados::IoCtx& io_ctx, std::string& oid, std::list<std::string> *refs, bool implicit_ref = false);
+#endif
+
+#endif