From 3bc1ff3a6b95c6bbb9119ec655180ffff3e0ecc0 Mon Sep 17 00:00:00 2001
From: liuy <liuy>
Date: Tue, 14 Aug 2007 02:22:47 +0000
Subject: [PATCH] Branch b1_6 b=11679 i=adilger, deen

fix lstripe failure with valid OST index
---
 lustre/ChangeLog       |  6 ++++++
 lustre/lov/lov_pack.c  |  6 +++---
 lustre/tests/sanity.sh | 29 +++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index bf25856d74..623579bde8 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -193,6 +193,12 @@ Description: client-side metadata stat-ahead during readdir(directory readahead)
 Details    : perform client-side metadata stat-ahead when the client detects
              readdir and sequential stat of dir entries therein
 
+Severity   : normal 
+Bugzilla   : 11679
+Description: lstripe command fails for valid OST index
+Details    : The stripe offset is compared to 'lov->desc.ld_tgt_count' 
+	     instead of lov->desc.ld_active_tgt_count.
+
 --------------------------------------------------------------------------------
 
 2007-07-30         Cluster File Systems, Inc. <info@clusterfs.com>
diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c
index f9b5ee3170..53a5a88a93 100644
--- a/lustre/lov/lov_pack.c
+++ b/lustre/lov/lov_pack.c
@@ -327,10 +327,10 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
                 lum.lmm_stripe_size = LOV_MIN_STRIPE_SIZE;
         }
 
-        if ((lum.lmm_stripe_offset >= lov->desc.ld_active_tgt_count) &&
+        if ((lum.lmm_stripe_offset >= lov->desc.ld_tgt_count) &&
             (lum.lmm_stripe_offset != (typeof(lum.lmm_stripe_offset))(-1))) {
-                CDEBUG(D_IOCTL, "stripe offset %u > number of active OSTs %u\n",
-                       lum.lmm_stripe_offset, lov->desc.ld_active_tgt_count);
+                CDEBUG(D_IOCTL, "stripe offset %u > number of OSTs %u\n",
+                       lum.lmm_stripe_offset, lov->desc.ld_tgt_count);
                 RETURN(-EINVAL);
         }
         stripe_count = lov_get_stripecnt(lov, lum.lmm_stripe_count);
diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index 5cbb3ee671..719778008a 100644
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -2728,6 +2728,35 @@ test_65j() { # bug6367
 }
 run_test 65j "set default striping on root directory (bug 6367)="
 
+test_65k() { # bug11679
+        [ "$OSTCOUNT" -lt 2 ] && skip "too few OSTs" && return
+
+        echo "Check OST status: "
+        MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
+        for OSC in $MDS_OSCS; do
+                echo $OSC "is activate"
+                do_facet mds lctl --device %$OSC activate
+        done
+        mkdir -p $DIR/$tdir
+        for INACTIVE_OSC in $MDS_OSCS; do
+                echo $INACTIVE_OSC "is Deactivate:"
+                do_facet mds lctl --device  %$INACTIVE_OSC deactivate
+                for STRIPE_OSC in $MDS_OSCS; do
+                        STRIPE_OST=`osc_to_ost $STRIPE_OSC`
+                        STRIPE_INDEX=`do_facet mds cat $LPROC/lov/*md*/target_obd |
+                                      grep $STRIPE_OST | awk -F: '{print $1}'`
+                        echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1"
+                        do_facet mds $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1
+                        RC=$?
+                        [ $RC -ne 0 ] && error "setstripe should have succeeded"
+                done
+                rm -f $DIR/$tdir/*
+                echo $INACTIVE_OSC "is Activate."
+                do_facet mds lctl --device  %$INACTIVE_OSC activate
+        done
+}
+run_test 65k "validate manual striping works properly with deactivated OSCs"
+
 # bug 2543 - update blocks count on client
 test_66() {
 	COUNT=${COUNT:-8}
-- 
GitLab