]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 Sebastien Ponce <sebastien.ponce@cern.ch> | |
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 "common/dout.h" | |
16 | ||
17 | #include "libradosstriper/MultiAioCompletionImpl.h" | |
18 | ||
19 | void libradosstriper::MultiAioCompletionImpl::complete_request(ssize_t r) | |
20 | { | |
21 | lock.Lock(); | |
22 | if (rval >= 0) { | |
23 | if (r < 0 && r != -EEXIST) | |
24 | rval = r; | |
25 | else if (r > 0) | |
26 | rval += r; | |
27 | } | |
28 | assert(pending_complete); | |
29 | int count = --pending_complete; | |
30 | if (!count && !building) { | |
31 | complete(); | |
32 | } | |
33 | put_unlock(); | |
34 | } | |
35 | ||
36 | void libradosstriper::MultiAioCompletionImpl::safe_request(ssize_t r) | |
37 | { | |
38 | lock.Lock(); | |
39 | if (rval >= 0) { | |
40 | if (r < 0 && r != -EEXIST) | |
41 | rval = r; | |
42 | } | |
43 | assert(pending_safe); | |
44 | int count = --pending_safe; | |
45 | if (!count && !building) { | |
46 | safe(); | |
47 | } | |
48 | put_unlock(); | |
49 | } | |
50 | ||
51 | void libradosstriper::MultiAioCompletionImpl::finish_adding_requests() | |
52 | { | |
53 | lock.Lock(); | |
54 | assert(building); | |
55 | building = false; | |
56 | if (!pending_complete) | |
57 | complete(); | |
58 | if (!pending_safe) | |
59 | safe(); | |
60 | lock.Unlock(); | |
61 | } | |
224ce89b WB |
62 | |
63 | void intrusive_ptr_add_ref(libradosstriper::MultiAioCompletionImpl* ptr) | |
64 | { | |
65 | ptr->get(); | |
66 | } | |
67 | ||
68 | void intrusive_ptr_release(libradosstriper::MultiAioCompletionImpl* ptr) | |
69 | { | |
70 | ptr->put(); | |
71 | } |