From 7c9a48086ce5b104596cb5b16f68469a6270f121 Mon Sep 17 00:00:00 2001 From: "Olaf P. Faaland" Date: Mon, 8 Jan 2024 21:36:50 -0800 Subject: [PATCH] LU-17409 scripts: correct ldev MGS handling ldev was incorrectly parsing the line specifying the hosts that can run the MGS, when of the form gopher1 gopher2 MGS gopher1/mgs as it assumed every target specified included a filesystem name, like 'lustre3-MDT0000'. This corrects that, assuming that an MGS may not be related to a specific file system. When such an input line is found, assume that MGS is used by any file systems included in the ldev.conf. When user includes option '-F ' as well as '-R MGS', include that MGS, in the targets reported. Test-Parameters: trivial Signed-off-by: Olaf Faaland Change-Id: Ifab5db1dfb094755e29747ec6b90d1566b16c18c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53619 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Cameron Harr Reviewed-by: Eric Carbonneau Reviewed-by: Andreas Dilger Reviewed-by: Gian-Carlo DeFazio Reviewed-by: Oleg Drokin --- lustre/scripts/ldev | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/lustre/scripts/ldev b/lustre/scripts/ldev index 77c0040..55d2418 100755 --- a/lustre/scripts/ldev +++ b/lustre/scripts/ldev @@ -46,6 +46,8 @@ my %eparse = ( my %conf = (); +my $global_mgs = ""; + # # Main # @@ -159,6 +161,7 @@ sub parse_config $type = $1; $dev = $2; } + eparse_line ($line, "efieldcount") if (!defined $dev); eparse_line ($line, "epairwise") if (exists $l2f{$local} && $l2f{$local} ne $foreign); @@ -166,25 +169,38 @@ sub parse_config eparse_line ($line, "elabel_uniq") if (exists $label2dev{$label} || exists $label2local{$label}); - /(\w+)-(OST|MDT|MGS)([0-9a-fA-F]{4})/, $label; - my $filesys = $1; - my $nodetype = $2; + $label2dev{$label} = $dev; $label2local{$label} = $local; $label2journal{$label} = $j if defined $j; $label2raidtab{$label} = $raidtab if defined $raidtab; + $label2hostname{$label}=$local; if (defined $type) { $label2type{$label} = $type; if ($type eq "zfs" && $dev =~ m{^([^/]+)/[^/]+$}) { $label2zpool{$label} = $1; } } - $label2hostname{$label}=$local; - if ($nodetype eq "MGS") { + my $filesys; + my $nodetype; + if ($label eq "MGS") { + $filesys = ""; + $nodetype = $label; + } else { + /(\w+)-(OST|MDT|MGS)([0-9a-fA-F]{4})/, $label; + $filesys = $1; + $nodetype = $2; + } + + if ($nodetype eq "MGS" or $label eq "MGS") { $filesys2mgs{$filesys} = $label; } + if ($label eq "MGS") { + $global_mgs = $label; + } + next if $conf{role} and lc $conf{role} ne lc $nodetype; if ($local eq $conf{hostname}) { @@ -456,6 +472,7 @@ sub exec_cmd @labels = (@{$conf{local_labels}}, @{$conf{foreign_labels}}); } elsif ($conf{fsname}) { @labels = (@labels, @{$conf{fs_labels}}); + push(@labels, $global_mgs) if ($global_mgs); } else { @labels = @{$conf{local_labels}}; } @@ -481,21 +498,28 @@ sub exec_cmd my $hostname = $label2hostname{$_}; my $mgsnid; if ($cmd =~ /%m/) { - if (!exists $filesys2mgs{$fsname}) { + my $mgs; + my $mgs_host; + + if (exists $filesys2mgs{$fsname}) { + $mgs = $filesys2mgs{$fsname}; + } elsif ($global_mgs) { + $mgs = $global_mgs; + } else { log_fatal ("$fsname has no MGS defined\n"); } - my $mgs = $filesys2mgs{$fsname}; - if (!exists $label2hostname{$mgs}) { + if (exists $label2hostname{$mgs}) { + $mgs_host = $label2hostname{$mgs}; + } else { log_fatal ("$mgs has no hostname defined\n"); } my %host2nid = %{$conf{host2nid}}; - $mgs = $label2hostname{$mgs}; - if (!exists $host2nid{$mgs}) { - log_fatal ("$mgs has no NID defined\n"); + if (!exists $host2nid{$mgs_host}) { + log_fatal ("$mgs and $mgs_host have no NID defined\n"); } - $mgsnid = $host2nid{$mgs}; + $mgsnid = $host2nid{$mgs_host}; } $cmd =~ s/%f/$fsname/g; # %f = fsname -- 1.8.3.1