Skip to content

Commit 815481c

Browse files
authored
Merge pull request ceph#51071 from ivancich/wip-versioned-reindex
rgw: reindex of objects in versioned buckets Reviewed-by: Casey Bodley <[email protected]>
2 parents abfede8 + 89f8121 commit 815481c

File tree

13 files changed

+627
-186
lines changed

13 files changed

+627
-186
lines changed

ceph.spec.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,7 @@ exit 0
17041704
%{_mandir}/man8/rbd-replay-many.8*
17051705
%{_mandir}/man8/rbd-replay-prep.8*
17061706
%{_mandir}/man8/rgw-orphan-list.8*
1707+
%{_mandir}/man8/rgw-restore-bucket-index.8*
17071708
%dir %{_datadir}/ceph/
17081709
%{_datadir}/ceph/known_hosts_drop.ceph.com
17091710
%{_datadir}/ceph/id_rsa_drop.ceph.com

debian/radosgw.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ usr/bin/radosgw-token
77
usr/share/man/man8/ceph-diff-sorted.8
88
usr/share/man/man8/radosgw.8
99
usr/share/man/man8/rgw-orphan-list.8
10+
usr/share/man/man8/rgw-restore-bucket-index.8

doc/man/8/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ if(WITH_RADOSGW)
6060
radosgw-admin.rst
6161
rgw-orphan-list.rst
6262
rgw-policy-check.rst
63-
ceph-diff-sorted.rst)
63+
ceph-diff-sorted.rst
64+
rgw-restore-bucket-index.rst)
6465
endif()
6566

6667
if(WITH_RBD)

doc/man/8/radosgw-admin.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ as follows:
146146
:command:`object rewrite`
147147
Rewrite the specified object.
148148

149+
:command:`object reindex`
150+
Add an object to its bucket's index. Used rarely for emergency repairs.
151+
149152
:command:`objects expire`
150153
Run expired objects cleanup.
151154

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
:orphan:
2+
3+
==================================================================================
4+
rgw-restore-bucket-index -- try to restore a bucket's objects to its bucket index
5+
==================================================================================
6+
7+
.. program:: rgw-restore-bucket-index
8+
9+
Synopsis
10+
========
11+
12+
| **rgw-restore-bucket-index**
13+
14+
Description
15+
===========
16+
17+
:program:`rgw-restore-bucket-index` is an *EXPERIMENTAL* RADOS gateway
18+
user administration utility. It scans the data pool for objects that
19+
belong to a given bucket and tries to add those objects back to the
20+
bucket index. It's intended as a **last resort** after a
21+
**catastrophic** loss of a bucket index. Please thorougly review the
22+
*Warnings* listed below.
23+
24+
The utility works with regular (i.e., un-versioned) buckets, versioned
25+
buckets, and buckets were versioning has been suspended.
26+
27+
Warnings
28+
========
29+
30+
This utility is currently considered *EXPERIMENTAL*.
31+
32+
The results are unpredictable if the bucket is in
33+
active use while this utility is running.
34+
35+
The results are unpredictable if only some bucket's objects are
36+
missing from the bucket index. In such a case, consider using the
37+
"object reindex" subcommand of `radosgw-admin` to restore object's to
38+
the bucket index one-by-one.
39+
40+
For objects in versioned buckets, if the latest version is a delete
41+
marker, it will be restored. If a delete marker has been written over
42+
with a new version, then that delete marker will not be restored. This
43+
should have minimal impact on results in that the it recovers the
44+
latest version and previous versions are all accessible.
45+
46+
Command-Line Arguments
47+
======================
48+
49+
.. option:: -b <bucket>
50+
51+
Specify the bucket to be reindexed.
52+
53+
.. option:: -p <pool>
54+
55+
Optional, specify the data pool containing head objects for the
56+
bucket. If omitted the utility will try to determine the data pool
57+
on its own.
58+
59+
.. option:: -r <realm-name>
60+
61+
Optional, specify the realm if the restoration is not being applied
62+
to the default realm.
63+
64+
.. option:: -g <zonegroup-name>
65+
66+
Optional, specify the zonegroup if the restoration is not being applied
67+
to the default zonegroup.
68+
69+
.. option:: -z <zone-name>
70+
71+
Optional, specify the zone if the restoration is not being applied
72+
to the default zone.
73+
74+
.. option:: -l <rados-ls-output-file>
75+
76+
Optional, specify a file containing the output of a rados listing
77+
of the data pool. Since listing the data pool can be an expensive
78+
and time-consuming operation, if trying to recover the indices for
79+
multiple buckets, it could be more efficient to re-use the same
80+
listing.
81+
82+
.. option:: -y
83+
84+
Optional, proceed without further prompting. Without this option
85+
the utility will display some information and prompt the user as to
86+
whether to proceed. When provided, the utility will simply
87+
proceed. Please use caution when using this option.
88+
89+
Examples
90+
========
91+
92+
Attempt to restore the index for a bucket named *summer-2023-photos*::
93+
94+
$ rgw-restore-bucket-index -b summer-2023-photos
95+
96+
Availability
97+
============
98+
99+
:program:`rgw-restore-bucket-index` is part of Ceph, a massively
100+
scalable, open-source, distributed storage system. Please refer to
101+
the Ceph documentation at https://docs.ceph.com for more information.
102+
103+
See also
104+
========
105+
106+
:doc:`radosgw-admin <radosgw-admin>`\(8)

doc/man_index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@
4848
man/8/ceph-immutable-object-cache
4949
man/8/ceph-diff-sorted
5050
man/8/rgw-policy-check
51+
man/8/rgw-restore-bucket-index

src/cls/rgw/cls_rgw_client.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, const s
286286
const rgw_bucket_dir_entry_meta& dir_meta,
287287
const list<cls_rgw_obj_key> *remove_objs, bool log_op,
288288
uint16_t bilog_flags,
289-
const rgw_zone_set *zones_trace)
289+
const rgw_zone_set *zones_trace,
290+
const std::string& obj_locator)
290291
{
291292

292293
bufferlist in;
@@ -295,6 +296,7 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, const s
295296
call.tag = tag;
296297
call.key = key;
297298
call.ver = ver;
299+
call.locator = obj_locator;
298300
call.meta = dir_meta;
299301
call.log_op = log_op;
300302
call.bilog_flags = bilog_flags;

src/cls/rgw/cls_rgw_client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp o
355355
const cls_rgw_obj_key& key,
356356
const rgw_bucket_dir_entry_meta& dir_meta,
357357
const std::list<cls_rgw_obj_key> *remove_objs, bool log_op,
358-
uint16_t bilog_op, const rgw_zone_set *zones_trace);
358+
uint16_t bilog_op, const rgw_zone_set *zones_trace,
359+
const std::string& obj_locator = ""); // ignored if it's the empty string
359360

360361
void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, std::list<std::string>& keep_attr_prefixes);
361362
void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const std::string& attr);

0 commit comments

Comments
 (0)