}
}
+void Server::set_reply_extra_bl(const cref_t<MClientRequest> &req, inodeno_t ino, bufferlist& extra_bl)
+{
+ Session *session = mds->get_session(req);
+
+ if (session->info.has_feature(CEPHFS_FEATURE_DELEG_INO)) {
+ openc_response_t ocresp;
+
+ dout(10) << "adding created_ino and delegated_inos" << dendl;
+ ocresp.created_ino = ino;
+
+ if (delegate_inos_pct && !req->is_queued_for_replay()) {
+ // Try to delegate some prealloc_inos to the client, if it's down to half the max
+ unsigned frac = 100 / delegate_inos_pct;
+ if (session->delegated_inos.size() < (unsigned)g_conf()->mds_client_prealloc_inos / frac / 2)
+ session->delegate_inos(g_conf()->mds_client_prealloc_inos / frac, ocresp.delegated_inos);
+ }
+
+ encode(ocresp, extra_bl);
+ } else if (req->get_connection()->has_feature(CEPH_FEATURE_REPLY_CREATE_INODE)) {
+ dout(10) << "adding ino to reply to indicate inode was created" << dendl;
+ // add the file created flag onto the reply if create_flags features is supported
+ encode(ino, extra_bl);
+ }
+}
+
void Server::handle_client_request(const cref_t<MClientRequest> &req)
{
dout(4) << "handle_client_request " << *req << dendl;
C_MDS_openc_finish *fin = new C_MDS_openc_finish(this, mdr, dn, newi);
- if (mdr->session->info.has_feature(CEPHFS_FEATURE_DELEG_INO)) {
- openc_response_t ocresp;
-
- dout(10) << "adding created_ino and delegated_inos" << dendl;
- ocresp.created_ino = _inode->ino;
-
- if (delegate_inos_pct && !req->is_queued_for_replay()) {
- // Try to delegate some prealloc_inos to the client, if it's down to half the max
- unsigned frac = 100 / delegate_inos_pct;
- if (mdr->session->delegated_inos.size() < (unsigned)g_conf()->mds_client_prealloc_inos / frac / 2)
- mdr->session->delegate_inos(g_conf()->mds_client_prealloc_inos / frac, ocresp.delegated_inos);
- }
-
- encode(ocresp, mdr->reply_extra_bl);
- } else if (mdr->client_request->get_connection()->has_feature(CEPH_FEATURE_REPLY_CREATE_INODE)) {
- dout(10) << "adding ino to reply to indicate inode was created" << dendl;
- // add the file created flag onto the reply if create_flags features is supported
- encode(_inode->ino, mdr->reply_extra_bl);
- }
+ set_reply_extra_bl(req, _inode->ino, mdr->reply_extra_bl);
journal_and_reply(mdr, newi, dn, le, fin);