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 24 /* 25 * The parsed workload file starts off with the header, which 26 * contains the count of the total # of files that are operated on. 27 * and the total number of IO operations. 28 */ 29 struct ioshark_header { 30 int num_files; 31 int num_io_operations; 32 }; 33 34 /* 35 * After the header, we have a table of #files entries. Each entry 36 * in this table describes 1 file, indexed by fileno and with the 37 * specified size. 38 * Before the tests starts, these files are pre-created. 39 */ 40 struct ioshark_file_state { 41 int fileno; /* 1..num_files, with files name ioshark.<fileno> */ 42 size_t size; 43 int global_filename_ix; 44 }; 45 46 enum file_op { 47 IOSHARK_LSEEK = 0, 48 IOSHARK_LLSEEK, 49 IOSHARK_PREAD64, 50 IOSHARK_PWRITE64, 51 IOSHARK_READ, 52 IOSHARK_WRITE, 53 IOSHARK_MMAP, 54 IOSHARK_MMAP2, 55 IOSHARK_OPEN, 56 IOSHARK_FSYNC, 57 IOSHARK_FDATASYNC, 58 IOSHARK_CLOSE, 59 IOSHARK_MAPPED_PREAD, 60 IOSHARK_MAPPED_PWRITE, 61 IOSHARK_MAX_FILE_OP 62 }; 63 64 /* mmap prot flags */ 65 #define IOSHARK_PROT_READ 0x1 66 #define IOSHARK_PROT_WRITE 0x2 67 68 /* 69 * Next we have the table of IO operatiosn to perform. Each 70 * IO operation is described by this entry. 71 */ 72 struct ioshark_file_operation { 73 /* delta us between previous file op and this */ 74 u_int64_t delta_us; 75 enum file_op file_op; 76 int fileno; 77 union { 78 struct lseek_args { 79 #define lseek_offset u.lseek_a.offset 80 #define lseek_action u.lseek_a.action 81 off_t offset; 82 int action; 83 } lseek_a; 84 struct prw_args { 85 #define prw_offset u.prw_a.offset 86 #define prw_len u.prw_a.len 87 off_t offset; 88 size_t len; 89 } prw_a; 90 #define rw_len u.rw_a.len 91 struct rw_args { 92 size_t len; 93 } rw_a; 94 #define mmap_offset u.mmap_a.offset 95 #define mmap_len u.mmap_a.len 96 #define mmap_prot u.mmap_a.prot 97 struct mmap_args { 98 off_t offset; 99 size_t len; 100 int prot; 101 } mmap_a; 102 #define open_flags u.open_a.flags 103 #define open_mode u.open_a.mode 104 struct open_args { 105 int flags; 106 mode_t mode; 107 } open_a; 108 } u; 109 }; 110 111 #define MAX_IOSHARK_PATHLEN 512 112 113 /* 114 * Global table of all fileames 115 */ 116 struct ioshark_filename_struct 117 { 118 char path[MAX_IOSHARK_PATHLEN]; 119 }; 120