OSTIDX=${OSTIDX:-0} # the OST index in LOV
OBJGRP=${OBJGRP:-0} # the OST object group
-[ -d "$SHARED_DIRECTORY" ] || \
- { skip "SHARED_DIRECTORY should be specified with a shared directory \
-which can be accessable on all of the nodes" && exit 0; }
+[ ! -d "$SHARED_DIRECTORY" ] &&
+ skip_env "SHARED_DIRECTORY should be accessible on all 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; }
echo $ost_objids
}
-# Get the OST nodet name (given the OST index).
-get_ost_node() {
- local obdidx=$1
- local ost_uuid
- local ost_node
- local node
-
- ost_uuid=$(ostuuid_from_index $obdidx)
-
- for node in $(osts_nodes); do
- do_node $node "lctl get_param -n obdfilter.*.uuid" | grep -q $ost_uuid
- [ ${PIPESTATUS[1]} -eq 0 ] && ost_node=$node && break
- done
- [ -z "$ost_node" ] && \
- echo "failed to find the OST with index $obdidx" && return 1
- echo $ost_node
-}
-
# Get the OST target device (given the OST facet name and OST index).
get_ost_dev() {
local node=$1
echo $files
}
-# Remove objects associated with files.
+# Remove objects from OST.
remove_objects() {
- local node=$1
- shift
- local ostdev=$1
- shift
- local group=$1
- shift
- local objids="$@"
- local tmp
- local i
- local rc
-
- echo "removing objects from $ostdev on $facet: $objids"
- tmp=$(mktemp $SHARED_DIRECTORY/debugfs.XXXXXXXXXX)
- for i in $objids; do
- echo "rm O/$group/d$((i % 32))/$i" >> $tmp
- done
-
- do_node $node "$DEBUGFS -w -f $tmp $ostdev"
- rc=${PIPESTATUS[0]}
- rm -f $tmp
-
- return $rc
+ do_rpc_nodes $(facet_host $1) remove_ost_objects $@
}
# Remove files from MDS.
# get the server target devices
get_svr_devs
+TESTDIR=$DIR/d0.$TESTSUITE
if is_empty_fs $MOUNT; then
# create test directory
- TESTDIR=$DIR/d0.$TESTSUITE
mkdir -p $TESTDIR || error "mkdir $TESTDIR failed"
# create some dirs and files on the filesystem
create_files $TESTDIR $NUMDIRS $NUMFILES
- # get the objids for files in group $OBJGRP on the OST with index $OSTIDX
+ # get objids for files in group $OBJGRP on the OST with index $OSTIDX
+ echo "objects to be removed, leaving dangling references:"
OST_REMOVE=$(get_objects $OSTIDX $OBJGRP \
$(seq -f $TESTDIR/testfile.%g $NUMFILES))
# get the node name and target device for the OST with index $OSTIDX
- OSTNODE=$(get_ost_node $OSTIDX) || error "get_ost_node by index $OSTIDX failed"
- OSTDEV=$(get_ost_dev $OSTNODE $OSTIDX) || \
+ OSTNODE=$(facet_active_host ost$((OSTIDX + 1)))
+ OSTDEV=$(get_ost_dev $OSTNODE $OSTIDX) ||
error "get_ost_dev $OSTNODE $OSTIDX failed"
# get the file names to be duplicated on the MDS
+ echo "files to be duplicated, leaving double-referenced objects:"
MDS_DUPE=$(get_files dup $TESTDIR $NUMFILES) || error "$MDS_DUPE"
# get the file names to be removed from the MDS
+ echo "files to be removed, leaving orphan objects:"
MDS_REMOVE=$(get_files remove $TESTDIR $NUMFILES) || error "$MDS_REMOVE"
stopall -f || error "cleanupall failed"
# remove objects associated with files in group $OBJGRP
# on the OST with index $OSTIDX
- remove_objects $OSTNODE $OSTDEV $OBJGRP $OST_REMOVE || \
+ remove_objects ost$((OSTIDX + 1)) $OSTDEV $OBJGRP $OST_REMOVE ||
error "removing objects failed"
# remove files from MDS
remove_files mds $MDSDEV $MDS_REMOVE || error "removing files failed"
# create EAs on files so objects are referenced from different files
- duplicate_files mds $MDSDEV $MDS_DUPE || \
+ duplicate_files mds $MDSDEV $MDS_DUPE ||
error "duplicating files failed"
FSCK_MAX_ERR=1 # file system errors corrected
else # is_empty_fs $MOUNT
generate_db
# remount filesystem
+ORIG_REFORMAT=$REFORMAT
REFORMAT=""
check_and_setup_lustre
+REFORMAT=$ORIG_REFORMAT
# run lfsck
rc=0
fi
complete $(basename $0) $SECONDS
+# The test directory contains some files referencing to some object
+# which could cause error when removing the directory.
+RMCNT=0
+while [ -d $TESTDIR ]; do
+ RMCNT=$((RMCNT + 1))
+ rm -fr $TESTDIR || echo "$RMCNT round: rm $TESTDIR failed"
+ [ $RMCNT -ge 10 ] && error "cleanup $TESTDIR failed $RMCNT times"
+ remount_client $MOUNT
+done
check_and_cleanup_lustre
exit_status
is_empty_fs() {
[ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
-print | wc -l) = 1 ] || return 1
- [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
- [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
- return 1
+ [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found || return 1
+ [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre || return 1
+ return 0
}
check_and_setup_lustre() {
echo $service_time
}
+# Remove objects from OST
+remove_ost_objects() {
+ local facet=$1
+ local ostdev=$2
+ local group=$3
+ shift 3
+ local objids="$@"
+ local mntpt=$(facet_mntpt $facet)
+ local opts=$OST_MOUNT_OPTS
+ local i
+ local rc
+
+ echo "removing objects from $ostdev on $facet: $objids"
+ mount -t $FSTYPE $OST_MOUNT_OPTS $ostdev $mntpt || return $?
+ rc=0
+ for i in $objids; do
+ rm $mntpt/O/$group/d$((i % 32))/$i || { rc=$?; break; }
+ done
+ umount -f $mntpt || return $?
+ return $rc
+}
+
+#Remove files from MDT
remove_mdt_files() {
local facet=$1
local mdtdev=$2
echo "removing files from $mdtdev on $facet: $files"
mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
- rc=0;
+ rc=0
for f in $files; do
rm $mntpt/ROOT/$f || { rc=$?; break; }
done