Skip to content

Commit 63ad865

Browse files
committed
Merge PR ceph#57754 into main
* refs/pull/57754/head: mds: set the proper extra bl for the create request mds: encode the correct extra info depending on the feature bits mds: add set_reply_extra_bl() helper support mds: cleanup the code to make it to be more readable Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-by: Greg Farnum <[email protected]>
2 parents 426beef + 3482100 commit 63ad865

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

src/mds/Server.cc

Lines changed: 37 additions & 22 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;
@@ -2549,7 +2574,7 @@ void Server::handle_client_request(const cref_t<MClientRequest> &req)
25492574
auto reply = make_message<MClientReply>(*req, 0);
25502575
if (created != inodeno_t()) {
25512576
bufferlist extra;
2552-
encode(created, extra);
2577+
set_reply_extra_bl(req, created, extra);
25532578
reply->set_extra_bl(extra);
25542579
}
25552580
mds->send_message_client(reply, session);
@@ -2765,10 +2790,18 @@ void Server::dispatch_client_request(const MDRequestRef& mdr)
27652790

27662791
// funky.
27672792
case CEPH_MDS_OP_CREATE:
2768-
if (mdr->has_completed)
2793+
if (mdr->has_completed) {
2794+
inodeno_t created;
2795+
2796+
ceph_assert(mdr->session);
2797+
mdr->session->have_completed_request(req->get_reqid().tid, &created);
2798+
ceph_assert(created != inodeno_t());
2799+
2800+
set_reply_extra_bl(req, created, mdr->reply_extra_bl);
27692801
handle_client_open(mdr); // already created.. just open
2770-
else
2802+
} else {
27712803
handle_client_openc(mdr);
2804+
}
27722805
break;
27732806

27742807
case CEPH_MDS_OP_OPEN:
@@ -4794,25 +4827,7 @@ void Server::handle_client_openc(const MDRequestRef& mdr)
47944827

47954828
C_MDS_openc_finish *fin = new C_MDS_openc_finish(this, mdr, dn, newi);
47964829

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(newi->ino(), mdr->reply_extra_bl);
4815-
}
4830+
set_reply_extra_bl(req, _inode->ino, mdr->reply_extra_bl);
48164831

48174832
journal_and_reply(mdr, newi, dn, le, fin);
48184833

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)