From 571e1548322593c3b153fb38db2b4b114ea14544 Mon Sep 17 00:00:00 2001
From: "robert.read" <robert.read>
Date: Fri, 13 Jun 2008 22:22:26 +0000
Subject: [PATCH] Merge b1_8 from b1_6 (20080613_1435)

---
 lustre/ChangeLog                  | 15 ++++++++++++++-
 lustre/autoconf/lustre-core.m4    | 16 ++++++++++++++++
 lustre/ldlm/ldlm_resource.c       |  5 +++--
 lustre/lvfs/fsfilt_ext3.c         |  6 ++++--
 lustre/mds/mds_lov.c              |  5 +++--
 lustre/obdclass/genops.c          |  6 ++----
 lustre/tests/acceptance-small.sh  |  4 +---
 lustre/tests/conf-sanity.sh       |  1 +
 lustre/tests/replay-dual.sh       |  2 +-
 lustre/tests/replay-ost-single.sh | 11 ++++++-----
 lustre/tests/replay-single.sh     |  2 +-
 lustre/tests/sanity.sh            |  8 ++++----
 lustre/tests/sanityN.sh           |  8 +++++---
 lustre/tests/test-framework.sh    | 28 +++++++++++++++++-----------
 lustre/utils/mkfs_lustre.c        |  6 ------
 15 files changed, 78 insertions(+), 45 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 3c6e6f8852..850a66b63d 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -31,6 +31,12 @@ Details    : ptlrpcd_check call obd_zombie_impexp_cull and wait request which sh
              handled by ptlrpcd. This produce long age waiting and -ETIMEOUT
              ptlrpc_invalidate_import and as result LASSERT.
 
+Severity   : normal
+Frequency  : only with broken builds/installations
+Bugzilla   : 15779
+Description: do not LBUG if lquota.ko and fsfilt_ldiskfs.ko are of different versions
+Details    : just return an error to a user, put a console error message
+
 Severity   : enhancement
 Bugzilla   : 15741
 Description: Update to RHEL5 kernel-2.6.18-53.1.19.el5.
@@ -121,7 +127,7 @@ Description: fix build on ppc32
 Details    : compile code with -m64 flag produce wrong object file for ppc32.
 
 Severity   : normal
-Bugzilla   : 15774
+Bugzilla   : 15574
 Description: MDS LBUG: ASSERTION(!IS_ERR(dchild))
 Details    : In reconstruct_* functions, LASSERTs on both the data supplied by
              a client, and the data on disk are dangerous and incorrect. Change
@@ -141,6 +147,13 @@ Details    : as planned, when lustre is beyond b1_8, lquota won't support for 32
 	     qunit. That means servers of b1_4 and servers of b1_8 can't be used
 	     together if users want to use quota.
 
