This means we can skip the Linux specific compile, so enable it
on all platforms.
Signed-off-by: Jens Axboe <axboe@fb.com>
T_BTRACE_FIO_PROGS = t/btrace2fio
endif
T_BTRACE_FIO_PROGS = t/btrace2fio
endif
-ifeq ($(CONFIG_TARGET_OS), Linux)
T_DEDUPE_OBJS = t/dedupe.o
T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
memalign.o lib/bloom.o t/debug.o crc/xxhash.o crc/murmur3.o \
crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
T_DEDUPE_PROGS = t/dedupe
T_DEDUPE_OBJS = t/dedupe.o
T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
memalign.o lib/bloom.o t/debug.o crc/xxhash.o crc/murmur3.o \
crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
T_DEDUPE_PROGS = t/dedupe
T_OBJS = $(T_SMALLOC_OBJS)
T_OBJS += $(T_IEEE_OBJS)
T_OBJS = $(T_SMALLOC_OBJS)
T_OBJS += $(T_IEEE_OBJS)
static uint64_t cur_offset;
static struct fio_mutex *size_lock;
static uint64_t cur_offset;
static struct fio_mutex *size_lock;
+static struct fio_file file;
-static uint64_t get_size(int fd, struct stat *sb)
+static uint64_t get_size(struct fio_file *f, struct stat *sb)
{
uint64_t ret;
if (S_ISBLK(sb->st_mode)) {
{
uint64_t ret;
if (S_ISBLK(sb->st_mode)) {
- if (ioctl(fd, BLKGETSIZE64, &ret) < 0) {
- perror("ioctl");
+ unsigned long long bytes;
+
+ if (blockdev_size(f, &bytes)) {
+ log_err("dedupe: failed getting bdev size\n");
} else
ret = sb->st_size;
} else
ret = sb->st_size;
ibuf = fio_memalign(blocksize, blocksize);
e = flist_entry(c->extent_list[0].next, struct extent, list);
ibuf = fio_memalign(blocksize, blocksize);
e = flist_entry(c->extent_list[0].next, struct extent, list);
- if (read_block(dev_fd, cbuf, e->offset))
+ if (read_block(file.fd, cbuf, e->offset))
- if (read_block(dev_fd, ibuf, i->offset))
+ if (read_block(file.fd, ibuf, i->offset))
goto out;
ret = memcmp(ibuf, cbuf, blocksize);
goto out;
ret = memcmp(ibuf, cbuf, blocksize);
-static int run_dedupe_threads(int fd, uint64_t dev_size, uint64_t *nextents,
- uint64_t *nchunks)
+static int run_dedupe_threads(struct fio_file *f, uint64_t dev_size,
+ uint64_t *nextents, uint64_t *nchunks)
{
struct worker_thread *threads;
unsigned long nitems, total_items;
{
struct worker_thread *threads;
unsigned long nitems, total_items;
threads = malloc(num_threads * sizeof(struct worker_thread));
for (i = 0; i < num_threads; i++) {
threads = malloc(num_threads * sizeof(struct worker_thread));
for (i = 0; i < num_threads; i++) {
threads[i].items = 0;
threads[i].err = 0;
threads[i].done = 0;
threads[i].items = 0;
threads[i].err = 0;
threads[i].done = 0;
if (odirect)
flags |= O_DIRECT;
if (odirect)
flags |= O_DIRECT;
- dev_fd = open(filename, flags);
- if (dev_fd == -1) {
+ memset(&file, 0, sizeof(file));
+ file.file_name = strdup(filename);
+
+ file.fd = open(filename, flags);
+ if (file.fd == -1) {
- if (fstat(dev_fd, &sb) < 0) {
+ if (fstat(file.fd, &sb) < 0) {
- close(dev_fd);
- return 1;
- dev_size = get_size(dev_fd, &sb);
- if (!dev_size) {
- close(dev_fd);
- return 1;
- }
+ dev_size = get_size(&file, &sb);
+ if (!dev_size)
+ goto err;
if (use_bloom) {
uint64_t bloom_entries;
if (use_bloom) {
uint64_t bloom_entries;
printf("Will check <%s>, size <%llu>, using %u threads\n", filename, (unsigned long long) dev_size, num_threads);
printf("Will check <%s>, size <%llu>, using %u threads\n", filename, (unsigned long long) dev_size, num_threads);
- return run_dedupe_threads(dev_fd, dev_size, nextents, nchunks);
+ return run_dedupe_threads(&file, dev_size, nextents, nchunks);
+err:
+ if (file.fd != -1)
+ close(file.fd);
+ free(file.file_name);
+ return 1;
}
static void show_chunk(struct chunk *c)
}
static void show_chunk(struct chunk *c)