Commit 169bc8e
committed
utils/nvme: Enhanced get_ns_status to support namespace-based topology fallback
The 'nvme show-topology /dev/<controller>' form fails on some nvme-cli
builds, returning {"error": "Invalid device name"} instead of a valid
JSON topology. Additionally, in multi-path subsystems where two controllers
(e.g. nvme0 and nvme3) share a namespace (e.g. nvme3n1), the namespace
block device is named after only one of the controllers, making a
namespace name constructed from controller_name unreliable.
Enhance get_ns_status with a two-stage approach:
Primary path (unchanged behaviour):
nvme show-topology /dev/<controller_name> -o json
Parses the original JSON structure where paths["Name"] matches
the controller name. Returns immediately on success.
Fallback path (new):
nvme show-topology -o json (whole-system, no device argument)
Triggered when the primary path returns an error payload (dict
instead of list), raises JSONDecodeError, or yields no match.
Locates the correct path by matching NSID and Controller.Name
inside the Paths[].Controller[] array, which is unambiguous
across multi-controller subsystems and avoids any namespace
device name construction.
Both paths return [State, ANAState] preserving the existing API.
Signed-off-by: Maram Srimannarayana Murthy <msmurthy@linux.vnet.ibm.com>1 parent 2454cd2 commit 169bc8e
2 files changed
Lines changed: 61 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
655 | | - | |
| 655 | + | |
656 | 656 | | |
657 | | - | |
658 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
659 | 665 | | |
660 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
661 | 670 | | |
662 | 671 | | |
| 672 | + | |
663 | 673 | | |
664 | 674 | | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
673 | 716 | | |
674 | 717 | | |
675 | 718 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
0 commit comments