+Severity   : normal
+Frequency  : blocks per group is less than blocksize*8 and uninit_groups is enabled
+Bugzilla   : 15932
+Description: ldiskfs error: XXX blocks in bitmap, YYY in gd
+Details    : If blocks per group is less than blocksize*8, set rest of the
+	     bitmap to 1.
+
 -------------------------------------------------------------------------------
 
 
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index a96a250cc3..527b8001d4 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -794,6 +794,19 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# LC_SYMVERFILE
+# SLES 9 uses a different name for this file - unsure about vanilla kernels
+# around this version, but it matters for servers only.
+AC_DEFUN([LC_SYMVERFILE],
+         [AC_MSG_CHECKING([name of symverfile])
+          if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost ; then
+              SYMVERFILE=Modules.symvers
+          else
+              SYMVERFILE=Module.symvers
+          fi
+	  AC_MSG_RESULT($SYMVERFILE)
+          AC_SUBST(SYMVERFILE)])
+
 # LC_DQUOTOFF_MUTEX
 # after 2.6.17 dquote use mutex instead if semaphore
 AC_DEFUN([LC_DQUOTOFF_MUTEX],
@@ -1298,6 +1311,9 @@ AC_DEFUN([LC_PROG_LINUX],
           # 2.6.15
           LC_INODE_I_MUTEX
 
+          # SLES 10 (at least)
+          LC_SYMVERFILE
+
           # 2.6.17
           LC_DQUOTOFF_MUTEX
 
diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c
index 92d41aac98..138743adbe 100644
--- a/lustre/ldlm/ldlm_resource.c
+++ b/lustre/ldlm/ldlm_resource.c
@@ -326,6 +326,7 @@ ldlm_namespace_new(struct obd_device *obd, char *name,
         strcpy(ns->ns_name, name);
 
         CFS_INIT_LIST_HEAD(&ns->ns_root_list);
+        CFS_INIT_LIST_HEAD(&ns->ns_list_chain);
         ns->ns_refcount = 0;
         ns->ns_client = client;
         spin_lock_init(&ns->ns_hash_lock);
@@ -360,8 +361,8 @@ ldlm_namespace_new(struct obd_device *obd, char *name,
         }
 
         at_init(&ns->ns_at_estimate, ldlm_enqueue_min, 0);
-        ldlm_namespace_register(ns, client);
 
+        ldlm_namespace_register(ns, client);
         RETURN(ns);
 out_proc:
         ldlm_namespace_cleanup(ns, 0);
@@ -554,7 +555,7 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
                 return;
         }
 
-        /* Remove @ns from list. */
+        /* Make sure that nobody can find this ns in its list. */
         ldlm_namespace_unregister(ns, ns->ns_client);
 
         /* Can fail with -EINTR when force == 0 in which case try harder */
diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c
index d134000e6f..d0e1f88e8f 100644
--- a/lustre/lvfs/fsfilt_ext3.c
+++ b/lustre/lvfs/fsfilt_ext3.c
@@ -2085,8 +2085,10 @@ static int fsfilt_ext3_quotainfo(struct lustre_quota_info *lqi, int type,
                 rc = lustre_quota_convert(lqi, type);
                 break;
         default:
-                CERROR("Unsupported admin quota file cmd %d\n", cmd);
-                LBUG();
+                rc = -ENOTSUPP;
+                CERROR("Unsupported admin quota file cmd %d\n"
+                       "Are lquota.ko and fsfilt_ldiskfs.ko modules in sync?\n",
+                       cmd);
                 break;
         }
         RETURN(rc);
diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c
index f377629045..3495f3a5e1 100644
--- a/lustre/mds/mds_lov.c
+++ b/lustre/mds/mds_lov.c
@@ -140,7 +140,7 @@ void mds_lov_destroy_objids(struct obd_device *obd)
         }
 
         if (mds->mds_lov_objid_filp) {
-                rc = filp_close((struct file *)mds->mds_lov_objid_filp, 0);
+                rc = filp_close((struct file *)mds->mds_lov_objid_filp, NULL);
                 mds->mds_lov_objid_filp = NULL;
                 if (rc)
                         CERROR("%s file won't close, rc=%d\n", LOV_OBJID, rc);
@@ -235,7 +235,7 @@ out:
 int mds_lov_write_objids(struct obd_device *obd)
 {
         struct mds_obd *mds = &obd->u.mds;
-        int i, rc = 0;
+        int i = 0, rc = 0;
         ENTRY;
 
         if (cfs_bitmap_check_empty(mds->mds_lov_page_dirty))
@@ -254,6 +254,7 @@ int mds_lov_write_objids(struct obd_device *obd)
                 if (i == mds->mds_lov_objid_lastpage)
                         size = (mds->mds_lov_objid_lastidx + 1) * sizeof(obd_id);
 
+		CDEBUG(D_INFO,"write %lld - %ld\n", off, size);
                 rc = fsfilt_write_record(obd, mds->mds_lov_objid_filp, data,
                                          size, &off, 0);
                 if (rc < 0)
diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c
index 102f06d514..83053aeefb 100644
--- a/lustre/obdclass/genops.c
+++ b/lustre/obdclass/genops.c
@@ -622,8 +622,7 @@ void __class_export_put(struct obd_export *exp)
                 list_add(&exp->exp_obd_chain, &obd_zombie_exports);
                 spin_unlock(&obd_zombie_impexp_lock);
 
-                if (obd_zombie_impexp_notify != NULL)
-                        obd_zombie_impexp_notify();
+                obd_zombie_impexp_notify();
         }
 }
 EXPORT_SYMBOL(__class_export_put);
@@ -764,8 +763,7 @@ void class_import_put(struct obd_import *import)
                 list_add(&import->imp_zombie_chain, &obd_zombie_imports);
                 spin_unlock(&obd_zombie_impexp_lock);
 
-                if (obd_zombie_impexp_notify != NULL)
-                        obd_zombie_impexp_notify();
+                obd_zombie_impexp_notify();
         }
 
         EXIT;
diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh
index 2cab7c9d51..90d96302c5 100755
--- a/lustre/tests/acceptance-small.sh
+++ b/lustre/tests/acceptance-small.sh
@@ -4,8 +4,6 @@
 #set -vx
 set -e
 
