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 #include "common/ceph_argparse.h"
17 #include "common/debug.h"
18 #include "os/filestore/FileStore.h"
19 #include "global/global_init.h"
20 #include "include/ceph_assert.h"
22 #define dout_context g_ceph_context
23 #define dout_subsys ceph_subsys_filestore
25 #define dout_prefix *_dout
29 struct Foo
: public Thread
{
30 void *entry() override
{
31 dout(0) << "foo started" << dendl
;
33 dout(0) << "foo asserting 0" << dendl
;
38 int main(int argc
, const char **argv
)
40 auto args
= argv_to_vec(argc
, argv
);
42 auto cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_CLIENT
,
43 CODE_ENVIRONMENT_UTILITY
,
44 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE
);
45 common_init_finish(g_ceph_context
);
48 if (args
.size() < 2) return -1;
49 const char *filename
= args
[0];
50 int mb
= atoi(args
[1]);
52 cout
<< "#dev " << filename
<< std::endl
;
53 cout
<< "#mb " << mb
<< std::endl
;
55 ObjectStore
*fs
= new FileStore(cct
.get(), filename
, NULL
);
56 if (fs
->mount() < 0) {
57 cout
<< "mount failed" << std::endl
;
61 ObjectStore::Transaction t
;
64 bl
.append(buf
, sizeof(buf
));
65 auto ch
= fs
->create_new_collection(coll_t());
66 t
.create_collection(coll_t(), 0);
68 for (int i
=0; i
<mb
; i
++) {
70 snprintf(f
, sizeof(f
), "foo%d\n", i
);
71 sobject_t
soid(f
, CEPH_NOSNAP
);
72 t
.write(coll_t(), ghobject_t(hobject_t(soid
)), 0, bl
.length(), bl
);
75 dout(0) << "starting thread" << dendl
;
77 dout(0) << "starting op" << dendl
;
78 fs
->queue_transaction(ch
, std::move(t
));