| 321 | #define ALLOC_SIZE 4096 |
| 322 | |
| 323 | void write_data(BlueFS &fs, uint64_t rationed_bytes) |
| 324 | { |
| 325 | int j=0, r=0; |
| 326 | uint64_t written_bytes = 0; |
| 327 | rationed_bytes -= ALLOC_SIZE; |
| 328 | stringstream ss; |
| 329 | string dir = "dir."; |
| 330 | ss << std::this_thread::get_id(); |
| 331 | dir.append(ss.str()); |
| 332 | dir.append("."); |
| 333 | dir.append(to_string(j)); |
| 334 | ASSERT_EQ(0, fs.mkdir(dir)); |
| 335 | while (1) { |
| 336 | string file = "file."; |
| 337 | file.append(to_string(j)); |
| 338 | BlueFS::FileWriter *h; |
| 339 | ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false)); |
| 340 | ASSERT_NE(nullptr, h); |
| 341 | auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); }); |
| 342 | bufferlist bl; |
| 343 | std::unique_ptr<char[]> buf = gen_buffer(ALLOC_SIZE); |
| 344 | bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf.get()); |
| 345 | bl.push_back(bp); |
| 346 | h->append(bl.c_str(), bl.length()); |
| 347 | r = fs.fsync(h); |
| 348 | if (r < 0) { |
| 349 | break; |
| 350 | } |
| 351 | written_bytes += g_conf()->bluefs_alloc_size; |
| 352 | j++; |
| 353 | if ((rationed_bytes - written_bytes) <= g_conf()->bluefs_alloc_size) { |
| 354 | break; |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | void create_single_file(BlueFS &fs) |
| 360 | { |
nothing calls this directly
no test coverage detected