void Inode::get_open_ref(int mode)
{
+ client->inc_opened_files();
+ if (open_by_mode.count(mode) == 0)
+ client->inc_opened_inodes();
open_by_mode[mode]++;
break_deleg(!(mode & CEPH_FILE_MODE_WR));
}
//cout << "open_by_mode[" << mode << "] " << open_by_mode[mode] << " -> " << (open_by_mode[mode]-1) << std::endl;
auto& ref = open_by_mode.at(mode);
ceph_assert(ref > 0);
- if (--ref == 0)
+ client->dec_opened_files();
+ if (--ref == 0) {
+ client->dec_opened_inodes();
return true;
+ }
return false;
}
* This is the bog standard "check whether we have the required caps" operation.
* Typically, we only check against the capset that is currently "issued".
* In other words, we ignore caps that have been revoked but not yet released.
+ * Also account capability hit/miss stats.
*
* Some callers (particularly those doing attribute retrieval) can also make
* use of the full set of "implemented" caps to satisfy requests from the
cap_is_valid(*auth_cap) &&
(auth_cap->issued & mask) == mask) {
auth_cap->touch();
+ client->cap_hit();
return true;
}
// try any cap
if (cap_is_valid(cap)) {
if ((cap.issued & mask) == mask) {
cap.touch();
+ client->cap_hit();
return true;
}
c |= cap.issued;
for (auto &pair : caps) {
pair.second.touch();
}
+ client->cap_hit();
return true;
}
+
+ client->cap_miss();
return false;
}
if (is_dir()) {
f->dump_int("dir_hashed", (int)dir_hashed);
f->dump_int("dir_replicated", (int)dir_replicated);
+ if (dir_replicated) {
+ f->open_array_section("dirfrags");
+ for (const auto &frag : frag_repmap) {
+ f->open_object_section("frags");
+ CachedStackStringStream css;
+ *css << std::hex << frag.first.value() << "/" << std::dec << frag.first.bits();
+ f->dump_string("frag", css->strv());
+
+ f->open_array_section("repmap");
+ for (const auto &mds : frag.second) {
+ f->dump_int("mds", mds);
+ }
+ f->close_section();
+
+ f->close_section();
+ }
+ f->close_section();
+ }
}
f->open_array_section("caps");
* allow it, with an unusual error to make it clear.
*/
if (!client->get_deleg_timeout())
- return -ETIME;
+ return -CEPHFS_ETIME;
// Just say no if we have any recalled delegs still outstanding
if (has_recalled_deleg()) {
lsubdout(client->cct, client, 10) << __func__ <<
": has_recalled_deleg" << dendl;
- return -EAGAIN;
+ return -CEPHFS_EAGAIN;
}
// check vs. currently open files on this inode
if (open_count_for_write()) {
lsubdout(client->cct, client, 10) << __func__ <<
": open for write" << dendl;
- return -EAGAIN;
+ return -CEPHFS_EAGAIN;
}
break;
case CEPH_DELEGATION_WR:
if (open_count() > 1) {
lsubdout(client->cct, client, 10) << __func__ << ": open" << dendl;
- return -EAGAIN;
+ return -CEPHFS_EAGAIN;
}
break;
default:
- return -EINVAL;
+ return -CEPHFS_EINVAL;
}
/*
if (!caps_issued_mask(need)) {
lsubdout(client->cct, client, 10) << __func__ << ": cap mismatch, have="
<< ccap_string(caps_issued()) << " need=" << ccap_string(need) << dendl;
- return -EAGAIN;
+ return -CEPHFS_EAGAIN;
}
for (list<Delegation>::iterator d = delegations.begin();