From 2d90aec73eff8fbdcbd2b0210a23ebd50ea78c88 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 28 May 2024 12:18:06 +0800 Subject: [PATCH] mds: add set_reply_extra_bl() helper support Fixes: https://tracker.ceph.com/issues/63265 Signed-off-by: Xiubo Li (cherry picked from commit 6615a568cdfbefb421c37ef790acba03ce20f843) --- src/mds/Server.cc | 45 ++++++++++++++++++++++++++------------------- src/mds/Server.h | 1 + 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index ca083118bd2d4..e80e4c2433a9b 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -2475,6 +2475,31 @@ void Server::trim_completed_request_list(ceph_tid_t tid, Session *session) } } +void Server::set_reply_extra_bl(const cref_t &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 &req) { dout(4) << "handle_client_request " << *req << dendl; @@ -4776,25 +4801,7 @@ void Server::handle_client_openc(MDRequestRef& mdr) 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); diff --git a/src/mds/Server.h b/src/mds/Server.h index 47f86518b5141..3e7f1887789b3 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -158,6 +158,7 @@ public: void force_clients_readonly(); // -- requests -- + void set_reply_extra_bl(const cref_t &req, inodeno_t ino, bufferlist& extra_bl); void trim_completed_request_list(ceph_tid_t tid, Session *session); void handle_client_request(const cref_t &m); void handle_client_reply(const cref_t &m); -- 2.39.5