\fI--filesys\fR options.
The following substitutions are made:
%f=fsname, %d=device, %j=journal, %i=index, %I=hex-index, %t=type, %l=label,
-%n=nid, %N=failnid, %m=mgsnid. On failure of any child processes, \fBldev\fR will
-return a non-zero exit code.
+%n=nid, %N=failnid, %m=mgsnid, %H=hostname, %b=backing-fs. On failure of
+any child processes, \fBldev\fR will return a non-zero exit code.
.LP
It is an error if %n, %N, or %m is used in a command and /etc/nids does not
contain appropriate host to NID mappings.
CMD [ARGS] ... Run CMD in parallel for each device substituting:
%f=fsname %d=device %i=dec-index %n=main-nid %l=label
%t=srvtype %j=journal %I=hex-index %N=fail-nid %m=mgs-nid
+ %H=hostname %b=backing-fs
May be used in combination with -l, -f, -a, -F options.
EOF
my @labels = ();
my @cmds = ();
my %label2dev = %{$conf{label2dev}};
+ my %label2type = %{$conf{label2type}};
my %label2journal = %{$conf{label2journal}};
my %filesys2mgs = %{$conf{filesys2mgs}};
my %label2hostname = %{$conf{label2hostname}};
log_fatal ("%j used but no journal defined for $_\n");
}
my $journal = $label2journal{$_};
+ my $fstype = $label2type{$_};
+ if (!defined $fstype or $fstype ne "zfs") {
+ $fstype = "ldiskfs";
+ }
+ my $hostname = $label2hostname{$_};
my $mgsnid;
if ($cmd =~ /%m/) {
if (!exists $filesys2mgs{$fsname}) {
$cmd =~ s/%n/$nid/g; # %n = nid
$cmd =~ s/%N/$failnid/g; # %N = failnid
$cmd =~ s/%m/$mgsnid/g; # %m = MGS nid
+ $cmd =~ s/%b/$fstype/g; # %b = backing file system type
+ $cmd =~ s/%H/$hostname/g;# %H = hostname
push @cmds, "$_ $cmd";
}
generate_ldev_conf() {
# generate an ldev.conf file
local ldevconfpath=$1
+ local fstype=
+ local fsldevformat=""
touch $ldevconfpath
- printf "%s\t-\t%s-MGS0000\t%s\n" \
+
+ fstype=$(facet_fstype mgs)
+ if [ "$fstype" == "zfs" ]; then
+ fsldevformat="$fstype:"
+ else
+ fsldevformat=""
+ fi
+
+ printf "%s\t-\t%s-MGS0000\t%s%s\n" \
$mgs_HOST \
$FSNAME \
+ $fsldevformat \
$(mgsdevname) > $ldevconfpath
local mdsfo_host=$mdsfailover_HOST;
fi
for num in $(seq $MDSCOUNT); do
- printf "%s\t%s\t%s-MDT%04d\t%s\n" \
+ fstype=$(facet_fstype mds$num)
+ if [ "$fstype" == "zfs" ]; then
+ fsldevformat="$fstype:"
+ else
+ fsldevformat=""
+ fi
+
+ printf "%s\t%s\t%s-MDT%04d\t%s%s\n" \
$mds_HOST \
$mdsfo_host \
$FSNAME \
$num \
+ $fsldevformat \
$(mdsdevname $num) >> $ldevconfpath
done
fi
for num in $(seq $OSTCOUNT); do
- printf "%s\t%s\t%s-OST%04d\t%s\n" \
+ fstype=$(facet_fstype ost$num)
+ if [ "$fstype" == "zfs" ]; then
+ fsldevformat="$fstype:"
+ else
+ fsldevformat=""
+ fi
+
+ printf "%s\t%s\t%s-OST%04d\t%s%s\n" \
$ost_HOST \
$ostfo_host \
$FSNAME \
$num \
+ $fsldevformat \
$(ostdevname $num) >> $ldevconfpath
done
}
run_test 95 "ldev should only allow one label filter"
+test_96() {
+ if [ -z "$LDEV" ]; then
+ error "ldev is missing!"
+ fi
+
+ local LDEVCONFPATH=$TMP/ldev.conf
+ local NIDSPATH=$TMP/nids
+
+ generate_ldev_conf $LDEVCONFPATH
+ generate_nids $NIDSPATH
+
+ local LDEV_OUTPUT=$TMP/ldev-output.txt
+ $LDEV -c $LDEVCONFPATH -n $NIDSPATH -H $mgs_HOST \
+ echo %H-%b | \
+ awk '{print $2}' > $LDEV_OUTPUT
+
+ # ldev failed, error
+ if [ $? -ne 0 ]; then
+ rm $LDEVCONFPATH $NIDSPATH $LDEV_OUTPUT
+ error "ldev failed to execute!"
+ fi
+
+ # expected output
+ local EXPECTED_OUTPUT=$TMP/ldev-expected-output.txt
+
+ echo "$mgs_HOST-$(facet_fstype mgs)" > $EXPECTED_OUTPUT
+
+ if [ "$mgs_HOST" == "$mds_HOST" ]; then
+ for num in $(seq $MDSCOUNT); do
+ echo "$mds_HOST-$(facet_fstype mds$num)" \
+ >> $EXPECTED_OUTPUT
+ done
+ fi
+
+ if [ "$mgs_HOST" == "$ost_HOST" ]; then
+ for num in $(seq $OSTCOUNT); do
+ echo "$ost_HOST-$(facet_fstype ost$num)" \
+ >> $EXPECTED_OUTPUT
+ done
+ fi
+
+ compare_ldev_output $LDEV_OUTPUT $EXPECTED_OUTPUT
+
+ if [ $? -ne 0 ]; then
+ rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
+ error "ldev failed to produce the correct output!"
+ fi
+
+ rm $LDEVCONFPATH $NIDSPATH $EXPECTED_OUTPUT $LDEV_OUTPUT
+}
+run_test 96 "ldev returns hostname and backend fs correctly in command sub"
+
if ! combined_mgs_mds ; then
stop mgs
fi