* Configure a write error inject that either fails an OSD or causes a * client write operation to be rolled back. * * Type 0 - Tests rollback. Drop a write I/O to a shard, then simulate an OSD * down to force rollback to occur, lastly fail the retried write from the * client so the results of the rollback can be inspected. * * Type 1 - Drop a write I/O to a shard. Used on its
| 96 | * @return string Result of configuring the error inect. |
| 97 | */ |
| 98 | std::string write_error(const ghobject_t& o, |
| 99 | const int64_t type, |
| 100 | const int64_t when, |
| 101 | const int64_t duration) { |
| 102 | std::lock_guard<ceph::recursive_mutex> l(lock); |
| 103 | std::map<ghobject_t,std::pair<int64_t,int64_t>> *failures; |
| 104 | ghobject_t os = o; |
| 105 | bool no_shard = true; |
| 106 | std::string result; |
| 107 | switch (type) { |
| 108 | case 0: |
| 109 | failures = &write_failures0; |
| 110 | result = "ok - drop write, sim OSD down and fail client retry with EINVAL"; |
| 111 | break; |
| 112 | case 1: |
| 113 | failures = &write_failures1; |
| 114 | no_shard = false; |
| 115 | result = "ok - drop write to shard"; |
| 116 | break; |
| 117 | case 2: |
| 118 | failures = &write_failures2; |
| 119 | result = "ok - inject OSD down"; |
| 120 | break; |
| 121 | case 3: |
| 122 | if (duration != 1) { |
| 123 | return "duration must be 1"; |
| 124 | } |
| 125 | failures = &write_failures3; |
| 126 | result = "ok - write abort OSDs"; |
| 127 | break; |
| 128 | default: |
| 129 | return "unrecognized error inject type"; |
| 130 | } |
| 131 | if (no_shard) { |
| 132 | os.set_shard(shard_id_t::NO_SHARD); |
| 133 | } |
| 134 | if (os.hobj.oid.name == "*") { |
| 135 | os.hobj.set_hash(0); |
| 136 | } |
| 137 | (*failures)[os] = std::pair(when, duration); |
| 138 | if (type == 0) { |
| 139 | write_failures0_shard[os] = o.shard_id; |
| 140 | } |
| 141 | return result; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Configure a parity read inject that typically forces parity shards in an |