From: Emoly Liu Date: Tue, 5 Feb 2013 14:27:06 +0000 (+0800) Subject: LU-2571 lfsck: run lfsck on server node X-Git-Tag: 2.3.63~42 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=4d5bc3e5e74c3c2fc01cf51570ed8cee3521fd72 LU-2571 lfsck: run lfsck on server node 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 Change-Id: I3979dc0236e81163f3283eac3148c36c8ddccf63 Reviewed-on: http://review.whamcloud.com/5139 Tested-by: Hudson Reviewed-by: Jian Yu Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/lfsck.sh b/lustre/tests/lfsck.sh index 46b067c..9e08e0b 100644 --- a/lustre/tests/lfsck.sh +++ b/lustre/tests/lfsck.sh @@ -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 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 6216ad6..3b5214e 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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() {