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

Method random_walk

src/client/SyntheticClient.cc:2635–2823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2633
2634
2635int SyntheticClient::random_walk(int num_req)
2636{
2637 int left = num_req;
2638
2639 //dout(1) << "random_walk() will do " << left << " ops" << dendl;
2640
2641 init_op_dist(); // set up metadata op distribution
2642
2643 UserPerm perms = client->pick_my_perms();
2644 while (left > 0) {
2645 left--;
2646
2647 if (time_to_stop()) break;
2648
2649 // ascend?
2650 if (cwd.depth() && !roll_die(::pow((double).9, (double)cwd.depth()))) {
2651 dout(DBL) << "die says up" << dendl;
2652 up();
2653 continue;
2654 }
2655
2656 // descend?
2657 if (roll_die(::pow((double).9,(double)cwd.depth())) && !subdirs.empty()) {
2658 string s = get_random_subdir();
2659 cwd.push_dentry( s );
2660 dout(DBL) << "cd " << s << " -> " << cwd << dendl;
2661 clear_dir();
2662 continue;
2663 }
2664
2665 int op = 0;
2666 filepath path;
2667
2668 if (contents.empty() && roll_die(.3)) {
2669 if (did_readdir) {
2670 dout(DBL) << "empty dir, up" << dendl;
2671 up();
2672 } else
2673 op = CEPH_MDS_OP_READDIR;
2674 } else {
2675 op = op_dist.sample();
2676 }
2677 //dout(DBL) << "op is " << op << dendl;
2678
2679 int r = 0;
2680
2681 // do op
2682 if (op == CEPH_MDS_OP_UNLINK) {
2683 if (contents.empty())
2684 op = CEPH_MDS_OP_READDIR;
2685 else
2686 r = client->unlink(get_random_sub(), perms); // will fail on dirs
2687 }
2688
2689 if (op == CEPH_MDS_OP_RENAME) {
2690 if (contents.empty())
2691 op = CEPH_MDS_OP_READDIR;
2692 else {

Callers

nothing calls this directly

Calls 15

roll_dieFunction · 0.85
pick_my_permsMethod · 0.80
depthMethod · 0.80
mknodMethod · 0.80
getdirMethod · 0.80
emptyMethod · 0.45
push_dentryMethod · 0.45
sampleMethod · 0.45
unlinkMethod · 0.45
renameMethod · 0.45
mkdirMethod · 0.45
rmdirMethod · 0.45

Tested by

no test coverage detected