From 9b8cc5bbb5afd78501ea505232e2e1c606a6145c Mon Sep 17 00:00:00 2001
From: johann <johann>
Date: Fri, 18 Jul 2008 10:26:57 +0000
Subject: [PATCH] Branch b1_6 b=16002 i=wangdi

Add regression test for bug 13913.
---
 lustre/include/obd_support.h  |  1 +
 lustre/obdclass/llog_obd.c    |  8 ++++++--
 lustre/tests/replay-single.sh | 10 ++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h
index cc6e5dbc1e..9e7dfe3c8d 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 a49c621a68..599e6fcbf2 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 baab91dc2f..fd74e0167a 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
-- 
GitLab