]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
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. | |
12 | * | |
13 | */ | |
14 | ||
15 | #include <iostream> | |
16 | #include "common/ceph_argparse.h" | |
17 | #include "common/debug.h" | |
1e59de90 | 18 | #include "os/bluestore/BlueStore.h" |
7c673cae | 19 | #include "global/global_init.h" |
11fdf7f2 | 20 | #include "include/ceph_assert.h" |
7c673cae FG |
21 | |
22 | #define dout_context g_ceph_context | |
23 | #define dout_subsys ceph_subsys_filestore | |
24 | #undef dout_prefix | |
25 | #define dout_prefix *_dout | |
26 | ||
20effc67 TL |
27 | using namespace std; |
28 | ||
7c673cae FG |
29 | struct Foo : public Thread { |
30 | void *entry() override { | |
31 | dout(0) << "foo started" << dendl; | |
32 | sleep(1); | |
33 | dout(0) << "foo asserting 0" << dendl; | |
34 | ceph_abort(); | |
35 | } | |
36 | } foo; | |
37 | ||
38 | int main(int argc, const char **argv) | |
39 | { | |
20effc67 | 40 | auto args = argv_to_vec(argc, argv); |
7c673cae FG |
41 | |
42 | auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, | |
11fdf7f2 TL |
43 | CODE_ENVIRONMENT_UTILITY, |
44 | CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); | |
7c673cae FG |
45 | common_init_finish(g_ceph_context); |
46 | ||
47 | // args | |
48 | if (args.size() < 2) return -1; | |
49 | const char *filename = args[0]; | |
50 | int mb = atoi(args[1]); | |
51 | ||
52 | cout << "#dev " << filename << std::endl; | |
53 | cout << "#mb " << mb << std::endl; | |
54 | ||
1e59de90 | 55 | ObjectStore *fs = new BlueStore(cct.get(), filename); |
7c673cae FG |
56 | if (fs->mount() < 0) { |
57 | cout << "mount failed" << std::endl; | |
58 | return -1; | |
59 | } | |
60 | ||
7c673cae FG |
61 | ObjectStore::Transaction t; |
62 | char buf[1 << 20]; | |
63 | bufferlist bl; | |
64 | bl.append(buf, sizeof(buf)); | |
11fdf7f2 | 65 | auto ch = fs->create_new_collection(coll_t()); |
7c673cae FG |
66 | t.create_collection(coll_t(), 0); |
67 | ||
68 | for (int i=0; i<mb; i++) { | |
69 | char f[30]; | |
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); | |
73 | } | |
74 | ||
75 | dout(0) << "starting thread" << dendl; | |
76 | foo.create("foo"); | |
77 | dout(0) << "starting op" << dendl; | |
11fdf7f2 | 78 | fs->queue_transaction(ch, std::move(t)); |
7c673cae FG |
79 | } |
80 |