Skip to content

Commit b5d44d3

Browse files
authored
Merge pull request ceph#61567 from idryomov/wip-58185
librbd: stop filtering async request error codes Reviewed-by: Ramana Raja <[email protected]>
2 parents a6db252 + afc89fd commit b5d44d3

File tree

3 files changed

+87
-53
lines changed

3 files changed

+87
-53
lines changed

qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
overrides:
2+
install:
3+
extra_system_packages:
4+
rpm:
5+
- qemu-kvm-block-rbd
6+
deb:
7+
- qemu-block-extra
8+
- qemu-utils
19
tasks:
210
- workunit:
311
clients:

qa/workunits/rbd/cli_migration.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,68 @@ EOF
596596
kill_nbd_server
597597
}
598598

599+
test_import_nbd_stream_disconnected() {
600+
local dest_image=$1
601+
local migration_execute_pid
602+
603+
dd if=/dev/urandom of=${TEMPDIR}/large.raw bs=1M count=20480
604+
qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
605+
${TEMPDIR}/large.raw
606+
607+
cat > ${TEMPDIR}/spec.json <<EOF
608+
{
609+
"type": "raw",
610+
"stream": {
611+
"type": "nbd",
612+
"uri": "nbd://localhost"
613+
}
614+
}
615+
EOF
616+
cat ${TEMPDIR}/spec.json
617+
618+
# server disappears while importing - abort
619+
rbd migration prepare --import-only \
620+
--source-spec-path ${TEMPDIR}/spec.json ${dest_image}
621+
rbd status ${dest_image} | grep 'state: prepared'
622+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
623+
rbd migration execute ${dest_image} &
624+
migration_execute_pid=$!
625+
sleep $((5 + RANDOM % 35))
626+
kill_nbd_server
627+
expect_false wait $migration_execute_pid
628+
expect_false rbd status ${dest_image}
629+
rbd migration abort ${dest_image}
630+
631+
qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
632+
${TEMPDIR}/large.raw
633+
634+
# server disappears while importing - resume
635+
rbd migration prepare --import-only \
636+
--source-spec-path ${TEMPDIR}/spec.json ${dest_image}
637+
rbd status ${dest_image} | grep 'state: prepared'
638+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
639+
rbd migration execute ${dest_image} &
640+
migration_execute_pid=$!
641+
sleep $((5 + RANDOM % 35))
642+
kill_nbd_server
643+
expect_false wait $migration_execute_pid
644+
expect_false rbd status ${dest_image}
645+
qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
646+
${TEMPDIR}/large.raw
647+
rbd status ${dest_image} | grep 'state: executing'
648+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
649+
rbd migration execute ${dest_image}
650+
rbd status ${dest_image} | grep 'state: executed'
651+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
652+
rbd migration commit ${dest_image}
653+
rbd status ${dest_image} | expect_false grep 'Migration:'
654+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
655+
656+
remove_image "${dest_image}"
657+
658+
kill_nbd_server
659+
}
660+
599661
# make sure rbd pool is EMPTY.. this is a test script!!
600662
rbd ls 2>&1 | wc -l | grep -v '^0$' && echo "nonempty rbd pool, aborting! run this script on an empty test cluster only." && exit 1
601663

@@ -614,6 +676,8 @@ test_import_nbd_stream_qcow2 ${IMAGE2} ${IMAGE3}
614676
test_import_raw_format ${IMAGE1} ${IMAGE2}
615677
test_import_nbd_stream_raw ${IMAGE1} ${IMAGE2}
616678

679+
test_import_nbd_stream_disconnected ${IMAGE2}
680+
617681
rbd namespace create rbd/${NAMESPACE1}
618682
rbd namespace create rbd/${NAMESPACE2}
619683
create_base_image rbd/${NAMESPACE1}/${IMAGE1}

