]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/services/svc_user_rados.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / services / svc_user_rados.h
CommitLineData
9f95a23c
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab ft=cpp
3
4/*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2019 Red Hat, Inc.
8 *
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.
13 *
14 */
15
16
17#pragma once
18
19#include "rgw/rgw_service.h"
20
21#include "svc_meta_be.h"
22#include "svc_user.h"
23
24class RGWSI_RADOS;
25class RGWSI_Zone;
26class RGWSI_SysObj;
27class RGWSI_SysObj_Cache;
28class RGWSI_Meta;
29class RGWSI_SyncModules;
30class RGWSI_MetaBackend_Handler;
31
32struct rgw_cache_entry_info;
33
34class RGWUserBuckets;
35
36class RGWGetUserHeader_CB;
37class RGWGetUserStats_CB;
38
39template <class T>
40class RGWChainedCacheImpl;
41
42class RGWSI_User_RADOS : public RGWSI_User
43{
44 friend class PutOperation;
45
46 std::unique_ptr<RGWSI_MetaBackend::Module> be_module;
47 RGWSI_MetaBackend_Handler *be_handler;
48
49 struct user_info_cache_entry {
50 RGWUserInfo info;
51 RGWObjVersionTracker objv_tracker;
52 real_time mtime;
53 };
54
55 using RGWChainedCacheImpl_user_info_cache_entry = RGWChainedCacheImpl<user_info_cache_entry>;
56 unique_ptr<RGWChainedCacheImpl_user_info_cache_entry> uinfo_cache;
57
58 rgw_raw_obj get_buckets_obj(const rgw_user& user_id) const;
59
60 int get_user_info_from_index(RGWSI_MetaBackend::Context *ctx,
61 const string& key,
62 const rgw_pool& pool,
63 RGWUserInfo *info,
64 RGWObjVersionTracker * const objv_tracker,
65 real_time * const pmtime,
b3b6e05e
TL
66 optional_yield y,
67 const DoutPrefixProvider *dpp);
9f95a23c
TL
68
69 int remove_uid_index(RGWSI_MetaBackend::Context *ctx, const RGWUserInfo& user_info, RGWObjVersionTracker *objv_tracker,
b3b6e05e 70 optional_yield y, const DoutPrefixProvider *dpp);
9f95a23c 71
b3b6e05e
TL
72 int remove_key_index(const DoutPrefixProvider *dpp, RGWSI_MetaBackend::Context *ctx, const RGWAccessKey& access_key, optional_yield y);
73 int remove_email_index(const DoutPrefixProvider *dpp, RGWSI_MetaBackend::Context *ctx, const string& email, optional_yield y);
74 int remove_swift_name_index(const DoutPrefixProvider *dpp, RGWSI_MetaBackend::Context *ctx, const string& swift_name, optional_yield y);
9f95a23c
TL
75
76 /* admin management */
b3b6e05e
TL
77 int cls_user_update_buckets(const DoutPrefixProvider *dpp, rgw_raw_obj& obj, list<cls_user_bucket_entry>& entries, bool add, optional_yield y);
78 int cls_user_add_bucket(const DoutPrefixProvider *dpp, rgw_raw_obj& obj, const cls_user_bucket_entry& entry, optional_yield y);
79 int cls_user_remove_bucket(const DoutPrefixProvider *dpp, rgw_raw_obj& obj, const cls_user_bucket& bucket, optional_yield y);
9f95a23c
TL
80
81 /* quota stats */
b3b6e05e 82 int cls_user_flush_bucket_stats(const DoutPrefixProvider *dpp, rgw_raw_obj& user_obj,
f67539c2 83 const RGWBucketEnt& ent, optional_yield y);
b3b6e05e
TL
84 int cls_user_list_buckets(const DoutPrefixProvider *dpp,
85 rgw_raw_obj& obj,
9f95a23c
TL
86 const string& in_marker,
87 const string& end_marker,
88 const int max_entries,
89 list<cls_user_bucket_entry>& entries,
90 string * const out_marker,
f67539c2
TL
91 bool * const truncated,
92 optional_yield y);
9f95a23c 93
b3b6e05e
TL
94 int cls_user_reset_stats(const DoutPrefixProvider *dpp, const rgw_user& user, optional_yield y);
95 int cls_user_get_header(const DoutPrefixProvider *dpp, const rgw_user& user, cls_user_header *header, optional_yield y);
96 int cls_user_get_header_async(const DoutPrefixProvider *dpp, const string& user, RGWGetUserHeader_CB *cb);
9f95a23c 97
b3b6e05e 98 int do_start(optional_yield, const DoutPrefixProvider *dpp) override;
9f95a23c
TL
99public:
100 struct Svc {
101 RGWSI_User_RADOS *user{nullptr};
102 RGWSI_RADOS *rados{nullptr};
103 RGWSI_Zone *zone{nullptr};
104 RGWSI_SysObj *sysobj{nullptr};
105 RGWSI_SysObj_Cache *cache{nullptr};
106 RGWSI_Meta *meta{nullptr};
107 RGWSI_MetaBackend *meta_be{nullptr};
108 RGWSI_SyncModules *sync_modules{nullptr};
109 } svc;
110
111 RGWSI_User_RADOS(CephContext *cct);
112 ~RGWSI_User_RADOS();
113
114 void init(RGWSI_RADOS *_rados_svc,
115 RGWSI_Zone *_zone_svc, RGWSI_SysObj *_sysobj_svc,
116 RGWSI_SysObj_Cache *_cache_svc, RGWSI_Meta *_meta_svc,
117 RGWSI_MetaBackend *_meta_be_svc,
118 RGWSI_SyncModules *_sync_modules);
119
120 RGWSI_MetaBackend_Handler *get_be_handler() override {
121 return be_handler;
122 }
123
124 int read_user_info(RGWSI_MetaBackend::Context *ctx,
125 const rgw_user& user,
126 RGWUserInfo *info,
127 RGWObjVersionTracker * const objv_tracker,
128 real_time * const pmtime,
129 rgw_cache_entry_info * const cache_info,
130 map<string, bufferlist> * const pattrs,
b3b6e05e
TL
131 optional_yield y,
132 const DoutPrefixProvider *dpp) override;
9f95a23c
TL
133
134 int store_user_info(RGWSI_MetaBackend::Context *ctx,
135 const RGWUserInfo& info,
136 RGWUserInfo *old_info,
137 RGWObjVersionTracker *objv_tracker,
138 const real_time& mtime,
139 bool exclusive,
140 map<string, bufferlist> *attrs,
b3b6e05e
TL
141 optional_yield y,
142 const DoutPrefixProvider *dpp) override;
9f95a23c
TL
143
144 int remove_user_info(RGWSI_MetaBackend::Context *ctx,
145 const RGWUserInfo& info,
146 RGWObjVersionTracker *objv_tracker,
b3b6e05e
TL
147 optional_yield y,
148 const DoutPrefixProvider *dpp) override;
9f95a23c
TL
149
150 int get_user_info_by_email(RGWSI_MetaBackend::Context *ctx,
151 const string& email, RGWUserInfo *info,
152 RGWObjVersionTracker *objv_tracker,
153 real_time *pmtime,
b3b6e05e
TL
154 optional_yield y,
155 const DoutPrefixProvider *dpp) override;
9f95a23c
TL
156 int get_user_info_by_swift(RGWSI_MetaBackend::Context *ctx,
157 const string& swift_name,
158 RGWUserInfo *info, /* out */
159 RGWObjVersionTracker * const objv_tracker,
160 real_time * const pmtime,
b3b6e05e
TL
161 optional_yield y,
162 const DoutPrefixProvider *dpp) override;
9f95a23c
TL
163 int get_user_info_by_access_key(RGWSI_MetaBackend::Context *ctx,
164 const std::string& access_key,
165 RGWUserInfo *info,
166 RGWObjVersionTracker* objv_tracker,
167 real_time *pmtime,
b3b6e05e
TL
168 optional_yield y,
169 const DoutPrefixProvider *dpp) override;
9f95a23c
TL
170
171 /* user buckets directory */
172
b3b6e05e
TL
173 int add_bucket(const DoutPrefixProvider *dpp,
174 RGWSI_MetaBackend::Context *ctx,
9f95a23c
TL
175 const rgw_user& user,
176 const rgw_bucket& bucket,
f67539c2
TL
177 ceph::real_time creation_time,
178 optional_yield y) override;
b3b6e05e
TL
179 int remove_bucket(const DoutPrefixProvider *dpp,
180 RGWSI_MetaBackend::Context *ctx,
9f95a23c 181 const rgw_user& user,
f67539c2
TL
182 const rgw_bucket& _bucket,
183 optional_yield y) override;
b3b6e05e
TL
184 int list_buckets(const DoutPrefixProvider *dpp,
185 RGWSI_MetaBackend::Context *ctx,
9f95a23c
TL
186 const rgw_user& user,
187 const string& marker,
188 const string& end_marker,
189 uint64_t max,
190 RGWUserBuckets *buckets,
f67539c2
TL
191 bool *is_truncated,
192 optional_yield y) override;
9f95a23c
TL
193
194 /* quota related */
b3b6e05e
TL
195 int flush_bucket_stats(const DoutPrefixProvider *dpp,
196 RGWSI_MetaBackend::Context *ctx,
9f95a23c 197 const rgw_user& user,
f67539c2 198 const RGWBucketEnt& ent, optional_yield y) override;
9f95a23c 199
b3b6e05e
TL
200 int complete_flush_stats(const DoutPrefixProvider *dpp,
201 RGWSI_MetaBackend::Context *ctx,
f67539c2 202 const rgw_user& user, optional_yield y) override;
9f95a23c 203
b3b6e05e
TL
204 int reset_bucket_stats(const DoutPrefixProvider *dpp,
205 RGWSI_MetaBackend::Context *ctx,
f67539c2
TL
206 const rgw_user& user,
207 optional_yield y) override;
b3b6e05e
TL
208 int read_stats(const DoutPrefixProvider *dpp,
209 RGWSI_MetaBackend::Context *ctx,
9f95a23c
TL
210 const rgw_user& user, RGWStorageStats *stats,
211 ceph::real_time *last_stats_sync, /* last time a full stats sync completed */
f67539c2
TL
212 ceph::real_time *last_stats_update,
213 optional_yield y) override; /* last time a stats update was done */
9f95a23c 214
b3b6e05e 215 int read_stats_async(const DoutPrefixProvider *dpp, RGWSI_MetaBackend::Context *ctx,
9f95a23c
TL
216 const rgw_user& user, RGWGetUserStats_CB *cb) override;
217};
218