Skip to content

Commit

Permalink
vdev_id: Fix PHY sorting
Browse files Browse the repository at this point in the history
One of our developers noticed a bug in vdev_id where we were incorrectly
sorting PHYs using alphabetical sorting (which usually works) instead
of natural sorting (-v).  For example:

	[port-0:0]# ls -d phy*
	phy-0:10  phy-0:11  phy-0:8  phy-0:9

	[port-0:0]# ls -vd phy*
	phy-0:8  phy-0:9  phy-0:10  phy-0:11

This fixes the issue.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#12699
  • Loading branch information
tonyhutter committed Nov 12, 2021
1 parent bc16046 commit 7a0f951
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/vdev_id/vdev_id
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ sas_handler() {
i=$((i + 1))
done

PHY=$(ls -d "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}')
PHY=$(ls -vd "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}')
if [ -z "$PHY" ] ; then
PHY=0
fi
Expand Down

0 comments on commit 7a0f951

Please sign in to comment.