aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2023-03-10 17:47:08 +0000
committerAlan Somers <asomers@FreeBSD.org>2023-09-06 20:39:35 +0000
commita6506dda739c04186e7fe966687200cc74d36091 (patch)
tree096ff622bbd2a5331049b4482f3845e2ec8bea43
parent3fc299d68897a0748d96510de5f191f5a8249216 (diff)
downloadsrc-a6506dda739c04186e7fe966687200cc74d36091.tar.gz
src-a6506dda739c04186e7fe966687200cc74d36091.zip
sesutil: fix "fault all" with zoned jbods
Some SAS JBODs support zoning. This feature allows individual SAS targets to be accessible by only some initiator ports. One application would be connecting two servers to the same JBOD, but they wouldn't be able to see each other's disks. A zoned JBOD should also prohibit initiators from accessing SES elements corresponding to inaccessible SAS targets. It reports that by setting the element's status code to 0x8 (No Access Allowed). The bug is that when doing "sesutil (fault|locate) all ...", sesutil will attempt a ENCIOC_SETELMSTAT ioctl for every single element, even the inaccessible ones. The enclosure will reject the command, the kernel will return EINVAL, and sesutil will exit. The solution is to check the element's status, and skip trying to set it if the status is 0x8. But if the user actually supplied a ses ID, then assume that he knows what he's doing and try to set it anyway. PR: 270093 Sponsored by: Axcient Reviewed by: mav, trasz Differential Revision: https://reviews.freebsd.org/D39017 (cherry picked from commit 57dc6f5e200b10d34ccb97ccc18d06b3f0b9b933)
-rw-r--r--usr.sbin/sesutil/sesutil.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.sbin/sesutil/sesutil.c b/usr.sbin/sesutil/sesutil.c
index 99f6b2de63b0..863b95a0f8b0 100644
--- a/usr.sbin/sesutil/sesutil.c
+++ b/usr.sbin/sesutil/sesutil.c
@@ -279,6 +279,16 @@ sesled(int argc, char **argv, bool setfault)
char devnames[devnames_size];
if (all) {
+ encioc_elm_status_t es;
+ memset(&es, 0, sizeof(es));
+ es.elm_idx = objp[j].elm_idx;
+ if (ioctl(fd, ENCIOC_GETELMSTAT, &es) < 0) {
+ close(fd);
+ xo_err(EXIT_FAILURE,
+ "ENCIOC_GETELMSTAT");
+ }
+ if ((es.cstat[0] & 0xf) == SES_OBJSTAT_NOACCESS)
+ continue;
do_led(fd, objp[j].elm_idx, objp[j].elm_type,
onoff, setfault);
continue;