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