Skip to content

Commit 6615a56

Browse files
lxbszxiubli
authored andcommitted
mds: add set_reply_extra_bl() helper support
Fixes: https://tracker.ceph.com/issues/63265 Signed-off-by: Xiubo Li <[email protected]>
1 parent d48b169 commit 6615a56

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/mds/Server.cc

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,6 +2489,31 @@ void Server::trim_completed_request_list(ceph_tid_t tid, Session *session)
24892489
}
24902490
}
24912491

2492+
void Server::set_reply_extra_bl(const cref_t<MClientRequest> &req, inodeno_t ino, bufferlist& extra_bl)
2493+
{
2494+
Session *session = mds->get_session(req);
2495+
2496+
if (session->info.has_feature(CEPHFS_FEATURE_DELEG_INO)) {
2497+
openc_response_t ocresp;
2498+
2499+
dout(10) << "adding created_ino and delegated_inos" << dendl;
2500+
ocresp.created_ino = ino;
2501+
2502+
if (delegate_inos_pct && !req->is_queued_for_replay()) {
2503+
// Try to delegate some prealloc_inos to the client, if it's down to half the max
2504+
unsigned frac = 100 / delegate_inos_pct;
2505+
if (session->delegated_inos.size() < (unsigned)g_conf()->mds_client_prealloc_inos / frac / 2)
2506+
session->delegate_inos(g_conf()->mds_client_prealloc_inos / frac, ocresp.delegated_inos);
2507+
}
2508+
2509+
encode(ocresp, extra_bl);
2510+
} else if (req->get_connection()->has_feature(CEPH_FEATURE_REPLY_CREATE_INODE)) {
2511+
dout(10) << "adding ino to reply to indicate inode was created" << dendl;
2512+
// add the file created flag onto the reply if create_flags features is supported
2513+
encode(ino, extra_bl);
2514+
}
2515+
}
2516+
24922517
void Server::handle_client_request(const cref_t<MClientRequest> &req)
24932518
{
24942519
dout(4) << "handle_client_request " << *req << dendl;
@@ -4794,25 +4819,7 @@ void Server::handle_client_openc(const MDRequestRef& mdr)
47944819

47954820
C_MDS_openc_finish *fin = new C_MDS_openc_finish(this, mdr, dn, newi);
47964821

4797-
if (mdr->session->info.has_feature(CEPHFS_FEATURE_DELEG_INO)) {
4798-
openc_response_t ocresp;
4799-
4800-
dout(10) << "adding created_ino and delegated_inos" << dendl;
4801-
ocresp.created_ino = _inode->ino;
4802-
4803-
if (delegate_inos_pct && !req->is_queued_for_replay()) {
4804-
// Try to delegate some prealloc_inos to the client, if it's down to half the max
4805-
unsigned frac = 100 / delegate_inos_pct;
4806-
if (mdr->session->delegated_inos.size() < (unsigned)g_conf()->mds_client_prealloc_inos / frac / 2)
4807-
mdr->session->delegate_inos(g_conf()->mds_client_prealloc_inos / frac, ocresp.delegated_inos);
4808-
}
4809-
4810-
encode(ocresp, mdr->reply_extra_bl);
4811-
} else if (mdr->client_request->get_connection()->has_feature(CEPH_FEATURE_REPLY_CREATE_INODE)) {
4812-
dout(10) << "adding ino to reply to indicate inode was created" << dendl;
4813-
// add the file created flag onto the reply if create_flags features is supported
4814-
encode(_inode->ino, mdr->reply_extra_bl);
4815-
}
4822+
set_reply_extra_bl(req, _inode->ino, mdr->reply_extra_bl);
48164823

48174824
journal_and_reply(mdr, newi, dn, le, fin);
48184825

src/mds/Server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class Server {
160160
void force_clients_readonly();
161161

162162
// -- requests --
163+
void set_reply_extra_bl(const cref_t<MClientRequest> &req, inodeno_t ino, bufferlist& extra_bl);
163164
void trim_completed_request_list(ceph_tid_t tid, Session *session);
164165
void handle_client_request(const cref_t<MClientRequest> &m);
165166
void handle_client_reply(const cref_t<MClientReply> &m);

0 commit comments

Comments
 (0)