int64_t Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl)
{
+ int have = 0;
+ bool movepos = false;
+ std::unique_ptr<C_SaferCond> onuninline;
+ int64_t r;
const md_config_t *conf = cct->_conf;
Inode *in = f->inode.get();
return -EBADF;
//bool lazy = f->mode == CEPH_FILE_MODE_LAZY;
- bool movepos = false;
if (offset < 0) {
lock_fh_pos(f);
offset = f->pos;
if (in->inline_version == 0) {
int r = _getattr(in, CEPH_STAT_CAP_INLINE_DATA, f->actor_perms, true);
if (r < 0) {
- if (movepos)
- unlock_fh_pos(f);
- return r;
+ goto done;
}
assert(in->inline_version > 0);
}
retry:
- int have;
- int r = get_caps(in, CEPH_CAP_FILE_RD, CEPH_CAP_FILE_CACHE, &have, -1);
+ have = 0;
+ r = get_caps(in, CEPH_CAP_FILE_RD, CEPH_CAP_FILE_CACHE, &have, -1);
if (r < 0) {
- if (movepos)
- unlock_fh_pos(f);
- return r;
+ goto done;
}
if (f->flags & O_DIRECT)
have &= ~CEPH_CAP_FILE_CACHE;
- std::unique_ptr<C_SaferCond> onuninline = nullptr;
-
if (in->inline_version < CEPH_INLINE_NONE) {
if (!(have & CEPH_CAP_FILE_CACHE)) {
onuninline.reset(new C_SaferCond("Client::_read_uninline_data flock"));
}
success:
+ assert(r >= 0);
if (movepos) {
// adjust fd pos
- f->pos = start_pos + bl->length();
- unlock_fh_pos(f);
+ f->pos = start_pos + r;
}
done:
// done!
- if (nullptr != onuninline) {
+ if (onuninline) {
client_lock.Unlock();
int ret = onuninline->wait();
client_lock.Lock();
} else
r = ret;
}
-
- if (have)
+ if (have) {
put_cap_ref(in, CEPH_CAP_FILE_RD);
- if (r < 0) {
- if (movepos)
- unlock_fh_pos(f);
- return r;
- } else
- return bl->length();
+ }
+ if (movepos) {
+ unlock_fh_pos(f);
+ }
+ return r;
}
Client::C_Readahead::C_Readahead(Client *c, Fh *f) :