| 1321 | } |
| 1322 | |
| 1323 | std::unique_ptr<Device> createFileDevice( |
| 1324 | std::vector<std::string> filePaths, |
| 1325 | uint64_t fdSize, |
| 1326 | bool truncateFile, |
| 1327 | uint32_t blockSize, |
| 1328 | uint32_t stripeSize, |
| 1329 | uint32_t maxDeviceWriteSize, |
| 1330 | IoEngine ioEngine, |
| 1331 | uint32_t qDepth, |
| 1332 | bool isFDPEnabled, |
| 1333 | std::shared_ptr<navy::DeviceEncryptor> encryptor, |
| 1334 | bool isExclusiveOwner) { |
| 1335 | // File paths are opened in the increasing order of the |
| 1336 | // path string. This ensures that RAID0 stripes aren't |
| 1337 | // out of order even if the caller changes the order of |
| 1338 | // the file paths. We can recover the cache as long as all |
| 1339 | // the paths are specified, regardless of the order. |
| 1340 | |
| 1341 | std::sort(filePaths.begin(), filePaths.end()); |
| 1342 | std::vector<folly::File> fileVec; |
| 1343 | fileVec.reserve(filePaths.size()); |
| 1344 | for (const auto& path : filePaths) { |
| 1345 | try { |
| 1346 | // TODO: beyondsora implement |
| 1347 | fileVec.emplace_back( |
| 1348 | openCacheFile(path, fdSize, truncateFile, isExclusiveOwner)); |
| 1349 | } catch (const std::exception& e) { |
| 1350 | XLOG(ERR) << "Exception in openCacheFile(" << path << "): " << e.what() |
| 1351 | << ". Errno: " << errno; |
| 1352 | throw; |
| 1353 | } |
| 1354 | } |
| 1355 | |
| 1356 | return createDirectIoFileDevice(std::move(fileVec), |
| 1357 | std::move(filePaths), |
| 1358 | fdSize, |
| 1359 | blockSize, |
| 1360 | stripeSize, |
| 1361 | maxDeviceWriteSize, |
| 1362 | ioEngine, |
| 1363 | qDepth, |
| 1364 | isFDPEnabled, |
| 1365 | std::move(encryptor)); |
| 1366 | } |
| 1367 | } // namespace facebook::cachelib::navy |