]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/io/ImageDispatchSpec.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / io / ImageDispatchSpec.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "librbd/io/ImageDispatchSpec.h"
5 #include "librbd/ImageCtx.h"
6 #include "librbd/io/AioCompletion.h"
7 #include "librbd/io/ImageRequest.h"
8 #include "librbd/io/ImageDispatcherInterface.h"
9 #include <boost/variant.hpp>
10
11 namespace librbd {
12 namespace io {
13
14 void ImageDispatchSpec::C_Dispatcher::complete(int r) {
15 switch (image_dispatch_spec->dispatch_result) {
16 case DISPATCH_RESULT_RESTART:
17 ceph_assert(image_dispatch_spec->dispatch_layer != 0);
18 image_dispatch_spec->dispatch_layer = static_cast<ImageDispatchLayer>(
19 image_dispatch_spec->dispatch_layer - 1);
20 [[fallthrough]];
21 case DISPATCH_RESULT_CONTINUE:
22 if (r < 0) {
23 // bubble dispatch failure through AioCompletion
24 image_dispatch_spec->dispatch_result = DISPATCH_RESULT_COMPLETE;
25 image_dispatch_spec->fail(r);
26 return;
27 }
28
29 image_dispatch_spec->send();
30 break;
31 case DISPATCH_RESULT_COMPLETE:
32 finish(r);
33 break;
34 case DISPATCH_RESULT_INVALID:
35 ceph_abort();
36 break;
37 }
38 }
39
40 void ImageDispatchSpec::C_Dispatcher::finish(int r) {
41 delete image_dispatch_spec;
42 }
43
44 void ImageDispatchSpec::send() {
45 image_dispatcher->send(this);
46 }
47
48 void ImageDispatchSpec::fail(int r) {
49 dispatch_result = DISPATCH_RESULT_COMPLETE;
50 aio_comp->fail(r);
51 }
52
53 } // namespace io
54 } // namespace librbd