mds_caps_wanted.swap(m);
if (old_empty != (bool)mds_caps_wanted.empty()) {
if (old_empty)
- adjust_num_caps_wanted(1);
+ adjust_num_caps_notable(1);
else
- adjust_num_caps_wanted(-1);
+ adjust_num_caps_notable(-1);
}
}
if (wanted) {
mds_caps_wanted[mds] = wanted;
if (old_empty)
- adjust_num_caps_wanted(1);
+ adjust_num_caps_notable(1);
} else if (!old_empty) {
mds_caps_wanted.erase(mds);
if (mds_caps_wanted.empty())
- adjust_num_caps_wanted(-1);
+ adjust_num_caps_notable(-1);
}
}
-void CInode::adjust_num_caps_wanted(int d)
+void CInode::adjust_num_caps_notable(int d)
{
- if (!num_caps_wanted && d > 0)
+ if (!num_caps_notable && d > 0)
mdcache->open_file_table.add_inode(this);
- else if (num_caps_wanted > 0 && num_caps_wanted == -d)
+ else if (num_caps_notable > 0 && num_caps_notable == -d)
mdcache->open_file_table.remove_inode(this);
- num_caps_wanted +=d;
- ceph_assert(num_caps_wanted >= 0);
+ num_caps_notable +=d;
+ ceph_assert(num_caps_notable >= 0);
}
Capability *CInode::add_client_cap(client_t client, Session *session,
if (client == loner_cap)
loner_cap = -1;
- if (cap->wanted())
- adjust_num_caps_wanted(-1);
+ if (cap->is_wanted_notable())
+ adjust_num_caps_notable(-1);
client_caps.erase(it);
if (client_caps.empty()) {
clear_file_locks();
ceph_assert(num_projected_xattrs == 0);
ceph_assert(num_projected_srnodes == 0);
- ceph_assert(num_caps_wanted == 0);
+ ceph_assert(num_caps_notable == 0);
ceph_assert(num_subtree_roots == 0);
ceph_assert(num_exporting_dirs == 0);
ceph_assert(batch_ops.empty());
}
}
- int get_num_caps_wanted() const { return num_caps_wanted; }
- void adjust_num_caps_wanted(int d);
+ int get_num_caps_notable() const { return num_caps_notable; }
+ void adjust_num_caps_notable(int d);
Capability *add_client_cap(client_t client, Session *session,
SnapRealm *conrealm=nullptr, bool new_inode=false);
mempool_cap_map client_caps; // client -> caps
mempool::mds_co::compact_map<int32_t, int32_t> mds_caps_wanted; // [auth] mds -> caps wanted
int replica_caps_wanted = 0; // [replica] what i've requested from auth
- int num_caps_wanted = 0;
+ int num_caps_notable = 0;
ceph_lock_state_t *fcntl_locks = nullptr;
ceph_lock_state_t *flock_locks = nullptr;
void Capability::set_wanted(int w) {
CInode *in = get_inode();
if (in) {
- if (!_wanted && w) {
- in->adjust_num_caps_wanted(1);
- } else if (_wanted && !w) {
- in->adjust_num_caps_wanted(-1);
- }
if (!is_wanted_notable(_wanted) && is_wanted_notable(w)) {
+ in->adjust_num_caps_notable(1);
if (!is_notable())
mark_notable();
} else if (is_wanted_notable(_wanted) && !is_wanted_notable(w)) {
+ in->adjust_num_caps_notable(-1);
maybe_clear_notable();
}
}
static bool is_wanted_notable(int wanted) {
return wanted & (CEPH_CAP_ANY_WR|CEPH_CAP_FILE_WR|CEPH_CAP_FILE_RD);
}
+ bool is_wanted_notable() const {
+ return is_wanted_notable(wanted());
+ }
bool is_notable() const { return state & STATE_NOTABLE; }
bool is_stale() const;