]> git.proxmox.com Git - ceph.git/blob - ceph/src/rbd_replay/PendingIO.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rbd_replay / PendingIO.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 Adam Crume <adamcrume@gmail.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #include "PendingIO.hpp"
16 #include "rbd_replay_debug.hpp"
17
18 #define dout_context g_ceph_context
19
20 using namespace rbd_replay;
21
22 extern "C"
23 void rbd_replay_pending_io_callback(librbd::completion_t cb, void *arg) {
24 PendingIO *io = static_cast<PendingIO*>(arg);
25 io->completed(cb);
26 }
27
28 PendingIO::PendingIO(action_id_t id,
29 ActionCtx &worker)
30 : m_id(id),
31 m_completion(new librbd::RBD::AioCompletion(this, rbd_replay_pending_io_callback)),
32 m_worker(worker) {
33 }
34
35 PendingIO::~PendingIO() {
36 m_completion->release();
37 }
38
39 void PendingIO::completed(librbd::completion_t cb) {
40 dout(ACTION_LEVEL) << "Completed pending IO #" << m_id << dendl;
41 ssize_t r = m_completion->get_return_value();
42 assertf(r >= 0, "id = %d, r = %d", m_id, r);
43 m_worker.remove_pending(shared_from_this());
44 }