From 97622806dce34589735a2399f3c4fe56a684e836 Mon Sep 17 00:00:00 2001
From: yury <yury>
Date: Mon, 10 Nov 2008 14:07:22 +0000
Subject: [PATCH] b=17617 (in fact this is part of 17310 for HEAD)

- fixes manual_umount_client() in conf_sanity.sh to handle --force correctly as it is used by number of tests (this part should be missed in tests porting);

- add assert before decref mgc refcounter;
- fixed possible leaked niduuid in case of error;
- kill @rc in server_put_super() as it is not used;
- use OBD_FAIL_CHECK_ORSET in ptlrpc_check_set() to avoid assert;
- enable test_45 as it is working now.
---
 lustre/obdclass/obd_mount.c | 18 ++++++++----------
 lustre/ptlrpc/client.c      |  4 ++--
 lustre/tests/conf-sanity.sh | 10 +++++++---
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c
index ea3473e2dc..b21a58cabf 100644
--- a/lustre/obdclass/obd_mount.c
+++ b/lustre/obdclass/obd_mount.c
@@ -791,6 +791,7 @@ static int lustre_stop_mgc(struct super_block *sb)
         lsi->lsi_mgc = NULL;
 
         mutex_down(&mgc_start_lock);
+        LASSERT(atomic_read(&obd->u.cli.cl_mgc_refcount) > 0);
         if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) {
                 /* This is not fatal, every client that stops
                    will call in here. */
@@ -826,7 +827,8 @@ static int lustre_stop_mgc(struct super_block *sb)
 
         /* Clean the nid uuids */
         if (!niduuid)
-                RETURN(-ENOMEM);
+                GOTO(out, rc = -ENOMEM);
+
         for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
                 sprintf(ptr, "_%x", i);
                 rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
@@ -835,10 +837,11 @@ static int lustre_stop_mgc(struct super_block *sb)
                         CERROR("del MDC UUID %s failed: rc = %d\n",
                                niduuid, rc);
         }
-        OBD_FREE(niduuid, len);
-        /* class_import_put will get rid of the additional connections */
-
 out:
+        if (niduuid)
+                OBD_FREE(niduuid, len);
+
+        /* class_import_put will get rid of the additional connections */
         mutex_up(&mgc_start_lock);
         RETURN(rc);
 }
@@ -1378,7 +1381,6 @@ static void server_put_super(struct super_block *sb)
         int tmpname_sz;
         int lddflags = lsi->lsi_ldd->ldd_flags;
         int lsiflags = lsi->lsi_flags;
-        int rc;
         ENTRY;
 
         LASSERT(lsiflags & LSI_SERVER);
@@ -1423,17 +1425,13 @@ static void server_put_super(struct super_block *sb)
         /* If they wanted the mgs to stop separately from the mdt, they
            should have put it on a different device. */
         if (IS_MGS(lsi->lsi_ldd)) {
-                /* stop the mgc before the mgs so the connection gets cleaned
-                   up */
-                lustre_stop_mgc(sb);
                 /* if MDS start with --nomgs, don't stop MGS then */
                 if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOMGS))
                         server_stop_mgs(sb);
         }
 
         /* Clean the mgc and sb */
-        rc = lustre_common_put_super(sb);
-        /* FIXME how can I report a failure to umount? */
+        lustre_common_put_super(sb);
 
         /* Wait for the targets to really clean up - can't exit (and let the
            sb get destroyed) while the mount is still in use */
diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index 8e605b3eb3..3285c1bb15 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -1182,8 +1182,8 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
                          * Turn fail_loc off to prevent it from looping
                          * forever. 
                          */
-                        OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_UNLINK | 
-                                       OBD_FAIL_ONCE);
+                        OBD_FAIL_CHECK_ORSET(OBD_FAIL_PTLRPC_LONG_UNLINK,
+                                             OBD_FAIL_ONCE);
 
                         /* 
                          * Move to next phase if reply was successfully 
diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh
index 0149579fc9..8fcb2b9f99 100644
--- a/lustre/tests/conf-sanity.sh
+++ b/lustre/tests/conf-sanity.sh
@@ -11,8 +11,8 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 
-# bug number for skipped test: 13739   17617
-HEAD_EXCEPT="                  32a 32b 45"
+# bug number for skipped test: 13739
+HEAD_EXCEPT="                  32a 32b"
 
 # bug number for skipped test:                                 
 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $HEAD_EXCEPT"
@@ -129,8 +129,12 @@ umount_client() {
 }
 
 manual_umount_client(){
+	local rc
+	local FORCE=$1
 	echo "manual umount lustre on ${MOUNT}...."
-	do_facet client "umount -d $MOUNT"
+	do_facet client "umount -d ${FORCE} $MOUNT"
+	rc=$?
+	return $rc
 }
 
 setup() {
-- 
GitLab