]>
git.proxmox.com Git - ceph.git/blob - ceph/src/client/SyntheticClient.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
16 #ifndef CEPH_SYNTHETICCLIENT_H
17 #define CEPH_SYNTHETICCLIENT_H
22 #include "include/Distribution.h"
26 #define SYNCLIENT_FIRST_POOL 0
28 #define SYNCLIENT_MODE_RANDOMWALK 1
29 #define SYNCLIENT_MODE_FULLWALK 2
30 #define SYNCLIENT_MODE_REPEATWALK 3
32 #define SYNCLIENT_MODE_MAKEDIRMESS 7
33 #define SYNCLIENT_MODE_MAKEDIRS 8 // dirs files depth
34 #define SYNCLIENT_MODE_STATDIRS 9 // dirs files depth
35 #define SYNCLIENT_MODE_READDIRS 10 // dirs files depth
37 #define SYNCLIENT_MODE_MAKEFILES 11 // num count private
38 #define SYNCLIENT_MODE_MAKEFILES2 12 // num count private
39 #define SYNCLIENT_MODE_CREATESHARED 13 // num
40 #define SYNCLIENT_MODE_OPENSHARED 14 // num count
42 #define SYNCLIENT_MODE_RMFILE 19
43 #define SYNCLIENT_MODE_WRITEFILE 20
44 #define SYNCLIENT_MODE_READFILE 21
45 #define SYNCLIENT_MODE_WRITEBATCH 22
46 #define SYNCLIENT_MODE_WRSHARED 23
47 #define SYNCLIENT_MODE_READSHARED 24
48 #define SYNCLIENT_MODE_RDWRRANDOM 25
49 #define SYNCLIENT_MODE_RDWRRANDOM_EX 26
51 #define SYNCLIENT_MODE_LINKTEST 27
53 #define SYNCLIENT_MODE_OVERLOAD_OSD_0 28 // two args
55 #define SYNCLIENT_MODE_DROPCACHE 29
57 #define SYNCLIENT_MODE_TRACE 30
59 #define SYNCLIENT_MODE_CREATEOBJECTS 35
60 #define SYNCLIENT_MODE_OBJECTRW 36
62 #define SYNCLIENT_MODE_OPENTEST 40
63 #define SYNCLIENT_MODE_OPTEST 41
65 #define SYNCLIENT_MODE_ONLY 50
66 #define SYNCLIENT_MODE_ONLYRANGE 51
67 #define SYNCLIENT_MODE_EXCLUDE 52
68 #define SYNCLIENT_MODE_EXCLUDERANGE 53
70 #define SYNCLIENT_MODE_UNTIL 55
71 #define SYNCLIENT_MODE_SLEEPUNTIL 56
73 #define SYNCLIENT_MODE_RANDOMSLEEP 61
74 #define SYNCLIENT_MODE_SLEEP 62
76 #define SYNCLIENT_MODE_DUMP 63
78 #define SYNCLIENT_MODE_LOOKUPHASH 70
79 #define SYNCLIENT_MODE_LOOKUPINO 71
81 #define SYNCLIENT_MODE_TRUNCATE 200
83 #define SYNCLIENT_MODE_FOO 100
84 #define SYNCLIENT_MODE_THRASHLINKS 101
86 #define SYNCLIENT_MODE_IMPORTFIND 300
88 #define SYNCLIENT_MODE_CHUNK 400
90 #define SYNCLIENT_MODE_MKSNAP 1000
91 #define SYNCLIENT_MODE_RMSNAP 1001
93 #define SYNCLIENT_MODE_MKSNAPFILE 1002
97 void parse_syn_options(vector
<const char*>& args
);
99 class SyntheticClient
{
100 StandaloneClient
*client
;
105 Distribution op_dist
;
112 map
<string
, struct stat
*> contents
;
125 int get_random_fh() {
126 int r
= rand() % open_files
.size();
127 set
<int>::iterator it
= open_files
.begin();
134 const char *get_random_subdir() {
135 assert(!subdirs
.empty());
136 int r
= ((rand() % subdirs
.size()) + (rand() % subdirs
.size())) / 2; // non-uniform distn
137 set
<string
>::iterator it
= subdirs
.begin();
141 n1
.push_dentry( *it
);
142 return n1
.get_path().c_str();
145 const char *get_random_sub() {
146 assert(!contents
.empty());
147 int r
= ((rand() % contents
.size()) + (rand() % contents
.size())) / 2; // non-uniform distn
148 if (cwd
.depth() && cwd
.last_dentry().length())
149 r
+= cwd
.last_dentry().c_str()[0]; // slightly permuted
150 r
%= contents
.size();
152 map
<string
,struct stat
*>::iterator it
= contents
.begin();
156 n2
.push_dentry( it
->first
);
157 return n2
.get_path().c_str();
162 const char *make_sub(const char *base
) {
163 snprintf(sub_s
, sizeof(sub_s
), "%s.%d", base
, rand() % 100);
171 SyntheticClient(StandaloneClient
*client
, int w
= -1);
180 if (run_only
== client
->get_nodeid())
189 run_until
= utime_t();
192 // run() will do one of these things:
202 string
get_sarg(int seq
);
204 int i
= iargs
.front();
209 bool time_to_stop() {
210 utime_t now
= ceph_clock_now();
211 if (0) cout
<< "time_to_stop .. now " << now
212 << " until " << run_until
213 << " start " << run_start
215 if (run_until
.sec() && now
> run_until
)
221 string
compose_path(string
& prefix
, char *rest
) {
222 return prefix
+ rest
;
225 int full_walk(string
& fromdir
);
226 int random_walk(int n
);
228 int dump_placement(string
& fn
);
231 int make_dirs(const char *basedir
, int dirs
, int files
, int depth
);
232 int stat_dirs(const char *basedir
, int dirs
, int files
, int depth
);
233 int read_dirs(const char *basedir
, int dirs
, int files
, int depth
);
234 int make_files(int num
, int count
, int priv
, bool more
);
237 int create_shared(int num
);
238 int open_shared(int num
, int count
);
240 int rm_file(string
& fn
);
241 int write_file(string
& fn
, int mb
, loff_t chunk
);
242 int write_fd(int fd
, int size
, int wrsize
);
244 int write_batch(int nfile
, int mb
, int chunk
);
245 int read_file(const std::string
& fn
, int mb
, int chunk
, bool ignoreprint
=false);
247 int create_objects(int nobj
, int osize
, int inflight
);
248 int object_rw(int nobj
, int osize
, int wrpc
, int overlap
,
249 double rskew
, double wskew
);
251 int read_random(string
& fn
, int mb
, int chunk
);
252 int read_random_ex(string
& fn
, int mb
, int chunk
);
254 int overload_osd_0(int n
, int sie
, int wrsize
);
255 int check_first_primary(int fd
);
257 int clean_dir(string
& basedir
);
259 int play_trace(Trace
& t
, string
& prefix
, bool metadata_only
=false);
261 void make_dir_mess(const char *basedir
, int n
);
264 int thrash_links(const char *basedir
, int dirs
, int files
, int depth
, int n
);
266 void import_find(const char *basedir
, const char *find
, bool writedata
);
268 int lookup_hash(inodeno_t ino
, inodeno_t dirino
, const char *name
,
269 const UserPerm
& perms
);
270 int lookup_ino(inodeno_t ino
, const UserPerm
& perms
);
272 int chunk_file(string
&filename
);
274 void mksnap(const char *base
, const char *name
, const UserPerm
& perms
);
275 void rmsnap(const char *base
, const char *name
, const UserPerm
& perms
);
276 void mksnapfile(const char *dir
);