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 | |
| 17 | /* |
| 18 | * Format of the parsed workload files. |
| 19 | * 1) Header |
| 20 | * 2) Table of the entries, each entry describes 1 file |
| 21 | * 3) Table of IO operations to perform on the files |
| 22 | */ |
| 23 | |
Yi Kong | 4e80f59 | 2018-01-09 19:59:55 -0800 | [diff] [blame] | 24 | #pragma pack(push, 1) |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 25 | |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 26 | /* |
| 27 | * The parsed workload file starts off with the header, which |
| 28 | * contains the count of the total # of files that are operated on. |
| 29 | * and the total number of IO operations. |
| 30 | */ |
| 31 | struct ioshark_header { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 32 | #define IOSHARK_VERSION 2 |
| 33 | u_int64_t version; |
| 34 | u_int64_t num_files; |
| 35 | u_int64_t num_io_operations; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | /* |
| 39 | * After the header, we have a table of #files entries. Each entry |
| 40 | * in this table describes 1 file, indexed by fileno and with the |
| 41 | * specified size. |
| 42 | * Before the tests starts, these files are pre-created. |
| 43 | */ |
| 44 | struct ioshark_file_state { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 45 | u_int64_t fileno; /* 1..num_files, with files name ioshark.<fileno> */ |
| 46 | u_int64_t size; |
| 47 | u_int64_t global_filename_ix; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | enum file_op { |
| 51 | IOSHARK_LSEEK = 0, |
| 52 | IOSHARK_LLSEEK, |
| 53 | IOSHARK_PREAD64, |
| 54 | IOSHARK_PWRITE64, |
| 55 | IOSHARK_READ, |
| 56 | IOSHARK_WRITE, |
| 57 | IOSHARK_MMAP, |
| 58 | IOSHARK_MMAP2, |
| 59 | IOSHARK_OPEN, |
| 60 | IOSHARK_FSYNC, |
| 61 | IOSHARK_FDATASYNC, |
| 62 | IOSHARK_CLOSE, |
| 63 | IOSHARK_MAPPED_PREAD, |
| 64 | IOSHARK_MAPPED_PWRITE, |
| 65 | IOSHARK_MAX_FILE_OP |
| 66 | }; |
| 67 | |
| 68 | /* mmap prot flags */ |
| 69 | #define IOSHARK_PROT_READ 0x1 |
| 70 | #define IOSHARK_PROT_WRITE 0x2 |
| 71 | |
| 72 | /* |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 73 | * Next we have the table of IO operations to perform. Each |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 74 | * IO operation is described by this entry. |
| 75 | */ |
| 76 | struct ioshark_file_operation { |
| 77 | /* delta us between previous file op and this */ |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 78 | u_int64_t delta_us; |
| 79 | #define ioshark_io_op op_union.file_op_u |
| 80 | union { |
| 81 | enum file_op file_op_u; |
| 82 | u_int32_t enum_size; |
| 83 | } op_union; |
| 84 | u_int64_t fileno; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 85 | union { |
| 86 | struct lseek_args { |
| 87 | #define lseek_offset u.lseek_a.offset |
| 88 | #define lseek_action u.lseek_a.action |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 89 | u_int64_t offset; |
| 90 | u_int32_t action; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 91 | } lseek_a; |
| 92 | struct prw_args { |
| 93 | #define prw_offset u.prw_a.offset |
| 94 | #define prw_len u.prw_a.len |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 95 | u_int64_t offset; |
| 96 | u_int64_t len; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 97 | } prw_a; |
| 98 | #define rw_len u.rw_a.len |
| 99 | struct rw_args { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 100 | u_int64_t len; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 101 | } rw_a; |
| 102 | #define mmap_offset u.mmap_a.offset |
| 103 | #define mmap_len u.mmap_a.len |
| 104 | #define mmap_prot u.mmap_a.prot |
| 105 | struct mmap_args { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 106 | u_int64_t offset; |
| 107 | u_int64_t len; |
| 108 | u_int32_t prot; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 109 | } mmap_a; |
| 110 | #define open_flags u.open_a.flags |
| 111 | #define open_mode u.open_a.mode |
| 112 | struct open_args { |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 113 | u_int32_t flags; |
| 114 | u_int32_t mode; |
Mohan Srinivasan | b707f30 | 2017-01-19 16:40:52 -0800 | [diff] [blame] | 115 | } open_a; |
| 116 | } u; |
| 117 | }; |
Mohan Srinivasan | 02f8626 | 2017-02-24 16:34:28 -0800 | [diff] [blame] | 118 | |
| 119 | #define MAX_IOSHARK_PATHLEN 512 |
| 120 | |
| 121 | /* |
| 122 | * Global table of all fileames |
| 123 | */ |
| 124 | struct ioshark_filename_struct |
| 125 | { |
| 126 | char path[MAX_IOSHARK_PATHLEN]; |
| 127 | }; |
Mohan Srinivasan | 9dd7870 | 2017-07-19 15:26:57 -0700 | [diff] [blame] | 128 | |
Yi Kong | 4e80f59 | 2018-01-09 19:59:55 -0800 | [diff] [blame] | 129 | #pragma pack(pop) |