-PATH=`dirname $0`/../utils:$PATH
-
 [ -z "$CONFIG" -a "$NAME" ] && CONFIGS=$NAME
 [ "$CONFIGS" ] || CONFIGS="local"  #"local lov"
 [ "$MAX_THREADS" ] || MAX_THREADS=20
@@ -42,7 +40,7 @@ LIBLUSTRETESTS=${LIBLUSTRETESTS:-../liblustre/tests}
 STARTTIME=`date +%s`
 RANTEST=""
 
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 
diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh
index 256678ce86..9f75d8c216 100644
--- a/lustre/tests/conf-sanity.sh
+++ b/lustre/tests/conf-sanity.sh
@@ -800,6 +800,7 @@ test_22() {
 	echo Client mount before any osts are in the logs
 	mount_client $MOUNT
 	check_mount && return 41
+	umount_client $MOUNT
 	pass
 
 	echo Client mount with ost in logs, but none running
diff --git a/lustre/tests/replay-dual.sh b/lustre/tests/replay-dual.sh
index ec4190de0e..dd087a3971 100755
--- a/lustre/tests/replay-dual.sh
+++ b/lustre/tests/replay-dual.sh
@@ -7,7 +7,7 @@ ALWAYS_EXCEPT="15c   $REPLAY_DUAL_EXCEPT"
 
 SAVE_PWD=$PWD
 PTLDEBUG=${PTLDEBUG:--1}
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 SETUP=${SETUP:-""}
 CLEANUP=${CLEANUP:-""}
 MOUNT_2=${MOUNT_2:-"yes"}
diff --git a/lustre/tests/replay-ost-single.sh b/lustre/tests/replay-ost-single.sh
index 260ec07ef5..b652b0f216 100755
--- a/lustre/tests/replay-ost-single.sh
+++ b/lustre/tests/replay-ost-single.sh
@@ -3,7 +3,7 @@
 set -e
 
 PTLDEBUG=${PTLDEBUG:--1}
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 SETUP=${SETUP:-""}
 CLEANUP=${CLEANUP:-""}
 . $LUSTRE/tests/test-framework.sh
@@ -97,10 +97,11 @@ run_test 4 "Fail OST during read, with verification"
 
 test_5() {
     [ -z "`which iozone 2> /dev/null`" ] && log "iozone missing" && return
-    FREE=`df -P -h $DIR | tail -n 1 | awk '{ print $3 }'`
-    case $FREE in
-    *T|*G) FREE=1G;;
-    esac
+    FREE=`df -P $DIR | tail -n 1 | awk '{ print $4/2 }'`
+    GB=1048576  # 1048576KB == 1GB
+    if (( FREE > GB )); then
+        FREE=$GB
+    fi
     IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
     iozone $IOZONE_OPTS -f $DIR/$tfile &
     PID=$!
diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh
index c79656cc1a..2902b8c592 100755
--- a/lustre/tests/replay-single.sh
+++ b/lustre/tests/replay-single.sh
@@ -7,7 +7,7 @@ set -e
 # This test needs to be run on the client
 #
 SAVE_PWD=$PWD
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 SETUP=${SETUP:-}
 CLEANUP=${CLEANUP:-}
 . $LUSTRE/tests/test-framework.sh
diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index cfc8eba510..cd09890d6f 100644
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -23,8 +23,8 @@ case `uname -r` in
 *) error "unsupported kernel" ;;
 esac
 
-SRCDIR=`dirname $0`
-export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH:/sbin
+SRCDIR=$(cd $(dirname $0); echo $PWD)
+export PATH=$PATH:/sbin
 
 TMP=${TMP:-/tmp}
 
@@ -63,7 +63,7 @@ SAVE_PWD=$PWD
 CLEANUP=${CLEANUP:-:}
 SETUP=${SETUP:-:}
 TRACE=${TRACE:-""}
-LUSTRE=${LUSTRE:-`dirname $0`/..}
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
@@ -5002,7 +5002,7 @@ test_129() {
 	echo 0 >$ldiskfs_prefix/$proc_file
 	rm -rf $DIR/$tdir
 }
-run_test 129 "test directory size limit ========================"
+# run_test 129 "test directory size limit ========================"
 
 TMPDIR=$OLDTMPDIR
 TMP=$OLDTMP
diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh
index 10b570f473..627ef82c0e 100644
--- a/lustre/tests/sanityN.sh
+++ b/lustre/tests/sanityN.sh
@@ -203,17 +203,19 @@ test_10a() {
 run_test 10a "write of file with sub-page size on multiple mounts "
 
 test_10b() {
-	yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
+	# create a seed file
+	yes "R" | head -c 4000 >$TMP/f10b-seed
+	dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
 
 	truncate $DIR1/f10b 4096 || error "truncate 4096"
 
 	dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
 
 	# create a test file locally to compare
-	yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
+	dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
 	truncate $TMP/f10b 4096 || error "truncate 4096"
 	cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
-	rm $TMP/f10b $TMP/f10b-lustre
+	rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
 }
 run_test 10b "write of file with sub-page size on multiple mounts "
 
diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh
index 1808f6fb79..4cab5544ec 100644
--- a/lustre/tests/test-framework.sh
+++ b/lustre/tests/test-framework.sh
@@ -72,8 +72,12 @@ init_test_env() {
     export TMP=${TMP:-$ROOT/tmp}
     export TESTSUITELOG=${TMP}/${TESTSUITE}.log
     export HOSTNAME=${HOSTNAME:-`hostname`}
-
-    export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
+    if ! echo $PATH | grep -q $LUSTRE/utils; then
+	export PATH=$PATH:$LUSTRE/utils
+    fi
+    if ! echo $PATH | grep -q $LUSTRE/test; then
+	export PATH=$PATH:$LUSTRE/tests
+    fi
     export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
     export LFS=${LFS:-"$LUSTRE/utils/lfs"}
     [ ! -f "$LCTL" ] && export LCTL=$(which lctl) 
@@ -89,6 +93,7 @@ init_test_env() {
     export LPROC=/proc/fs/lustre
     export DIR2
     export AT_MAX_PATH
+    export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
 
     if [ "$ACCEPTOR_PORT" ]; then
         export PORT_OPT="--port $ACCEPTOR_PORT"
@@ -263,16 +268,16 @@ mount_facet() {
     local dev=${facet}_dev
     local opt=${facet}_opt
     echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
+        do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
+            lctl set_param subsystem_debug=${SUBSYSTEM# }; \
+            lctl set_param debug_mb=${DEBUG_SIZE}; \
+            sync"
+
     do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}     
     RC=${PIPESTATUS[0]}
     if [ $RC -ne 0 ]; then
         echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
         echo "Start of ${!dev} on ${facet} failed ${RC}"
-    else 
-        do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
-            lctl set_param subsystem_debug=${SUBSYSTEM# }; \
-            lctl set_param debug_mb=${DEBUG_SIZE}; \
-            sync"
     fi
     return $RC
 }
@@ -332,11 +337,12 @@ zconf_mount() {
 
     echo "Starting client: $client: $OPTIONS $device $mnt" 
     do_node $client mkdir -p $mnt
-    do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
-
     do_node $client "lctl set_param debug=$PTLDEBUG;
         lctl set_param subsystem_debug=${SUBSYSTEM# };
         lctl set_param debug_mb=${DEBUG_SIZE}"
+
+    do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
+
     [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
     return 0
 }
@@ -759,7 +765,7 @@ stopall() {
 
     if [ -n "$CLIENTS" ]; then
             zconf_umount_clients $CLIENTS $MOUNT "$*" || true
-            zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
+            [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
     fi
 
     [ "$CLIENTONLY" ] && return
@@ -1284,6 +1290,7 @@ run_one() {
     export TESTNAME=test_$testnum
     test_${testnum} || error "test_$testnum failed with $?"
     #check_mds
+    cd $SAVE_PWD
     reset_fail_loc
     check_grant ${testnum} || error "check_grant $testnum failed with $?"
     [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
@@ -1294,7 +1301,6 @@ run_one() {
     unset TESTNAME
     unset tdir
     umask $SAVE_UMASK
-    cd $SAVE_PWD
     $CLEANUP
 }
 
diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c
index d872ecf636..24163f48da 100644
--- a/lustre/utils/mkfs_lustre.c
+++ b/lustre/utils/mkfs_lustre.c
@@ -1204,12 +1204,6 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                                 return 1;
                         rc = add_param(mop->mo_ldd.ldd_params, PARAM_FAILNODE,
                                        nids, 0);
-                        /* Combo needs to add MDT failnodes as MGS failnodes
-                           as well */
-                        if (!rc && IS_MGS(&mop->mo_ldd)) {
-                                rc = add_param(mop->mo_ldd.ldd_params,
-                                               PARAM_MGSNODE, nids, 0);
-                        }
                         free(nids);
                         if (rc)
                                 return rc;
-- 
GitLab