The function changes lock to SYNC state without checking issued caps.
which can cause inconsistent between lock state and issued caps.
Besides the function is not very useful because locks except nestlock
have SYNC state as default. It's unlikely that unused lock is in LOCK
state.
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit
509651702cebd4d4e09eb12865627652ba8cd0c7)
// -- replication
void encode_replica(mds_rank_t mds, bufferlist& bl, bool need_recover) {
- if (!is_replicated())
- lock.replicate_relax();
-
__u32 nonce = add_replica(mds);
encode(nonce, bl);
encode(first, bl);
return false;
}
-void CInode::replicate_relax_locks()
-{
- //dout(10) << " relaxing locks on " << *this << dendl;
- ceph_assert(is_auth());
- ceph_assert(!is_replicated());
-
- authlock.replicate_relax();
- linklock.replicate_relax();
- dirfragtreelock.replicate_relax();
- filelock.replicate_relax();
- xattrlock.replicate_relax();
- snaplock.replicate_relax();
- nestlock.replicate_relax();
- flocklock.replicate_relax();
- policylock.replicate_relax();
-}
-
-
// =============================================
void encode_replica(mds_rank_t rep, bufferlist& bl, uint64_t features, bool need_recover) {
ceph_assert(is_auth());
- // relax locks?
- if (!is_replicated())
- replicate_relax_locks();
-
__u32 nonce = add_replica(rep);
using ceph::encode;
encode(nonce, bl);
bool is_any_caps_wanted() const;
int get_caps_wanted(int *ploner = 0, int *pother = 0, int shift = 0, int mask = -1) const;
bool issued_caps_need_gather(SimpleLock *lock);
- void replicate_relax_locks();
// -- authority --
mds_authority_t authority() const override;
dout(7) << "encode_export_inode " << *in << dendl;
ceph_assert(!in->is_replica(mds->get_nodeid()));
- // relax locks?
- if (!in->is_replicated()) {
- in->replicate_relax_locks();
- dout(20) << " did replicate_relax_locks, now " << *in << dendl;
- }
-
encode(in->inode.ino, enc_state);
encode(in->last, enc_state);
in->encode_export(enc_state);
for (auto &p : *dir) {
CDentry *dn = p.second;
CInode *in = dn->get_linkage()->get_inode();
-
- if (!dn->is_replicated())
- dn->lock.replicate_relax();
num_exported++;
state_flags &= ~LEASED;
}
- bool is_used() const {
- return is_xlocked() || is_rdlocked() || is_wrlocked() || is_leased();
- }
-
bool needs_recover() const {
return state_flags & NEED_RECOVER;
}
state = get_replica_state();
}
- /** replicate_relax
- * called on first replica creation.
- */
- void replicate_relax() {
- ceph_assert(parent->is_auth());
- ceph_assert(!parent->is_replicated());
- if (state == LOCK_LOCK && !is_used())
- state = LOCK_SYNC;
- }
bool remove_replica(int from) {
if (is_gathering(from)) {
remove_gather(from);