Skip to content

Commit abec732

Browse files
authored
Merge pull request ceph#63302 from VinayBhaskar-V/wip-sort-snaps-changes
librbd: retry list_snap_orders() once instead of failing sort_snaps() Reviewed-by: Ilya Dryomov <[email protected]>
2 parents d183187 + 3c21aec commit abec732

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/librbd/group/ListSnapshotsRequest.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ void ListSnapshotsRequest<I>::handle_list_snap_orders(int r) {
9292

9393
m_snap_orders.insert(snap_orders.begin(), snap_orders.end());
9494
if (snap_orders.size() < MAX_RETURN) {
95-
list_snaps();
95+
if (m_retried_snap_orders) {
96+
sort_snaps();
97+
} else {
98+
list_snaps();
99+
}
96100
return;
97101
}
98102

@@ -158,7 +162,18 @@ void ListSnapshotsRequest<I>::sort_snaps() {
158162
for (const auto& snap : *m_snaps) {
159163
if (m_snap_orders.find(snap.id) == m_snap_orders.end()) {
160164
ldout(cct, 10) << "Missing order for snap_id=" << snap.id << dendl;
161-
finish(m_fail_if_not_sorted ? -EINVAL : 0);
165+
if (m_fail_if_not_sorted) {
166+
if (!m_retried_snap_orders) {
167+
ldout(cct, 10) << "Retrying to fetch missing snap orders..." << dendl;
168+
m_retried_snap_orders = true;
169+
m_start_after_order = "";
170+
list_snap_orders();
171+
} else {
172+
finish(-EINVAL);
173+
}
174+
} else {
175+
finish(0);
176+
}
162177
return;
163178
}
164179
}

src/librbd/group/ListSnapshotsRequest.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,24 @@ class ListSnapshotsRequest {
4444
* @verbatim
4545
*
4646
* <start> /--------\
47-
* | | | (if required. repeat if more
47+
* | | | (if requested, repeat if more
4848
* v v | entries)
4949
* LIST_SNAP_ORDERS --/
50+
* |
5051
* | /--------\
5152
* | | | (repeat if more
5253
* v v | snapshots)
5354
* LIST_SNAPS --------/
5455
* |
55-
* v
56-
* SORT_SNAPS (if required)
56+
* | /--------\
57+
* |/-------<--------\ | | (repeat if more
58+
* | | v | entries)
59+
* | LIST_SNAP_ORDERS --/
60+
* | ^
61+
* | | (retry if ordering is required and
62+
* | | an entry is missing for a snapshot)
63+
* v (if requested) |
64+
* SORT_SNAPS ---------/
5765
* |
5866
* v
5967
* <finish>
@@ -73,6 +81,7 @@ class ListSnapshotsRequest {
7381
cls::rbd::GroupSnapshot m_start_after;
7482
std::string m_start_after_order;
7583
bufferlist m_out_bl;
84+
bool m_retried_snap_orders = false;
7685

7786
void list_snaps();
7887
void handle_list_snaps(int r);

0 commit comments

Comments
 (0)