summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-03-15 15:01:33 +0100
committerJens Axboe <jens.axboe@oracle.com>2007-03-15 15:01:33 +0100
commit2dc1bbeb58edc85f2829eed6729862c438ea2353 (patch)
tree57000b694e792e8a5ae9367525f726598ece7f04 /memory.c
parentd3aad8f28b9e214fccfce5e3a406dec723f57a62 (diff)
downloadfio-2dc1bbeb58edc85f2829eed6729862c438ea2353.tar.gz
fio-2dc1bbeb58edc85f2829eed6729862c438ea2353.tar.bz2
Move thread options into a seperate structure
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/memory.c b/memory.c
index 9df23211..f108e470 100644
--- a/memory.c
+++ b/memory.c
@@ -59,12 +59,12 @@ int fio_pin_memory(void)
*/
int allocate_io_mem(struct thread_data *td)
{
- if (td->mem_type == MEM_MALLOC)
+ if (td->o.mem_type == MEM_MALLOC)
td->orig_buffer = malloc(td->orig_buffer_size);
- else if (td->mem_type == MEM_SHM || td->mem_type == MEM_SHMHUGE) {
+ else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE) {
int flags = IPC_CREAT | SHM_R | SHM_W;
- if (td->mem_type == MEM_SHMHUGE)
+ if (td->o.mem_type == MEM_SHMHUGE)
flags |= SHM_HUGETLB;
td->shm_id = shmget(IPC_PRIVATE, td->orig_buffer_size, flags);
@@ -81,7 +81,8 @@ int allocate_io_mem(struct thread_data *td)
td->orig_buffer = NULL;
return 1;
}
- } else if (td->mem_type == MEM_MMAP || td->mem_type == MEM_MMAPHUGE) {
+ } else if (td->o.mem_type == MEM_MMAP ||
+ td->o.mem_type == MEM_MMAPHUGE) {
int flags = MAP_PRIVATE;
td->mmapfd = 0;
@@ -117,14 +118,15 @@ int allocate_io_mem(struct thread_data *td)
void free_io_mem(struct thread_data *td)
{
- if (td->mem_type == MEM_MALLOC)
+ if (td->o.mem_type == MEM_MALLOC)
free(td->orig_buffer);
- else if (td->mem_type == MEM_SHM || td->mem_type == MEM_SHMHUGE) {
+ else if (td->o.mem_type == MEM_SHM || td->o.mem_type == MEM_SHMHUGE) {
struct shmid_ds sbuf;
shmdt(td->orig_buffer);
shmctl(td->shm_id, IPC_RMID, &sbuf);
- } else if (td->mem_type == MEM_MMAP || td->mem_type == MEM_MMAPHUGE) {
+ } else if (td->o.mem_type == MEM_MMAP ||
+ td->o.mem_type == MEM_MMAPHUGE) {
munmap(td->orig_buffer, td->orig_buffer_size);
if (td->mmapfile) {
close(td->mmapfd);
@@ -132,7 +134,7 @@ void free_io_mem(struct thread_data *td)
free(td->mmapfile);
}
} else
- log_err("Bad memory type %u\n", td->mem_type);
+ log_err("Bad memory type %u\n", td->o.mem_type);
td->orig_buffer = NULL;
}