diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-01-17 19:50:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-17 19:50:07 +0200 |
commit | 50edeeeecd5a96a0c6a2bc9b28569fbd9284888a (patch) | |
tree | a04a38e7033bca74d8767c656dd5cbae5810f6b7 /database/engine/journalfile.c | |
parent | 7279dd092c23fbafcd7edb8ef7f3f79e1a0e5ecb (diff) |
fix for dbengine2 improvements part 3 (#14284)
return true when the file is already unmounted
Diffstat (limited to 'database/engine/journalfile.c')
-rw-r--r-- | database/engine/journalfile.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c index 5560bd21ea..52446f06fb 100644 --- a/database/engine/journalfile.c +++ b/database/engine/journalfile.c @@ -174,19 +174,21 @@ static bool journalfile_v2_mounted_data_unmount(struct rrdengine_journalfile *jo netdata_spinlock_lock(&journalfile->v2.spinlock); } - if(!journalfile->v2.refcount && journalfile->mmap.data) { - if (munmap(journalfile->mmap.data, journalfile->mmap.size)) { - char path[RRDENG_PATH_MAX]; - journalfile_v2_generate_path(journalfile->datafile, path, sizeof(path)); - error("DBENGINE: failed to unmap index file '%s'", path); - internal_fatal(true, "DBENGINE: failed to unmap file '%s'", path); - ++journalfile->datafile->ctx->stats.fs_errors; - rrd_stat_atomic_add(&global_fs_errors, 1); - } - else { - __atomic_add_fetch(&rrdeng_cache_efficiency_stats.journal_v2_unmapped, 1, __ATOMIC_RELAXED); - journalfile->mmap.data = NULL; - journalfile->v2.flags &= ~JOURNALFILE_FLAG_IS_MOUNTED; + if(!journalfile->v2.refcount) { + if(journalfile->mmap.data) { + if (munmap(journalfile->mmap.data, journalfile->mmap.size)) { + char path[RRDENG_PATH_MAX]; + journalfile_v2_generate_path(journalfile->datafile, path, sizeof(path)); + error("DBENGINE: failed to unmap index file '%s'", path); + internal_fatal(true, "DBENGINE: failed to unmap file '%s'", path); + ++journalfile->datafile->ctx->stats.fs_errors; + rrd_stat_atomic_add(&global_fs_errors, 1); + } + else { + __atomic_add_fetch(&rrdeng_cache_efficiency_stats.journal_v2_unmapped, 1, __ATOMIC_RELAXED); + journalfile->mmap.data = NULL; + journalfile->v2.flags &= ~JOURNALFILE_FLAG_IS_MOUNTED; + } } unmounted = true; |