MCPcopy Create free account
hub / github.com/ceph/ceph / write_data

Function write_data

src/test/objectstore/test_bluefs.cc:323–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321#define ALLOC_SIZE 4096
322
323void 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
359void create_single_file(BlueFS &fs)
360{

Callers

nothing calls this directly

Calls 14

make_scope_guardFunction · 0.85
close_writerMethod · 0.80
gen_bufferFunction · 0.70
get_idFunction · 0.50
to_stringFunction · 0.50
appendMethod · 0.45
strMethod · 0.45
mkdirMethod · 0.45
open_for_writeMethod · 0.45
getMethod · 0.45
push_backMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected