From 95e809e700e6cce6fc8cd8c3b245ff2b1daafdaa Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 30 Oct 2014 20:29:47 +0800 Subject: [PATCH] LU-5827 mdt: do not crash server upon unsupported opc mdt_handler_find() needs to check opc as well as whether we've defined its handler to decide that the operation is supported. Signed-off-by: Bobi Jam Change-Id: Iefc2629cd4ad2d9df1b19ada7aa620282c5dab19 Reviewed-on: http://review.whamcloud.com/12497 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/mdt/mdt_handler.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index f69cfc8..c0b189b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2917,23 +2917,26 @@ void mdt_object_unlock_put(struct mdt_thread_info * info, struct mdt_handler *mdt_handler_find(__u32 opc, struct mdt_opc_slice *supported) { - struct mdt_opc_slice *s; - struct mdt_handler *h; - - h = NULL; - for (s = supported; s->mos_hs != NULL; s++) { - if (s->mos_opc_start <= opc && opc < s->mos_opc_end) { - h = s->mos_hs + (opc - s->mos_opc_start); - if (likely(h->mh_opc != 0)) - LASSERTF(h->mh_opc == opc, - "opcode mismatch %d != %d\n", - h->mh_opc, opc); - else - h = NULL; /* unsupported opc */ - break; - } - } - return h; + struct mdt_opc_slice *s; + struct mdt_handler *h; + + h = NULL; + for (s = supported; s->mos_hs != NULL; s++) { + if (s->mos_opc_start <= opc && opc < s->mos_opc_end) { + h = s->mos_hs + (opc - s->mos_opc_start); + if (likely(h->mh_opc != 0)) { + LASSERTF(h->mh_opc == opc, + "opcode mismatch %d != %d\n", + h->mh_opc, opc); + if (h->mh_act == NULL) /* unsupported opc */ + h = NULL; + } else { + h = NULL; /* unsupported opc */ + } + break; + } + } + return h; } static int mdt_lock_resname_compat(struct mdt_device *m, -- 1.8.3.1