Whamcloud - gitweb
ORNL-8 IR: minor fixes to IR patches
authorJinshan Xiong <jay@whamcloud.com>
Thu, 20 Oct 2011 18:34:23 +0000 (11:34 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 9 Nov 2011 22:36:22 +0000 (17:36 -0500)
Summary of fixes:
1. ORNL-13: add comments to mgs_handle_fslog_hack();
2. ORNL-14: typo and accurate error/debug messages;
            minor fixes in recovery-small.sh;

Change-Id: I6317067eb6250faf5df21be719c82de17b0f4cc9
Signed-off-by: Jinshan Xiong <jay@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1582
Tested-by: Hudson
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/tests/recovery-small.sh
lustre/tests/test-framework.sh

index ca8873f..a628354 100644 (file)
@@ -1231,7 +1231,7 @@ enum {
         CONFIG_READ_NRPAGES      = 4
 };
 
-static int mgc_apply_recover_logs(struct obd_device *obd,
+static int mgc_apply_recover_logs(struct obd_device *mgc,
                                   struct config_llog_data *cld,
                                   __u64 max_version,
                                   void *data, int datalen)
@@ -1244,26 +1244,29 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
         u64   prev_version = 0;
         char *inst;
         char *buf;
-        int   bufsz = CFS_PAGE_SIZE;
+        int   bufsz;
         int   pos;
         int   rc  = 0;
         int   off = 0;
-
-        OBD_ALLOC(buf, CFS_PAGE_SIZE);
-        if (buf == NULL)
-                return -ENOMEM;
+        ENTRY;
 
         LASSERT(cfg->cfg_instance != NULL);
         LASSERT(cfg->cfg_sb == cfg->cfg_instance);
-        inst = buf;
+
+        OBD_ALLOC(inst, CFS_PAGE_SIZE);
+        if (inst == NULL)
+                RETURN(-ENOMEM);
+
         if (!(lsi->lsi_flags & LSI_SERVER)) {
                 pos = sprintf(inst, "%p", cfg->cfg_instance);
         } else {
                 LASSERT(IS_MDT(lsi->lsi_ldd));
                 pos = sprintf(inst, "MDT%04x", lsi->lsi_ldd->ldd_svindex);
         }
-        buf   += pos + 1;
-        bufsz -= pos + 1;
+
+        ++pos;
+        buf   = inst + pos;
+        bufsz = CFS_PAGE_SIZE - pos;
 
         while (datalen > 0) {
                 int   entry_len = sizeof(*entry);
@@ -1329,7 +1332,8 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
                 strcpy(obdname, cld->cld_logname);
                 cname = strrchr(obdname, '-');
                 if (cname == NULL) {
-                        CERROR("mgc: invalid logname %s\n", obdname);
+                        CERROR("mgc %s: invalid logname %s\n",
+                               mgc->obd_name, obdname);
                         break;
                 }
 
@@ -1345,8 +1349,8 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
                 /* find the obd by obdname */
                 obd = class_name2obd(obdname);
                 if (obd == NULL) {
-                        CDEBUG(D_INFO, "mgc: cannot find obdname %s\n",
-                               obdname);
+                        CDEBUG(D_INFO, "mgc %s: cannot find obdname %s\n",
+                               mgc->obd_name, obdname);
 
                         /* this is a safe race, when the ost is starting up...*/
                         continue;
@@ -1398,7 +1402,7 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
         }
 
         OBD_FREE(inst, CFS_PAGE_SIZE);
-        return rc;
+        RETURN(rc);
 }
 
 /**
index ff572f8..bb2705e 100644 (file)
@@ -747,6 +747,21 @@ static int mgs_handle_exception(struct ptlrpc_request *req)
         RETURN(0);
 }
 
+/*
+ * For old clients there is no direct way of knowing which filesystems
+ * a client is operating at the MGS side. But we need to pick up those
+ * clients so that the MGS can mark the corresponding filesystem as
+ * non-IR capable because old clients are not ready to be notified.
+ *
+ * This is why we have this _hack_ function. We detect the filesystem's
+ * name by hacking llog operation which is currently used by the clients
+ * to fetch configuration logs. At present this is fine because this is
+ * the ONLY llog operation between mgc and the MGS.
+ *
+ * If extra llog operation is going to be added, this function needs fixing.
+ *
+ * If releases prior than 2.0 are not supported, we can remove this function.
+ */
 static int mgs_handle_fslog_hack(struct ptlrpc_request *req)
 {
         char *logname;
index f9bbf42..34b5a7f 100755 (executable)
@@ -1102,10 +1102,10 @@ run_test 61 "Verify to not reuse orphan objects - bug 17025"
 
 check_cli_ir_state()
 {
-        local NODE=${1:-`hostname`}
+        local NODE=${1:-$HOSTNAME}
         local st
         st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
-                            awk '/imperative_recovery:/ { print \\\$2}' ")
+                            awk '/imperative_recovery:/ { print \\\$2}'")
         [ $st != ON -o $st != OFF ] ||
                 error "Error state $st, must be ON or OFF"
         echo -n $st
@@ -1148,7 +1148,7 @@ nidtbl_version_mgs()
 nidtbl_version_client()
 {
         local cli=$1
-        local node=${2:-`hostname`}
+        local node=${2:-$HOSTNAME}
 
         if [ X$cli = Xclient ]; then
                 cli=$FSNAME-client
@@ -1156,7 +1156,7 @@ nidtbl_version_client()
                 local obdtype=${cli/%[0-9]*/}
                 [ $obdtype != mds ] && error "wrong parameters $cli"
 
-                node=`facet_active_host $cli`
+                node=$(facet_active_host $cli)
                 local t=${cli}_svc
                 cli=${!t}
         fi
@@ -1172,7 +1172,7 @@ nidtbl_version_client()
 
 nidtbl_versions_match()
 {
-        [ `nidtbl_version_mgs` -eq `nidtbl_version_client ${1:-client}` ]
+        [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
 }
 
 target_instance_match()
@@ -1198,11 +1198,11 @@ target_instance_match()
         esac
 
         local target=${srv}_svc
-        local si=`do_facet $srv lctl get_param -n $obdname.${!target}.instance`
-        local ci=`lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
-                  awk '/instance/{ print $2 }' |head -1`
+        local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
+        local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
+                  awk '/instance/{ print $2 }' |head -1)
 
-        return `[ $si -eq $ci ]`
+        return $([ $si -eq $ci ])
 }
 
 test_100()
@@ -1211,7 +1211,7 @@ test_100()
         set_ir_status disabled
 
         local saved_FAILURE_MODE=$FAILURE_MODE
-        [ `facet_host mgs` = `facet_host ost1` ] && FAILURE_MODE="SOFT"
+        [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
         fail ost1
 
         # valid check
@@ -1245,7 +1245,7 @@ run_test 101 "IR: Make sure IR works w/o normal recovery"
 
 test_102()
 {
-        local clients=${CLIENTS:-`hostname`}
+        local clients=${CLIENTS:-$HOSTNAME}
         local old_version
         local new_version
         local mgsdev=mgs
@@ -1270,7 +1270,7 @@ test_102()
         nidtbl_versions_match || error "nidtbl mismatch"
 
         # get the version #
-        old_version=`nidtbl_version_client client`
+        old_version=$(nidtbl_version_client client)
 
         zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
 
@@ -1282,7 +1282,7 @@ test_102()
         zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
 
         # check new version
-        new_version=`nidtbl_version_client client`
+        new_version=$(nidtbl_version_client client)
         [ $new_version -lt $old_version ] &&
                 error "nidtbl version wrong after mgs restarts"
         return 0
@@ -1313,7 +1313,7 @@ test_103()
         # sleep 30 seconds so the MDS has a chance to detect MGS restarting
         local count=30
         while [ $count -gt 0 ]; do
-                [ `nidtbl_version_client mds1` -ne 0 ] && break
+                [ $(nidtbl_version_client mds1) -ne 0 ] && break
                 sleep 1
                 count=$((count-1))
         done
@@ -1332,13 +1332,12 @@ test_104()
         set_ir_status full
 
         stop ost1
-        start ost1 `ostdevname 1` "$OST_MOUNT_OPTS -onoir" ||
+        start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
                 error "OST1 cannot start"
         clients_up
 
         local ir_state=$(check_target_ir_state ost1)
         [ $ir_state = "OFF" ] || error "ir status on ost1 should be OFF"
-        ost1_opt=
 }
 run_test 104 "IR: ost can disable IR voluntarily"
 
@@ -1349,7 +1348,7 @@ test_105()
         set_ir_status full
 
         # get one of the clients from client list
-        rcli=`echo $RCLIENTS |cut -d' ' -f 1`
+        local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
 
         local old_MOUNTOPT=$MOUNTOPT
         MOUNTOPT=${MOUNTOPT},noir
@@ -1361,7 +1360,7 @@ test_105()
         [ $ir_state = OFF ] || error "IR state must be OFF at $rcli"
 
         # make sure MGS's state is Partial
-        [ `get_ir_status` = "partial" ] || error "MGS IR state must be partial"
+        [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
 
         fail ost1
         # make sure IR on ost1 is OFF
@@ -1374,7 +1373,7 @@ test_105()
         zconf_mount $rcli $MOUNT || error "mount failed"
 
         # make sure MGS's state is full
-        [ `get_ir_status` = "full" ] || error "MGS IR status must be full"
+        [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
 
         fail ost1
         # make sure IR on ost1 is ON
index 78a5802..51c3d92 100644 (file)
@@ -3886,7 +3886,7 @@ wait_import_state() {
     done
 }
 
-# One client request could be timeouted because server was not ready
+# One client request could be timed out because server was not ready
 # when request was sent by client.
 # The request timeout calculation details :
 # ptl_send_rpc ()
@@ -3942,7 +3942,7 @@ wait_osc_import_state() {
     local maxtime=$(( 2 * $(request_timeout $facet)))
 
     if ! do_rpc_nodes $(facet_host $facet) \
-_wait_import_state $expected $param $maxtime; then
+                _wait_import_state $expected $param $maxtime; then
         error "import is not in ${expected} state"
         return 1
     fi