summaryrefslogtreecommitdiffstats
path: root/src/common/io_exerciser/IoOp.h
blob: 60c02a93d4e221891567d5448ea041e6ea198fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once

#include <string>
#include <memory>
#include "include/ceph_assert.h"

/* Overview
 *
 * enum OpType
 *   Enumeration of different types of I/O operation
 *
 * class IoOp
 *   Stores details for an I/O operation. Generated by IoSequences
 *   and applied by IoExerciser's
 */

namespace ceph {
  namespace io_exerciser {

    enum class OpType {
      Done,       // End of I/O sequence
      BARRIER,    // Barrier - all prior I/Os must complete
      CREATE,     // Create object and pattern with data
      REMOVE,     // Remove object
      READ,       // Read
      READ2,      // 2 Reads in one op
      READ3,      // 3 Reads in one op
      WRITE,      // Write
      WRITE2,     // 2 Writes in one op
      WRITE3      // 3 Writes in one op
    };

    class IoOp {
    protected:
      std::string value_to_string(uint64_t v) const;

    public:
      OpType op;
      uint64_t offset1;
      uint64_t length1;
      uint64_t offset2;
      uint64_t length2;
      uint64_t offset3;
      uint64_t length3;

      IoOp( OpType op,
            uint64_t offset1 = 0, uint64_t length1 = 0,
            uint64_t offset2 = 0, uint64_t length2 = 0,
            uint64_t offset3 = 0, uint64_t length3 = 0 );

      static std::unique_ptr<IoOp> generate_done();

      static std::unique_ptr<IoOp> generate_barrier();

      static std::unique_ptr<IoOp> generate_create(uint64_t size);

      static std::unique_ptr<IoOp> generate_remove();

      static std::unique_ptr<IoOp> generate_read(uint64_t offset,
                                                 uint64_t length);

      static std::unique_ptr<IoOp> generate_read2(uint64_t offset1,
                                                  uint64_t length1,
                                                  uint64_t offset2,
                                                  uint64_t length2);

      static std::unique_ptr<IoOp> generate_read3(uint64_t offset1,
                                                  uint64_t length1,
                                                  uint64_t offset2,
                                                  uint64_t length2,
                                                  uint64_t offset3,
                                                  uint64_t length3);

      static std::unique_ptr<IoOp> generate_write(uint64_t offset,
                                                  uint64_t length);

      static std::unique_ptr<IoOp> generate_write2(uint64_t offset1,
                                                   uint64_t length1,
                                                   uint64_t offset2,
                                                   uint64_t length2);

      static std::unique_ptr<IoOp> generate_write3(uint64_t offset1,
                                                   uint64_t length1,
                                                   uint64_t offset2,
                                                   uint64_t length2,
                                                   uint64_t offset3,
                                                   uint64_t length3);

      bool done();

      std::string to_string(uint64_t block_size) const;
    };
  }
}