]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/objectstore/test_bluefs.cc
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / test / objectstore / test_bluefs.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include <stdio.h>
5 #include <string.h>
6 #include <iostream>
7 #include <time.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10 #include <random>
11 #include <thread>
12 #include "global/global_init.h"
13 #include "common/ceph_argparse.h"
14 #include "include/stringify.h"
15 #include "include/scope_guard.h"
16 #include "common/errno.h"
17 #include <gtest/gtest.h>
18
19 #include "os/bluestore/BlueFS.h"
20
21 string get_temp_bdev(uint64_t size)
22 {
23 static int n = 0;
24 string fn = "ceph_test_bluefs.tmp.block." + stringify(getpid())
25 + "." + stringify(++n);
26 int fd = ::open(fn.c_str(), O_CREAT|O_RDWR|O_TRUNC, 0644);
27 ceph_assert(fd >= 0);
28 int r = ::ftruncate(fd, size);
29 ceph_assert(r >= 0);
30 ::close(fd);
31 return fn;
32 }
33
34 std::unique_ptr<char[]> gen_buffer(uint64_t size)
35 {
36 std::unique_ptr<char[]> buffer = std::make_unique<char[]>(size);
37 std::independent_bits_engine<std::default_random_engine, CHAR_BIT, unsigned char> e;
38 std::generate(buffer.get(), buffer.get()+size, std::ref(e));
39 return buffer;
40 }
41
42
43 void rm_temp_bdev(string f)
44 {
45 ::unlink(f.c_str());
46 }
47
48 TEST(BlueFS, mkfs) {
49 uint64_t size = 1048576 * 128;
50 string fn = get_temp_bdev(size);
51 uuid_d fsid;
52 BlueFS fs(g_ceph_context);
53 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
54 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
55 ASSERT_EQ(0, fs.mkfs(fsid));
56 rm_temp_bdev(fn);
57 }
58
59 TEST(BlueFS, mkfs_mount) {
60 uint64_t size = 1048576 * 128;
61 string fn = get_temp_bdev(size);
62 BlueFS fs(g_ceph_context);
63 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
64 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
65 uuid_d fsid;
66 ASSERT_EQ(0, fs.mkfs(fsid));
67 ASSERT_EQ(0, fs.mount());
68 ASSERT_EQ(fs.get_total(BlueFS::BDEV_DB), size - 1048576);
69 ASSERT_LT(fs.get_free(BlueFS::BDEV_DB), size - 1048576);
70 fs.umount();
71 rm_temp_bdev(fn);
72 }
73
74 TEST(BlueFS, write_read) {
75 uint64_t size = 1048576 * 128;
76 string fn = get_temp_bdev(size);
77 BlueFS fs(g_ceph_context);
78 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
79 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
80 uuid_d fsid;
81 ASSERT_EQ(0, fs.mkfs(fsid));
82 ASSERT_EQ(0, fs.mount());
83 {
84 BlueFS::FileWriter *h;
85 ASSERT_EQ(0, fs.mkdir("dir"));
86 ASSERT_EQ(0, fs.open_for_write("dir", "file", &h, false));
87 h->append("foo", 3);
88 h->append("bar", 3);
89 h->append("baz", 3);
90 fs.fsync(h);
91 fs.close_writer(h);
92 }
93 {
94 BlueFS::FileReader *h;
95 ASSERT_EQ(0, fs.open_for_read("dir", "file", &h));
96 bufferlist bl;
97 BlueFS::FileReaderBuffer buf(4096);
98 ASSERT_EQ(9, fs.read(h, &buf, 0, 1024, &bl, NULL));
99 ASSERT_EQ(0, strncmp("foobarbaz", bl.c_str(), 9));
100 delete h;
101 }
102 fs.umount();
103 rm_temp_bdev(fn);
104 }
105
106 TEST(BlueFS, small_appends) {
107 uint64_t size = 1048576 * 128;
108 string fn = get_temp_bdev(size);
109 BlueFS fs(g_ceph_context);
110 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
111 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
112 uuid_d fsid;
113 ASSERT_EQ(0, fs.mkfs(fsid));
114 ASSERT_EQ(0, fs.mount());
115 {
116 BlueFS::FileWriter *h;
117 ASSERT_EQ(0, fs.mkdir("dir"));
118 ASSERT_EQ(0, fs.open_for_write("dir", "file", &h, false));
119 for (unsigned i = 0; i < 10000; ++i) {
120 h->append("abcdeabcdeabcdeabcdeabcdeabc", 23);
121 }
122 fs.fsync(h);
123 fs.close_writer(h);
124 }
125 {
126 BlueFS::FileWriter *h;
127 ASSERT_EQ(0, fs.open_for_write("dir", "file_sync", &h, false));
128 for (unsigned i = 0; i < 1000; ++i) {
129 h->append("abcdeabcdeabcdeabcdeabcdeabc", 23);
130 ASSERT_EQ(0, fs.fsync(h));
131 }
132 fs.close_writer(h);
133 }
134 fs.umount();
135 rm_temp_bdev(fn);
136 }
137
138 TEST(BlueFS, very_large_write) {
139 // we'll write a ~3G file, so allocate more than that for the whole fs
140 uint64_t size = 1048576 * 1024 * 8ull;
141 string fn = get_temp_bdev(size);
142 BlueFS fs(g_ceph_context);
143
144 bool old = g_ceph_context->_conf.get_val<bool>("bluefs_buffered_io");
145 g_ceph_context->_conf.set_val("bluefs_buffered_io", "false");
146
147 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
148 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
149 uuid_d fsid;
150 ASSERT_EQ(0, fs.mkfs(fsid));
151 ASSERT_EQ(0, fs.mount());
152 char buf[1048571]; // this is biggish, but intentionally not evenly aligned
153 for (unsigned i = 0; i < sizeof(buf); ++i) {
154 buf[i] = i;
155 }
156 {
157 BlueFS::FileWriter *h;
158 ASSERT_EQ(0, fs.mkdir("dir"));
159 ASSERT_EQ(0, fs.open_for_write("dir", "bigfile", &h, false));
160 for (unsigned i = 0; i < 3*1024*1048576ull / sizeof(buf); ++i) {
161 h->append(buf, sizeof(buf));
162 }
163 fs.fsync(h);
164 fs.close_writer(h);
165 }
166 {
167 BlueFS::FileReader *h;
168 ASSERT_EQ(0, fs.open_for_read("dir", "bigfile", &h));
169 bufferlist bl;
170 BlueFS::FileReaderBuffer readbuf(10485760);
171 for (unsigned i = 0; i < 3*1024*1048576ull / sizeof(buf); ++i) {
172 bl.clear();
173 fs.read(h, &readbuf, i * sizeof(buf), sizeof(buf), &bl, NULL);
174 int r = memcmp(buf, bl.c_str(), sizeof(buf));
175 if (r) {
176 cerr << "read got mismatch at offset " << i*sizeof(buf) << " r " << r
177 << std::endl;
178 }
179 ASSERT_EQ(0, r);
180 }
181 delete h;
182 }
183 fs.umount();
184
185 g_ceph_context->_conf.set_val("bluefs_buffered_io", stringify((int)old));
186
187 rm_temp_bdev(fn);
188 }
189
190 #define ALLOC_SIZE 4096
191
192 void write_data(BlueFS &fs, uint64_t rationed_bytes)
193 {
194 int j=0, r=0;
195 uint64_t written_bytes = 0;
196 rationed_bytes -= ALLOC_SIZE;
197 stringstream ss;
198 string dir = "dir.";
199 ss << std::this_thread::get_id();
200 dir.append(ss.str());
201 dir.append(".");
202 dir.append(to_string(j));
203 ASSERT_EQ(0, fs.mkdir(dir));
204 while (1) {
205 string file = "file.";
206 file.append(to_string(j));
207 BlueFS::FileWriter *h;
208 ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false));
209 ASSERT_NE(nullptr, h);
210 auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); });
211 bufferlist bl;
212 std::unique_ptr<char[]> buf = gen_buffer(ALLOC_SIZE);
213 bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf.get());
214 bl.push_back(bp);
215 h->append(bl.c_str(), bl.length());
216 r = fs.fsync(h);
217 if (r < 0) {
218 break;
219 }
220 written_bytes += g_conf()->bluefs_alloc_size;
221 j++;
222 if ((rationed_bytes - written_bytes) <= g_conf()->bluefs_alloc_size) {
223 break;
224 }
225 }
226 }
227
228 void create_single_file(BlueFS &fs)
229 {
230 BlueFS::FileWriter *h;
231 stringstream ss;
232 string dir = "dir.test";
233 ASSERT_EQ(0, fs.mkdir(dir));
234 string file = "testfile";
235 ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false));
236 bufferlist bl;
237 std::unique_ptr<char[]> buf = gen_buffer(ALLOC_SIZE);
238 bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf.get());
239 bl.push_back(bp);
240 h->append(bl.c_str(), bl.length());
241 fs.fsync(h);
242 fs.close_writer(h);
243 }
244
245 void write_single_file(BlueFS &fs, uint64_t rationed_bytes)
246 {
247 stringstream ss;
248 const string dir = "dir.test";
249 const string file = "testfile";
250 uint64_t written_bytes = 0;
251 rationed_bytes -= ALLOC_SIZE;
252 while (1) {
253 BlueFS::FileWriter *h;
254 ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false));
255 ASSERT_NE(nullptr, h);
256 auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); });
257 bufferlist bl;
258 std::unique_ptr<char[]> buf = gen_buffer(ALLOC_SIZE);
259 bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf.get());
260 bl.push_back(bp);
261 h->append(bl.c_str(), bl.length());
262 int r = fs.fsync(h);
263 if (r < 0) {
264 break;
265 }
266 written_bytes += g_conf()->bluefs_alloc_size;
267 if ((rationed_bytes - written_bytes) <= g_conf()->bluefs_alloc_size) {
268 break;
269 }
270 }
271 }
272
273 bool writes_done = false;
274
275 void sync_fs(BlueFS &fs)
276 {
277 while (1) {
278 if (writes_done == true)
279 break;
280 fs.sync_metadata();
281 sleep(1);
282 }
283 }
284
285
286 void do_join(std::thread& t)
287 {
288 t.join();
289 }
290
291 void join_all(std::vector<std::thread>& v)
292 {
293 std::for_each(v.begin(),v.end(),do_join);
294 }
295
296 #define NUM_WRITERS 3
297 #define NUM_SYNC_THREADS 1
298
299 #define NUM_SINGLE_FILE_WRITERS 1
300 #define NUM_MULTIPLE_FILE_WRITERS 2
301
302 TEST(BlueFS, test_flush_1) {
303 uint64_t size = 1048576 * 128;
304 string fn = get_temp_bdev(size);
305 g_ceph_context->_conf.set_val(
306 "bluefs_alloc_size",
307 "65536");
308 g_ceph_context->_conf.apply_changes(nullptr);
309
310 BlueFS fs(g_ceph_context);
311 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
312 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
313 uuid_d fsid;
314 ASSERT_EQ(0, fs.mkfs(fsid));
315 ASSERT_EQ(0, fs.mount());
316 {
317 std::vector<std::thread> write_thread_multiple;
318 uint64_t effective_size = size - (32 * 1048576); // leaving the last 32 MB for log compaction
319 uint64_t per_thread_bytes = (effective_size/(NUM_MULTIPLE_FILE_WRITERS + NUM_SINGLE_FILE_WRITERS));
320 for (int i=0; i<NUM_MULTIPLE_FILE_WRITERS ; i++) {
321 write_thread_multiple.push_back(std::thread(write_data, std::ref(fs), per_thread_bytes));
322 }
323
324 create_single_file(fs);
325 std::vector<std::thread> write_thread_single;
326 for (int i=0; i<NUM_SINGLE_FILE_WRITERS; i++) {
327 write_thread_single.push_back(std::thread(write_single_file, std::ref(fs), per_thread_bytes));
328 }
329
330 join_all(write_thread_single);
331 join_all(write_thread_multiple);
332 }
333 fs.umount();
334 rm_temp_bdev(fn);
335 }
336
337 TEST(BlueFS, test_flush_2) {
338 uint64_t size = 1048576 * 256;
339 string fn = get_temp_bdev(size);
340 g_ceph_context->_conf.set_val(
341 "bluefs_alloc_size",
342 "65536");
343 g_ceph_context->_conf.apply_changes(nullptr);
344
345 BlueFS fs(g_ceph_context);
346 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
347 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
348 uuid_d fsid;
349 ASSERT_EQ(0, fs.mkfs(fsid));
350 ASSERT_EQ(0, fs.mount());
351 {
352 uint64_t effective_size = size - (128 * 1048576); // leaving the last 32 MB for log compaction
353 uint64_t per_thread_bytes = (effective_size/(NUM_WRITERS));
354 std::vector<std::thread> write_thread_multiple;
355 for (int i=0; i<NUM_WRITERS; i++) {
356 write_thread_multiple.push_back(std::thread(write_data, std::ref(fs), per_thread_bytes));
357 }
358
359 join_all(write_thread_multiple);
360 }
361 fs.umount();
362 rm_temp_bdev(fn);
363 }
364
365 TEST(BlueFS, test_flush_3) {
366 uint64_t size = 1048576 * 256;
367 string fn = get_temp_bdev(size);
368 g_ceph_context->_conf.set_val(
369 "bluefs_alloc_size",
370 "65536");
371 g_ceph_context->_conf.apply_changes(nullptr);
372
373 BlueFS fs(g_ceph_context);
374 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
375 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
376 uuid_d fsid;
377 ASSERT_EQ(0, fs.mkfs(fsid));
378 ASSERT_EQ(0, fs.mount());
379 {
380 std::vector<std::thread> write_threads;
381 uint64_t effective_size = size - (64 * 1048576); // leaving the last 11 MB for log compaction
382 uint64_t per_thread_bytes = (effective_size/(NUM_WRITERS));
383 for (int i=0; i<NUM_WRITERS; i++) {
384 write_threads.push_back(std::thread(write_data, std::ref(fs), per_thread_bytes));
385 }
386
387 std::vector<std::thread> sync_threads;
388 for (int i=0; i<NUM_SYNC_THREADS; i++) {
389 sync_threads.push_back(std::thread(sync_fs, std::ref(fs)));
390 }
391
392 join_all(write_threads);
393 writes_done = true;
394 join_all(sync_threads);
395 }
396 fs.umount();
397 rm_temp_bdev(fn);
398 }
399
400 TEST(BlueFS, test_simple_compaction_sync) {
401 g_ceph_context->_conf.set_val(
402 "bluefs_compact_log_sync",
403 "true");
404 uint64_t size = 1048576 * 128;
405 string fn = get_temp_bdev(size);
406
407 BlueFS fs(g_ceph_context);
408 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
409 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
410 uuid_d fsid;
411 ASSERT_EQ(0, fs.mkfs(fsid));
412 ASSERT_EQ(0, fs.mount());
413 {
414 for (int i=0; i<10; i++) {
415 string dir = "dir.";
416 dir.append(to_string(i));
417 ASSERT_EQ(0, fs.mkdir(dir));
418 for (int j=0; j<10; j++) {
419 string file = "file.";
420 file.append(to_string(j));
421 BlueFS::FileWriter *h;
422 ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false));
423 ASSERT_NE(nullptr, h);
424 auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); });
425 bufferlist bl;
426 std::unique_ptr<char[]> buf = gen_buffer(4096);
427 bufferptr bp = buffer::claim_char(4096, buf.get());
428 bl.push_back(bp);
429 h->append(bl.c_str(), bl.length());
430 fs.fsync(h);
431 }
432 }
433 }
434 {
435 for (int i=0; i<10; i+=2) {
436 string dir = "dir.";
437 dir.append(to_string(i));
438 for (int j=0; j<10; j++) {
439 string file = "file.";
440 file.append(to_string(j));
441 fs.unlink(dir, file);
442 fs.flush_log();
443 }
444 ASSERT_EQ(0, fs.rmdir(dir));
445 fs.flush_log();
446 }
447 }
448 fs.compact_log();
449 fs.umount();
450 rm_temp_bdev(fn);
451 }
452
453 TEST(BlueFS, test_simple_compaction_async) {
454 g_ceph_context->_conf.set_val(
455 "bluefs_compact_log_sync",
456 "false");
457 uint64_t size = 1048576 * 128;
458 string fn = get_temp_bdev(size);
459
460 BlueFS fs(g_ceph_context);
461 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
462 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
463 uuid_d fsid;
464 ASSERT_EQ(0, fs.mkfs(fsid));
465 ASSERT_EQ(0, fs.mount());
466 {
467 for (int i=0; i<10; i++) {
468 string dir = "dir.";
469 dir.append(to_string(i));
470 ASSERT_EQ(0, fs.mkdir(dir));
471 for (int j=0; j<10; j++) {
472 string file = "file.";
473 file.append(to_string(j));
474 BlueFS::FileWriter *h;
475 ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false));
476 ASSERT_NE(nullptr, h);
477 auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); });
478 bufferlist bl;
479 std::unique_ptr<char[]> buf = gen_buffer(4096);
480 bufferptr bp = buffer::claim_char(4096, buf.get());
481 bl.push_back(bp);
482 h->append(bl.c_str(), bl.length());
483 fs.fsync(h);
484 }
485 }
486 }
487 {
488 for (int i=0; i<10; i+=2) {
489 string dir = "dir.";
490 dir.append(to_string(i));
491 for (int j=0; j<10; j++) {
492 string file = "file.";
493 file.append(to_string(j));
494 fs.unlink(dir, file);
495 fs.flush_log();
496 }
497 ASSERT_EQ(0, fs.rmdir(dir));
498 fs.flush_log();
499 }
500 }
501 fs.compact_log();
502 fs.umount();
503 rm_temp_bdev(fn);
504 }
505
506 TEST(BlueFS, test_compaction_sync) {
507 uint64_t size = 1048576 * 128;
508 string fn = get_temp_bdev(size);
509 g_ceph_context->_conf.set_val(
510 "bluefs_alloc_size",
511 "65536");
512 g_ceph_context->_conf.set_val(
513 "bluefs_compact_log_sync",
514 "true");
515
516 BlueFS fs(g_ceph_context);
517 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
518 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
519 uuid_d fsid;
520 ASSERT_EQ(0, fs.mkfs(fsid));
521 ASSERT_EQ(0, fs.mount());
522 {
523 std::vector<std::thread> write_threads;
524 uint64_t effective_size = size - (32 * 1048576); // leaving the last 32 MB for log compaction
525 uint64_t per_thread_bytes = (effective_size/(NUM_WRITERS));
526 for (int i=0; i<NUM_WRITERS; i++) {
527 write_threads.push_back(std::thread(write_data, std::ref(fs), per_thread_bytes));
528 }
529
530 std::vector<std::thread> sync_threads;
531 for (int i=0; i<NUM_SYNC_THREADS; i++) {
532 sync_threads.push_back(std::thread(sync_fs, std::ref(fs)));
533 }
534
535 join_all(write_threads);
536 writes_done = true;
537 join_all(sync_threads);
538 fs.compact_log();
539 }
540 fs.umount();
541 rm_temp_bdev(fn);
542 }
543
544 TEST(BlueFS, test_compaction_async) {
545 uint64_t size = 1048576 * 128;
546 string fn = get_temp_bdev(size);
547 g_ceph_context->_conf.set_val(
548 "bluefs_alloc_size",
549 "65536");
550 g_ceph_context->_conf.set_val(
551 "bluefs_compact_log_sync",
552 "false");
553
554 BlueFS fs(g_ceph_context);
555 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
556 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
557 uuid_d fsid;
558 ASSERT_EQ(0, fs.mkfs(fsid));
559 ASSERT_EQ(0, fs.mount());
560 {
561 std::vector<std::thread> write_threads;
562 uint64_t effective_size = size - (32 * 1048576); // leaving the last 32 MB for log compaction
563 uint64_t per_thread_bytes = (effective_size/(NUM_WRITERS));
564 for (int i=0; i<NUM_WRITERS; i++) {
565 write_threads.push_back(std::thread(write_data, std::ref(fs), per_thread_bytes));
566 }
567
568 std::vector<std::thread> sync_threads;
569 for (int i=0; i<NUM_SYNC_THREADS; i++) {
570 sync_threads.push_back(std::thread(sync_fs, std::ref(fs)));
571 }
572
573 join_all(write_threads);
574 writes_done = true;
575 join_all(sync_threads);
576 fs.compact_log();
577 }
578 fs.umount();
579 rm_temp_bdev(fn);
580 }
581
582 TEST(BlueFS, test_replay) {
583 uint64_t size = 1048576 * 128;
584 string fn = get_temp_bdev(size);
585 g_ceph_context->_conf.set_val(
586 "bluefs_alloc_size",
587 "65536");
588 g_ceph_context->_conf.set_val(
589 "bluefs_compact_log_sync",
590 "false");
591
592 BlueFS fs(g_ceph_context);
593 ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
594 fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
595 uuid_d fsid;
596 ASSERT_EQ(0, fs.mkfs(fsid));
597 ASSERT_EQ(0, fs.mount());
598 {
599 std::vector<std::thread> write_threads;
600 uint64_t effective_size = size - (32 * 1048576); // leaving the last 32 MB for log compaction
601 uint64_t per_thread_bytes = (effective_size/(NUM_WRITERS));
602 for (int i=0; i<NUM_WRITERS; i++) {
603 write_threads.push_back(std::thread(write_data, std::ref(fs), per_thread_bytes));
604 }
605
606 std::vector<std::thread> sync_threads;
607 for (int i=0; i<NUM_SYNC_THREADS; i++) {
608 sync_threads.push_back(std::thread(sync_fs, std::ref(fs)));
609 }
610
611 join_all(write_threads);
612 writes_done = true;
613 join_all(sync_threads);
614 fs.compact_log();
615 }
616 fs.umount();
617 // remount and check log can replay safe?
618 ASSERT_EQ(0, fs.mount());
619 fs.umount();
620 rm_temp_bdev(fn);
621 }
622
623 int main(int argc, char **argv) {
624 vector<const char*> args;
625 argv_to_vec(argc, (const char **)argv, args);
626
627 map<string,string> defaults = {
628 { "debug_bluefs", "1/20" },
629 { "debug_bdev", "1/20" }
630 };
631
632 auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT,
633 CODE_ENVIRONMENT_UTILITY,
634 CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
635 common_init_finish(g_ceph_context);
636 g_ceph_context->_conf.set_val(
637 "enable_experimental_unrecoverable_data_corrupting_features",
638 "*");
639 g_ceph_context->_conf.apply_changes(nullptr);
640
641 ::testing::InitGoogleTest(&argc, argv);
642 return RUN_ALL_TESTS();
643 }