Skip to content

Commit 0331c2f

Browse files
committed
librados: expose op cancellation through AioCompletion::cancel()
Signed-off-by: Casey Bodley <[email protected]>
1 parent 5fd7d2a commit 0331c2f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

PendingReleaseNotes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
(--yes-i-really-mean-it). This has been added as a precaution to tell the
3535
users that modifying "max_mds" may not help with troubleshooting or recovery
3636
effort. Instead, it might further destabilize the cluster.
37+
* RADOS: Added convenience function `librados::AioCompletion::cancel()` with
38+
the same behavior as `librados::IoCtx::aio_cancel()`.
3739

3840
* mgr/restful, mgr/zabbix: both modules, already deprecated since 2020, have been
3941
finally removed. They have not been actively maintenance in the last years,

src/include/rados/librados.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ inline namespace v14_2_0 {
202202
int set_complete_callback(void *cb_arg, callback_t cb);
203203
int set_safe_callback(void *cb_arg, callback_t cb)
204204
__attribute__ ((deprecated));
205+
/// Request immediate cancellation with error code -ECANCELED
206+
/// if the operation hasn't already completed.
207+
int cancel();
205208
int wait_for_complete();
206209
int wait_for_safe() __attribute__ ((deprecated));
207210
int wait_for_complete_and_cb();

src/librados/librados_cxx.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,14 @@ void librados::AioCompletion::release()
11031103
delete this;
11041104
}
11051105

1106+
int librados::AioCompletion::cancel()
1107+
{
1108+
if (!pc->io) {
1109+
return 0; // no operation was started
1110+
}
1111+
return pc->io->aio_cancel(pc);
1112+
}
1113+
11061114
///////////////////////////// IoCtx //////////////////////////////
11071115
librados::IoCtx::IoCtx() : io_ctx_impl(NULL)
11081116
{

0 commit comments

Comments
 (0)