diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h
index cc6e5dbc1eef4686d2ebf7f9d8964e2e6f5af697..9e7dfe3c8dcc6cf42cfb9199fd82ad573a5ae07b 100644
--- a/lustre/include/obd_support.h
+++ b/lustre/include/obd_support.h
@@ -248,6 +248,7 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_OBD_LOGD_NET            0x602
 #define OBD_FAIL_OBD_QC_CALLBACK_NET     0x603
 #define OBD_FAIL_OBD_DQACQ               0x604
+#define OBD_FAIL_OBD_LLOG_SETUP          0x605
 
 #define OBD_FAIL_TGT_REPLY_NET           0x700
 #define OBD_FAIL_TGT_CONN_RACE           0x701
diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c
index a49c621a6851cd28846c40c84557e43b39a14f50..599e6fcbf20c85884dd69f3eb8f32f0d8a634c44 100644
--- a/lustre/obdclass/llog_obd.c
+++ b/lustre/obdclass/llog_obd.c
@@ -151,8 +151,12 @@ int llog_setup(struct obd_device *obd, int index, struct obd_device *disk_obd,
         ctxt->loc_logops = op;
         sema_init(&ctxt->loc_sem, 1);
 
-        if (op->lop_setup)
-                rc = op->lop_setup(obd, index, disk_obd, count, logid);
+        if (op->lop_setup) {
+                if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LLOG_SETUP))
+                        rc = -EOPNOTSUPP;
+                else
+                        rc = op->lop_setup(obd, index, disk_obd, count, logid);
+        }
 
         if (rc) {
                 llog_ctxt_destroy(ctxt);
diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh
index baab91dc2f345331084ee17a10cfd30347216e3d..fd74e0167a2e3a5725382f7ab4cdea32b1a62729 100755
--- a/lustre/tests/replay-single.sh
+++ b/lustre/tests/replay-single.sh
@@ -1331,6 +1331,16 @@ test_61c() {
 }
 run_test 61c "test race mds llog sync vs llog cleanup"
 
+test_61d() { # bug 16002
+#define OBD_FAIL_OBD_LLOG_SETUP        0x605
+    stop mds
+    do_facet mds "lctl set_param fail_loc=0x80000605"
+    start mds $MDSDEV $MDS_MOUNT_OPTS && error "mds start should have failed"
+    do_facet mds "lctl set_param fail_loc=0"
+    start mds $MDSDEV $MDS_MOUNT_OPTS || error "cannot restart mds"
+}
+run_test 61d "error in llog_setup should cleanup the llog context correctly"
+
 test_62() { # Bug 15756 - don't mis-drop resent replay
     mkdir -p $DIR/$tdir
     replay_barrier mds