if (r < 0)
return r;
+ c->get();
for (uint64_t i = start_block; i <= end_block; i++) {
bufferlist bl;
- string oid = get_block_oid(&ictx->header, i);
- uint64_t block_ofs = get_block_ofs(&ictx->header, off + total_write);
+ ictx->lock.Lock();
+ string oid = get_block_oid(ictx->header, i);
+ uint64_t block_ofs = get_block_ofs(ictx->header, off + total_write);
+ ictx->lock.Unlock();
uint64_t write_len = min(block_size - block_ofs, left);
bl.append(buf + total_write, write_len);
AioBlockCompletion *block_completion = new AioBlockCompletion(c, off, len, NULL);
int64_t ret;
int total_read = 0;
- uint64_t start_block = get_block_num(&ictx->header, off);
- uint64_t end_block = get_block_num(&ictx->header, off + len);
- uint64_t block_size = get_block_size(&ictx->header);
+ ictx->lock.Lock();
+ uint64_t start_block = get_block_num(ictx->header, off);
+ uint64_t end_block = get_block_num(ictx->header, off + len);
+ uint64_t block_size = get_block_size(ictx->header);
+ ictx->lock.Unlock();
uint64_t left = len;
+ c->get();
for (uint64_t i = start_block; i <= end_block; i++) {
bufferlist bl;
- string oid = get_block_oid(&ictx->header, i);
- uint64_t block_ofs = get_block_ofs(&ictx->header, off + total_read);
+ ictx->lock.Lock();
+ string oid = get_block_oid(ictx->header, i);
+ uint64_t block_ofs = get_block_ofs(ictx->header, off + total_read);
+ ictx->lock.Unlock();
uint64_t read_len = min(block_size - block_ofs, left);
map<uint64_t,uint64_t> m;