From: Jens Axboe Date: Wed, 19 Aug 2020 18:04:38 +0000 (-0600) Subject: file: track allocation origin X-Git-Tag: fio-3.23~26 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=6081231af0fd6b15e88b5ba0189e10695e366ec0;p=fio.git file: track allocation origin We can't always rely on the engine options for the file, as files can come from various places. So mark the file as having come from smalloc/calloc and use that when freeing it. Signed-off-by: Jens Axboe --- diff --git a/file.h b/file.h index 375bbfd3..5e2ef998 100644 --- a/file.h +++ b/file.h @@ -33,6 +33,7 @@ enum fio_file_flags { FIO_FILE_partial_mmap = 1 << 6, /* can't do full mmap */ FIO_FILE_axmap = 1 << 7, /* uses axmap */ FIO_FILE_lfsr = 1 << 8, /* lfsr is used */ + FIO_FILE_smalloc = 1 << 9, /* smalloc file/file_name */ }; enum file_lock_mode { @@ -188,6 +189,7 @@ FILE_FLAG_FNS(hashed); FILE_FLAG_FNS(partial_mmap); FILE_FLAG_FNS(axmap); FILE_FLAG_FNS(lfsr); +FILE_FLAG_FNS(smalloc); #undef FILE_FLAG_FNS /* diff --git a/filesetup.c b/filesetup.c index 49c54b81..a1c60445 100644 --- a/filesetup.c +++ b/filesetup.c @@ -1449,7 +1449,6 @@ void close_and_free_files(struct thread_data *td) { struct fio_file *f; unsigned int i; - bool use_free = td_ioengine_flagged(td, FIO_NOFILEHASH); dprint(FD_FILE, "close files\n"); @@ -1471,7 +1470,7 @@ void close_and_free_files(struct thread_data *td) zbd_close_file(f); - if (use_free) + if (!fio_file_smalloc(f)) free(f->file_name); else sfree(f->file_name); @@ -1480,7 +1479,7 @@ void close_and_free_files(struct thread_data *td) axmap_free(f->io_axmap); f->io_axmap = NULL; } - if (use_free) + if (!fio_file_smalloc(f)) free(f); else sfree(f); @@ -1609,6 +1608,8 @@ static struct fio_file *alloc_new_file(struct thread_data *td) f->fd = -1; f->shadow_fd = -1; fio_file_reset(td, f); + if (!td_ioengine_flagged(td, FIO_NOFILEHASH)) + fio_file_set_smalloc(f); return f; }