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
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() {