"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stress-iomix.c" between
stress-ng-0.13.04.tar.xz and stress-ng-0.13.05.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

stress-iomix.c  (stress-ng-0.13.04.tar.xz):stress-iomix.c  (stress-ng-0.13.05.tar.xz)
skipping to change at line 56 skipping to change at line 56
/* /*
* stress_iomix_rnd_offset() * stress_iomix_rnd_offset()
* generate a random offset between 0..max-1 * generate a random offset between 0..max-1
*/ */
static off_t stress_iomix_rnd_offset(const off_t max) static off_t stress_iomix_rnd_offset(const off_t max)
{ {
return (off_t)(stress_mwc64() % max); return (off_t)(stress_mwc64() % max);
} }
/* /*
* stress_iomix_fsync_min_1Hz()
* sync written data at most every once a second while
* trying to minimize the number time get calls
*/
static void stress_iomix_fsync_min_1Hz(const int fd)
{
static double time_last = -1.0;
static int counter = 0;
static int counter_max = 1;
if (time_last <= 0.0)
time_last = stress_time_now() + 1.0;
if (counter++ >= counter_max) {
const double now = stress_time_now();
const double delta = now - time_last;
/* Less than 1Hz? try again */
if (delta < 1.0)
return;
counter_max = (int)((double)counter / delta);
counter = 0;
time_last = now;
switch (stress_mwc8() % 3) {
case 0:
(void)shim_fsync(fd);
break;
case 1:
(void)shim_fdatasync(fd);
break;
case 2:
(void)sync();
break;
}
}
}
/*
* stress_iomix_wr_seq_bursts() * stress_iomix_wr_seq_bursts()
* bursty sequential writes * bursty sequential writes
*/ */
static void stress_iomix_wr_seq_bursts( static void stress_iomix_wr_seq_bursts(
const stress_args_t *args, const stress_args_t *args,
const int fd, const int fd,
const off_t iomix_bytes) const off_t iomix_bytes)
{ {
do { do {
off_t ret, posn; off_t ret, posn;
skipping to change at line 101 skipping to change at line 142
if (errno != EPERM) { if (errno != EPERM) {
pr_fail("%s: write failed, errno=%d (%s)\ n", pr_fail("%s: write failed, errno=%d (%s)\ n",
args->name, errno, strerror(errno )); args->name, errno, strerror(errno ));
return; return;
} }
} }
posn += rc; posn += rc;
if (!keep_stressing(args)) if (!keep_stressing(args))
return; return;
inc_counter(args); inc_counter(args);
stress_iomix_fsync_min_1Hz(fd);
} }
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = stress_mwc32() % 1000000; tv.tv_usec = stress_mwc32() % 1000000;
(void)select(0, NULL, NULL, NULL, &tv); (void)select(0, NULL, NULL, NULL, &tv);
} while (keep_stressing(args)); } while (keep_stressing(args));
} }
/* /*
* stress_iomix_wr_rnd_bursts() * stress_iomix_wr_rnd_bursts()
* bursty random writes * bursty random writes
skipping to change at line 152 skipping to change at line 194
if (rc < 0) { if (rc < 0) {
if (errno != EPERM) { if (errno != EPERM) {
pr_fail("%s: write failed, errno=%d (%s)\ n", pr_fail("%s: write failed, errno=%d (%s)\ n",
args->name, errno, strerror(errno )); args->name, errno, strerror(errno ));
return; return;
} }
} }
if (!keep_stressing(args)) if (!keep_stressing(args))
return; return;
inc_counter(args); inc_counter(args);
stress_iomix_fsync_min_1Hz(fd);
} }
tv.tv_sec = stress_mwc32() % 2; tv.tv_sec = stress_mwc32() % 2;
tv.tv_usec = stress_mwc32() % 1000000; tv.tv_usec = stress_mwc32() % 1000000;
(void)select(0, NULL, NULL, NULL, &tv); (void)select(0, NULL, NULL, NULL, &tv);
} while (keep_stressing(args)); } while (keep_stressing(args));
} }
/* /*
* stress_iomix_wr_seq_slow() * stress_iomix_wr_seq_slow()
skipping to change at line 203 skipping to change at line 246
pr_fail("%s: write failed, errno=%d (%s)\ n", pr_fail("%s: write failed, errno=%d (%s)\ n",
args->name, errno, strerror(errno )); args->name, errno, strerror(errno ));
return; return;
} }
} }
(void)shim_usleep(250000); (void)shim_usleep(250000);
posn += rc; posn += rc;
if (!keep_stressing(args)) if (!keep_stressing(args))
return; return;
inc_counter(args); inc_counter(args);
stress_iomix_fsync_min_1Hz(fd);
} }
} while (keep_stressing(args)); } while (keep_stressing(args));
} }
/* /*
* stress_iomix_rd_seq_bursts() * stress_iomix_rd_seq_bursts()
* bursty sequential reads * bursty sequential reads
*/ */
static void stress_iomix_rd_seq_bursts( static void stress_iomix_rd_seq_bursts(
const stress_args_t *args, const stress_args_t *args,
skipping to change at line 344 skipping to change at line 388
if (rc < 0) { if (rc < 0) {
pr_fail("%s: read failed, errno=%d (%s)\n", pr_fail("%s: read failed, errno=%d (%s)\n",
args->name, errno, strerror(errno)); args->name, errno, strerror(errno));
return; return;
} }
(void)shim_usleep(333333); (void)shim_usleep(333333);
posn += rc; posn += rc;
if (!keep_stressing(args)) if (!keep_stressing(args))
return; return;
inc_counter(args); inc_counter(args);
stress_iomix_fsync_min_1Hz(fd);
} }
} while (keep_stressing(args)); } while (keep_stressing(args));
} }
/* /*
* stress_iomix_sync() * stress_iomix_sync()
* file syncs * file syncs
*/ */
static void stress_iomix_sync( static void stress_iomix_sync(
const stress_args_t *args, const stress_args_t *args,
skipping to change at line 502 skipping to change at line 547
if (errno != EPERM) { if (errno != EPERM) {
pr_fail("%s: write failed, errno=%d (%s)\ n", pr_fail("%s: write failed, errno=%d (%s)\ n",
args->name, errno, strerror(errno )); args->name, errno, strerror(errno ));
return; return;
} } } }
(void)shim_usleep(1000); (void)shim_usleep(1000);
posn += rc; posn += rc;
if (!keep_stressing(args)) if (!keep_stressing(args))
return; return;
inc_counter(args); inc_counter(args);
stress_iomix_fsync_min_1Hz(fd);
}
} while (keep_stressing(args));
}
/*
* stress_iomix_wr_rev_bytes()
* lots of small 1 byte writes in reverse order
*/
static void stress_iomix_wr_rev_bytes(
const stress_args_t *args,
const int fd,
const off_t iomix_bytes)
{
do {
off_t ret, posn = iomix_bytes;
ret = lseek(fd, 0, SEEK_SET);
if (ret < 0) {
pr_fail("%s: lseek failed, errno=%d (%s)\n",
args->name, errno, strerror(errno));
return;
}
while (posn != 0) {
char buffer[1] = { (stress_mwc8() % 26) + 'A' };
ssize_t rc;
rc = write(fd, buffer, sizeof(buffer));
if (rc < 0) {
if (errno != EPERM) {
pr_fail("%s: write failed, errno=%d (%s)\
n",
args->name, errno, strerror(errno
));
return;
} }
(void)shim_usleep(1000);
posn--;
if (!keep_stressing(args))
return;
inc_counter(args);
stress_iomix_fsync_min_1Hz(fd);
} }
} while (keep_stressing(args)); } while (keep_stressing(args));
} }
/* /*
* stress_iomix_rd_bytes() * stress_iomix_rd_bytes()
* lots of small 1 byte reads * lots of small 1 byte reads
*/ */
static void stress_iomix_rd_bytes( static void stress_iomix_rd_bytes(
const stress_args_t *args, const stress_args_t *args,
skipping to change at line 644 skipping to change at line 729
stress_iomix_inode_ioctl(args, fd, FS_SECRM_FL, &ok); stress_iomix_inode_ioctl(args, fd, FS_SECRM_FL, &ok);
#endif #endif
#if defined(FS_SYNC_FL) #if defined(FS_SYNC_FL)
stress_iomix_inode_ioctl(args, fd, FS_SYNC_FL, &ok); stress_iomix_inode_ioctl(args, fd, FS_SYNC_FL, &ok);
#endif #endif
#if defined(FS_UNRM_FL) #if defined(FS_UNRM_FL)
stress_iomix_inode_ioctl(args, fd, FS_UNRM_FL, &ok); stress_iomix_inode_ioctl(args, fd, FS_UNRM_FL, &ok);
#endif #endif
if (!ok) if (!ok)
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
stress_iomix_fsync_min_1Hz(fd);
} while (keep_stressing(args)); } while (keep_stressing(args));
} }
#endif #endif
#if defined(__linux__) #if defined(__linux__)
/* /*
* stress_iomix_drop_caches() * stress_iomix_drop_caches()
* occasional file cache dropping * occasional file cache dropping
*/ */
static void stress_iomix_drop_caches( static void stress_iomix_drop_caches(
skipping to change at line 697 skipping to change at line 783
stress_iomix_rd_seq_bursts, stress_iomix_rd_seq_bursts,
stress_iomix_rd_rnd_bursts, stress_iomix_rd_rnd_bursts,
stress_iomix_rd_seq_slow, stress_iomix_rd_seq_slow,
stress_iomix_rd_seq_slow, stress_iomix_rd_seq_slow,
stress_iomix_sync, stress_iomix_sync,
#if defined(HAVE_POSIX_FADVISE) #if defined(HAVE_POSIX_FADVISE)
stress_iomix_bad_advise, stress_iomix_bad_advise,
#endif #endif
stress_iomix_rd_wr_mmap, stress_iomix_rd_wr_mmap,
stress_iomix_wr_bytes, stress_iomix_wr_bytes,
stress_iomix_wr_rev_bytes,
stress_iomix_rd_bytes, stress_iomix_rd_bytes,
#if defined(__linux__) #if defined(__linux__)
stress_iomix_inode_flags, stress_iomix_inode_flags,
#endif #endif
#if defined(__linux__) #if defined(__linux__)
stress_iomix_drop_caches stress_iomix_drop_caches
#endif #endif
}; };
/* /*
 End of changes. 8 change blocks. 
0 lines changed or deleted 89 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)