| 1242 | } |
| 1243 | |
| 1244 | std::unique_ptr<Device> createDirectIoFileDevice( |
| 1245 | std::vector<folly::File> fVec, |
| 1246 | std::vector<std::string> filePaths, |
| 1247 | uint64_t fileSize, |
| 1248 | uint32_t blockSize, |
| 1249 | uint32_t stripeSize, |
| 1250 | uint32_t maxDeviceWriteSize, |
| 1251 | IoEngine ioEngine, |
| 1252 | uint32_t qDepthPerContext, |
| 1253 | bool isFDPEnabled, |
| 1254 | std::shared_ptr<DeviceEncryptor> encryptor) { |
| 1255 | XDCHECK(folly::isPowTwo(blockSize)); |
| 1256 | |
| 1257 | uint32_t maxIOSize = maxDeviceWriteSize; |
| 1258 | std::vector<std::shared_ptr<FdpNvme>> fdpNvmeVec{}; |
| 1259 | #ifndef CACHELIB_IOURING_DISABLE |
| 1260 | if (isFDPEnabled) { |
| 1261 | try { |
| 1262 | if (filePaths.size() > 1) { |
| 1263 | throw std::invalid_argument(fmt::format( |
| 1264 | "{} input files; but FDP mode does not support RAID files yet", |
| 1265 | filePaths.size())); |
| 1266 | } |
| 1267 | |
| 1268 | for (const auto& path : filePaths) { |
| 1269 | auto fdpNvme = std::make_shared<FdpNvme>(path); |
| 1270 | |
| 1271 | auto maxDevIOSize = fdpNvme->getMaxIOSize(); |
| 1272 | if (maxDevIOSize != 0u && |
| 1273 | (maxIOSize == 0u || maxDevIOSize < maxIOSize)) { |
| 1274 | maxIOSize = maxDevIOSize; |
| 1275 | } |
| 1276 | |
| 1277 | fdpNvmeVec.push_back(std::move(fdpNvme)); |
| 1278 | } |
| 1279 | } catch (const std::exception& e) { |
| 1280 | XLOGF(ERR, "NVMe FDP mode could not be enabled {}, Errno: {}", e.what(), |
| 1281 | errno); |
| 1282 | fdpNvmeVec.clear(); |
| 1283 | maxIOSize = 0u; |
| 1284 | } |
| 1285 | } |
| 1286 | #endif |
| 1287 | |
| 1288 | if (maxIOSize != 0u) { |
| 1289 | maxDeviceWriteSize = std::min<size_t>(maxDeviceWriteSize, maxIOSize); |
| 1290 | } |
| 1291 | |
| 1292 | return std::make_unique<FileDevice>(std::move(fVec), |
| 1293 | std::move(fdpNvmeVec), |
| 1294 | fileSize, |
| 1295 | blockSize, |
| 1296 | stripeSize, |
| 1297 | maxIOSize, |
| 1298 | maxDeviceWriteSize, |
| 1299 | ioEngine, |
| 1300 | qDepthPerContext, |
| 1301 | encryptor); |
no test coverage detected