]> git.proxmox.com Git - ceph.git/blob - ceph/src/cls/refcount/cls_refcount_client.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / cls / refcount / cls_refcount_client.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_CLS_REFCOUNT_CLIENT_H
5 #define CEPH_CLS_REFCOUNT_CLIENT_H
6
7 #include "include/rados/librados_fwd.hpp"
8 #include "include/types.h"
9
10 /*
11 * refcount objclass
12 *
13 * The refcount objclass implements a refcounting scheme that allows having multiple references
14 * to a single rados object. The canonical way to use it is to add a reference and to remove a
15 * reference using a specific tag. This way we ensure that refcounting operations are idempotent,
16 * that is, a single client can only increase/decrease the refcount once using a single tag, so
17 * any replay of operations (implicit or explicit) is possible.
18 *
19 * So, the regular usage would be to create an object, to increase the refcount. Then, when
20 * wanting to have another reference to it, increase the refcount using a different tag. When
21 * removing a reference it is required to drop the refcount (using the same tag that was used
22 * for that reference). When the refcount drops to zero, the object is removed automaticfally.
23 *
24 * In order to maintain backwards compatibility with objects that were created without having
25 * their refcount increased, the implicit_ref was added. Any object that was created without
26 * having it's refcount increased (explicitly) is having an implicit refcount of 1. Since
27 * we don't have a tag for this refcount, we consider this tag as a wildcard. So if the refcount
28 * is being decreased by an unknown tag and we still have one wildcard tag, we'll accept it
29 * as the relevant tag, and the refcount will be decreased.
30 */
31
32 void cls_refcount_get(librados::ObjectWriteOperation& op, const std::string& tag, bool implicit_ref = false);
33 void cls_refcount_put(librados::ObjectWriteOperation& op, const std::string& tag, bool implicit_ref = false);
34 void cls_refcount_set(librados::ObjectWriteOperation& op, std::list<std::string>& refs);
35 // these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw.
36 // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec()
37 #ifndef CLS_CLIENT_HIDE_IOCTX
38 int cls_refcount_read(librados::IoCtx& io_ctx, std::string& oid, std::list<std::string> *refs, bool implicit_ref = false);
39 #endif
40
41 #endif