manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 3 | #include <boost/algorithm/string.hpp> |
| 4 | #include <boost/container/flat_map.hpp> |
Manojkiran Eda | 55fd1a9 | 2020-04-30 19:06:48 +0530 | [diff] [blame] | 5 | #include <boost/endian/conversion.hpp> |
Ed Tanous | 04e438c | 2020-10-03 08:06:26 -0700 | [diff] [blame] | 6 | #include <logging.hpp> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 7 | #include <nlohmann/json.hpp> |
| 8 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 9 | #include <filesystem> |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 10 | #include <fstream> |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 11 | |
| 12 | namespace crow |
| 13 | { |
| 14 | namespace ibm_mc_lock |
| 15 | { |
| 16 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 17 | using SType = std::string; |
| 18 | |
| 19 | /*---------------------------------------- |
| 20 | |Segment flags : LockFlag | SegmentLength| |
| 21 | ------------------------------------------*/ |
| 22 | |
| 23 | using SegmentFlags = std::vector<std::pair<SType, uint32_t>>; |
| 24 | |
| 25 | // Lockrequest = session-id | hmc-id | locktype | resourceid | segmentinfo |
| 26 | using LockRequest = std::tuple<SType, SType, SType, uint64_t, SegmentFlags>; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 27 | using LockRequests = std::vector<LockRequest>; |
| 28 | using Rc = |
| 29 | std::pair<bool, std::variant<uint32_t, std::pair<uint32_t, LockRequest>>>; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 30 | using RcRelaseLock = std::pair<bool, std::pair<uint32_t, LockRequest>>; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 31 | using RcGetLockList = |
| 32 | std::variant<std::string, std::vector<std::pair<uint32_t, LockRequests>>>; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 33 | using ListOfTransactionIds = std::vector<uint32_t>; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 34 | using RcAcquireLock = std::pair<bool, std::variant<Rc, std::pair<bool, int>>>; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 35 | using RcReleaseLockApi = std::pair<bool, std::variant<bool, RcRelaseLock>>; |
| 36 | using SessionFlags = std::pair<SType, SType>; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 37 | using ListOfSessionIds = std::vector<std::string>; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 38 | static constexpr const char* fileName = |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 39 | "/var/lib/obmc/bmc-console-mgmt/locks/ibm_mc_persistent_lock_data.json"; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 40 | |
| 41 | class Lock |
| 42 | { |
| 43 | uint32_t transactionId; |
| 44 | boost::container::flat_map<uint32_t, LockRequests> lockTable; |
| 45 | |
| 46 | /* |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 47 | * This API implements the logic to persist the locks that are contained in |
| 48 | * the lock table into a json file. |
| 49 | */ |
| 50 | void saveLocks(); |
| 51 | |
| 52 | /* |
| 53 | * This API implements the logic to load the locks that are present in the |
| 54 | * json file into the lock table. |
| 55 | */ |
| 56 | void loadLocks(); |
| 57 | |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 58 | bool createPersistentLockFilePath(); |
| 59 | |
| 60 | protected: |
| 61 | /* |
| 62 | * This function implements the logic for validating an incoming |
| 63 | * lock request/requests. |
| 64 | * |
| 65 | * Returns : True (if Valid) |
| 66 | * Returns : False (if not a Valid lock request) |
| 67 | */ |
| 68 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 69 | virtual bool isValidLockRequest(const LockRequest&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 70 | |
| 71 | /* |
| 72 | * This function implements the logic of checking if the incoming |
| 73 | * multi-lock request is not having conflicting requirements. |
| 74 | * |
| 75 | * Returns : True (if conflicting) |
| 76 | * Returns : False (if not conflicting) |
| 77 | */ |
| 78 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 79 | virtual bool isConflictRequest(const LockRequests&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 80 | /* |
| 81 | * Implements the core algorithm to find the conflicting |
| 82 | * lock requests. |
| 83 | * |
| 84 | * This functions takes two lock requests and check if both |
| 85 | * are conflicting to each other. |
| 86 | * |
| 87 | * Returns : True (if conflicting) |
| 88 | * Returns : False (if not conflicting) |
| 89 | */ |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 90 | virtual bool isConflictRecord(const LockRequest&, const LockRequest&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 91 | |
| 92 | /* |
| 93 | * This function implements the logic of checking the conflicting |
| 94 | * locks from a incoming single/multi lock requests with the already |
| 95 | * existing lock request in the lock table. |
| 96 | * |
| 97 | */ |
| 98 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 99 | virtual Rc isConflictWithTable(const LockRequests&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 100 | /* |
| 101 | * This function implements the logic of checking the ownership of the |
| 102 | * lock from the releaselock request. |
| 103 | * |
| 104 | * Returns : True (if the requesting HMC & Session owns the lock(s)) |
| 105 | * Returns : False (if the request HMC or Session does not own the lock(s)) |
| 106 | */ |
| 107 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 108 | virtual RcRelaseLock isItMyLock(const ListOfTransactionIds&, |
| 109 | const SessionFlags&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 110 | |
| 111 | /* |
| 112 | * This function validates the the list of transactionID's and returns false |
| 113 | * if the transaction ID is not valid & not present in the lock table |
| 114 | */ |
| 115 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 116 | virtual bool validateRids(const ListOfTransactionIds&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 117 | |
| 118 | /* |
| 119 | * This function releases the locks that are already obtained by the |
| 120 | * requesting Management console. |
| 121 | */ |
| 122 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 123 | void releaseLock(const ListOfTransactionIds&); |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 124 | |
| 125 | Lock() |
| 126 | { |
| 127 | loadLocks(); |
| 128 | transactionId = lockTable.empty() ? 0 : prev(lockTable.end())->first; |
| 129 | } |
| 130 | |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 131 | /* |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 132 | * This function implements the algorithm for checking the respective |
| 133 | * bytes of the resource id based on the lock management algorithm. |
| 134 | */ |
| 135 | |
| 136 | bool checkByte(uint64_t, uint64_t, uint32_t); |
| 137 | |
| 138 | /* |
| 139 | * This functions implements a counter that generates a unique 32 bit |
| 140 | * number for every successful transaction. This number will be used by |
| 141 | * the Management Console for debug. |
| 142 | */ |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 143 | virtual uint32_t generateTransactionId(); |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 144 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 145 | public: |
| 146 | /* |
| 147 | * This function implements the logic for acquiring a lock on a |
Manojkiran Eda | 5bb0ece | 2020-01-20 20:22:36 +0530 | [diff] [blame] | 148 | * resource if the incoming request is legitimate without any |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 149 | * conflicting requirements & without any conflicting requirement |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 150 | * with the existing locks in the lock table. |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 151 | * |
| 152 | */ |
| 153 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 154 | RcAcquireLock acquireLock(const LockRequests&); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 155 | |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 156 | /* |
| 157 | * This function implements the logic for releasing the lock that are |
| 158 | * owned by a management console session. |
| 159 | * |
| 160 | * The locks can be released by two ways |
| 161 | * - Using list of transaction ID's |
| 162 | * - Using a Session ID |
| 163 | * |
| 164 | * Client can choose either of the ways by using `Type` JSON key. |
| 165 | * |
| 166 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 167 | RcReleaseLockApi releaseLock(const ListOfTransactionIds&, |
| 168 | const SessionFlags&); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 169 | |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 170 | /* |
| 171 | * This function implements the logic for getting the list of locks obtained |
| 172 | * by a particular management console. |
| 173 | */ |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 174 | RcGetLockList getLockList(const ListOfSessionIds&); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 175 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 176 | /* |
| 177 | * This function is releases all the locks obtained by a particular |
| 178 | * session. |
| 179 | */ |
| 180 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 181 | void releaseLock(const std::string&); |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 182 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 183 | static Lock& getInstance() |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 184 | { |
| 185 | static Lock lockObject; |
| 186 | return lockObject; |
| 187 | } |
manojkiraneda | 4eaf2ee | 2019-12-13 17:10:41 +0530 | [diff] [blame] | 188 | |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 189 | virtual ~Lock() = default; |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 190 | }; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 191 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 192 | inline bool Lock::createPersistentLockFilePath() |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 193 | { |
| 194 | // The path /var/lib/obmc will be created by initrdscripts |
| 195 | // Create the directories for the persistent lock file |
| 196 | std::error_code ec; |
| 197 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt", ec)) |
| 198 | { |
| 199 | std::filesystem::create_directory("/var/lib/obmc/bmc-console-mgmt", ec); |
| 200 | } |
| 201 | if (ec) |
| 202 | { |
| 203 | BMCWEB_LOG_DEBUG |
| 204 | << "Failed to prepare bmc-console-mgmt directory. ec : " << ec; |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt/locks", |
| 209 | ec)) |
| 210 | { |
| 211 | std::filesystem::create_directory( |
| 212 | "/var/lib/obmc/bmc-console-mgmt/locks", ec); |
| 213 | } |
| 214 | if (ec) |
| 215 | { |
| 216 | BMCWEB_LOG_DEBUG |
| 217 | << "Failed to prepare persistent lock file directory. ec : " << ec; |
| 218 | return false; |
| 219 | } |
| 220 | return true; |
| 221 | } |
| 222 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 223 | inline void Lock::loadLocks() |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 224 | { |
| 225 | std::ifstream persistentFile(fileName); |
| 226 | if (persistentFile.is_open()) |
| 227 | { |
| 228 | auto data = nlohmann::json::parse(persistentFile, nullptr, false); |
| 229 | if (data.is_discarded()) |
| 230 | { |
| 231 | BMCWEB_LOG_ERROR << "Error parsing persistent data in json file."; |
| 232 | return; |
| 233 | } |
| 234 | BMCWEB_LOG_DEBUG << "The persistent lock data is available"; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 235 | for (const auto& item : data.items()) |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 236 | { |
| 237 | BMCWEB_LOG_DEBUG << item.key(); |
| 238 | BMCWEB_LOG_DEBUG << item.value(); |
| 239 | LockRequests locks = item.value(); |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 240 | lockTable.emplace(std::pair<uint32_t, LockRequests>( |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 241 | std::stoul(item.key()), locks)); |
| 242 | BMCWEB_LOG_DEBUG << "The persistent lock data loaded"; |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 247 | inline void Lock::saveLocks() |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 248 | { |
| 249 | std::error_code ec; |
| 250 | if (!std::filesystem::is_directory("/var/lib/obmc/bmc-console-mgmt/locks", |
| 251 | ec)) |
| 252 | { |
| 253 | if (!createPersistentLockFilePath()) |
| 254 | { |
| 255 | BMCWEB_LOG_DEBUG << "Failed to create lock persistent path"; |
| 256 | return; |
| 257 | } |
| 258 | } |
| 259 | std::ofstream persistentFile(fileName); |
| 260 | // set the permission of the file to 640 |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 261 | std::filesystem::perms permission = std::filesystem::perms::owner_read | |
| 262 | std::filesystem::perms::owner_write | |
| 263 | std::filesystem::perms::group_read; |
| 264 | std::filesystem::permissions(fileName, permission); |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 265 | nlohmann::json data; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 266 | for (const auto& it : lockTable) |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 267 | { |
| 268 | data[std::to_string(it.first)] = it.second; |
| 269 | } |
| 270 | BMCWEB_LOG_DEBUG << "data is " << data; |
| 271 | persistentFile << data; |
| 272 | } |
| 273 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 274 | inline RcGetLockList Lock::getLockList(const ListOfSessionIds& listSessionId) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 275 | { |
| 276 | |
| 277 | std::vector<std::pair<uint32_t, LockRequests>> lockList; |
| 278 | |
| 279 | if (!lockTable.empty()) |
| 280 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 281 | for (const auto& i : listSessionId) |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 282 | { |
| 283 | auto it = lockTable.begin(); |
| 284 | while (it != lockTable.end()) |
| 285 | { |
| 286 | // Check if session id of this entry matches with session id |
| 287 | // given |
| 288 | if (std::get<0>(it->second[0]) == i) |
| 289 | { |
| 290 | BMCWEB_LOG_DEBUG << "Session id is found in the locktable"; |
| 291 | |
| 292 | // Push the whole lock record into a vector for returning |
| 293 | // the json |
Ed Tanous | 4e08751 | 2020-09-28 18:41:25 -0700 | [diff] [blame] | 294 | lockList.emplace_back(it->first, it->second); |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 295 | } |
| 296 | // Go to next entry in map |
| 297 | it++; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | // we may have found at least one entry with the given session id |
| 302 | // return the json list of lock records pertaining to the given |
| 303 | // session id, or send an empty list if lock table is empty |
Ed Tanous | 02379d3 | 2020-09-15 21:15:44 -0700 | [diff] [blame] | 304 | return {lockList}; |
manojkiraneda | 402b571 | 2019-12-13 17:07:09 +0530 | [diff] [blame] | 305 | } |
| 306 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 307 | inline RcReleaseLockApi Lock::releaseLock(const ListOfTransactionIds& p, |
| 308 | const SessionFlags& ids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 309 | { |
| 310 | |
| 311 | bool status = validateRids(p); |
| 312 | |
| 313 | if (!status) |
| 314 | { |
| 315 | // Validation of rids failed |
| 316 | BMCWEB_LOG_DEBUG << "Not a Valid request id"; |
| 317 | return std::make_pair(false, status); |
| 318 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 319 | // Validation passed, check if all the locks are owned by the |
| 320 | // requesting HMC |
| 321 | auto status2 = isItMyLock(p, ids); |
| 322 | if (status2.first) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 323 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 324 | // The current hmc owns all the locks, so we can release |
| 325 | // them |
| 326 | releaseLock(p); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 327 | } |
Manojkiran Eda | a1ffbb8 | 2020-10-28 17:42:21 +0530 | [diff] [blame] | 328 | return std::make_pair(true, status2); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 329 | } |
| 330 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 331 | inline RcAcquireLock Lock::acquireLock(const LockRequests& lockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 332 | { |
| 333 | |
| 334 | // validate the lock request |
| 335 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 336 | for (auto& lockRecord : lockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 337 | { |
| 338 | bool status = isValidLockRequest(lockRecord); |
| 339 | if (!status) |
| 340 | { |
| 341 | BMCWEB_LOG_DEBUG << "Not a Valid record"; |
| 342 | BMCWEB_LOG_DEBUG << "Bad json in request"; |
| 343 | return std::make_pair(true, std::make_pair(status, 0)); |
| 344 | } |
| 345 | } |
| 346 | // check for conflict record |
| 347 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 348 | const LockRequests& multiRequest = lockRequestStructure; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 349 | bool status = isConflictRequest(multiRequest); |
| 350 | |
| 351 | if (status) |
| 352 | { |
| 353 | BMCWEB_LOG_DEBUG << "There is a conflict within itself"; |
| 354 | return std::make_pair(true, std::make_pair(status, 1)); |
| 355 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 356 | BMCWEB_LOG_DEBUG << "The request is not conflicting within itself"; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 357 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 358 | // Need to check for conflict with the locktable entries. |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 359 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 360 | auto conflict = isConflictWithTable(multiRequest); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 361 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 362 | BMCWEB_LOG_DEBUG << "Done with checking conflict with the locktable"; |
| 363 | return std::make_pair(false, conflict); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 364 | } |
| 365 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 366 | inline void Lock::releaseLock(const ListOfTransactionIds& refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 367 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 368 | for (const auto& id : refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 369 | { |
| 370 | if (lockTable.erase(id)) |
| 371 | { |
| 372 | BMCWEB_LOG_DEBUG << "Removing the locks with transaction ID : " |
| 373 | << id; |
| 374 | } |
| 375 | |
| 376 | else |
| 377 | { |
| 378 | BMCWEB_LOG_DEBUG << "Removing the locks from the lock table " |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 379 | "failed, transaction ID: " |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 380 | << id; |
| 381 | } |
| 382 | } |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 383 | |
| 384 | saveLocks(); |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 385 | } |
| 386 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 387 | inline void Lock::releaseLock(const std::string& sessionId) |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 388 | { |
| 389 | bool isErased = false; |
| 390 | if (!lockTable.empty()) |
| 391 | { |
| 392 | auto it = lockTable.begin(); |
| 393 | while (it != lockTable.end()) |
| 394 | { |
| 395 | if (it->second.size() != 0) |
| 396 | { |
| 397 | // Check if session id of this entry matches with session id |
| 398 | // given |
| 399 | if (std::get<0>(it->second[0]) == sessionId) |
| 400 | { |
| 401 | BMCWEB_LOG_DEBUG << "Remove the lock from the locktable " |
| 402 | "having sessionID=" |
| 403 | << sessionId; |
| 404 | BMCWEB_LOG_DEBUG << "TransactionID =" << it->first; |
| 405 | it = lockTable.erase(it); |
| 406 | isErased = true; |
| 407 | } |
| 408 | else |
| 409 | { |
| 410 | it++; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | if (isErased) |
| 415 | { |
| 416 | // save the lock in the persistent file |
| 417 | saveLocks(); |
| 418 | } |
| 419 | } |
| 420 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 421 | inline RcRelaseLock Lock::isItMyLock(const ListOfTransactionIds& refRids, |
| 422 | const SessionFlags& ids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 423 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 424 | for (const auto& id : refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 425 | { |
| 426 | // Just need to compare the client id of the first lock records in the |
| 427 | // complete lock row(in the map), because the rest of the lock records |
| 428 | // would have the same client id |
| 429 | |
| 430 | std::string expectedClientId = std::get<1>(lockTable[id][0]); |
| 431 | std::string expectedSessionId = std::get<0>(lockTable[id][0]); |
| 432 | |
| 433 | if ((expectedClientId == ids.first) && |
| 434 | (expectedSessionId == ids.second)) |
| 435 | { |
| 436 | // It is owned by the currently request hmc |
| 437 | BMCWEB_LOG_DEBUG << "Lock is owned by the current hmc"; |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | BMCWEB_LOG_DEBUG << "Lock is not owned by the current hmc"; |
| 442 | return std::make_pair(false, std::make_pair(id, lockTable[id][0])); |
| 443 | } |
| 444 | } |
| 445 | return std::make_pair(true, std::make_pair(0, LockRequest())); |
| 446 | } |
| 447 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 448 | inline bool Lock::validateRids(const ListOfTransactionIds& refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 449 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 450 | for (const auto& id : refRids) |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 451 | { |
| 452 | auto search = lockTable.find(id); |
| 453 | |
| 454 | if (search != lockTable.end()) |
| 455 | { |
| 456 | BMCWEB_LOG_DEBUG << "Valid Transaction id"; |
| 457 | // continue for the next rid |
| 458 | } |
| 459 | else |
| 460 | { |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 461 | BMCWEB_LOG_DEBUG << "At least 1 inValid Request id"; |
manojkiraneda | 3b6dea6 | 2019-12-13 17:05:36 +0530 | [diff] [blame] | 462 | return false; |
| 463 | } |
| 464 | } |
| 465 | return true; |
| 466 | } |
| 467 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 468 | inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 469 | { |
| 470 | |
| 471 | // validate the locktype |
| 472 | |
| 473 | if (!((boost::equals(std::get<2>(refLockRecord), "Read") || |
| 474 | (boost::equals(std::get<2>(refLockRecord), "Write"))))) |
| 475 | { |
| 476 | BMCWEB_LOG_DEBUG << "Validation of LockType Failed"; |
| 477 | BMCWEB_LOG_DEBUG << "Locktype : " << std::get<2>(refLockRecord); |
| 478 | return false; |
| 479 | } |
| 480 | |
| 481 | BMCWEB_LOG_DEBUG << static_cast<int>(std::get<4>(refLockRecord).size()); |
| 482 | |
| 483 | // validate the number of segments |
| 484 | // Allowed No of segments are between 2 and 6 |
| 485 | if ((static_cast<int>(std::get<4>(refLockRecord).size()) > 6) || |
| 486 | (static_cast<int>(std::get<4>(refLockRecord).size()) < 2)) |
| 487 | { |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 488 | BMCWEB_LOG_DEBUG << "Validation of Number of Segments Failed"; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 489 | BMCWEB_LOG_DEBUG << "Number of Segments provied : " |
Ed Tanous | 7cd94e4 | 2020-09-29 16:03:02 -0700 | [diff] [blame] | 490 | << std::get<4>(refLockRecord).size(); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 491 | return false; |
| 492 | } |
| 493 | |
| 494 | int lockFlag = 0; |
| 495 | // validate the lockflags & segment length |
| 496 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 497 | for (const auto& p : std::get<4>(refLockRecord)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 498 | { |
| 499 | |
| 500 | // validate the lock flags |
| 501 | // Allowed lockflags are locksame,lockall & dontlock |
| 502 | |
| 503 | if (!((boost::equals(p.first, "LockSame") || |
| 504 | (boost::equals(p.first, "LockAll")) || |
| 505 | (boost::equals(p.first, "DontLock"))))) |
| 506 | { |
| 507 | BMCWEB_LOG_DEBUG << "Validation of lock flags failed"; |
| 508 | BMCWEB_LOG_DEBUG << p.first; |
| 509 | return false; |
| 510 | } |
| 511 | |
| 512 | // validate the segment length |
| 513 | // Allowed values of segment length are between 1 and 4 |
| 514 | |
| 515 | if (p.second < 1 || p.second > 4) |
| 516 | { |
| 517 | BMCWEB_LOG_DEBUG << "Validation of Segment Length Failed"; |
| 518 | BMCWEB_LOG_DEBUG << p.second; |
| 519 | return false; |
| 520 | } |
| 521 | |
| 522 | if ((boost::equals(p.first, "LockSame") || |
| 523 | (boost::equals(p.first, "LockAll")))) |
| 524 | { |
| 525 | ++lockFlag; |
| 526 | if (lockFlag >= 2) |
| 527 | { |
| 528 | return false; |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 533 | return true; |
| 534 | } |
| 535 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 536 | inline Rc Lock::isConflictWithTable(const LockRequests& refLockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 537 | { |
| 538 | |
| 539 | uint32_t transactionId; |
| 540 | |
| 541 | if (lockTable.empty()) |
| 542 | { |
| 543 | transactionId = generateTransactionId(); |
| 544 | BMCWEB_LOG_DEBUG << transactionId; |
| 545 | // Lock table is empty, so we are safe to add the lockrecords |
| 546 | // as there will be no conflict |
| 547 | BMCWEB_LOG_DEBUG << "Lock table is empty, so adding the lockrecords"; |
| 548 | lockTable.emplace(std::pair<uint32_t, LockRequests>( |
| 549 | transactionId, refLockRequestStructure)); |
| 550 | |
Sunitha Harish | 8a3bb71 | 2019-12-13 03:48:09 -0600 | [diff] [blame] | 551 | // save the lock in the persistent file |
| 552 | saveLocks(); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 553 | return std::make_pair(false, transactionId); |
| 554 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 555 | BMCWEB_LOG_DEBUG |
| 556 | << "Lock table is not empty, check for conflict with lock table"; |
| 557 | // Lock table is not empty, compare the lockrequest entries with |
| 558 | // the entries in the lock table |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 559 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 560 | for (const auto& lockRecord1 : refLockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 561 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 562 | for (const auto& map : lockTable) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 563 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 564 | for (const auto& lockRecord2 : map.second) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 565 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 566 | bool status = isConflictRecord(lockRecord1, lockRecord2); |
| 567 | if (status) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 568 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 569 | return std::make_pair( |
| 570 | true, std::make_pair(map.first, lockRecord2)); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 571 | } |
| 572 | } |
| 573 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 574 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 575 | |
| 576 | // Reached here, so no conflict with the locktable, so we are safe to |
| 577 | // add the request records into the lock table |
| 578 | |
| 579 | // Lock table is empty, so we are safe to add the lockrecords |
| 580 | // as there will be no conflict |
| 581 | BMCWEB_LOG_DEBUG << " Adding elements into lock table"; |
| 582 | transactionId = generateTransactionId(); |
| 583 | lockTable.emplace(std::make_pair(transactionId, refLockRequestStructure)); |
| 584 | |
| 585 | // save the lock in the persistent file |
| 586 | saveLocks(); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 587 | return std::make_pair(false, transactionId); |
| 588 | } |
| 589 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 590 | inline bool Lock::isConflictRequest(const LockRequests& refLockRequestStructure) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 591 | { |
| 592 | // check for all the locks coming in as a part of single request |
| 593 | // return conflict if any two lock requests are conflicting |
| 594 | |
| 595 | if (refLockRequestStructure.size() == 1) |
| 596 | { |
| 597 | BMCWEB_LOG_DEBUG << "Only single lock request, so there is no conflict"; |
| 598 | // This means , we have only one lock request in the current |
| 599 | // request , so no conflict within the request |
| 600 | return false; |
| 601 | } |
| 602 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 603 | BMCWEB_LOG_DEBUG |
| 604 | << "There are multiple lock requests coming in a single request"; |
| 605 | |
| 606 | // There are multiple requests a part of one request |
| 607 | |
| 608 | for (uint32_t i = 0; i < refLockRequestStructure.size(); i++) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 609 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 610 | for (uint32_t j = i + 1; j < refLockRequestStructure.size(); j++) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 611 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 612 | const LockRequest& p = refLockRequestStructure[i]; |
| 613 | const LockRequest& q = refLockRequestStructure[j]; |
| 614 | bool status = isConflictRecord(p, q); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 615 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 616 | if (status) |
| 617 | { |
| 618 | return true; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 619 | } |
| 620 | } |
| 621 | } |
| 622 | return false; |
| 623 | } |
| 624 | |
| 625 | // This function converts the provided uint64_t resource id's from the two |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 626 | // lock requests subjected for comparison, and this function also compares |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 627 | // the content by bytes mentioned by a uint32_t number. |
| 628 | |
| 629 | // If all the elements in the lock requests which are subjected for comparison |
Gunnar Mills | caa3ce3 | 2020-07-08 14:46:53 -0500 | [diff] [blame] | 630 | // are same, then the last comparison would be to check for the respective |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 631 | // bytes in the resourceid based on the segment length. |
| 632 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 633 | inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2, |
| 634 | uint32_t position) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 635 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 636 | uint8_t* p = reinterpret_cast<uint8_t*>(&resourceId1); |
| 637 | uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2); |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 638 | |
| 639 | BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(p[position]) << "," |
| 640 | << std::to_string(q[position]); |
| 641 | if (p[position] != q[position]) |
| 642 | { |
| 643 | return false; |
| 644 | } |
| 645 | |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 646 | return true; |
| 647 | } |
| 648 | |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 649 | inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1, |
| 650 | const LockRequest& refLockRecord2) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 651 | { |
| 652 | // No conflict if both are read locks |
| 653 | |
| 654 | if (boost::equals(std::get<2>(refLockRecord1), "Read") && |
| 655 | boost::equals(std::get<2>(refLockRecord2), "Read")) |
| 656 | { |
| 657 | BMCWEB_LOG_DEBUG << "Both are read locks, no conflict"; |
| 658 | return false; |
| 659 | } |
| 660 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 661 | uint32_t i = 0; |
| 662 | for (const auto& p : std::get<4>(refLockRecord1)) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 663 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 664 | |
| 665 | // return conflict when any of them is try to lock all resources |
| 666 | // under the current resource level. |
| 667 | if (boost::equals(p.first, "LockAll") || |
| 668 | boost::equals(std::get<4>(refLockRecord2)[i].first, "LockAll")) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 669 | { |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 670 | BMCWEB_LOG_DEBUG |
| 671 | << "Either of the Comparing locks are trying to lock all " |
| 672 | "resources under the current resource level"; |
| 673 | return true; |
| 674 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 675 | |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 676 | // determine if there is a lock-all-with-same-segment-size. |
| 677 | // If the current segment sizes are the same,then we should fail. |
| 678 | |
| 679 | if ((boost::equals(p.first, "LockSame") || |
| 680 | boost::equals(std::get<4>(refLockRecord2)[i].first, "LockSame")) && |
| 681 | (p.second == std::get<4>(refLockRecord2)[i].second)) |
| 682 | { |
| 683 | return true; |
| 684 | } |
| 685 | |
| 686 | // if segment lengths are not the same, it means two different locks |
| 687 | // So no conflict |
| 688 | if (p.second != std::get<4>(refLockRecord2)[i].second) |
| 689 | { |
| 690 | BMCWEB_LOG_DEBUG << "Segment lengths are not same"; |
| 691 | BMCWEB_LOG_DEBUG << "Segment 1 length : " << p.second; |
| 692 | BMCWEB_LOG_DEBUG << "Segment 2 length : " |
| 693 | << std::get<4>(refLockRecord2)[i].second; |
| 694 | return false; |
| 695 | } |
| 696 | |
| 697 | // compare segment data |
| 698 | |
| 699 | for (uint32_t i = 0; i < p.second; i++) |
| 700 | { |
| 701 | // if the segment data is different , then the locks is on a |
| 702 | // different resource So no conflict between the lock |
| 703 | // records. |
| 704 | // BMC is little endian , but the resourceID is formed by |
| 705 | // the Management Console in such a way that, the first byte |
| 706 | // from the MSB Position corresponds to the First Segment |
| 707 | // data. Therefore we need to convert the in-comming |
| 708 | // resourceID into Big Endian before processing further. |
| 709 | if (!(checkByte( |
| 710 | boost::endian::endian_reverse(std::get<3>(refLockRecord1)), |
| 711 | boost::endian::endian_reverse(std::get<3>(refLockRecord2)), |
| 712 | i))) |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 713 | { |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 714 | return false; |
| 715 | } |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 716 | } |
Ed Tanous | 3174e4d | 2020-10-07 11:41:22 -0700 | [diff] [blame] | 717 | |
| 718 | ++i; |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | return false; |
| 722 | } |
| 723 | |
Ratan Gupta | 07386c6 | 2019-12-14 14:06:09 +0530 | [diff] [blame] | 724 | inline uint32_t Lock::generateTransactionId() |
manojkiraneda | 0b631ae | 2019-12-03 17:54:28 +0530 | [diff] [blame] | 725 | { |
| 726 | ++transactionId; |
| 727 | return transactionId; |
| 728 | } |
| 729 | |
| 730 | } // namespace ibm_mc_lock |
| 731 | } // namespace crow |