}
}
-void CInode::split_need_snapflush(CInode *cowin, CInode *in)
+bool CInode::split_need_snapflush(CInode *cowin, CInode *in)
{
dout(10) << "split_need_snapflush [" << cowin->first << "," << cowin->last << "] for " << *cowin << dendl;
+ bool need_flush = false;
for (compact_map<snapid_t, set<client_t> >::iterator p = client_need_snapflush.lower_bound(cowin->first);
p != client_need_snapflush.end() && p->first < in->first; ) {
compact_map<snapid_t, set<client_t> >::iterator q = p;
++p;
assert(!q->second.empty());
- if (cowin->last >= q->first)
+ if (cowin->last >= q->first) {
cowin->auth_pin(this);
- else
+ need_flush = true;
+ } else
client_need_snapflush.erase(q);
in->auth_unpin(this);
}
+ return need_flush;
}
void CInode::mark_dirty_rstat()
void add_need_snapflush(CInode *snapin, snapid_t snapid, client_t client);
void remove_need_snapflush(CInode *snapin, snapid_t snapid, client_t client);
- void split_need_snapflush(CInode *cowin, CInode *in);
+ bool split_need_snapflush(CInode *cowin, CInode *in);
protected:
if (in->last != CEPH_NOSNAP) {
CInode *head_in = get_inode(in->ino());
assert(head_in);
- head_in->split_need_snapflush(oldin, in);
+ if (head_in->split_need_snapflush(oldin, in)) {
+ oldin->client_snap_caps = in->client_snap_caps;
+ for (compact_map<int,set<client_t> >::iterator p = in->client_snap_caps.begin();
+ p != in->client_snap_caps.end();
+ ++p) {
+ SimpleLock *lock = oldin->get_lock(p->first);
+ assert(lock);
+ for (auto q = p->second.begin(); q != p->second.end(); ++q) {
+ oldin->auth_pin(lock);
+ lock->set_state(LOCK_SNAP_SYNC); // gathering
+ lock->get_wrlock(true);
+ }
+ }
+ }
+ return oldin;
}
// clone caps?