@@ -301,6 +301,9 @@ public:
// -- replication
void encode_replica(int mds, bufferlist& bl) {
+ if (!is_replicated())
+ lock.replicate_relax();
+
__u32 nonce = add_replica(mds);
::encode(nonce, bl);
::encode(first, bl);
@@ -1425,13 +1425,16 @@ bool Locker::xlock_start(SimpleLock *lock, MDRequest *mut)
void Locker::_finish_xlock(SimpleLock *lock, bool *pneed_issue)
{
assert(!lock->is_stable());
- lock->get_parent()->auth_unpin(lock);
if (lock->get_type() != CEPH_LOCK_DN && ((CInode*)lock->get_parent())->get_loner() >= 0)
lock->set_state(LOCK_EXCL);
else
lock->set_state(LOCK_LOCK);
+ if (lock->get_type() == CEPH_LOCK_DN && lock->get_parent()->is_replicated() &&
+ !lock->is_waiter_for(SimpleLock::WAIT_WR))
+ simple_sync(lock, pneed_issue);
if (lock->get_cap_shift())
*pneed_issue = true;
+ lock->get_parent()->auth_unpin(lock);
}
void Locker::xlock_finish(SimpleLock *lock, Mutation *mut, bool *pneed_issue)
@@ -6735,14 +6735,10 @@ int MDCache::path_traverse(MDRequest *mdr, Message *req, Context *fin, // wh
(dn->lock.is_xlocked() && dn->lock.get_xlock_by() == mdr)) {
dout(10) << "traverse: miss on null+readable dentry " << path[depth] << " " << *dn << dendl;
return -ENOENT;
- } else if (curdir->is_auth()) {
+ } else {
dout(10) << "miss on dentry " << *dn << ", can't read due to lock" << dendl;
dn->lock.add_waiter(SimpleLock::WAIT_RD, _get_waiter(mdr, req, fin));
return 1;
- } else {
- // non-auth and can not read, treat this as no dentry
- dn = NULL;
- dnl = NULL;
}
}
@@ -1135,6 +1135,9 @@ int Migrator::encode_export_dir(bufferlist& exportbl,
CDentry *dn = it->second;
CInode *in = dn->get_linkage()->get_inode();
+ if (!dn->is_replicated())
+ dn->lock.replicate_relax();
+
num_exported++;
// -- dentry