コード例 #1
0
ファイル: libpmem.c プロジェクト: arh/fio
static int fio_libpmem_open_file(struct thread_data *td, struct fio_file *f)
{
	struct fio_libpmem_data *fdd;
	int ret;

	dprint(FD_IO,"DEBUG fio_libpmem_open_file\n");
	dprint(FD_IO,"f->io_size=%ld \n",f->io_size);
	dprint(FD_IO,"td->o.size=%lld \n",td->o.size);
	dprint(FD_IO,"td->o.iodepth=%d\n",td->o.iodepth);
	dprint(FD_IO,"td->o.iodepth_batch=%d \n",td->o.iodepth_batch);

	ret = generic_open_file(td, f);
	if (ret)
		return ret;

	fdd = calloc(1, sizeof(*fdd));
	if (!fdd) {
		int fio_unused __ret;
		__ret = generic_close_file(td, f);
		return 1;
	}

	FILE_SET_ENG_DATA(f, fdd);

	return 0;
}
コード例 #2
0
ファイル: mtd.c プロジェクト: rainmeng/fio
static int fio_mtd_open_file(struct thread_data *td, struct fio_file *f)
{
    struct fio_mtd_data *fmd;
    int ret;

    ret = generic_open_file(td, f);
    if (ret)
        return ret;

    fmd = calloc(1, sizeof(*fmd));
    if (!fmd)
        goto err_close;

    ret = mtd_get_dev_info(desc, f->file_name, &fmd->info);
    if (ret != 0) {
        td_verror(td, errno, "mtd_get_dev_info");
        goto err_free;
    }

    FILE_SET_ENG_DATA(f, fmd);
    return 0;

err_free:
    free(fmd);
err_close:
    {
        int fio_unused __ret;
        __ret = generic_close_file(td, f);
        return 1;
    }
}
コード例 #3
0
ファイル: file.c プロジェクト: KeenS/benz
pic_value
pic_file_open_binary_output_file(pic_state *pic)
{
  static const short flags = PIC_PORT_OUT | PIC_PORT_BINARY;
  char *fname;

  pic_get_args(pic, "z", &fname);

  return generic_open_file(pic, fname, "wb", flags);
}
コード例 #4
0
ファイル: file.c プロジェクト: KeenS/benz
pic_value
pic_file_open_input_file(pic_state *pic)
{
  static const short flags = PIC_PORT_IN | PIC_PORT_TEXT;
  char *fname;

  pic_get_args(pic, "z", &fname);

  return generic_open_file(pic, fname, "r", flags);
}
コード例 #5
0
ファイル: mmap.c プロジェクト: tlbdk/Sys-Splice
static int fio_mmapio_open(struct thread_data *td, struct fio_file *f)
{
	int ret, flags;

	ret = generic_open_file(td, f);
	if (ret)
		return ret;

	/*
	 * for size checkup, don't mmap anything.
	 */
	if (!f->io_size)
		return 0;

	if (td_rw(td))
		flags = PROT_READ | PROT_WRITE;
	else if (td_write(td)) {
		flags = PROT_WRITE;

		if (td->o.verify != VERIFY_NONE)
			flags |= PROT_READ;
	} else
		flags = PROT_READ;

	f->mmap = mmap(NULL, f->io_size, flags, MAP_SHARED, f->fd, f->file_offset);
	if (f->mmap == MAP_FAILED) {
		f->mmap = NULL;
		td_verror(td, errno, "mmap");
		goto err;
	}

	if (file_invalidate_cache(td, f))
		goto err;

	if (!td_random(td)) {
		if (madvise(f->mmap, f->io_size, MADV_SEQUENTIAL) < 0) {
			td_verror(td, errno, "madvise");
			goto err;
		}
	} else {
		if (madvise(f->mmap, f->io_size, MADV_RANDOM) < 0) {
			td_verror(td, errno, "madvise");
			goto err;
		}
	}

	return 0;

err:
	td->io_ops->close_file(td, f);
	return 1;
}
コード例 #6
0
ファイル: mmap.c プロジェクト: arh/fio
static int fio_mmapio_open_file(struct thread_data *td, struct fio_file *f)
{
	struct fio_mmap_data *fmd;
	int ret;

	ret = generic_open_file(td, f);
	if (ret)
		return ret;

	fmd = calloc(1, sizeof(*fmd));
	if (!fmd) {
		int fio_unused __ret;
		__ret = generic_close_file(td, f);
		return 1;
	}

	FILE_SET_ENG_DATA(f, fmd);
	return 0;
}