diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2012-09-10 13:19:53 -0700 |
---|---|---|
committer | Josh Durgin <josh.durgin@inktank.com> | 2012-09-10 13:21:35 -0700 |
commit | 97d8a734ce937ce2a683c7c36f5b72395c6456c2 (patch) | |
tree | fb51da38a613f35d770a4b58c9e24739cd440d26 /src/librbd.cc | |
parent | 61d705e2d67f83c81aa7c6362ec6703e014ecb87 (diff) | |
download | ceph-97d8a734ce937ce2a683c7c36f5b72395c6456c2.tar.gz |
librbd: ignore -ENOENT during discard
This is a backport of a3ad98a3eef062e9ed51dd2d1e58c593e12c9703
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'src/librbd.cc')
-rw-r--r-- | src/librbd.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/librbd.cc b/src/librbd.cc index 754ac283fb7..569a372acf7 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -1819,7 +1819,7 @@ int discard(ImageCtx *ictx, uint64_t off, uint64_t len) else write_op.zero(block_ofs, write_len); r = ictx->data_ctx.operate(oid, &write_op); - if (r < 0) + if (r < 0 && r != -ENOENT) return r; total_write += write_len; left -= write_len; @@ -1942,6 +1942,16 @@ void rados_cb(rados_completion_t c, void *arg) delete block_completion; } +void rados_discard_cb(rados_completion_t c, void *arg) +{ + AioBlockCompletion *block_completion = (AioBlockCompletion *)arg; + int r = rados_aio_get_return_value(c); + if (r == -ENOENT) + r = 0; + block_completion->finish(r); + delete block_completion; +} + int check_io(ImageCtx *ictx, uint64_t off, uint64_t len) { ictx->lock.Lock(); @@ -2107,7 +2117,7 @@ int aio_discard(ImageCtx *ictx, uint64_t off, uint64_t len, AioCompletion *c) c->add_block_completion(block_completion); librados::AioCompletion *rados_completion = - Rados::aio_create_completion(block_completion, NULL, rados_cb); + Rados::aio_create_completion(block_completion, NULL, rados_discard_cb); r = ictx->data_ctx.aio_operate(oid, rados_completion, &block_completion->write_op); rados_completion->release(); |