Whamcloud - gitweb
LU-5827 mdt: do not crash server upon unsupported opc 97/12497/2
authorBobi Jam <bobijam.xu@intel.com>
Thu, 30 Oct 2014 12:29:47 +0000 (20:29 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 4 Dec 2014 20:29:16 +0000 (20:29 +0000)
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 <bobijam.xu@intel.com>
Change-Id: Iefc2629cd4ad2d9df1b19ada7aa620282c5dab19
Reviewed-on: http://review.whamcloud.com/12497
Tested-by: Jenkins
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/mdt/mdt_handler.c

index f69cfc8..c0b189b 100644 (file)
@@ -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,