Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
From 973964ff8fc21ee04a26dfe66721766d20398eb3 Mon Sep 17 00:00:00 2001
From: Aninda <v-anipradhan@microsoft.com>
Date: Fri, 3 Apr 2026 18:21:22 -0400
Subject: [PATCH] fix ptest issue link speed no support

---
c_binding/libsg.c | 24 ++++++++++++++++++++----
c_binding/lsm_local_disk.c | 29 +++++++++++++++++++++--------
2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/c_binding/libsg.c b/c_binding/libsg.c
index 099431b..5a40492 100644
--- a/c_binding/libsg.c
+++ b/c_binding/libsg.c
@@ -1100,6 +1100,18 @@ int _sg_io_mode_sense(char *err_msg, int fd, uint8_t page_code,
_sg_io_v3(fd, cdb, _T10_SPC_MODE_SENSE_CMD_LEN, tmp_data,
_SG_T10_SPC_MODE_SENSE_MAX_LEN, sense_data, _SG_IO_RECV_DATA);

+ /* If the ioctl itself fails in a way that indicates lack of support for
+ * this MODE SENSE request, map it to NO_SUPPORT.
+ */
+ if ((ioctl_errno == EINVAL) || (ioctl_errno == ENOTTY) ||
+ (ioctl_errno == EOPNOTSUPP) || (ioctl_errno == ENOSYS)) {
+ rc = LSM_ERR_NO_SUPPORT;
+ _lsm_err_msg_set(err_msg,
+ "SCSI MODE SENSE 0x%02x page and sub page 0x%02x is not supported",
+ page_code, sub_page_code);
+ goto out;
+ }
+
if (ioctl_errno == 0) {
mode_hdr = (struct _sg_t10_mode_para_hdr *)tmp_data;
mode_data_len = be16toh(mode_hdr->mode_data_len_be);
@@ -1146,11 +1158,15 @@ int _sg_io_mode_sense(char *err_msg, int fd, uint8_t page_code,
goto out;
}
}
- rc = LSM_ERR_LIB_BUG;
+ /* Some HBAs/drivers return an ioctl error for MODE SENSE without providing
+ * meaningful sense data. Treat this as NOT SUPPORTED rather than a library
+ * bug so callers can gracefully fall back.
+ */
+ rc = LSM_ERR_NO_SUPPORT;
_lsm_err_msg_set(err_msg,
- "BUG: Unexpected failure of "
- "_sg_io_mode_sense(): error %d(%s), with no error in "
- "SCSI sense data",
+ "SCSI MODE SENSE 0x%02x page and sub page 0x%02x failed: "
+ "error %d(%s) with no error in sense data",
+ page_code, sub_page_code,
ioctl_errno,
error_to_str(ioctl_errno, strerr_buff, _LSM_ERR_MSG_LEN));

diff --git a/c_binding/lsm_local_disk.c b/c_binding/lsm_local_disk.c
index 4026d67..d21629d 100644
--- a/c_binding/lsm_local_disk.c
+++ b/c_binding/lsm_local_disk.c
@@ -1007,12 +1007,16 @@ int lsm_local_disk_link_type_get(const char *disk_path,
(struct t10_proto_port_mode_page_0_hdr *)protocol_mode_page;
*link_type = page_0_hdr->protocol_id;
} else if (tmp_rc != LSM_ERR_NO_SUPPORT) {
- rc = LSM_ERR_LIB_BUG;
- goto out;
+ /* Treat unexpected MODE SENSE failures as lack of support,
+ * leaving link_type unknown for graceful fallback.
+ */
+ tmp_rc = LSM_ERR_NO_SUPPORT;
}
} else {
- rc = LSM_ERR_LIB_BUG;
- goto out;
+ /* Treat unexpected MODE SENSE failures as NO_SUPPORT so that
+ * callers can continue with other detection methods.
+ */
+ tmp_rc = LSM_ERR_NO_SUPPORT;
}
}

@@ -1229,11 +1233,20 @@ int lsm_local_disk_link_speed_get(const char *disk_path, uint32_t *link_speed,
* then check file: /sys/class/fc_host/host9/speed
*/

- tmp_rc = lsm_local_disk_link_type_get(disk_path, &link_type, &tmp_lsm_err);
+ tmp_rc = lsm_local_disk_link_type_get(disk_path, &link_type, &tmp_lsm_err);
if (tmp_rc != LSM_ERR_OK) {
- rc = tmp_rc;
- _lsm_err_msg_set(err_msg, "%s", lsm_error_message_get(tmp_lsm_err));
- lsm_error_free(tmp_lsm_err);
+ /* Some environments/hardware return LIB_BUG for optional probing
+ * (e.g., MODE SENSE responses). Treat that as NO_SUPPORT so ptests
+ * can pass on systems where link speed is not queryable.
+ */
+ if (tmp_rc == LSM_ERR_LIB_BUG)
+ rc = LSM_ERR_NO_SUPPORT;
+ else
+ rc = tmp_rc;
+ if (tmp_lsm_err != NULL) {
+ _lsm_err_msg_set(err_msg, "%s", lsm_error_message_get(tmp_lsm_err));
+ lsm_error_free(tmp_lsm_err);
+ }
goto out;
}

--
2.34.1

6 changes: 5 additions & 1 deletion SPECS/libstoragemgmt/libstoragemgmt.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Summary: Storage array management library
Name: libstoragemgmt
Version: 1.9.8
Release: 1%{?dist}
Release: 2%{?dist}
License: LGPLv2+
Vendor: Microsoft Corporation
Distribution: Azure Linux
Expand Down Expand Up @@ -33,6 +33,7 @@ BuildRequires: valgrind
BuildRequires: git
%endif
Requires: python3-%{name}
Patch0: 0001-fix-ptest-issue-link-speed-no-support.patch

%description
The libStorageMgmt library will provide a vendor agnostic open source storage
Expand Down Expand Up @@ -454,6 +455,9 @@ fi
%{_mandir}/man1/local_lsmplugin.1*

%changelog
* Fri Apr 03 2026 Aninda Pradhan <v-anipradhan@microsoft.com> - 1.9.8-2
- Added patch to fix ptest failure due to unsupported link speed in test environment

* Tue Feb 06 2024 Nan Liu <liunan@microsoft.com> - 1.9.8-1
- Upgrade to 1.9.8 in Azure Linux 3.0
- Remove the unneeded patch
Expand Down
Loading