if (in->cap_snaps.size())
flush_snaps(in, true);
if (in->flushing_caps)
- flush_caps(in, session);
+ flush_caps(in, session, flags & CHECK_CAPS_SYNCHRONOUS);
}
int flushing;
flush_tid = 0;
}
- send_cap(in, session, cap, false, cap_used, wanted, retain, flushing,
- flush_tid);
+ send_cap(in, session, cap, flags & CHECK_CAPS_SYNCHRONOUS, cap_used, wanted,
+ retain, flushing, flush_tid);
}
}
}
}
-void Client::flush_caps(Inode *in, MetaSession *session)
+void Client::flush_caps(Inode *in, MetaSession *session, bool sync)
{
ldout(cct, 10) << "flush_caps " << in << " mds." << session->mds_num << dendl;
Cap *cap = in->auth_cap;
for (map<ceph_tid_t,int>::iterator p = in->flushing_cap_tids.begin();
p != in->flushing_cap_tids.end();
++p) {
- send_cap(in, session, cap, false, (get_caps_used(in) | in->caps_dirty()),
+ bool req_sync = false;
+
+ /* If this is a synchronous request, then flush the journal on last one */
+ if (sync && (p->first == in->flushing_cap_tids.rbegin()->first))
+ req_sync = true;
+
+ send_cap(in, session, cap, req_sync,
+ (get_caps_used(in) | in->caps_dirty()),
in->caps_wanted(), (cap->issued | cap->implemented),
p->second, p->first);
}
}
if (!syncdataonly && in->dirty_caps) {
- check_caps(in, CHECK_CAPS_NODELAY);
+ check_caps(in, CHECK_CAPS_NODELAY|CHECK_CAPS_SYNCHRONOUS);
if (in->flushing_caps)
flush_tid = last_flush_tid;
} else ldout(cct, 10) << "no metadata needs to commit" << dendl;
int mark_caps_flushing(Inode *in, ceph_tid_t *ptid);
void adjust_session_flushing_caps(Inode *in, MetaSession *old_s, MetaSession *new_s);
void flush_caps();
- void flush_caps(Inode *in, MetaSession *session);
+ void flush_caps(Inode *in, MetaSession *session, bool sync=false);
void kick_flushing_caps(MetaSession *session);
void early_kick_flushing_caps(MetaSession *session);
void kick_maxsize_requests(MetaSession *session);
/* Flags for check_caps() */
#define CHECK_CAPS_NODELAY (0x1)
+#define CHECK_CAPS_SYNCHRONOUS (0x2)
void check_caps(Inode *in, unsigned flags);
void get_cap_ref(Inode *in, int cap);