IOR
aiori-DUMMY.c
Go to the documentation of this file.
1 /*
2 * Dummy implementation doesn't do anything besides waiting
3 */
4 
5 #ifdef HAVE_CONFIG_H
6 # include "config.h"
7 #endif
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <time.h>
13 
14 #include "ior.h"
15 #include "aiori.h"
16 #include "utilities.h"
17 
18 
19 /************************** O P T I O N S *****************************/
20 typedef struct {
21  uint64_t delay_creates;
22  uint64_t delay_xfer;
25 
26 static char * current = (char*) 1;
27 
28 static option_help * DUMMY_options(aiori_mod_opt_t ** init_backend_options, aiori_mod_opt_t * init_values){
29  dummy_options_t * o = malloc(sizeof(dummy_options_t));
30  if (init_values != NULL){
31  memcpy(o, init_values, sizeof(dummy_options_t));
32  }else{
33  memset(o, 0, sizeof(dummy_options_t));
34  }
35 
36  *init_backend_options = (aiori_mod_opt_t*) o;
37 
38  option_help h [] = {
39  {0, "dummy.delay-create", "Delay per create in usec", OPTION_OPTIONAL_ARGUMENT, 'l', & o->delay_creates},
40  {0, "dummy.delay-xfer", "Delay per xfer in usec", OPTION_OPTIONAL_ARGUMENT, 'l', & o->delay_xfer},
41  {0, "dummy.delay-only-rank0", "Delay only Rank0", OPTION_FLAG, 'd', & o->delay_rank_0_only},
43  };
44  option_help * help = malloc(sizeof(h));
45  memcpy(help, h, sizeof(h));
46  return help;
47 }
48 
49 static int count_init = 0;
50 
51 static aiori_fd_t *DUMMY_Create(char *testFileName, int iorflags, aiori_mod_opt_t * options)
52 {
53  if(count_init <= 0){
54  ERR("DUMMY missing initialization in create\n");
55  }
56  if(verbose > 4){
57  fprintf(out_logfile, "DUMMY create: %s = %p\n", testFileName, current);
58  }
59  dummy_options_t * o = (dummy_options_t*) options;
60  if (o->delay_creates){
61  if (! o->delay_rank_0_only || (o->delay_rank_0_only && rank == 0)){
62  struct timespec wait = { o->delay_creates / 1000 / 1000, 1000l * (o->delay_creates % 1000000)};
63  nanosleep( & wait, NULL);
64  }
65  }
66  return (aiori_fd_t*) current++;
67 }
68 
69 static aiori_fd_t *DUMMY_Open(char *testFileName, int flags, aiori_mod_opt_t * options)
70 {
71  if(count_init <= 0){
72  ERR("DUMMY missing initialization in open\n");
73  }
74  if(verbose > 4){
75  fprintf(out_logfile, "DUMMY open: %s = %p\n", testFileName, current);
76  }
77  return (aiori_fd_t*) current++;
78 }
79 
81 {
82  if(verbose > 4){
83  fprintf(out_logfile, "DUMMY fsync %p\n", fd);
84  }
85 }
86 
87 
89 {
90 }
91 
93 {
94  if(verbose > 4){
95  fprintf(out_logfile, "DUMMY close %p\n", fd);
96  }
97 }
98 
99 static void DUMMY_Delete(char *testFileName, aiori_mod_opt_t * options)
100 {
101  if(verbose > 4){
102  fprintf(out_logfile, "DUMMY delete: %s\n", testFileName);
103  }
104 }
105 
106 static char * DUMMY_getVersion()
107 {
108  return "0.5";
109 }
110 
112 {
113  if(verbose > 4){
114  fprintf(out_logfile, "DUMMY getFileSize: %s\n", testFileName);
115  }
116  return 0;
117 }
118 
120  if(verbose > 4){
121  fprintf(out_logfile, "DUMMY xfer: %p\n", file);
122  }
123  dummy_options_t * o = (dummy_options_t*) options;
124  if (o->delay_xfer){
125  if (! o->delay_rank_0_only || (o->delay_rank_0_only && rank == 0)){
126  struct timespec wait = {o->delay_xfer / 1000 / 1000, 1000l * (o->delay_xfer % 1000000)};
127  nanosleep( & wait, NULL);
128  }
129  }
130  return length;
131 }
132 
133 static int DUMMY_statfs (const char * path, ior_aiori_statfs_t * stat, aiori_mod_opt_t * options){
134  stat->f_bsize = 1;
135  stat->f_blocks = 1;
136  stat->f_bfree = 1;
137  stat->f_bavail = 1;
138  stat->f_files = 1;
139  stat->f_ffree = 1;
140  return 0;
141 }
142 
143 static int DUMMY_mkdir (const char *path, mode_t mode, aiori_mod_opt_t * options){
144  return 0;
145 }
146 
147 static int DUMMY_rmdir (const char *path, aiori_mod_opt_t * options){
148  return 0;
149 }
150 
151 static int DUMMY_access (const char *path, int mode, aiori_mod_opt_t * options){
152  return 0;
153 }
154 
155 static int DUMMY_stat (const char *path, struct stat *buf, aiori_mod_opt_t * options){
156  return 0;
157 }
158 
159 static int DUMMY_rename (const char *path, const char *path2, aiori_mod_opt_t * options){
160  return 0;
161 }
162 
163 
165  return 0;
166 }
167 
169  WARN("DUMMY initialized");
170  count_init++;
171 }
172 
174  WARN("DUMMY finalized");
175  if(count_init <= 0){
176  ERR("DUMMY invalid finalization\n");
177  }
178  count_init--;
179 }
180 
181 
183  .name = "DUMMY",
184  .name_legacy = NULL,
185  .create = DUMMY_Create,
186  .open = DUMMY_Open,
187  .xfer = DUMMY_Xfer,
188  .close = DUMMY_Close,
189  .delete = DUMMY_Delete,
190  .get_version = DUMMY_getVersion,
191  .fsync = DUMMY_Fsync,
192  .get_file_size = DUMMY_GetFileSize,
193  .statfs = DUMMY_statfs,
194  .mkdir = DUMMY_mkdir,
195  .rmdir = DUMMY_rmdir,
196  .rename = DUMMY_rename,
197  .access = DUMMY_access,
198  .stat = DUMMY_stat,
199  .initialize = DUMMY_init,
200  .finalize = DUMMY_final,
201  .get_options = DUMMY_options,
202  .check_params = DUMMY_check_params,
203  .sync = DUMMY_Sync,
204  .enable_mdtest = true
205 };
uint64_t delay_xfer
Definition: aiori-DUMMY.c:22
static int DUMMY_rename(const char *path, const char *path2, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:159
uint64_t f_blocks
Definition: aiori.h:53
uint64_t f_bfree
Definition: aiori.h:54
static void DUMMY_final(aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:173
#define LAST_OPTION
Definition: option.h:39
FILE * out_logfile
Definition: utilities.c:72
static int DUMMY_check_params(aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:164
struct benchmark_options o
Definition: md-workbench.c:128
static void DUMMY_Delete(char *testFileName, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:99
static void DUMMY_init(aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:168
static int count_init
Definition: aiori-DUMMY.c:49
static void DUMMY_Fsync(aiori_fd_t *fd, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:80
uint64_t f_ffree
Definition: aiori.h:57
static int DUMMY_rmdir(const char *path, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:147
ior_aiori_t dummy_aiori
Definition: aiori-DUMMY.c:182
static int DUMMY_mkdir(const char *path, mode_t mode, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:143
uint64_t f_files
Definition: aiori.h:56
static option_help options[]
Definition: aiori-CEPHFS.c:54
uint64_t f_bsize
Definition: aiori.h:52
static IOR_offset_t DUMMY_GetFileSize(aiori_mod_opt_t *options, char *testFileName)
Definition: aiori-DUMMY.c:111
#define WARN(MSG)
Definition: aiori-debug.h:32
Definition: ior.h:56
static char * current
Definition: aiori-DUMMY.c:26
static IOR_offset_t DUMMY_Xfer(int access, aiori_fd_t *file, IOR_size_t *buffer, IOR_offset_t length, IOR_offset_t offset, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:119
static option_help * DUMMY_options(aiori_mod_opt_t **init_backend_options, aiori_mod_opt_t *init_values)
Definition: aiori-DUMMY.c:28
uint64_t delay_creates
Definition: aiori-DUMMY.c:21
static aiori_fd_t * DUMMY_Create(char *testFileName, int iorflags, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:51
static int DUMMY_statfs(const char *path, ior_aiori_statfs_t *stat, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:133
static aiori_fd_t * DUMMY_Open(char *testFileName, int flags, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:69
long long int IOR_size_t
Definition: iordef.h:110
uint64_t f_bavail
Definition: aiori.h:55
int verbose
Definition: utilities.c:70
static int DUMMY_access(const char *path, int mode, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:151
static void DUMMY_Close(aiori_fd_t *fd, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:92
#define ERR(MSG)
Definition: aiori-debug.h:92
static int DUMMY_stat(const char *path, struct stat *buf, aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:155
static char * DUMMY_getVersion()
Definition: aiori-DUMMY.c:106
char * name
Definition: aiori.h:88
long long int IOR_offset_t
Definition: iordef.h:109
int rank
Definition: utilities.c:68
static void DUMMY_Sync(aiori_mod_opt_t *options)
Definition: aiori-DUMMY.c:88
#define NULL
Definition: iordef.h:70