]>
git.proxmox.com Git - ceph.git/blob - ceph/src/cls/cmpomap/client.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2020 Red Hat, Inc
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
18 #include "include/rados/librados_fwd.hpp"
21 namespace cls::cmpomap
{
23 /// requests with too many key comparisons will be rejected with -E2BIG
24 static constexpr uint32_t max_keys
= 1000;
26 /// process each of the omap value comparisons according to the same rules as
27 /// cmpxattr(), and return -ECANCELED if a comparison is unsuccessful. for
28 /// comparisons with Mode::U64, failure to decode an input value is reported
29 /// as -EINVAL, an empty stored value is compared as 0, and failure to decode
30 /// a stored value is reported as -EIO
31 [[nodiscard
]] int cmp_vals(librados::ObjectReadOperation
& op
,
32 Mode mode
, Op comparison
, ComparisonMap values
,
33 std::optional
<ceph::bufferlist
> default_value
);
35 /// process each of the omap value comparisons according to the same rules as
36 /// cmpxattr(). any key/value pairs that compare successfully are overwritten
37 /// with the corresponding input value. for comparisons with Mode::U64, failure
38 /// to decode an input value is reported as -EINVAL. an empty stored value is
39 /// compared as 0, while decode failure of a stored value is treated as an
40 /// unsuccessful comparison and is not reported as an error
41 [[nodiscard
]] int cmp_set_vals(librados::ObjectWriteOperation
& writeop
,
42 Mode mode
, Op comparison
, ComparisonMap values
,
43 std::optional
<ceph::bufferlist
> default_value
);
45 /// process each of the omap value comparisons according to the same rules as
46 /// cmpxattr(). any key/value pairs that compare successfully are removed. for
47 /// comparisons with Mode::U64, failure to decode an input value is reported as
48 /// -EINVAL. an empty stored value is compared as 0, while decode failure of a
49 /// stored value is treated as an unsuccessful comparison and is not reported
51 [[nodiscard
]] int cmp_rm_keys(librados::ObjectWriteOperation
& writeop
,
52 Mode mode
, Op comparison
, ComparisonMap values
);
55 // bufferlist factories for comparison values
56 inline ceph::bufferlist
string_buffer(std::string_view value
) {
61 inline ceph::bufferlist
u64_buffer(uint64_t value
) {
68 } // namespace cls::cmpomap