#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include <libgen.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "fio.h"
#include "verify.h"
#include "parse.h"
#include "lib/fls.h"
#include "options.h"
#include "crc/crc32c.h"
/*
* Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
*/
static char *get_opt_postfix(const char *str)
{
char *p = strstr(str, ":");
if (!p)
return NULL;
p++;
strip_blank_front(&p);
strip_blank_end(p);
return strdup(p);
}
static int converthexchartoint(char a)
{
int base;
switch (a) {
case '0'...'9':
base = '0';
break;
case 'A'...'F':
base = 'A' - 10;
break;
case 'a'...'f':
base = 'a' - 10;
break;
default:
base = 0;
}
return a - base;
}
static int bs_cmp(const void *p1, const void *p2)
{
const struct bssplit *bsp1 = p1;
const struct bssplit *bsp2 = p2;
return bsp1->perc < bsp2->perc;
}
static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
{
struct bssplit *bssplit;
unsigned int i, perc, perc_missing;
unsigned int max_bs, min_bs;
long long val;
char *fname;
o->bssplit_nr[ddir] = 4;
bssplit = malloc(4 * sizeof(struct bssplit));
i = 0;
max_bs = 0;
min_bs = -1;
while ((fname = strsep(&str, ":")) != NULL) {
char *perc_str;
if (!strlen(fname))
break;
/*
* grow struct buffer, if needed
*/
if (i == o->bssplit_nr[ddir]) {
o->bssplit_nr[ddir] <<= 1;
bssplit = realloc(bssplit, o->bssplit_nr[ddir]
* sizeof(struct bssplit));
}
perc_str = strstr(fname, "/");
if (perc_str) {
*perc_str = '\0';
perc_str++;
perc = atoi(perc_str);
if (perc > 100)
perc = 100;
else if (!perc)
perc = -1;
} else
perc = -1;
if (str_to_decimal(fname, &val, 1, o)) {
log_err("fio: bssplit conversion failed\n");
free(o->bssplit);
return 1;
}
if (val > max_bs)
max_bs = val;
if (val < min_bs)
min_bs = val;
bssplit[i].bs = val;
bssplit[i].perc = perc;
i++;
}
o->bssplit_nr[ddir] = i;
/*
* Now check if the percentages add up, and how much is missing
*/
perc = perc_missing = 0;
for (i = 0; i < o->bssplit_nr[ddir]; i++) {
struct bssplit *bsp = &bssplit[i];
if (bsp->perc == (unsigned char) -1)
perc_missing++;
else
perc += bsp->perc;
}
if (perc > 100) {
log_err("fio: bssplit percentages add to more than 100%%\n");
free(bssplit);
return 1;
}
/*
* If values didn't have a percentage set, divide the remains between
* them.
*/
if (perc_missing) {
for (i = 0; i < o->bssplit_nr[ddir]; i++) {
struct bssplit *bsp = &bssplit[i];
if (bsp->perc == (unsigned char) -1)
bsp->perc = (100 - perc) / perc_missing;
}
}
o->min_bs[ddir] = min_bs;
o->max_bs[ddir] = max_bs;
/*
* now sort based on percentages, for ease of lookup
*/
qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
o->bssplit[ddir] = bssplit;
return 0;
}
static int str_bssplit_cb(void *data, const char *input)
{
struct thread_data *td = data;
char *str, *p, *odir, *ddir;
int ret = 0;
p = str = strdup(input);
strip_blank_front(&str);
strip_blank_end(str);
odir = strchr(str, ',');
if (odir) {
ddir = strchr(odir + 1, ',');
if (ddir) {
ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
if (!ret)
*ddir = '\0';
} else {
char *op;
op = strdup(odir + 1);
ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
free(op);
}
if (!ret)
ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
if (!ret) {
*odir = '\0';
ret = bssplit_ddir(&td->o, DDIR_READ, str);
}
} else {
char *op;
op = strdup(str);
ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
free(op);
if (!ret) {
op = strdup(str);
ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
free(op);
}
ret = bssplit_ddir(&td->o, DDIR_READ, str);
}
free(p);
return ret;
}
static int str2error(char *str)
{
const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
"ENXIO", "E2BIG", "ENOEXEC", "EBADF",
"ECHILD", "EAGAIN", "ENOMEM", "EACCES",
"EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
"EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
"EINVAL", "ENFILE", "EMFILE", "ENOTTY",
"ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
"EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
int i = 0, num = sizeof(err) / sizeof(void *);
while (i < num) {
if (!strcmp(err[i], str))
return i + 1;
i++;
}
return 0;
}
static int ignore_error_type(struct thread_data *td, int etype, char *str)
{
unsigned int i;
int *error;
char *fname;
if (etype >= ERROR_TYPE_CNT) {
log_err("Illegal error type\n");
return 1;
}
td->o.ignore_error_nr[etype] = 4;
error = malloc(4 * sizeof(struct bssplit));
i = 0;
while ((fname = strsep(&str, ":")) != NULL) {
if (!strlen(fname))
break;
/*
* grow struct buffer, if needed
*/
if (i == td->o.ignore_error_nr[etype]) {
td->o.ignore_error_nr[etype] <<= 1;
error = realloc(error, td->o.ignore_error_nr[etype]
* sizeof(int));
}
if (fname[0] == 'E') {
error[i] = str2error(fname);
} else {
error[i] = atoi(fname);
if (error[i] < 0)
error[i] = error[i];
}
if (!error[i]) {
log_err("Unknown error %s, please use number value \n",
fname);
free(error);
return 1;
}
i++;
}
if (i) {
td->o.continue_on_error |= 1 << etype;
td->o.ignore_error_nr[etype] = i;
td->o.ignore_error[etype] = error;
}
return 0;
}
static int str_ignore_error_cb(void *data, const char *input)
{
struct thread_data *td = data;
char *str, *p, *n;
int type = 0, ret = 1;
p = str = strdup(input);
strip_blank_front(&str);
strip_blank_end(str);
while (p) {
n = strchr(p, ',');
if (n)
*n++ = '\0';
ret = ignore_error_type(td, type, p);
if (ret)
break;
p = n;
type++;
}
free(str);
return ret;
}
static int str_rw_cb(void *data, const char *str)
{
struct thread_data *td = data;
struct thread_options *o = &td->o;
char *nr = get_opt_postfix(str);
o->ddir_seq_nr = 1;
o->ddir_seq_add = 0;
if (!nr)
return 0;
if (td_random(td))
o->ddir_seq_nr = atoi(nr);
else {
long long val;
if (str_to_decimal(nr, &val, 1, o)) {
log_err("fio: rw postfix parsing failed\n");
free(nr);
return 1;
}
o->ddir_seq_add = val;
}
free(nr);
return 0;
}
static int str_mem_cb(void *data, const char *mem)
{
struct thread_data *td = data;
if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
td->o.mmapfile = get_opt_postfix(mem);
return 0;
}
static int fio_clock_source_cb(void *data, const char *str)
{
struct thread_data *td = data;
fio_clock_source = td->o.clocksource;
fio_clock_source_set = 1;
fio_clock_init();
return 0;
}
static int str_rwmix_read_cb(void *data, unsigned long long *val)
{
struct thread_data *td = data;
td->o.rwmix[DDIR_READ] = *val;
td->o.rwmix[DDIR_WRITE] = 100 - *val;
return 0;
}
static int str_rwmix_write_cb(void *data, unsigned long long *val)
{
struct thread_data *td = data;
td->o.rwmix[DDIR_WRITE] = *val;
td->o.rwmix[DDIR_READ] = 100 - *val;
return 0;
}
static int str_exitall_cb(void)
{
exitall_on_terminate = 1;
return 0;
}
#ifdef FIO_HAVE_CPU_AFFINITY
static int str_cpumask_cb(void *data, unsigned long long *val)
{
struct thread_data *td = data;
unsigned int i;
long max_cpu;
int ret;
ret = fio_cpuset_init(&td->o.cpumask);
if (ret < 0) {
log_err("fio: cpuset_init failed\n");
td_verror(td, ret, "fio_cpuset_init");
return 1;
}
max_cpu = cpus_online();
for (i = 0; i < sizeof(int) * 8; i++) {
if ((1 << i) & *val) {
if (i > max_cpu) {
log_err("fio: CPU %d too large (max=%ld)\n", i,
max_cpu);
return 1;
}
dprint(FD_PARSE, "set cpu allowed %d\n", i);
fio_cpu_set(&td->o.cpumask, i);
}
}
td->o.cpumask_set = 1;
return 0;
}
static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
const char *input)
{
char *cpu, *str, *p;
long max_cpu;
没有合适的资源?快使用搜索试试~ 我知道了~
fio-2.1.2.tar.gz
需积分: 50 35 下载量 127 浏览量
2019-01-15
19:34:34
上传
评论 1
收藏 460KB GZ 举报
温馨提示
fio在Linux系统下使用比较方便,iometer在window系统下使用比较方便,Orion是oracle的IO测试软件,可在没有安装oracle数据库的情况下模拟oracle数据库场景的读写。 如下是在Linux系统上采用fio工具来对SAN存储进行的IO测试。 1、安装fio 在fio官网下载fio-2.1.10.tar文件,解压后./configure、make、make install之后就可以使用fio了。 2、fio参数解释 可以使用fio -help查看每个参数,具体的参数左右可以在官网查看how to文档,如下为几个常见的参数描述
资源推荐
资源详情
资源评论
收起资源包目录
fio-2.1.2.tar.gz (280个子文件)
fio.1 56KB
fio_generate_plots.1 2KB
options.c 80KB
gfio.c 51KB
stat.c 44KB
init.c 43KB
backend.c 41KB
gclient.c 40KB
goptions.c 38KB
io_u.c 36KB
server.c 35KB
client.c 34KB
rdma.c 29KB
filesetup.c 28KB
verify.c 25KB
parse.c 24KB
net.c 23KB
graph.c 23KB
posix.c 21KB
cconv.c 18KB
diskutil.c 16KB
eta.c 13KB
gettime.c 12KB
ioengines.c 12KB
prio_tree.c 12KB
iolog.c 11KB
idletime.c 11KB
axmap.c 10KB
windowsaio.c 10KB
blktrace.c 10KB
act.c 10KB
sha256.c 10KB
smalloc.c 9KB
sg.c 9KB
binject.c 9KB
sync.c 9KB
json.c 8KB
lfsr.c 7KB
rbtree.c 7KB
libaio.c 7KB
genzipf.c 7KB
sha512.c 7KB
splice.c 6KB
crc64.c 6KB
guasi.c 6KB
memory.c 6KB
sha1.c 6KB
posixaio.c 5KB
crc32c.c 5KB
libfio.c 5KB
ghelpers.c 5KB
solarisaio.c 5KB
mmap.c 5KB
fusion-aw.c 5KB
mutex.c 5KB
e4defrag.c 5KB
md5.c 4KB
printing.c 4KB
crc32.c 4KB
skeleton_external.c 4KB
cgroup.c 4KB
getopt_long.c 3KB
flist_sort.c 3KB
lfsr-test.c 3KB
tickmarks.c 3KB
rand.c 3KB
tiobench.c 3KB
crc16.c 3KB
falloc.c 2KB
null.c 2KB
axmap.c 2KB
fifo.c 2KB
flow.c 2KB
zipf.c 2KB
cpu.c 2KB
cairo_text_helpers.c 2KB
profile.c 2KB
log.c 2KB
gerror.c 2KB
filehash.c 2KB
crc7.c 2KB
crc32c-intel.c 2KB
time.c 2KB
ieee754.c 2KB
trim.c 2KB
gettime-thread.c 2KB
stest.c 1KB
num2str.c 1KB
fio.c 1KB
gcompat.c 1KB
td_error.c 911B
hweight.c 871B
io_u_queue.c 762B
helpers.c 706B
memalign.c 663B
log.c 593B
debug.c 466B
strsep.c 379B
strcasestr.c 366B
ieee754.c 360B
共 280 条
- 1
- 2
- 3
资源评论
test_sharing
- 粉丝: 47
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功