| 2633 | |
| 2634 | |
| 2635 | int 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 { |
nothing calls this directly
no test coverage detected