aboutsummaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2021-04-01 04:53:56 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2021-04-01 04:53:56 +0000
commit3eca65ae2a191c8a94138c4dea4286a9a9011ff0 (patch)
tree92d130fd2fdc246bf1a7b37c1f07a2426ce4a186 /testing
parent02bb2aad7c96e908c56e7416290487a6afb80fba (diff)
downloadsg3_utils-3eca65ae2a191c8a94138c4dea4286a9a9011ff0.tar.gz
move some hex file from examples to inhex directory; add testing/sg_take_snap; remove no_waitq from testing
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@893 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'testing')
-rw-r--r--testing/Makefile5
-rw-r--r--testing/sg_mrq_dd.cpp88
-rw-r--r--testing/sg_take_snap.c202
-rw-r--r--testing/sg_tst_async.cpp21
-rw-r--r--testing/sgh_dd.cpp78
-rw-r--r--testing/sgs_dd.c25
-rw-r--r--testing/uapi_sg.h12
7 files changed, 277 insertions, 154 deletions
diff --git a/testing/Makefile b/testing/Makefile
index ac152d8d..14ee0d27 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -7,7 +7,7 @@ MANDIR=$(DESTDIR)/$(PREFIX)/man
EXECS = sg_sense_test sg_queue_tst bsg_queue_tst sg_chk_asc sg_tst_nvme \
sg_tst_ioctl sg_tst_bidi tst_sg_lib sgs_dd sg_tst_excl \
sg_tst_excl2 sg_tst_excl3 sg_tst_context sg_tst_async sgh_dd \
- sg_mrq_dd sg_iovec_tst
+ sg_mrq_dd sg_iovec_tst sg_take_snap
EXTRAS =
@@ -117,6 +117,9 @@ sg_mrq_dd: sg_mrq_dd.o sg_scat_gath.o $(LIBFILESNEW)
sg_iovec_tst: sg_iovec_tst.o sg_scat_gath.o $(LIBFILESNEW)
$(CXXLD) -o $@ $(LDFLAGS) -pthread -latomic $^
+sg_take_snap: sg_take_snap.o $(LIBFILESNEW)
+ $(LD) -o $@ $(LDFLAGS) $^
+
install: $(EXECS)
install -d $(INSTDIR)
diff --git a/testing/sg_mrq_dd.cpp b/testing/sg_mrq_dd.cpp
index bed16233..832a21a1 100644
--- a/testing/sg_mrq_dd.cpp
+++ b/testing/sg_mrq_dd.cpp
@@ -30,7 +30,7 @@
*
*/
-static const char * version_str = "1.23 20210328";
+static const char * version_str = "1.25 20210331";
#define _XOPEN_SOURCE 600
#ifndef _GNU_SOURCE
@@ -190,6 +190,7 @@ struct flags_t {
bool masync; /* more async sg v4 driver fd flag */
bool no_dur;
bool nocreat;
+ bool no_waitq; /* dummy, no longer supported, just warn */
bool order;
bool qhead;
bool qtail;
@@ -266,7 +267,6 @@ struct global_collection /* one instance visible to all threads */
bool mrq_hipri;
bool ofile_given;
bool unit_nanosec; /* default duration unit is millisecond */
- bool no_waitq; /* if set use polling for response instead */
bool verify; /* don't copy, verify like Unix: cmp */
bool prefetch; /* for verify: do PF(b),RD(a),V(b)_a_data */
const char * infp;
@@ -504,13 +504,13 @@ sg_flags_str(int flags, int b_len, char * b)
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_NO_WAITQ & flags) { /* 0x40 */
- n += sg_scnpr(b + n, b_len - n, "NO_WTQ|");
+ if (SGV4_FLAG_DOUT_OFFSET & flags) { /* 0x40 */
+ n += sg_scnpr(b + n, b_len - n, "DOFF|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_DOUT_OFFSET & flags) { /* 0x80 */
- n += sg_scnpr(b + n, b_len - n, "DOFF|");
+ if (SGV4_FLAG_EVENTFD & flags) { /* 0x80 */
+ n += sg_scnpr(b + n, b_len - n, "EVFD|");
if (n >= b_len)
goto fini;
}
@@ -529,43 +529,43 @@ sg_flags_str(int flags, int b_len, char * b)
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_STOP_IF & flags) { /* 0x800 */
+ if (SGV4_FLAG_HIPRI & flags) { /* 0x800 */
+ n += sg_scnpr(b + n, b_len - n, "HIPRI|");
+ if (n >= b_len)
+ goto fini;
+ }
+ if (SGV4_FLAG_STOP_IF & flags) { /* 0x1000 */
n += sg_scnpr(b + n, b_len - n, "STOPIF|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_DEV_SCOPE & flags) { /* 0x1000 */
+ if (SGV4_FLAG_DEV_SCOPE & flags) { /* 0x2000 */
n += sg_scnpr(b + n, b_len - n, "DEV_SC|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_SHARE & flags) { /* 0x2000 */
+ if (SGV4_FLAG_SHARE & flags) { /* 0x4000 */
n += sg_scnpr(b + n, b_len - n, "SHARE|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_DO_ON_OTHER & flags) { /* 0x4000 */
+ if (SGV4_FLAG_DO_ON_OTHER & flags) { /* 0x8000 */
n += sg_scnpr(b + n, b_len - n, "DO_OTH|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_KEEP_SHARE & flags) { /* 0x8000 */
- n += sg_scnpr(b + n, b_len - n, "KEEP_SH|");
- if (n >= b_len)
- goto fini;
- }
if (SGV4_FLAG_NO_DXFER & flags) { /* 0x10000 */
n += sg_scnpr(b + n, b_len - n, "NDXFER|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_MULTIPLE_REQS & flags) { /* 0x20000 */
- n += sg_scnpr(b + n, b_len - n, "MRQS|");
+ if (SGV4_FLAG_KEEP_SHARE & flags) { /* 0x20000 */
+ n += sg_scnpr(b + n, b_len - n, "KEEP_SH|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_EVENTFD & flags) { /* 0x40000 */
- n += sg_scnpr(b + n, b_len - n, "EVFD|");
+ if (SGV4_FLAG_MULTIPLE_REQS & flags) { /* 0x40000 */
+ n += sg_scnpr(b + n, b_len - n, "MRQS|");
if (n >= b_len)
goto fini;
}
@@ -579,11 +579,8 @@ sg_flags_str(int flags, int b_len, char * b)
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_HIPRI & flags) { /* 0x200000 */
- n += sg_scnpr(b + n, b_len - n, "HIPRI|");
- if (n >= b_len)
- goto fini;
- }
+ if (0 == n)
+ n += sg_scnpr(b + n, b_len - n, "<none>");
fini:
if (n < b_len) { /* trim trailing '\' */
if ('|' == b[n - 1])
@@ -864,11 +861,11 @@ usage(int pg_num)
"[dio=0|1]\n"
" [elemsz_kb=EKB] [ese=0|1] [fua=0|1|2|3] "
"[hipri=NRQS]\n"
- " [mrq=NRQS] [no_waitq=0|1] [ofreg=OFREG] "
- "[sync=0|1]\n"
- " [thr=THR] [time=0|1|2[,TO]] [verbose=VERB] "
- "[--dry-run]\n"
- " [--pre-fetch] [--verbose] [--version]\n\n"
+ " [mrq=NRQS] [ofreg=OFREG] [sync=0|1] "
+ "[thr=THR]\n"
+ " [time=0|1|2[,TO]] [verbose=VERB] [--dry-run] "
+ "[--pre-fetch]\n"
+ " [--verbose] [--version]\n\n"
" where: operands have the form name=value and are pecular to "
"'dd'\n"
" style commands, and options start with one or "
@@ -934,8 +931,6 @@ page2:
" (def: 16). Does not set mrq hipri flag.\n"
" if mrq=0 does one-by-one, blocking "
"ioctl(SG_IO)s\n"
- " no_waitq=0|1 poll for completion when 1; def: 0 (use "
- "wait queue)\n"
" obs OFILE logical block size, cannot differ from "
"ibs or bs\n"
" ofreg OFREG is regular file or pipe to send what is "
@@ -1226,7 +1221,7 @@ sg_take_snap(int sg_fd, int id, bool vb_b)
seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
seip->sei_rd_mask |= SG_SEIM_CTL_FLAGS;
seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_SNAP_DEV;
- seip->ctl_flags &= SG_CTL_FLAGM_SNAP_DEV; /* 0 --> don't append */
+ seip->ctl_flags &= ~SG_CTL_FLAGM_SNAP_DEV; /* 0 --> append */
if (ioctl(sg_fd, SG_SET_GET_EXTENDED, seip) < 0) {
pr2serr_lk("tid=%d: ioctl(EXTENDED(SNAP_DEV), failed errno=%d %s\n",
id, errno, strerror(errno));
@@ -1912,8 +1907,6 @@ sg_half_segment_mrq0(Rq_elem * rep, scat_gath_iter & sg_it, bool is_wr,
rflags |= SGV4_FLAG_Q_AT_HEAD;
if (flagsp->qtail)
rflags |= SGV4_FLAG_Q_AT_TAIL;
- if (clp->no_waitq)
- rflags |= SGV4_FLAG_NO_WAITQ;
if (flagsp->hipri)
rflags |= SGV4_FLAG_HIPRI;
@@ -2033,8 +2026,6 @@ sg_half_segment(Rq_elem * rep, scat_gath_iter & sg_it, bool is_wr,
rflags |= SGV4_FLAG_Q_AT_HEAD;
if (flagsp->qtail)
rflags |= SGV4_FLAG_Q_AT_TAIL;
- if (clp->no_waitq)
- rflags |= SGV4_FLAG_NO_WAITQ;
if (flagsp->hipri)
rflags |= SGV4_FLAG_HIPRI;
@@ -2449,8 +2440,6 @@ do_both_sg_segment_mrq0(Rq_elem * rep, scat_gath_iter & i_sg_it,
iflags |= SGV4_FLAG_Q_AT_HEAD;
if (iflagsp->qtail)
iflags |= SGV4_FLAG_Q_AT_TAIL;
- if (clp->no_waitq)
- iflags |= SGV4_FLAG_NO_WAITQ;
if (iflagsp->hipri)
iflags |= SGV4_FLAG_HIPRI;
@@ -2461,8 +2450,6 @@ do_both_sg_segment_mrq0(Rq_elem * rep, scat_gath_iter & i_sg_it,
oflags |= SGV4_FLAG_Q_AT_HEAD;
if (oflagsp->qtail)
oflags |= SGV4_FLAG_Q_AT_TAIL;
- if (clp->no_waitq)
- oflags |= SGV4_FLAG_NO_WAITQ;
if (oflagsp->hipri)
oflags |= SGV4_FLAG_HIPRI;
@@ -2633,8 +2620,6 @@ do_both_sg_segment(Rq_elem * rep, scat_gath_iter & i_sg_it,
iflags |= SGV4_FLAG_Q_AT_HEAD;
if (iflagsp->qtail)
iflags |= SGV4_FLAG_Q_AT_TAIL;
- if (clp->no_waitq)
- iflags |= SGV4_FLAG_NO_WAITQ;
if (iflagsp->hipri)
iflags |= SGV4_FLAG_HIPRI;
@@ -2645,8 +2630,6 @@ do_both_sg_segment(Rq_elem * rep, scat_gath_iter & i_sg_it,
oflags |= SGV4_FLAG_Q_AT_HEAD;
if (oflagsp->qtail)
oflags |= SGV4_FLAG_Q_AT_TAIL;
- if (clp->no_waitq)
- oflags |= SGV4_FLAG_NO_WAITQ;
if (oflagsp->hipri)
oflags |= SGV4_FLAG_HIPRI;
oflags |= SGV4_FLAG_DO_ON_OTHER;
@@ -2987,17 +2970,6 @@ bypass:
errno, strerror(errno));
}
}
- if (clp->no_waitq) {
- memset(seip, 0, sizeof(*seip));
- seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
- seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_NO_WAIT_POLL;
- seip->ctl_flags |= SG_CTL_FLAGM_NO_WAIT_POLL;
- if (ioctl(fd, SG_SET_GET_EXTENDED, seip) < 0) {
- res = -1;
- pr2serr_lk("ioctl(EXTENDED(NO_WAIT_POLL)) failed, errno=%d %s\n",
- errno, strerror(errno));
- }
- }
if (clp->verbose) {
t = 1;
/* more info in /proc/scsi/sg/debug */
@@ -3459,7 +3431,8 @@ parse_cmdline_sanity(int argc, char * argv[], struct global_collection * clp,
my_name);
goto syn_err;
}
- clp->no_waitq = !!n;
+ clp->in_flags.no_waitq = true;
+ clp->out_flags.no_waitq = true;
} else if (0 == strcmp(key, "obs")) {
obs = sg_get_num(buf);
if (-1 == obs) {
@@ -4034,6 +4007,9 @@ main(int argc, char * argv[])
if (changed)
pr2serr(">> increasing cdbsz to 16 due to cdl > 0\n");
}
+ if ((clp->verbose > 0) &&
+ (clp->in_flags.no_waitq || clp->out_flags.no_waitq))
+ pr2serr("no_waitq=<n> operand is now ignored\n");
if (outf[0]) {
clp->ofile_given = true;
if (('-' == outf[0]))
diff --git a/testing/sg_take_snap.c b/testing/sg_take_snap.c
new file mode 100644
index 00000000..e0459dbc
--- /dev/null
+++ b/testing/sg_take_snap.c
@@ -0,0 +1,202 @@
+/* A utility program originally written for the Linux OS SCSI subsystem.
+ * Copyright (C) 2021 D. Gilbert
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This program is experimental. It allows the SG_CTL_FLAGM_SNAP_DEV
+ * variant of ioctl(SG_SET_GET_EXTENDED) to be called. This assumes
+ * a Linux sg driver whose version number > 4.00.30 .
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <getopt.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef HAVE_LINUX_SG_V4_HDR
+/* Kernel uapi header contain __user decorations on user space pointers
+ * to indicate they are unsafe in the kernel space. However glibc takes
+ * all those __user decorations out from headers in /usr/include/linux .
+ * So to stop compile errors when directly importing include/uapi/scsi/sg.h
+ * undef __user before doing that include. */
+#define __user
+
+/* Want to block the original sg.h header from also being included. That
+ * causes lots of multiple definition errors. This will only work if this
+ * header is included _before_ the original sg.h header. */
+#define _SCSI_GENERIC_H /* original kernel header guard */
+#define _SCSI_SG_H /* glibc header guard */
+
+#include "uapi_sg.h" /* local copy of include/uapi/scsi/sg.h */
+
+#else
+#define __user
+#endif /* end of: ifndef HAVE_LINUX_SG_V4_HDR */
+
+#include "sg_lib.h"
+#include "sg_pr2serr.h"
+
+
+#define ME "sg_take_snap: "
+
+static const char * version_str = "1.00.67 20210330";
+
+#define SG_TAKE_MAX_DEVS 16
+
+static const char *dev_arr[SG_TAKE_MAX_DEVS];
+static int next_vacant_dev_idx = 0;
+
+static struct option long_options[] = {
+ {"clear", no_argument, 0, 'c'},
+ {"help", no_argument, 0, 'h'},
+ {"verbose", no_argument, 0, 'v'},
+ {"version", no_argument, 0, 'V'},
+ {0, 0, 0, 0},
+};
+
+static void
+usage(void)
+{
+ pr2serr("Usage: sg_take_snap [--clear] [--help] [--verbose] [--version] "
+ "DEVICE*\n"
+ " where:\n"
+ " --clear|-c set 'clear_first' flag; otherwise appends\n"
+ " --help|-h print usage information then exit\n"
+ " --verbose|-v increase the level of verbosity\n"
+ " --version|-V print version number then exit\n\n"
+ "Use ioctl(SG_SET_GET_EXTENDED(SG_CTL_FLAGM_SNAP_DEV)) to take "
+ "snap .\nThe output is placed in /sys/kernel/debug/scsi_generic/"
+ "snapped and needs\nroot permissions to read. Requires a Linux "
+ "sg driver version > 4.00.30 .\nOne or more DEVICEs can be "
+ "given. Note: sending the ioctl to do this\ncreates some "
+ "'noise' in the output\n"
+ );
+}
+
+
+int main(int argc, char * argv[])
+{
+ bool clear_first = false;
+ int c, k, sg_fd, res;
+ int ret = 0;
+ int verbose = 0;
+ const char * device_name = NULL;
+ struct sg_extended_info sei;
+ struct sg_extended_info * seip;
+
+ while (1) {
+ int option_index = 0;
+
+ c = getopt_long(argc, argv, "chvV", long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'c':
+ clear_first = true;
+ break;
+ case 'h':
+ usage();
+ return 0;
+ case 'v':
+ ++verbose;
+ break;
+ case 'V':
+ pr2serr(ME "version: %s\n", version_str);
+ return 0;
+ default:
+ pr2serr("unrecognised option code 0x%x ??\n", c);
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ }
+
+ if (optind < argc) {
+ for (; optind < argc; ++optind) {
+ if (next_vacant_dev_idx < SG_TAKE_MAX_DEVS) {
+ dev_arr[next_vacant_dev_idx] = argv[optind];
+ ++next_vacant_dev_idx;
+ } else if (next_vacant_dev_idx == SG_TAKE_MAX_DEVS) {
+ pr2serr("Maximim of %d DEVICEs on command line\n",
+ next_vacant_dev_idx);
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ } else {
+ pr2serr("something is wrong ...\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ }
+ }
+ if (NULL == dev_arr[0]) {
+ pr2serr("Need at least one DEVICE name. Use '--help' to see "
+ "usage.\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+
+ for (k = 0; k < next_vacant_dev_idx; ++k) {
+ device_name = dev_arr[k];
+ sg_fd = open(device_name, O_RDWR | O_NONBLOCK);
+ if (sg_fd < 0) {
+ int err = errno;
+
+ ret = sg_convert_errno(err);
+ pr2serr(ME "open error: %s: ", device_name);
+ perror("");
+ sg_fd = -1;
+ goto fini;
+ }
+
+ seip = &sei;
+ memset(seip, 0, sizeof(*seip));
+ seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
+ seip->sei_rd_mask |= SG_SEIM_CTL_FLAGS;
+ seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_SNAP_DEV;
+ if (clear_first) /* ... else 0 (due to memset) --> append */
+ seip->ctl_flags |= SG_CTL_FLAGM_SNAP_DEV;
+ if (ioctl(sg_fd, SG_SET_GET_EXTENDED, seip) < 0) {
+ pr2serr("ioctl(SG_SET_GET_EXTENDED(SG_CTL_FLAGM_SNAP_DEV)), %s "
+ "failed errno=%d %s\n", device_name, errno,
+ strerror(errno));
+ ret = SG_LIB_FILE_ERROR;
+ goto fini;
+ }
+ if (verbose)
+ pr2serr("ioctl(%s, SG_SET_GET_EXTENDED(SG_CTL_FLAGM_SNAP_DEV)) "
+ "ok\n", device_name);
+ res = close(sg_fd);
+ sg_fd = -1;
+ if (res < 0) {
+ pr2serr("close errno=%d on %s\n", errno, device_name);
+ ret = res;
+ goto fini;
+ }
+ }
+
+fini:
+ if (sg_fd >= 0) {
+ res = close(sg_fd);
+ if (res < 0) {
+ res = sg_convert_errno(errno);
+ perror(ME "close error");
+ if (0 == ret)
+ ret = res;
+ }
+ }
+ return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
+}
diff --git a/testing/sg_tst_async.cpp b/testing/sg_tst_async.cpp
index e8203a10..2a3b54a8 100644
--- a/testing/sg_tst_async.cpp
+++ b/testing/sg_tst_async.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2019 Douglas Gilbert.
+ * Copyright (c) 2014-2021 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -89,7 +89,7 @@
#include "sg_pt.h"
#include "sg_cmds.h"
-static const char * version_str = "1.40 20190917";
+static const char * version_str = "1.41 20210331";
static const char * util_name = "sg_tst_async";
/* This is a test program for checking the async usage of the Linux sg
@@ -191,7 +191,6 @@ struct opts_t {
bool generic_sync;
bool masync;
bool mmap_io;
- bool no_waitq;
bool no_xfer;
bool pack_id_force;
bool sg_vn_ge_40000;
@@ -285,9 +284,6 @@ static struct option long_options[] = {
{"numpt", required_argument, 0, 'n'},
{"num-pt", required_argument, 0, 'n'},
{"num_pt", required_argument, 0, 'n'},
- {"nowaitq", no_argument, 0, 'z'},
- {"no_waitq", no_argument, 0, 'z'},
- {"no-waitq", no_argument, 0, 'z'},
{"noxfer", no_argument, 0, 'N'},
{"override", required_argument, 0, 'O'},
{"pack-id", no_argument, 0, 'p'},
@@ -351,8 +347,6 @@ usage(void)
printf(" --maxqpt=QPT|-M QPT maximum commands queued per thread "
"(def:%d)\n", MAX_Q_PER_FD);
printf(" --mmap-io|-m mmap-ed IO (1 cmd outstanding per thread)\n");
- printf(" --no-waitq|-z set SGV4_FLAG_NO_WAITQ, bypass poll() if "
- "requested\n");
printf(" --noxfer|-N no data xfer (def: xfer on READ and "
"WRITE)\n");
printf(" --numpt=NPT|-n NPT number of commands per thread "
@@ -882,8 +876,6 @@ work_sync_thread(int id, const char * dev_name, unsigned int /* hi_lba */,
pr2serr_lk("id=%d: only support TUR here for now\n", id);
goto err_out;
}
- if (op->no_waitq)
- pr2serr_lk("id=%d: ignoring --no-waitq option\n", id);
if (op->verbose)
pr2serr_lk("id=%d: using libsgutils generic sync passthrough\n", id);
@@ -1145,8 +1137,6 @@ work_thread(int id, struct opts_t * op)
sg_flags |= SG_FLAG_MMAP_IO;
if (op->no_xfer)
sg_flags |= SG_FLAG_NO_DXFER;
- if (op->no_waitq)
- sg_flags |= SGV4_FLAG_NO_WAITQ;
if (vb > 1)
pr2serr_lk(" id=%d, sg_flags=0x%x, %s cmds\n", id, sg_flags,
((SCSI_TUR == op->c2e) ? "TUR":
@@ -1421,7 +1411,7 @@ work_thread(int id, struct opts_t * op)
}
}
n = (op->wait_ms > 0) ? op->wait_ms : 0;
- if ((n > 0) && (! op->no_waitq)) {
+ if (n > 0) {
for (j = 0; (j < 1000000) &&
(0 == (res = poll(pfd, 1, n)));
++j)
@@ -1787,7 +1777,7 @@ main(int argc, char * argv[])
int option_index = 0;
c = getopt_long(argc, argv,
- "34acdefghl:L:mM:n:NO:pq:Q:Rs:St:TuvVw:Wz",
+ "34acdefghl:L:mM:n:NO:pq:Q:Rs:St:TuvVw:W",
long_options, &option_index);
if (c == -1)
break;
@@ -1995,9 +1985,6 @@ main(int argc, char * argv[])
case 'W':
op->c2e = SCSI_WRITE16;
break;
- case 'z':
- op->no_waitq = true;
- break;
default:
pr2serr_lk("unrecognised option code 0x%x ??\n", c);
usage();
diff --git a/testing/sgh_dd.cpp b/testing/sgh_dd.cpp
index c1b34218..1d3bf6fc 100644
--- a/testing/sgh_dd.cpp
+++ b/testing/sgh_dd.cpp
@@ -36,7 +36,7 @@
* renamed [20181221]
*/
-static const char * version_str = "2.01 20210328";
+static const char * version_str = "2.03 20210331";
#define _XOPEN_SOURCE 600
#ifndef _GNU_SOURCE
@@ -188,7 +188,7 @@ struct flags_t {
bool nocreat;
bool noshare;
bool no_unshare; /* leave it for driver close/release */
- bool no_waitq;
+ bool no_waitq; /* dummy, no longer supported, just warn */
bool noxfer;
bool qhead;
bool qtail;
@@ -257,7 +257,7 @@ struct global_collection
bool ofile2_given;
bool unit_nanosec; /* default duration unit is millisecond */
bool mrq_cmds; /* mrq=<NRQS>,C given */
- bool mrq_async; /* either mrq_immed or no_waitq flags given */
+ bool mrq_async; /* mrq_immed flag given */
bool noshare; /* don't use request sharing */
bool unbalanced_mrq; /* so _not_ sg->sg request sharing sync mrq */
bool verify; /* don't copy, verify like Unix: cmp */
@@ -538,13 +538,13 @@ sg_flags_str(int flags, int b_len, char * b)
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_NO_WAITQ & flags) { /* 0x40 */
- n += sg_scnpr(b + n, b_len - n, "NO_WTQ|");
+ if (SGV4_FLAG_DOUT_OFFSET & flags) { /* 0x40 */
+ n += sg_scnpr(b + n, b_len - n, "DOFF|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_DOUT_OFFSET & flags) { /* 0x80 */
- n += sg_scnpr(b + n, b_len - n, "DOFF|");
+ if (SGV4_FLAG_EVENTFD & flags) { /* 0x80 */
+ n += sg_scnpr(b + n, b_len - n, "EVFD|");
if (n >= b_len)
goto fini;
}
@@ -563,43 +563,43 @@ sg_flags_str(int flags, int b_len, char * b)
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_STOP_IF & flags) { /* 0x800 */
+ if (SGV4_FLAG_HIPRI & flags) { /* 0x800 */
+ n += sg_scnpr(b + n, b_len - n, "HIPRI|");
+ if (n >= b_len)
+ goto fini;
+ }
+ if (SGV4_FLAG_STOP_IF & flags) { /* 0x1000 */
n += sg_scnpr(b + n, b_len - n, "STOPIF|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_DEV_SCOPE & flags) { /* 0x1000 */
+ if (SGV4_FLAG_DEV_SCOPE & flags) { /* 0x2000 */
n += sg_scnpr(b + n, b_len - n, "DEV_SC|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_SHARE & flags) { /* 0x2000 */
+ if (SGV4_FLAG_SHARE & flags) { /* 0x4000 */
n += sg_scnpr(b + n, b_len - n, "SHARE|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_DO_ON_OTHER & flags) { /* 0x4000 */
+ if (SGV4_FLAG_DO_ON_OTHER & flags) { /* 0x8000 */
n += sg_scnpr(b + n, b_len - n, "DO_OTH|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_KEEP_SHARE & flags) { /* 0x8000 */
- n += sg_scnpr(b + n, b_len - n, "KEEP_SH|");
- if (n >= b_len)
- goto fini;
- }
if (SGV4_FLAG_NO_DXFER & flags) { /* 0x10000 */
n += sg_scnpr(b + n, b_len - n, "NDXFER|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_MULTIPLE_REQS & flags) { /* 0x20000 */
- n += sg_scnpr(b + n, b_len - n, "MRQS|");
+ if (SGV4_FLAG_KEEP_SHARE & flags) { /* 0x20000 */
+ n += sg_scnpr(b + n, b_len - n, "KEEP_SH|");
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_EVENTFD & flags) { /* 0x40000 */
- n += sg_scnpr(b + n, b_len - n, "EVFD|");
+ if (SGV4_FLAG_MULTIPLE_REQS & flags) { /* 0x40000 */
+ n += sg_scnpr(b + n, b_len - n, "MRQS|");
if (n >= b_len)
goto fini;
}
@@ -613,11 +613,6 @@ sg_flags_str(int flags, int b_len, char * b)
if (n >= b_len)
goto fini;
}
- if (SGV4_FLAG_HIPRI & flags) { /* 0x200000 */
- n += sg_scnpr(b + n, b_len - n, "HIPRI|");
- if (n >= b_len)
- goto fini;
- }
if (0 == n)
n += sg_scnpr(b + n, b_len - n, "<none>");
fini:
@@ -938,7 +933,7 @@ usage(int pg_num)
"direct,dpo,\n"
" dsync,excl,ff,fua,hipri,masync,mmap,mrq_immed,"
"mrq_svb,\n"
- " nocreat,nodur,no_waitq,noxfer,null,qhead,qtail,"
+ " nocreat,nodur,noxfer,null,qhead,qtail,"
"random,\n"
" same_fds,v3,v4,wq_excl]\n"
" of file or device to write to (def: /dev/null "
@@ -1052,8 +1047,6 @@ page3:
"blocking\n"
" nocreat will fail rather than create OFILE\n"
" nodur turns off command duration calculations\n"
- " no_waitq when non-blocking (async) don't use wait "
- "queue\n"
" noxfer no transfer to/from the user space\n"
" null does nothing, placeholder\n"
" qhead queue new request at head of block queue\n"
@@ -1363,7 +1356,7 @@ sg_take_snap(int sg_fd, int id, bool vb_b)
seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
seip->sei_rd_mask |= SG_SEIM_CTL_FLAGS;
seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_SNAP_DEV;
- seip->ctl_flags &= SG_CTL_FLAGM_SNAP_DEV; /* 0 --> don't append */
+ seip->ctl_flags &= ~SG_CTL_FLAGM_SNAP_DEV; /* 0 --> append */
if (ioctl(sg_fd, SG_SET_GET_EXTENDED, seip) < 0) {
pr2serr_lk("tid=%d: ioctl(EXTENDED(SNAP_DEV), failed errno=%d %s\n",
id, errno, strerror(errno));
@@ -2083,7 +2076,7 @@ sg_wr_swap_share(Rq_elem * rep, int to_fd, bool before)
seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
seip->sei_rd_mask |= SG_SEIM_CTL_FLAGS;
seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_READ_SIDE_FINI;
- seip->ctl_flags &= SG_CTL_FLAGM_READ_SIDE_FINI;/* would be 0 anyway */
+ seip->ctl_flags &= ~SG_CTL_FLAGM_READ_SIDE_FINI;/* would be 0 anyway */
}
for (k = 0; (ioctl(read_side_fd, SG_SET_GET_EXTENDED, seip) < 0) &&
(EBUSY == errno); ++k) {
@@ -2526,9 +2519,9 @@ sgh_do_async_mrq(Rq_elem * rep, mrq_arr_t & def_arr, int fd,
b_len = sizeof(b);
a_v4p = def_arr.first.data();
ctlop->flags = SGV4_FLAG_MULTIPLE_REQS;
- if (clp->in_flags.no_waitq || clp->out_flags.no_waitq) {
- /* waitless non-blocking */
- ctlop->flags |= (SGV4_FLAG_IMMED | SGV4_FLAG_NO_WAITQ);
+ if (clp->in_flags.hipri || clp->out_flags.hipri) {
+ /* hipri non-blocking */
+ ctlop->flags |= (SGV4_FLAG_IMMED | SGV4_FLAG_HIPRI);
if (!after1 && (clp->verbose > 1)) {
after1 = true;
pr2serr_lk("%s: %s\n", __func__, mrq_nw_nb_s);
@@ -3033,7 +3026,6 @@ sg_start_io(Rq_elem * rep, mrq_arr_t & def_arr, int & pack_id,
bool dpo = wr ? clp->out_flags.dpo : clp->in_flags.dpo;
bool dio = wr ? clp->out_flags.dio : clp->in_flags.dio;
bool mmap = wr ? clp->out_flags.mmap : clp->in_flags.mmap;
- bool no_waitq = wr ? clp->out_flags.no_waitq : clp->in_flags.no_waitq;
bool noxfer = wr ? clp->out_flags.noxfer : clp->in_flags.noxfer;
bool v4 = wr ? clp->out_flags.v4 : clp->in_flags.v4;
bool qhead = wr ? clp->out_flags.qhead : clp->in_flags.qhead;
@@ -3125,8 +3117,6 @@ sg_start_io(Rq_elem * rep, mrq_arr_t & def_arr, int & pack_id,
rep->rq_id = pack_id;
nblks = rep->num_blks;
blk_off = 0;
- if (no_waitq)
- flags |= SGV4_FLAG_NO_WAITQ;
if (clp->verbose && 0 == clp->nmrqs && vb_first_time.load()) {
vb_first_time.store(false);
pr2serr("First normal IO: %s, flags: %s\n", cp,
@@ -3524,7 +3514,6 @@ sg_prepare_resbuf(int fd, bool is_in, struct global_collection *clp,
bool no_dur = is_in ? clp->in_flags.no_dur : clp->out_flags.no_dur;
bool masync = is_in ? clp->in_flags.masync : clp->out_flags.masync;
bool wq_excl = is_in ? clp->in_flags.wq_excl : clp->out_flags.wq_excl;
- bool no_waitq = is_in ? clp->in_flags.no_waitq : clp->out_flags.no_waitq;
int res, t, num;
uint8_t *mmp;
struct sg_extended_info sei;
@@ -3633,17 +3622,6 @@ bypass:
errno, strerror(errno));
}
}
- if (no_waitq && sg_version_ge_40045) {
- memset(seip, 0, sizeof(*seip));
- seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
- seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_NO_WAIT_POLL;
- seip->ctl_flags |= SG_CTL_FLAGM_NO_WAIT_POLL;
- if (ioctl(fd, SG_SET_GET_EXTENDED, seip) < 0) {
- res = -1;
- pr2serr_lk("ioctl(EXTENDED(NO_WAIT_POLL)) failed, errno=%d %s\n",
- errno, strerror(errno));
- }
- }
t = 1;
res = ioctl(fd, SG_SET_DEBUG, &t); /* more info in /proc/scsi/sg/debug */
if (res < 0)
@@ -4241,8 +4219,6 @@ parse_cmdline_sanity(int argc, char * argv[], struct global_collection * clp,
if (clp->nmrqs > 0) {
if (clp->in_flags.mrq_immed || clp->out_flags.mrq_immed)
clp->mrq_async = true;
- if (clp->in_flags.no_waitq || clp->out_flags.no_waitq)
- clp->mrq_async = true;
}
/* defaulting transfer size to 128*2048 for CD/DVDs is too large
for the block layer in lk 2.6 and results in an EIO on the
@@ -4413,6 +4389,8 @@ main(int argc, char * argv[])
"device\n", my_name);
}
}
+ if (clp->verbose && (clp->in_flags.no_waitq || clp->out_flags.no_waitq))
+ pr2serr("no_waitq: flag no longer does anything\n");
if (outf[0])
clp->ofile_given = true;
if (outf[0] && ('-' != outf[0])) {
diff --git a/testing/sgs_dd.c b/testing/sgs_dd.c
index 0943340a..7f567d9f 100644
--- a/testing/sgs_dd.c
+++ b/testing/sgs_dd.c
@@ -84,7 +84,7 @@
#include "sg_unaligned.h"
-static const char * version_str = "4.17 20210218";
+static const char * version_str = "4.18 20210331";
static const char * my_name = "sgs_dd";
#ifndef SGV4_FLAG_HIPRI
@@ -127,7 +127,6 @@ struct flags_t {
bool immed;
bool mmap;
bool noxfer;
- bool no_waitq;
bool pack;
bool tag;
bool v3;
@@ -224,7 +223,7 @@ usage(int pg_num)
" -v (up to -vvvvv) sets deb value to number of 'v's\n"
" iflag comma separated list from: dio,evfd,excl,hipri,immed,"
"mmap\n"
- " no_waitq,noxfer,null,pack,tag,v3,v4 bound to IFILE\n"
+ " noxfer,null,pack,tag,v3,v4 bound to IFILE\n"
" no_sig 0-> use signals; 1-> no signals, hard polling "
"instead;\n"
" default 0, unless hipri flag(s) given then it's 1\n"
@@ -246,7 +245,6 @@ second_page:
" hipri set HIPRI flag and use blk_poll() for completion\n"
" immed use SGV4_FLAG_IMMED flag on each request\n"
" mmap use mmap()-ed IO on IFILE or OFILE\n"
- " no_waitq use SGV4_FLAG_NO_WAIQ flag on each request\n"
" noxfer no transfer between user space and kernel IO "
"buffers\n"
" null does nothing, placeholder\n"
@@ -363,8 +361,6 @@ sg_start_io(Rq_coll * clp, Rq_elem * rep)
hp->dxferp = rep->buffp;
if (flagp->evfd)
hp->flags |= SGV4_FLAG_EVENTFD;
- if (flagp->no_waitq)
- hp->flags |= SGV4_FLAG_NO_WAITQ;
if (clp->debug > 5) {
pr2serr("%s: SCSI %s, blk=%d num_blks=%d\n", __func__,
is_wr ? "WRITE" : "READ", rep->blk, rep->num_blks);
@@ -729,20 +725,6 @@ sz_reserve(Rq_coll * clp, bool is_in)
return 1;
}
}
- if (flagsp->no_waitq) {
- memset(seip, 0, sizeof(*seip));
- seip->sei_wr_mask |= SG_SEIM_CTL_FLAGS;
- seip->ctl_flags_wr_mask |= SG_CTL_FLAGM_NO_WAIT_POLL;
- seip->ctl_flags |= SG_CTL_FLAGM_NO_WAIT_POLL;
- if (ioctl(fd, SG_SET_GET_EXTENDED, seip) < 0) {
- pr2serr("ioctl(EXTENDED(NO_WAIT_POLL)) failed, errno=%d %s\n",
- errno, strerror(errno));
- return 1;
- }
- }
- } else if (flagsp->no_waitq) {
- pr2serr("need sg version >= 4.0.45 for no_waitq flag\n");
- return 1;
}
if (!clp->no_sig) {
if (-1 == fcntl(fd, F_SETOWN, getpid())) {
@@ -1209,9 +1191,6 @@ process_flags(const char * arg, struct flags_t * fp)
fp->immed = true;
else if (0 == strcmp(cp, "mmap"))
fp->mmap = true;
- else if ((0 == strcmp(cp, "no_waitq")) ||
- (0 == strcmp(cp, "no-waitq")))
- fp->no_waitq = true;
else if (0 == strcmp(cp, "noxfer"))
fp->noxfer = true;
else if (0 == strcmp(cp, "null"))
diff --git a/testing/uapi_sg.h b/testing/uapi_sg.h
index 3d7e9326..cf002847 100644
--- a/testing/uapi_sg.h
+++ b/testing/uapi_sg.h
@@ -114,8 +114,8 @@ typedef struct sg_io_hdr {
#define SGV4_FLAG_YIELD_TAG 0x8 /* sg_io_v4::generated_tag set after SG_IOS */
#define SGV4_FLAG_Q_AT_TAIL SG_FLAG_Q_AT_TAIL
#define SGV4_FLAG_Q_AT_HEAD SG_FLAG_Q_AT_HEAD
-#define SGV4_FLAG_NO_WAITQ 0x40 /* need to poll for completion */
-#define SGV4_FLAG_DOUT_OFFSET 0x80 /* dout byte offset in v4::spare_in */
+#define SGV4_FLAG_DOUT_OFFSET 0x40 /* dout byte offset in v4::spare_in */
+#define SGV4_FLAG_EVENTFD 0x80 /* signal completion on ... */
#define SGV4_FLAG_COMPLETE_B4 0x100 /* mrq: complete this rq before next */
#define SGV4_FLAG_SIGNAL 0x200 /* v3: ignored; v4 signal on completion */
#define SGV4_FLAG_IMMED 0x400 /* issue request and return immediately ... */
@@ -127,9 +127,8 @@ typedef struct sg_io_hdr {
#define SGV4_FLAG_NO_DXFER SG_FLAG_NO_DXFER /* but keep dev<-->kernel xfr */
#define SGV4_FLAG_KEEP_SHARE 0x20000 /* ... buffer for another dout command */
#define SGV4_FLAG_MULTIPLE_REQS 0x40000 /* 1 or more sg_io_v4-s in data-in */
-#define SGV4_FLAG_EVENTFD 0x80000 /* signal completion on ... */
-#define SGV4_FLAG_ORDERED_WR 0x100000 /* svb: issue in-order writes */
-#define SGV4_FLAG_REC_ORDER 0x200000 /* receive order in v4:request_priority */
+#define SGV4_FLAG_ORDERED_WR 0x80000 /* svb: issue in-order writes */
+#define SGV4_FLAG_REC_ORDER 0x100000 /* receive order in v4:request_priority */
/* Output (potentially OR-ed together) in v3::info or v4::info field */
#define SG_INFO_OK_MASK 0x1
@@ -220,8 +219,7 @@ typedef struct sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
#define SG_CTL_FLAGM_EXCL_WAITQ 0x1000 /* only 1 wake up per response */
#define SG_CTL_FLAGM_SNAP_DEV 0x2000 /* output to debugfs::snapped */
#define SG_CTL_FLAGM_RM_EVENTFD 0x4000 /* only if new eventfd wanted */
-#define SG_CTL_FLAGM_NO_WAIT_POLL 0x8000 /* POLLERR on poll(2)s that wait */
-#define SG_CTL_FLAGM_ALL_BITS 0xffff /* should be OR of previous items */
+#define SG_CTL_FLAGM_ALL_BITS 0x7fff /* should be OR of previous items */
/* Write one of the following values to sg_extended_info::read_value, get... */
#define SG_SEIRV_INT_MASK 0x0 /* get SG_SEIM_ALL_BITS */