Skip to content

Commit e1c9788

Browse files
kotreshhridryomov
authored andcommitted
ceph: don't rely on error_string to validate blocklisted session.
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. [ jlayton: minor formatting cleanup ] URL: https://tracker.ceph.com/issues/47450 Signed-off-by: Kotresh HR <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 25b7351 commit e1c9788

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

fs/ceph/mds_client.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,9 +3361,14 @@ static void handle_session(struct ceph_mds_session *session,
33613361

33623362
if (msg_version >= 3) {
33633363
u32 len;
3364-
/* version >= 2, metadata */
3365-
if (__decode_session_metadata(&p, end, &blocklisted) < 0)
3364+
/* version >= 2 and < 5, decode metadata, skip otherwise
3365+
* as it's handled via flags.
3366+
*/
3367+
if (msg_version >= 5)
3368+
ceph_decode_skip_map(&p, end, string, string, bad);
3369+
else if (__decode_session_metadata(&p, end, &blocklisted) < 0)
33663370
goto bad;
3371+
33673372
/* version >= 3, feature bits */
33683373
ceph_decode_32_safe(&p, end, len, bad);
33693374
if (len) {
@@ -3372,6 +3377,18 @@ static void handle_session(struct ceph_mds_session *session,
33723377
}
33733378
}
33743379

3380+
if (msg_version >= 5) {
3381+
u32 flags;
3382+
/* version >= 4, struct_v, struct_cv, len, metric_spec */
3383+
ceph_decode_skip_n(&p, end, 2 + sizeof(u32) * 2, bad);
3384+
/* version >= 5, flags */
3385+
ceph_decode_32_safe(&p, end, flags, bad);
3386+
if (flags & CEPH_SESSION_BLOCKLISTED) {
3387+
pr_warn("mds%d session blocklisted\n", session->s_mds);
3388+
blocklisted = true;
3389+
}
3390+
}
3391+
33753392
mutex_lock(&mdsc->mutex);
33763393
if (op == CEPH_SESSION_CLOSE) {
33773394
ceph_get_mds_session(session);

include/linux/ceph/ceph_fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ enum {
302302
CEPH_SESSION_REQUEST_FLUSH_MDLOG,
303303
};
304304

305+
#define CEPH_SESSION_BLOCKLISTED (1 << 0) /* session blocklisted */
306+
305307
extern const char *ceph_session_op_name(int op);
306308

307309
struct ceph_mds_session_head {

0 commit comments

Comments
 (0)