src/librbd/Operations.cc

Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ struct C_InvokeAsyncRequest : public Context {
185185
bool permit_snapshot;
186186
boost::function<void(Context*)> local;
187187
boost::function<void(Context*)> remote;
188-
std::set<int> filter_error_codes;
189188
Context *on_finish;
190189
bool request_lock = false;
191190

@@ -194,11 +193,10 @@ struct C_InvokeAsyncRequest : public Context {
194193
bool permit_snapshot,
195194
const boost::function<void(Context*)>& local,
196195
const boost::function<void(Context*)>& remote,
197-
const std::set<int> &filter_error_codes,
198196
Context *on_finish)
199197
: image_ctx(image_ctx), operation(operation), request_type(request_type),
200198
permit_snapshot(permit_snapshot), local(local), remote(remote),
201-
filter_error_codes(filter_error_codes), on_finish(on_finish) {
199+
on_finish(on_finish) {
202200
}
203201

204202
void send() {
@@ -382,9 +380,6 @@ struct C_InvokeAsyncRequest : public Context {
382380
}
383381

384382
void finish(int r) override {
385-
if (filter_error_codes.count(r) != 0) {
386-
r = 0;
387-
}
388383
on_finish->complete(r);
389384
}
390385
};
@@ -503,11 +498,8 @@ int Operations<I>::flatten(ProgressContext &prog_ctx) {
503498
m_image_ctx.image_watcher, request_id,
504499
boost::ref(prog_ctx), _1));
505500

506-
if (r < 0 && r != -EINVAL) {
507-
return r;
508-
}
509501
ldout(cct, 20) << "flatten finished" << dendl;
510-
return 0;
502+
return r;
511503
}
512504

513505
template <typename I>
@@ -582,10 +574,7 @@ int Operations<I>::rebuild_object_map(ProgressContext &prog_ctx) {
582574
boost::ref(prog_ctx), _1));
583575

584576
ldout(cct, 10) << "rebuild object map finished" << dendl;
585-
if (r < 0) {
586-
return r;
587-
}
588-
return 0;
577+
return r;
589578
}
590579

591580
template <typename I>
@@ -686,12 +675,9 @@ int Operations<I>::rename(const char *dstname) {
686675
boost::bind(&ImageWatcher<I>::notify_rename,
687676
m_image_ctx.image_watcher, request_id,
688677
dstname, _1));
689-
if (r < 0 && r != -EEXIST) {
690-
return r;
691-
}
692678

693679
m_image_ctx.set_image_name(dstname);
694-
return 0;
680+
return r;
695681
}
696682

697683
template <typename I>
@@ -874,7 +860,7 @@ void Operations<I>::snap_create(const cls::rbd::SnapshotNamespace &snap_namespac
874860
boost::bind(&ImageWatcher<I>::notify_snap_create, m_image_ctx.image_watcher,
875861
request_id, snap_namespace, snap_name, flags,
876862
boost::ref(prog_ctx), _1),
877-
{-EEXIST}, on_finish);
863+
on_finish);
878864
req->send();
879865
}
880866

@@ -1077,7 +1063,7 @@ void Operations<I>::snap_remove(const cls::rbd::SnapshotNamespace& snap_namespac
10771063
boost::bind(&ImageWatcher<I>::notify_snap_remove,
10781064
m_image_ctx.image_watcher, request_id, snap_namespace,
10791065
snap_name, _1),
1080-
{-ENOENT}, on_finish);
1066+
on_finish);
10811067
req->send();
10821068
} else {
10831069
std::shared_lock owner_lock{m_image_ctx.owner_lock};
@@ -1173,9 +1159,6 @@ int Operations<I>::snap_rename(const char *srcname, const char *dstname) {
11731159
boost::bind(&ImageWatcher<I>::notify_snap_rename,
11741160
m_image_ctx.image_watcher, request_id,
11751161
snap_id, dstname, _1));
1176-
if (r < 0 && r != -EEXIST) {
1177-
return r;
1178-
}
11791162
} else {
11801163
C_SaferCond cond_ctx;
11811164
{
@@ -1184,13 +1167,10 @@ int Operations<I>::snap_rename(const char *srcname, const char *dstname) {
11841167
}
11851168

11861169
r = cond_ctx.wait();
1187-
if (r < 0) {
1188-
return r;
1189-
}
11901170
}
11911171

11921172
m_image_ctx.perfcounter->inc(l_librbd_snap_rename);
1193-
return 0;
1173+
return r;
11941174
}
11951175

