Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
ThiƩbaud Weksteen | 1c72a41 | 2020-10-26 19:21:21 +0100 | [diff] [blame] | 17 | #pragma once |
| 18 | |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 19 | /* |
| 20 | * Format of the parsed workload files. |
| 21 | * 1) Header |
| 22 | * 2) Table of the entries, each entry describes 1 file |
| 23 | * 3) Table of IO operations to perform on the files |
| 24 | */ |
| 25 | |
Yi Kong | 4e80f59 | 2018-01-09 19:59:55 -0800 | [diff] [blame] | 26 | #pragma pack(push, 1) |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 27 | |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 28 | /* |
| 29 | * The parsed workload file starts off with the header, which |
| 30 | * contains the count of the total # of files that are operated on. |
| 31 | * and the total number of IO operations. |
| 32 | */ |
| 33 | struct ioshark_header { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 34 | #define IOSHARK_VERSION 2 |
| 35 | u_int64_t version; |
| 36 | u_int64_t num_files; |
| 37 | u_int64_t num_io_operations; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | /* |
| 41 | * After the header, we have a table of #files entries. Each entry |
| 42 | * in this table describes 1 file, indexed by fileno and with the |
| 43 | * specified size. |
| 44 | * Before the tests starts, these files are pre-created. |
| 45 | */ |
| 46 | struct ioshark_file_state { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 47 | u_int64_t fileno; /* 1..num_files, with files name ioshark.<fileno> */ |
| 48 | u_int64_t size; |
| 49 | u_int64_t global_filename_ix; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | enum file_op { |
| 53 | IOSHARK_LSEEK = 0, |
| 54 | IOSHARK_LLSEEK, |
| 55 | IOSHARK_PREAD64, |
| 56 | IOSHARK_PWRITE64, |
| 57 | IOSHARK_READ, |
| 58 | IOSHARK_WRITE, |
| 59 | IOSHARK_MMAP, |
| 60 | IOSHARK_MMAP2, |
| 61 | IOSHARK_OPEN, |
| 62 | IOSHARK_FSYNC, |
| 63 | IOSHARK_FDATASYNC, |
| 64 | IOSHARK_CLOSE, |
| 65 | IOSHARK_MAPPED_PREAD, |
| 66 | IOSHARK_MAPPED_PWRITE, |
| 67 | IOSHARK_MAX_FILE_OP |
| 68 | }; |
| 69 | |
| 70 | /* mmap prot flags */ |
| 71 | #define IOSHARK_PROT_READ 0x1 |
| 72 | #define IOSHARK_PROT_WRITE 0x2 |
| 73 | |
| 74 | /* |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 75 | * Next we have the table of IO operations to perform. Each |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 76 | * IO operation is described by this entry. |
| 77 | */ |
| 78 | struct ioshark_file_operation { |
| 79 | /* delta us between previous file op and this */ |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 80 | u_int64_t delta_us; |
| 81 | #define ioshark_io_op op_union.file_op_u |
| 82 | union { |
| 83 | enum file_op file_op_u; |
| 84 | u_int32_t enum_size; |
| 85 | } op_union; |
| 86 | u_int64_t fileno; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 87 | union { |
| 88 | struct lseek_args { |
| 89 | #define lseek_offset u.lseek_a.offset |
| 90 | #define lseek_action u.lseek_a.action |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 91 | u_int64_t offset; |
| 92 | u_int32_t action; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 93 | } lseek_a; |
| 94 | struct prw_args { |
| 95 | #define prw_offset u.prw_a.offset |
| 96 | #define prw_len u.prw_a.len |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 97 | u_int64_t offset; |
| 98 | u_int64_t len; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 99 | } prw_a; |
| 100 | #define rw_len u.rw_a.len |
| 101 | struct rw_args { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 102 | u_int64_t len; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 103 | } rw_a; |
| 104 | #define mmap_offset u.mmap_a.offset |
| 105 | #define mmap_len u.mmap_a.len |
| 106 | #define mmap_prot u.mmap_a.prot |
| 107 | struct mmap_args { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 108 | u_int64_t offset; |
| 109 | u_int64_t len; |
| 110 | u_int32_t prot; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 111 | } mmap_a; |
| 112 | #define open_flags u.open_a.flags |
| 113 | #define open_mode u.open_a.mode |
| 114 | struct open_args { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 115 | u_int32_t flags; |
| 116 | u_int32_t mode; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 117 | } open_a; |
| 118 | } u; |
| 119 | }; |
Mohan Srinivasan | 02f8626 | 2017-02-24 16:34:28 -0800 | [diff] [blame] | 120 | |
| 121 | #define MAX_IOSHARK_PATHLEN 512 |
| 122 | |
| 123 | /* |
| 124 | * Global table of all fileames |
| 125 | */ |
| 126 | struct ioshark_filename_struct |
| 127 | { |
| 128 | char path[MAX_IOSHARK_PATHLEN]; |
| 129 | }; |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 130 | |
Yi Kong | 4e80f59 | 2018-01-09 19:59:55 -0800 | [diff] [blame] | 131 | #pragma pack(pop) |