Whamcloud - gitweb
LU-2571 lfsck: run lfsck on server node
authorEmoly Liu <emoly.liu@intel.com>
Tue, 5 Feb 2013 14:27:06 +0000 (22:27 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 19 Mar 2013 05:41:23 +0000 (01:41 -0400)
Usually we run e2fsck on OST and MDS nodes, and run lfsck on clients,
but it's not necessary to install e2fsprogs rpm on clients.
So, if lfsck is not found on client, we will try server node instead.

Test-Parameters: testlist=lfsck
Signed-off-by: Liu Ying <emoly.liu@intel.com>
Change-Id: I3979dc0236e81163f3283eac3148c36c8ddccf63
Reviewed-on: http://review.whamcloud.com/5139
Tested-by: Hudson
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/lfsck.sh
lustre/tests/test-framework.sh

index 46b067c..9e08e0b 100644 (file)
@@ -28,11 +28,6 @@ which can be accessable on all of the nodes" && exit 0; }
 which getfattr &>/dev/null || { skip_env "could not find getfattr" && exit 0; }
 which setfattr &>/dev/null || { skip_env "could not find setfattr" && exit 0; }
 
-if [ ! -x `which $LFSCK_BIN` ]; then
-    log "$($E2FSCK -V)"
-    error "e2fsprogs does not support lfsck"
-fi
-
 MOUNT_2=""
 check_and_setup_lustre
 
index 6216ad6..3b5214e 100644 (file)
@@ -3558,17 +3558,55 @@ generate_db() {
     done
 }
 
+# Run lfsck on server node if lfsck can't be found on client (LU-2571)
+run_lfsck_remote() {
+       local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
+       local client=$1
+       local mounted=true
+       local rc=0
+
+       #Check if lustre is already mounted
+       do_rpc_nodes $client is_mounted $MOUNT || mounted=false
+       if ! $mounted; then
+               zconf_mount $client $MOUNT ||
+                       error "failed to mount Lustre on $client"
+       fi
+       #Run lfsck
+       echo $cmd
+       do_node $node $cmd || rc=$?
+       #Umount if necessary
+       if ! $mounted; then
+               zconf_umount $client $MOUNT ||
+                       error "failed to unmount Lustre on $client"
+       fi
+
+       [ $rc -le $FSCK_MAX_ERR ] ||
+               error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
+       echo "lfsck finished with rc=$rc"
+
+       return $rc
+}
+
 run_lfsck() {
-    local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
-    echo $cmd
-    local rc=0
-    eval $cmd || rc=$?
-    [ $rc -le $FSCK_MAX_ERR ] || \
-        error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
-    echo "lfsck finished with rc=$rc"
+       local facets="client $SINGLEMDS"
+       local found=false
+       local facet
+       local node
+       local rc=0
 
-    rm -rvf $MDSDB* $OSTDB* || true
-    return 0
+       for facet in $facets; do
+               node=$(facet_active_host $facet)
+               if check_progs_installed $node $LFSCK_BIN; then
+                       found=true
+                       break
+               fi
+       done
+       ! $found && error "None of \"$facets\" supports lfsck"
+
+       run_lfsck_remote $node || rc=$?
+
+       rm -rvf $MDSDB* $OSTDB* || true
+       return $rc
 }
 
 check_and_cleanup_lustre() {