diff --git a/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h b/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h index 8183736ea2e6e7022c7007e3ff2fec0b082f2ea3..6a1e99480351e2178fbee29e24a6c82774ce7740 100644 --- a/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h +++ b/services/cloudfiledaemon/include/fuse_manager/cloud_daemon_statistic.h @@ -24,6 +24,12 @@ #define OPEN_TIME_MAX 7 #define READ_SIZE_MAX 6 #define READ_TIME_MAX 10 +#define VIDEO_READ_INFO 2 + +enum VideoReadInfoIndex { + CACHE_SUM = 0, + READ_SUM, +}; namespace OHOS { namespace FileManagement { @@ -42,6 +48,7 @@ public: void UpdateReadSizeStat(uint64_t size); void UpdateReadTimeStat(uint64_t size, uint64_t time); void UpdateStatData(); + void UpdateReadInfo(uint32_t index); mutex mutex_; private: CloudDaemonStatistic() = default; @@ -55,6 +62,7 @@ private: vector readSizeStat_ = vector(READ_SIZE_MAX, 0); vector> readTimeStat_ = vector>(READ_SIZE_MAX, vector(READ_TIME_MAX, 0)); + vector videoReadInfo_ = vector(VIDEO_READ_INFO, 0); }; } // namespace CloudFile } // namespace FileManagement diff --git a/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp b/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp index 6e0d44bb50655b0c583e11d8ef05a46b816a7f70..ece0380535fa621899054bcc3f84479a622b33f6 100644 --- a/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp +++ b/services/cloudfiledaemon/src/fuse_manager/cloud_daemon_statistic.cpp @@ -107,6 +107,14 @@ void CloudDaemonStatistic::UpdateReadTimeStat(uint64_t size, uint64_t time) CheckOverflow(readTimeStat_[indexSize][indexTime], 1); } +void CloudDaemonStatistic::UpdateReadInfo(uint32_t index) +{ + if (index >= VIDEO_READ_INFO) { + return; + } + CheckOverflow(videoReadInfo_[index], 1); +} + void CloudDaemonStatistic::AddFileData() { /* file not exist means first time, no former data, normal case */ @@ -142,6 +150,10 @@ void CloudDaemonStatistic::AddFileData() CheckOverflow(readTimeStat_[i][j], tmpData); } } + for (uint32_t i = 0; i < VIDEO_READ_INFO; i++) { + statDataFile >> tmpData; + CheckOverflow(videoReadInfo_[i], tmpData); + } statDataFile.close(); } @@ -200,6 +212,12 @@ void CloudDaemonStatistic::OutputToFile() tmpStr += "\n"; } statDataFile << tmpStr << endl; + tmpStr = ""; + + for (uint32_t i = 0; i < VIDEO_READ_INFO; i++) { + tmpStr += (to_string(videoReadInfo_[i]) + " "); + } + statDataFile << tmpStr << endl; statDataFile.close(); } @@ -221,6 +239,9 @@ void CloudDaemonStatistic::ClearStat() readTimeStat_[i][j] = 0; } } + for (uint32_t i = 0; i < VIDEO_READ_INFO; i++) { + videoReadInfo_[i] = 0; + } } void CloudDaemonStatistic::UpdateStatData() diff --git a/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp b/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp index 0d34b12b39d1b68002b3e251922989e90e5f3190..d0e93c172b75cf9ed06ca32d2dc97b9f405d1013 100644 --- a/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp +++ b/services/cloudfiledaemon/src/fuse_manager/fuse_manager.cpp @@ -1190,6 +1190,8 @@ static bool CheckAndWait(pid_t pid, shared_ptr cInode, off_t off) lock, READ_TIMEOUT_S, [&] { return (it->flags & PG_UPTODATE) || CheckReadIsCanceled(pid, cInode); }); if (!waitStatus) { LOGE("CheckAndWait timeout: %{public}ld", static_cast(cacheIndex)); + CLOUD_FILE_FAULT_REPORT(CloudFileFaultInfo{PHOTOS_BUNDLE_NAME, FaultOperation::Read, + FaultType::CLOUD_READ_FILE_TIMEOUT, ENETUNREACH, "network timeout"}); return false; } } @@ -1266,6 +1268,10 @@ static void CloudReadOnCloudFile(pid_t pid, CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); readStat.UpdateReadSizeStat(readArgs->size); readStat.UpdateReadTimeStat(readArgs->size, readTime); + if (IsVideoType(cInode->mBase->name)) { + LOGI("Video expansion, try to up video info read sum in CloudReadOnCloudFile"); + readStat.UpdateReadInfo(READ_SUM); + } { unique_lock lck(cInode->readLock); @@ -1325,6 +1331,8 @@ static void CloudReadOnCacheFile(shared_ptr readArgs, CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); readStat.UpdateReadSizeStat(readArgs->size); readStat.UpdateReadTimeStat(readArgs->size, readTime); + LOGI("Video expansion, try to up video info read sum in CloudReadOnCacheFile"); + readStat.UpdateReadInfo(READ_SUM); cInode->SetReadCacheFlag(cacheIndex, PG_UPTODATE); wSesLock.lock(); @@ -1503,6 +1511,9 @@ static bool DoReadSlice(fuse_req_t req, int64_t cacheIndex = readArgs->offset / MAX_READ_SIZE; struct FuseData *data = static_cast(fuse_req_userdata(req)); if (IsVideoType(cInode->mBase->name) && cInode->cacheFileIndex.get()[cacheIndex] == HAS_CACHED) { + CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); + LOGI("Video expansion, try to up video info cache sum in DoReadSlice"); + readStat.UpdateReadInfo(CACHE_SUM); LOGI("DoReadSlice from local: %{public}ld", static_cast(cacheIndex)); *readArgs->readResult = ReadCacheFile(readArgs, cInode->path, data); if (*readArgs->readResult >= 0) { @@ -1547,6 +1558,9 @@ static bool DoCloudRead(fuse_req_t req, int flags, DoCloudReadParams params) int64_t cacheIndex = static_cast( (params.readArgsTail ? params.readArgsTail->offset : params.readArgsHead->offset) / MAX_READ_SIZE + i); if (IsVideoType(params.cInode->mBase->name) && params.cInode->cacheFileIndex.get()[cacheIndex] == HAS_CACHED) { + CloudDaemonStatistic &readStat = CloudDaemonStatistic::GetInstance(); + LOGI("Video expansion, try to up video info cache sum in DoReadSlice"); + readStat.UpdateReadInfo(CACHE_SUM); continue; } auto readArgsCache = make_shared(0, cacheIndex * MAX_READ_SIZE, pid);