]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/test_trans.cc
update sources to 12.2.7
[ceph.git] / ceph / src / test / test_trans.cc
CommitLineData
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"
18#include "os/filestore/FileStore.h"
19#include "global/global_init.h"
20#include "include/assert.h"
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
27struct Foo : public Thread {
28 void *entry() override {
29 dout(0) << "foo started" << dendl;
30 sleep(1);
31 dout(0) << "foo asserting 0" << dendl;
32 ceph_abort();
33 }
34} foo;
35
36int main(int argc, const char **argv)
37{
38 vector<const char*> args;
39 argv_to_vec(argc, argv, args);
40 env_to_vec(args);
41
42 auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
43 CODE_ENVIRONMENT_UTILITY, 0);
44 common_init_finish(g_ceph_context);
45
46 // args
47 if (args.size() < 2) return -1;
48 const char *filename = args[0];
49 int mb = atoi(args[1]);
50
51 cout << "#dev " << filename << std::endl;
52 cout << "#mb " << mb << std::endl;
53
54 ObjectStore *fs = new FileStore(cct.get(), filename, NULL);
55 if (fs->mount() < 0) {
56 cout << "mount failed" << std::endl;
57 return -1;
58 }
59
60 ObjectStore::Sequencer osr(__func__);
61 ObjectStore::Transaction t;
62 char buf[1 << 20];
63 bufferlist bl;
64 bl.append(buf, sizeof(buf));
65 t.create_collection(coll_t(), 0);
66
67 for (int i=0; i<mb; i++) {
68 char f[30];
69 snprintf(f, sizeof(f), "foo%d\n", i);
70 sobject_t soid(f, CEPH_NOSNAP);
71 t.write(coll_t(), ghobject_t(hobject_t(soid)), 0, bl.length(), bl);
72 }
73
74 dout(0) << "starting thread" << dendl;
75 foo.create("foo");
76 dout(0) << "starting op" << dendl;
77 fs->apply_transaction(&osr, std::move(t));
78
79}
80