sg_mrq_dd.cpp (sg3_utils-1.47r908.tgz) | : | sg_mrq_dd.cpp (sg3_utils-1.47r915.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* in this case) are transferred to or from the sg device in a single SCSI | * in this case) are transferred to or from the sg device in a single SCSI | |||
* command. | * command. | |||
* | * | |||
* This version is designed for the linux kernel 4 and 5 series. | * This version is designed for the linux kernel 4 and 5 series. | |||
* | * | |||
* sg_mrq_dd uses C++ threads and MRQ (multiple requests (in one invocation)) | * sg_mrq_dd uses C++ threads and MRQ (multiple requests (in one invocation)) | |||
* facilities in the sg version 4 driver to do "dd" type copies and verifies. | * facilities in the sg version 4 driver to do "dd" type copies and verifies. | |||
* | * | |||
*/ | */ | |||
static const char * version_str = "1.34 20210801"; | static const char * version_str = "1.36 20210906"; | |||
#define _XOPEN_SOURCE 600 | #define _XOPEN_SOURCE 600 | |||
#ifndef _GNU_SOURCE | #ifndef _GNU_SOURCE | |||
#define _GNU_SOURCE 1 | #define _GNU_SOURCE 1 | |||
#endif | #endif | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
skipping to change at line 348 | skipping to change at line 348 | |||
int64_t in_follow_on; | int64_t in_follow_on; | |||
int64_t out_follow_on; | int64_t out_follow_on; | |||
int64_t in_local_count; | int64_t in_local_count; | |||
int64_t out_local_count; | int64_t out_local_count; | |||
int64_t in_rem_count; | int64_t in_rem_count; | |||
int64_t out_rem_count; | int64_t out_rem_count; | |||
int in_local_partial; | int in_local_partial; | |||
int out_local_partial; | int out_local_partial; | |||
int in_resid_bytes; | int in_resid_bytes; | |||
long seed; | long seed; | |||
struct drand48_data drand; /* opaque, used by srand48_r and mrand48_r */ | #ifdef HAVE_SRAND48_R /* gcc extension. N.B. non-reentrant version slower */ | |||
struct drand48_data drand;/* opaque, used by srand48_r and mrand48_r */ | ||||
#endif | ||||
} Rq_elem; | } Rq_elem; | |||
/* Additional parameters for sg_start_io() and sg_finish_io() */ | /* Additional parameters for sg_start_io() and sg_finish_io() */ | |||
struct sg_io_extra { | struct sg_io_extra { | |||
bool prefetch; | bool prefetch; | |||
bool dout_is_split; | bool dout_is_split; | |||
int hpv4_ind; | int hpv4_ind; | |||
int blk_offset; | int blk_offset; | |||
int blks; | int blks; | |||
}; | }; | |||
skipping to change at line 1501 | skipping to change at line 1503 | |||
pr2serr_lk("%s: sigtimedwait() errno=%d\n", __func__, err); | pr2serr_lk("%s: sigtimedwait() errno=%d\n", __func__, err); | |||
} | } | |||
if (SIGINT == sig_number) { | if (SIGINT == sig_number) { | |||
pr2serr_lk("%sinterrupted by SIGINT\n", my_name); | pr2serr_lk("%sinterrupted by SIGINT\n", my_name); | |||
flag_all_stop(clp); | flag_all_stop(clp); | |||
shutting_down.store(true); | shutting_down.store(true); | |||
sigprocmask(SIG_SETMASK, &orig_signal_set, NULL); | sigprocmask(SIG_SETMASK, &orig_signal_set, NULL); | |||
raise(SIGINT); | raise(SIGINT); | |||
break; | break; | |||
} | } | |||
if (SIGUSR2 == sig_number) | if (SIGUSR2 == sig_number) | |||
break; | break; | |||
if (shutting_down) | if (shutting_down) | |||
break; | break; | |||
} /* end of while loop */ | } /* end of while loop */ | |||
if (clp->verbose > 3) | if (clp->verbose > 3) | |||
pr2serr_lk("%s: exiting\n", __func__); | pr2serr_lk("%s: exiting\n", __func__); | |||
} | } | |||
static bool | static bool | |||
sg_share_prepare(int write_side_fd, int read_side_fd, int id, bool vb_b) | sg_share_prepare(int write_side_fd, int read_side_fd, int id, bool vb_b) | |||
{ | { | |||
skipping to change at line 1652 | skipping to change at line 1654 | |||
if (ssz < (ssize_t)sizeof(rep->seed)) { | if (ssz < (ssize_t)sizeof(rep->seed)) { | |||
pr2serr_lk("[%d] %s: getrandom() failed, ret=%d\n", thr_idx, | pr2serr_lk("[%d] %s: getrandom() failed, ret=%d\n", thr_idx, | |||
__func__, (int)ssz); | __func__, (int)ssz); | |||
rep->seed = (long)time(NULL); | rep->seed = (long)time(NULL); | |||
} | } | |||
#else | #else | |||
rep->seed = (long)time(NULL); /* use seconds since epoch as proxy */ | rep->seed = (long)time(NULL); /* use seconds since epoch as proxy */ | |||
#endif | #endif | |||
if (vb > 1) | if (vb > 1) | |||
pr2serr_lk("[%d] %s: seed=%ld\n", thr_idx, __func__, rep->seed); | pr2serr_lk("[%d] %s: seed=%ld\n", thr_idx, __func__, rep->seed); | |||
#ifdef HAVE_SRAND48_R | ||||
srand48_r(rep->seed, &rep->drand); | srand48_r(rep->seed, &rep->drand); | |||
#else | ||||
srand48(rep->seed); | ||||
#endif | ||||
} | } | |||
if (in_is_sg && inf.size()) { | if (in_is_sg && inf.size()) { | |||
if ((clp->in_flags.same_fds || (0 == thr_idx)) && | if ((clp->in_flags.same_fds || (0 == thr_idx)) && | |||
(cvp.in_fd >= 0)) | (cvp.in_fd >= 0)) | |||
fd = cvp.in_fd; | fd = cvp.in_fd; | |||
else { | else { | |||
fd = sg_in_open(clp, inf, (in_mmap ? &rep->buffp : NULL), | fd = sg_in_open(clp, inf, (in_mmap ? &rep->buffp : NULL), | |||
(in_mmap ? &rep->mmap_len : NULL)); | (in_mmap ? &rep->mmap_len : NULL)); | |||
if (fd < 0) | if (fd < 0) | |||
skipping to change at line 1891 | skipping to change at line 1897 | |||
uint8_t * bp; | uint8_t * bp; | |||
if (clp->in_flags.zero) | if (clp->in_flags.zero) | |||
memset(rep->buffp + d_boff, 0, blocks * clp->bs); | memset(rep->buffp + d_boff, 0, blocks * clp->bs); | |||
else if (clp->in_flags.ff) | else if (clp->in_flags.ff) | |||
memset(rep->buffp + d_boff, 0xff, blocks * clp->bs); | memset(rep->buffp + d_boff, 0xff, blocks * clp->bs); | |||
else { | else { | |||
bp = rep->buffp + d_boff; | bp = rep->buffp + d_boff; | |||
for (k = 0; k < blocks; ++k, bp += clp->bs) { | for (k = 0; k < blocks; ++k, bp += clp->bs) { | |||
for (j = 0; j < clp->bs; j += jbump) { | for (j = 0; j < clp->bs; j += jbump) { | |||
/* mrand48 takes uniformly from [-2^31, 2^31) */ | /* mrand48 takes uniformly from [-2^31, 2^31) */ | |||
#ifdef HAVE_SRAND48_R | ||||
mrand48_r(&rep->drand, &rn); | mrand48_r(&rep->drand, &rn); | |||
#else | ||||
rn = mrand48(); | ||||
#endif | ||||
*((uint32_t *)(bp + j)) = (uint32_t)rn; | *((uint32_t *)(bp + j)) = (uint32_t)rn; | |||
} | } | |||
} | } | |||
} | } | |||
return blocks; | return blocks; | |||
} | } | |||
if (clp->in_type != FT_FIFO) { | if (clp->in_type != FT_FIFO) { | |||
int64_t pos = lba * clp->bs; | int64_t pos = lba * clp->bs; | |||
skipping to change at line 3381 | skipping to change at line 3391 | |||
else if (0 == strcmp(cp, "ff")) | else if (0 == strcmp(cp, "ff")) | |||
fp->ff = true; | fp->ff = true; | |||
else if (0 == strcmp(cp, "fua")) | else if (0 == strcmp(cp, "fua")) | |||
fp->fua = true; | fp->fua = true; | |||
else if (0 == strcmp(cp, "hipri")) | else if (0 == strcmp(cp, "hipri")) | |||
fp->hipri = true; | fp->hipri = true; | |||
else if (0 == strcmp(cp, "masync")) | else if (0 == strcmp(cp, "masync")) | |||
fp->masync = true; | fp->masync = true; | |||
else if (0 == strcmp(cp, "mmap")) | else if (0 == strcmp(cp, "mmap")) | |||
++fp->mmap; /* mmap > 1 stops munmap() being called */ | ++fp->mmap; /* mmap > 1 stops munmap() being called */ | |||
else if (0 == strcmp(cp, "nocreat")) | ||||
fp->nocreat = true; | ||||
else if (0 == strcmp(cp, "nodur")) | else if (0 == strcmp(cp, "nodur")) | |||
fp->no_dur = true; | fp->no_dur = true; | |||
else if (0 == strcmp(cp, "no_dur")) | else if (0 == strcmp(cp, "no_dur")) | |||
fp->no_dur = true; | fp->no_dur = true; | |||
else if (0 == strcmp(cp, "no-dur")) | else if (0 == strcmp(cp, "no-dur")) | |||
fp->no_dur = true; | fp->no_dur = true; | |||
else if (0 == strcmp(cp, "nothresh")) | else if (0 == strcmp(cp, "nothresh")) | |||
fp->no_thresh = true; | fp->no_thresh = true; | |||
else if (0 == strcmp(cp, "no_thresh")) | else if (0 == strcmp(cp, "no_thresh")) | |||
fp->no_thresh = true; | fp->no_thresh = true; | |||
End of changes. 8 change blocks. | ||||
5 lines changed or deleted | 17 lines changed or added |