aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_ses.84
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_ses.c29
-rw-r--r--testing/sgh_dd.cpp44
6 files changed, 70 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 34db2172..36a09741 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.45 [20200202] [svn: r840]
+Changelog for sg3_utils-1.45 [20200210] [svn: r841]
- sg_get_elem_status: new utility [sbc4r16]
- sg_ses: bug: --page= being overridden when --control
and --data= also given; fix
@@ -10,6 +10,7 @@ Changelog for sg3_utils-1.45 [20200202] [svn: r840]
- rename 'SAS SlimLine' to SlimSAS [ses4r02]
- add --inhex=FN, equivalent to --data=@FN, for
compatibility with other utilities
+ - 'fan speed factor' field added in 20-013r1
- sg_opcodes: expand MLU (now 2 bits, spc5r20)
- include RWCDLP field as extension of CDLP
field (spc5r01)
diff --git a/debian/changelog b/debian/changelog
index dd3e8819..9b57c763 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.45-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Sun, 02 Feb 2020 21:00:00 -0500
+ -- Douglas Gilbert <dgilbert@interlog.com> Mon, 10 Feb 2020 23:00:00 -0500
sg3-utils (1.44-0.1) unstable; urgency=low
diff --git a/doc/sg_ses.8 b/doc/sg_ses.8
index 044fa1af..d953e55b 100644
--- a/doc/sg_ses.8
+++ b/doc/sg_ses.8
@@ -1,4 +1,4 @@
-.TH SG_SES "8" "August 2019" "sg3_utils\-1.45" SG3_UTILS
+.TH SG_SES "8" "February 2020" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg_ses \- access a SCSI Enclosure Services (SES) device
.SH SYNOPSIS
@@ -759,7 +759,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2004\-2019 Douglas Gilbert
+Copyright \(co 2004\-2020 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 490972a6..1e1a1619 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -84,7 +84,7 @@ fi
%{_libdir}/*.la
%changelog
-* Sun Feb 02 2020 - dgilbert at interlog dot com
+* Mon Feb 10 2020 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.45
diff --git a/src/sg_ses.c b/src/sg_ses.c
index cc24c13e..23fc3b95 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2019 Douglas Gilbert.
+ * Copyright (c) 2004-2020 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -38,7 +38,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static const char * version_str = "2.47 20190913"; /* ses4r03 */
+static const char * version_str = "2.48 20200206"; /* ses4r03 + 20-013r1 */
#define MX_ALLOC_LEN ((64 * 1024) - 4) /* max allowable for big enclosures */
#define MX_ELEM_HDR 1024
@@ -2468,6 +2468,23 @@ find_sas_connector_type(int conn_type, bool abridged, char * buff,
return buff;
}
+/* 'Fan speed factor' new in 20-013r1, probably will be in ses4r04 */
+static int
+calc_fan_speed(int fan_speed_factor, int actual_fan_speed)
+{
+ switch (fan_speed_factor) {
+ case 0:
+ return actual_fan_speed * 10;
+ case 1:
+ return (actual_fan_speed * 10) + 20480;
+ case 2:
+ return actual_fan_speed * 100;
+ default:
+ break;
+ }
+ return -1; /* something is wrong */
+}
+
static const char * elem_status_code_desc[] = {
"Unsupported", "OK", "Critical", "Noncritical",
"Unrecoverable", "Not installed", "Unknown", "Not available",
@@ -2582,8 +2599,14 @@ enc_status_helper(const char * pad, const uint8_t * statp, int etype,
!!(statp[1] & 0x40), !!(statp[3] & 0x80),
!!(statp[3] & 0x40), !!(statp[3] & 0x20));
printf("%sOff=%d, Actual speed=%d rpm, Fan %s\n", pad,
- !!(statp[3] & 0x10), (((0x7 & statp[1]) << 8) + statp[2]) * 10,
+ !!(statp[3] & 0x10),
+ calc_fan_speed((statp[1] >> 3) & 0x3,
+ ((0x7 & statp[1]) << 8) + statp[2]),
actual_speed_desc[7 & statp[3]]);
+ if (op->verbose > 1) /* show real field values */
+ printf("%s [Fan_speed_factor=%d, Actual_fan_speed=%d]\n",
+ pad, (statp[1] >> 3) & 0x3,
+ ((0x7 & statp[1]) << 8) + statp[2]);
break;
case TEMPERATURE_ETC: /* temperature sensor */
if (nofilter || ((0xc0 & statp[1]) || (0xf & statp[3]))) {
diff --git a/testing/sgh_dd.cpp b/testing/sgh_dd.cpp
index 035acacc..d74605b3 100644
--- a/testing/sgh_dd.cpp
+++ b/testing/sgh_dd.cpp
@@ -108,7 +108,7 @@
using namespace std;
-static const char * version_str = "1.70 20200202";
+static const char * version_str = "1.71 20200207";
#ifdef __GNUC__
#ifndef __clang__
@@ -1234,7 +1234,25 @@ sg_unshare(int sg_fd, int id, bool vb_b)
pr2serr_lk("tid=%d: ioctl(UNSHARE) ok\n", id);
}
-#ifdef SGH_DD_SNAP_DEV
+static void
+sg_noshare_enlarge(int sg_fd, bool vb_b)
+{
+ struct sg_extended_info sei;
+ struct sg_extended_info * seip;
+
+ seip = &sei;
+ memset(seip, 0, sizeof(*seip));
+ sei.sei_wr_mask |= SG_SEIM_TOT_FD_THRESH;
+ seip->tot_fd_thresh = 96 * 1024 * 1024;
+ if (ioctl(sg_fd, SG_SET_GET_EXTENDED, seip) < 0) {
+ pr2serr_lk("%s: ioctl(EXTENDED(TOT_FD_THRESH), failed errno=%d %s\n",
+ __func__, errno, strerror(errno));
+ return;
+ }
+ if (vb_b)
+ pr2serr_lk("ioctl(TOT_FD_THRESH) ok\n");
+}
+
static void
sg_take_snap(int sg_fd, int id, bool vb_b)
{
@@ -1255,7 +1273,6 @@ sg_take_snap(int sg_fd, int id, bool vb_b)
if (vb_b)
pr2serr_lk("tid=%d: ioctl(SNAP_DEV) ok\n", id);
}
-#endif
static void
cleanup_in(void * v_clp)
@@ -2106,7 +2123,7 @@ fini:
xtrp->blk_offset = ofsplit;
xtrp->blks = rep->num_blks - ofsplit;
nblks = xtrp->blks;
- status = pthread_mutex_lock(mutexp);
+ status = pthread_mutex_lock(mutexp);
if (0 != status) err_exit(status, "lock out_mutex");
goto split_upper;
}
@@ -2147,9 +2164,14 @@ chk_mrq_response(Rq_elem * rep, const struct sg_io_v4 * ctl_v4p,
id, __func__, n_cmpl, n_subm);
n_cmpl = n_subm;
}
- if (sres)
+ if (sres) {
pr2serr_lk("[%d] %s: secondary error: %s [%d], info=0x%x\n", id,
__func__, strerror(sres), sres, ctl_v4p->info);
+ if (E2BIG == sres) {
+ sg_take_snap(rep->infd, id, true);
+ sg_take_snap(rep->outfd, id, true);
+ }
+ }
/* Check if those submitted have finished or not */
for (k = 0; k < n_subm; ++k, ++a_np) {
slen = a_np->response_len;
@@ -2260,6 +2282,8 @@ sgh_do_async_mrq(Rq_elem * rep, mrq_arr_t & def_arr, int fd,
res = ioctl(fd, SG_IOSUBMIT, ctlop);
if (res < 0) {
err = errno;
+ if (E2BIG == err)
+ sg_take_snap(fd, rep->id, true);
pr2serr_lk("%s: ioctl(SG_IOSUBMIT, %s)-->%d, errno=%d: %s\n", __func__,
sg_flags_str(ctlop->flags, b_len, b), res, err,
strerror(err));
@@ -2655,7 +2679,9 @@ try_again:
if (res < 0) {
int err = errno;
- if (EBUSY == err) {
+ if (E2BIG == err)
+ sg_take_snap(fd, id, true);
+ else if (EBUSY == err) {
++num_ebusy;
std::this_thread::yield();/* allow another thread to progress */
goto try_again;
@@ -2968,6 +2994,8 @@ do_v4:
if (res < 0) {
if (ENOMEM == err)
return 1;
+ if (E2BIG == err)
+ sg_take_snap(fd, rep->id, true);
pr2serr_lk("%s tid=%d: %s %s ioctl(2) failed: %s\n", __func__,
rep->id, cp, sg_flags_str(h4p->flags, b_len, b),
strerror(err));
@@ -3604,6 +3632,8 @@ sg_in_open(Gbl_coll *clp, const char *inf, uint8_t **mmpp, int * mmap_lenp)
clp->in_flags.wq_excl, mmpp);
if (n <= 0)
return -SG_LIB_FILE_ERROR;
+ if (clp->in_flags.noshare || clp->out_flags.noshare)
+ sg_noshare_enlarge(fd, clp->debug > 3);
if (mmap_lenp)
*mmap_lenp = n;
return fd;
@@ -3636,6 +3666,8 @@ sg_out_open(Gbl_coll *clp, const char *outf, uint8_t **mmpp, int * mmap_lenp)
clp->out_flags.wq_excl, mmpp);
if (n <= 0)
return -SG_LIB_FILE_ERROR;
+ if (clp->in_flags.noshare || clp->out_flags.noshare)
+ sg_noshare_enlarge(fd, clp->debug > 3);
if (mmap_lenp)
*mmap_lenp = n;
return fd;