From 8dcfe9e2c0ed6772675e3fb56acf81dbf6ea40d2 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Thu, 19 Jun 2014 23:49:10 +0400 Subject: [PATCH] LU-5218 llog: keep llog ctxt indices constant The llog context id table cannot be shrinked easily because that will cause index shifting and incompatibility between old client and new server and vice versa. Patch moves llog_ctxt_id table to the lustre_idl.h because this is wire protocol data, these values are added to the wirecheck and checks are added in llog server code for wire data. Signed-off-by: Mikhail Pershin Change-Id: I003120223504d95164e4392b01c096e3e8b0fef0 Reviewed-on: http://review.whamcloud.com/10758 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Oleg Drokin Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 24 +++++++++++++++++++++++- lustre/include/obd.h | 15 --------------- lustre/ptlrpc/llog_server.c | 30 ++++++++++++++++++++++++++++++ lustre/ptlrpc/wiretest.c | 13 +++++++++++++ lustre/utils/wirecheck.c | 14 ++++++++++++++ lustre/utils/wiretest.c | 13 +++++++++++++ 6 files changed, 93 insertions(+), 16 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index bd9aa6c..6f21697 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -3180,7 +3180,29 @@ typedef enum { } obd_cmd_t; #define OBD_FIRST_OPC OBD_PING -/* catalog of log objects */ +/** + * llog contexts indices. + * + * There is compatibility problem with indexes below, they are not + * continuous and must keep their numbers for compatibility needs. + * See LU-5218 for details. + */ +enum llog_ctxt_id { + LLOG_CONFIG_ORIG_CTXT = 0, + LLOG_CONFIG_REPL_CTXT = 1, + LLOG_MDS_OST_ORIG_CTXT = 2, + LLOG_MDS_OST_REPL_CTXT = 3, /* kept just to avoid re-assignment */ + LLOG_SIZE_ORIG_CTXT = 4, + LLOG_SIZE_REPL_CTXT = 5, + LLOG_TEST_ORIG_CTXT = 8, + LLOG_TEST_REPL_CTXT = 9, /* kept just to avoid re-assignment */ + LLOG_CHANGELOG_ORIG_CTXT = 12, /**< changelog generation on mdd */ + LLOG_CHANGELOG_REPL_CTXT = 13, /**< changelog access on clients */ + /* for multiple changelog consumers */ + LLOG_CHANGELOG_USER_ORIG_CTXT = 14, + LLOG_AGENT_ORIG_CTXT = 15, /**< agent requests generation on cdt */ + LLOG_MAX_CTXTS +}; /** Identifier for a single log object */ struct llog_logid { diff --git a/lustre/include/obd.h b/lustre/include/obd.h index f8255d0..25bd596 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -199,21 +199,6 @@ struct brw_page { obd_flag flag; }; -/* llog contexts */ -enum llog_ctxt_id { - LLOG_CONFIG_ORIG_CTXT = 0, - LLOG_CONFIG_REPL_CTXT, - LLOG_MDS_OST_ORIG_CTXT, - LLOG_SIZE_ORIG_CTXT, - LLOG_SIZE_REPL_CTXT, - LLOG_TEST_ORIG_CTXT, - LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ - LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ - LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ - LLOG_AGENT_ORIG_CTXT, /**< agent requests generation on cdt */ - LLOG_MAX_CTXTS -}; - struct timeout_item { enum timeout_event ti_event; cfs_time_t ti_timeout; diff --git a/lustre/ptlrpc/llog_server.c b/lustre/ptlrpc/llog_server.c index 2b2488b..b4d81c3 100644 --- a/lustre/ptlrpc/llog_server.c +++ b/lustre/ptlrpc/llog_server.c @@ -92,6 +92,12 @@ int llog_origin_handle_open(struct ptlrpc_request *req) CDEBUG(D_INFO, "%s: opening log %s\n", obd->obd_name, name); } + if (body->lgd_ctxt_idx >= LLOG_MAX_CTXTS) { + CDEBUG(D_WARNING, "%s: bad ctxt ID: idx=%d name=%s\n", + obd->obd_name, body->lgd_ctxt_idx, name); + RETURN(-EPROTO); + } + ctxt = llog_get_context(obd, body->lgd_ctxt_idx); if (ctxt == NULL) { CDEBUG(D_WARNING, "%s: no ctxt. group=%p idx=%d name=%s\n", @@ -139,6 +145,12 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) CERROR("%s: wrong llog flags %x\n", req->rq_export->exp_obd->obd_name, body->lgd_llh_flags); + if (body->lgd_ctxt_idx >= LLOG_MAX_CTXTS) { + CDEBUG(D_WARNING, "%s: bad ctxt ID: idx=%d\n", + req->rq_export->exp_obd->obd_name, body->lgd_ctxt_idx); + RETURN(-EPROTO); + } + ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) RETURN(-ENODEV); @@ -171,6 +183,12 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) if (rc) RETURN(err_serious(-ENOMEM)); + if (body->lgd_ctxt_idx >= LLOG_MAX_CTXTS) { + CDEBUG(D_WARNING, "%s: bad ctxt ID: idx=%d\n", + req->rq_export->exp_obd->obd_name, body->lgd_ctxt_idx); + RETURN(-EPROTO); + } + ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) RETURN(-ENODEV); @@ -226,6 +244,12 @@ int llog_origin_handle_prev_block(struct ptlrpc_request *req) if (rc) RETURN(err_serious(-ENOMEM)); + if (body->lgd_ctxt_idx >= LLOG_MAX_CTXTS) { + CDEBUG(D_WARNING, "%s: bad ctxt ID: idx=%d\n", + req->rq_export->exp_obd->obd_name, body->lgd_ctxt_idx); + RETURN(-EPROTO); + } + ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) RETURN(-ENODEV); @@ -278,6 +302,12 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) if (rc) RETURN(err_serious(-ENOMEM)); + if (body->lgd_ctxt_idx >= LLOG_MAX_CTXTS) { + CDEBUG(D_WARNING, "%s: bad ctxt ID: idx=%d\n", + req->rq_export->exp_obd->obd_name, body->lgd_ctxt_idx); + RETURN(-EPROTO); + } + ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) RETURN(-ENODEV); diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index a3b036a..25c8e60 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -3774,6 +3774,19 @@ void lustre_assert_wire_constants(void) CLASSERT(LLOG_ORIGIN_HANDLE_DESTROY == 509); CLASSERT(LLOG_FIRST_OPC == 501); CLASSERT(LLOG_LAST_OPC == 510); + CLASSERT(LLOG_CONFIG_ORIG_CTXT == 0); + CLASSERT(LLOG_CONFIG_REPL_CTXT == 1); + CLASSERT(LLOG_MDS_OST_ORIG_CTXT == 2); + CLASSERT(LLOG_MDS_OST_REPL_CTXT == 3); + CLASSERT(LLOG_SIZE_ORIG_CTXT == 4); + CLASSERT(LLOG_SIZE_REPL_CTXT == 5); + CLASSERT(LLOG_TEST_ORIG_CTXT == 8); + CLASSERT(LLOG_TEST_REPL_CTXT == 9); + CLASSERT(LLOG_CHANGELOG_ORIG_CTXT == 12); + CLASSERT(LLOG_CHANGELOG_REPL_CTXT == 13); + CLASSERT(LLOG_CHANGELOG_USER_ORIG_CTXT == 14); + CLASSERT(LLOG_AGENT_ORIG_CTXT == 15); + CLASSERT(LLOG_MAX_CTXTS == 16); /* Checks for struct llogd_conn_body */ LASSERTF((int)sizeof(struct llogd_conn_body) == 40, "found %lld\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 5e9d2ab..cd9c821 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -1653,6 +1653,20 @@ check_llogd_body(void) CHECK_CVALUE(LLOG_ORIGIN_HANDLE_DESTROY); CHECK_CVALUE(LLOG_FIRST_OPC); CHECK_CVALUE(LLOG_LAST_OPC); + + CHECK_CVALUE(LLOG_CONFIG_ORIG_CTXT); + CHECK_CVALUE(LLOG_CONFIG_REPL_CTXT); + CHECK_CVALUE(LLOG_MDS_OST_ORIG_CTXT); + CHECK_CVALUE(LLOG_MDS_OST_REPL_CTXT); + CHECK_CVALUE(LLOG_SIZE_ORIG_CTXT); + CHECK_CVALUE(LLOG_SIZE_REPL_CTXT); + CHECK_CVALUE(LLOG_TEST_ORIG_CTXT); + CHECK_CVALUE(LLOG_TEST_REPL_CTXT); + CHECK_CVALUE(LLOG_CHANGELOG_ORIG_CTXT); + CHECK_CVALUE(LLOG_CHANGELOG_REPL_CTXT); + CHECK_CVALUE(LLOG_CHANGELOG_USER_ORIG_CTXT); + CHECK_CVALUE(LLOG_AGENT_ORIG_CTXT); + CHECK_CVALUE(LLOG_MAX_CTXTS); } static void diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 182f7f0..e2251be 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -3780,6 +3780,19 @@ void lustre_assert_wire_constants(void) CLASSERT(LLOG_ORIGIN_HANDLE_DESTROY == 509); CLASSERT(LLOG_FIRST_OPC == 501); CLASSERT(LLOG_LAST_OPC == 510); + CLASSERT(LLOG_CONFIG_ORIG_CTXT == 0); + CLASSERT(LLOG_CONFIG_REPL_CTXT == 1); + CLASSERT(LLOG_MDS_OST_ORIG_CTXT == 2); + CLASSERT(LLOG_MDS_OST_REPL_CTXT == 3); + CLASSERT(LLOG_SIZE_ORIG_CTXT == 4); + CLASSERT(LLOG_SIZE_REPL_CTXT == 5); + CLASSERT(LLOG_TEST_ORIG_CTXT == 8); + CLASSERT(LLOG_TEST_REPL_CTXT == 9); + CLASSERT(LLOG_CHANGELOG_ORIG_CTXT == 12); + CLASSERT(LLOG_CHANGELOG_REPL_CTXT == 13); + CLASSERT(LLOG_CHANGELOG_USER_ORIG_CTXT == 14); + CLASSERT(LLOG_AGENT_ORIG_CTXT == 15); + CLASSERT(LLOG_MAX_CTXTS == 16); /* Checks for struct llogd_conn_body */ LASSERTF((int)sizeof(struct llogd_conn_body) == 40, "found %lld\n", -- 1.8.3.1