11961176
template <typename I>
@@ -1275,9 +1255,6 @@ int Operations<I>::snap_protect(const cls::rbd::SnapshotNamespace& snap_namespac
12751255
boost::bind(&ImageWatcher<I>::notify_snap_protect,
12761256
m_image_ctx.image_watcher, request_id,
12771257
snap_namespace, snap_name, _1));
1278-
if (r < 0 && r != -EBUSY) {
1279-
return r;
1280-
}
12811258
} else {
12821259
C_SaferCond cond_ctx;
12831260
{
@@ -1286,11 +1263,9 @@ int Operations<I>::snap_protect(const cls::rbd::SnapshotNamespace& snap_namespac
12861263
}
12871264

12881265
r = cond_ctx.wait();
1289-
if (r < 0) {
1290-
return r;
1291-
}
12921266
}
1293-
return 0;
1267+
1268+
return r;
12941269
}
12951270

12961271
template <typename I>
@@ -1373,9 +1348,6 @@ int Operations<I>::snap_unprotect(const cls::rbd::SnapshotNamespace& snap_namesp
13731348
boost::bind(&ImageWatcher<I>::notify_snap_unprotect,
13741349
m_image_ctx.image_watcher, request_id,
13751350
snap_namespace, snap_name, _1));
1376-
if (r < 0 && r != -EINVAL) {
1377-
return r;
1378-
}
13791351
} else {
13801352
C_SaferCond cond_ctx;
13811353
{
@@ -1384,11 +1356,9 @@ int Operations<I>::snap_unprotect(const cls::rbd::SnapshotNamespace& snap_namesp
13841356
}
13851357

13861358
r = cond_ctx.wait();
1387-
if (r < 0) {
1388-
return r;
1389-
}
13901359
}
1391-
return 0;
1360+
1361+
return r;
13921362
}
13931363

13941364
template <typename I>
@@ -1709,9 +1679,6 @@ int Operations<I>::metadata_remove(const std::string &key) {
17091679
boost::bind(&ImageWatcher<I>::notify_metadata_remove,
17101680
m_image_ctx.image_watcher, request_id,
17111681
key, _1));
1712-
if (r == -ENOENT) {
1713-
r = 0;
1714-
}
17151682

17161683
std::string config_key;
17171684
if (util::is_metadata_config_override(key, &config_key) && r >= 0) {
@@ -1775,11 +1742,8 @@ int Operations<I>::migrate(ProgressContext &prog_ctx) {
17751742
m_image_ctx.image_watcher, request_id,
17761743
boost::ref(prog_ctx), _1));
17771744

1778-
if (r < 0 && r != -EINVAL) {
1779-
return r;
1780-
}
17811745
ldout(cct, 20) << "migrate finished" << dendl;
1782-
return 0;
1746+
return r;
17831747
}
17841748

17851749
template <typename I>
@@ -1842,11 +1806,9 @@ int Operations<I>::sparsify(size_t sparse_size, ProgressContext &prog_ctx) {
18421806
m_image_ctx.image_watcher,
18431807
request_id, sparse_size,
18441808
boost::ref(prog_ctx), _1));
1845-
if (r < 0 && r != -EINVAL) {
1846-
return r;
1847-
}
1809+
18481810
ldout(cct, 20) << "resparsify finished" << dendl;
1849-
return 0;
1811+
return r;
18501812
}
18511813

18521814
template <typename I>
@@ -1934,7 +1896,7 @@ int Operations<I>::invoke_async_request(
19341896
permit_snapshot,
19351897
local_request,
19361898
remote_request,
1937-
{}, &ctx);
1899+
&ctx);
19381900
req->send();
19391901
return ctx.wait();
19401902
}

0 commit comments

Comments
 (0)