ceph: don't rely on error_string to validate blocklisted session.
Subsystems (2)
PATCH 1/1 ceph: don't rely on error_string to validate blocklisted session.
From: Kotresh HR <[email protected]>
The "error_string" in the metadata of MClientSession is being parsed by kclient to validate whether the session is blocklisted. The "error_string" is for humans and shouldn't be relied on it. Hence added the flag to MClientsession to indicate the session is blocklisted.
URL: https://tracker.ceph.com/issues/47450
--- fs/ceph/mds_client.c | 13 +++++++++++++ include/linux/ceph/ceph_fs.h | 2 ++ 2 files changed, 15 insertions(+)
fs/ceph/mds_client.c +13 -0
@@ -3407,6 +3407,19 @@ static void handle_session(struct ceph_mds_session *session, } } +if (msg_version >=5 ) { +u32 len; +u32 flags; +/* version >= 4, metric_spec (struct_v, struct_cv, len, metric_flag) */ +ceph_decode_skip_n (&p, end,2 +sizeof (u32) *2 , bad); +/* version >= 5, flags */ +ceph_decode_32_safe (&p, end, flags, bad); +if (flags &CEPH_SESSION_BLOCKLISTED ) { +pr_info ("mds%d session blocklisted\n" , session->s_mds); + blocklisted = true; + } + } +mutex_lock (&mdsc->mutex);if (op ==CEPH_SESSION_CLOSE ) {ceph_get_mds_session (session);
include/linux/ceph/ceph_fs.h +2 -0
@@ -302,6 +302,8 @@ enum { CEPH_SESSION_REQUEST_FLUSH_MDLOG, }; +#define CEPH_SESSION_BLOCKLISTED (1 << 0)/* session blocklisted */ +extern const char *ceph_session_op_name (int op);struct ceph_mds_session_head {
Signature · 1 line
2.25.1
Quoted 22 lines · On Thu, 2021-09-23 at 18:56 +0530, [email protected] wrote:
From: Kotresh HR <[email protected]>
The "
error_string" in the metadata of MClientSession is being parsed by kclient to validate whether the session is blocklisted. The "error_string" is for humans and shouldn't be relied on it. Hence added the flag to MClientsession to indicate the session is blocklisted.URL: https://tracker.ceph.com/issues/47450
Signed-off-by Kotresh HR <[email protected]>--- fs/ceph/mds_client.c | 13 +++++++++++++ include/linux/ceph/ceph_fs.h | 2 ++ 2 files changed, 15 insertions(+)fs/ceph/mds_client.c +0
-0@@ -3407,6 +3407,19 @@ static void handle_session(struct ceph_mds_session *session, } }
fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3418
Quoted 10 lines
fs/ceph/mds_client.c +9
-0+if (msg_version >=5 ) { +u32 len; +u32 flags; +/* version >= 4, metric_spec (struct_v, struct_cv, len, metric_flag) */ +ceph_decode_skip_n (&p, end,2 +sizeof (u32) *2 , bad); +/* version >= 5, flags */ +ceph_decode_32_safe (&p, end, flags, bad); +if (flags &CEPH_SESSION_BLOCKLISTED ) { +pr_info ("mds%d session blocklisted\n" , session->s_mds);
Things are likely to not work well if this flag is set. Maybe this should be a pr_warn?
Quoted 12 lines
fs/ceph/mds_client.c +4
-0+ blocklisted = true; + } + } +mutex_lock (&mdsc->mutex);if (op ==CEPH_SESSION_CLOSE ) {ceph_get_mds_session (session);include/linux/ceph/ceph_fs.h +0
-0
include/linux/ceph/ceph_fs.h enum { · line 309
Quoted 8 lines
include/linux/ceph/ceph_fs.h +2
-0@@ -302,6 +302,8 @@ enum { CEPH_SESSION_REQUEST_FLUSH_MDLOG, }; +#define CEPH_SESSION_BLOCKLISTED (1 << 0)/* session blocklisted */ +extern const char *ceph_session_op_name (int op);struct ceph_mds_session_head {
This looks reasonable, but incomplete.
If the msg_version >= 5, then we probably also don't need to scan for "blacklisted" in the strings, right? In fact, it looks like we can avoid doing most of __decode_session_metadata in that case and can just skip over the text blob section.
Signature · 1 line
Jeff Layton <[email protected]>