mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
rbd: correct the return code and perf counter in discard op
If length is clipped in aio_discard, the actual discarded length would be less than the passed in argument. Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
This commit is contained in:
parent
40c2662128
commit
865b1e6f22
@ -3121,9 +3121,17 @@ reprotect_and_return_err:
|
||||
bool done;
|
||||
int ret;
|
||||
|
||||
uint64_t mylen = len;
|
||||
ictx->snap_lock.get_read();
|
||||
int r = clip_io(ictx, off, &mylen);
|
||||
ictx->snap_lock.put_read();
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
Context *ctx = new C_SafeCond(&mylock, &cond, &done, &ret);
|
||||
AioCompletion *c = aio_create_completion_internal(ctx, rbd_ctx_cb);
|
||||
int r = aio_discard(ictx, off, len, c);
|
||||
r = aio_discard(ictx, off, mylen, c);
|
||||
if (r < 0) {
|
||||
c->release();
|
||||
delete ctx;
|
||||
@ -3142,8 +3150,8 @@ reprotect_and_return_err:
|
||||
elapsed = ceph_clock_now(ictx->cct) - start_time;
|
||||
ictx->perfcounter->inc(l_librbd_discard_latency, elapsed);
|
||||
ictx->perfcounter->inc(l_librbd_discard);
|
||||
ictx->perfcounter->inc(l_librbd_discard_bytes, len);
|
||||
return len;
|
||||
ictx->perfcounter->inc(l_librbd_discard_bytes, mylen);
|
||||
return mylen;
|
||||
}
|
||||
|
||||
ssize_t handle_sparse_read(CephContext *cct,
|
||||
|
Loading…
Reference in New Issue
Block a user