From dad26eef2cf1a4570a87a74e7a4cbf1823b86073 Mon Sep 17 00:00:00 2001
From: Hazeman <hazeman@skytechnology.pl>
Date: Mon, 22 May 2017 11:14:48 +0200
Subject: [PATCH] master: Fix dangling nodes in defective files list
This commit fixes dangling entries in defective files list.
Fixes #548
Change-Id: I3735fbbb1d7080f73db835196f993db31a4f1155
---
src/master/filesystem_node.cc | 2 ++
src/master/filesystem_periodic.cc | 11 +++++++++++
src/master/filesystem_periodic.h | 1 +
3 files changed, 14 insertions(+)
diff --git a/src/master/filesystem_node.cc b/src/master/filesystem_node.cc
index 7661738..8d1ef5c 100644
--- a/src/master/filesystem_node.cc
+++ b/src/master/filesystem_node.cc
@@ -34,6 +34,7 @@
#include "master/filesystem_freenode.h"
#include "master/filesystem_metadata.h"
#include "master/filesystem_operations.h"
+#include "master/filesystem_periodic.h"
#include "master/filesystem_quota.h"
#include "master/fs_context.h"
@@ -1119,6 +1120,7 @@ static inline void fsnodes_remove_node(uint32_t ts, FSNode *toremove) {
fsnodes_quota_update(toremove, {{QuotaResource::kInodes, -1}});
fsnodes_quota_remove(QuotaOwnerType::kInode, toremove->id);
#ifndef METARESTORE
+ fsnodes_periodic_remove(toremove->id);
dcm_modify(toremove->id, 0);
#endif
FSNode::destroy(toremove);
diff --git a/src/master/filesystem_periodic.cc b/src/master/filesystem_periodic.cc
index cb42ced..b8079aa 100644
--- a/src/master/filesystem_periodic.cc
+++ b/src/master/filesystem_periodic.cc
@@ -169,6 +169,10 @@ void fs_test_getdata(uint32_t &loopstart, uint32_t &loopend, uint32_t &files, ui
}
FSNode *node = fsnodes_id_to_node<FSNode>(entry.first);
+ if (!node) {
+ continue;
+ }
+
if (node->type == FSNode::kFile || node->type == FSNode::kTrash ||
node->type == FSNode::kReserved) {
FSNodeFile *file_node = static_cast<FSNodeFile *>(node);
@@ -490,6 +494,13 @@ void fs_background_file_test(void) {
}
}
}
+
+void fsnodes_periodic_remove(uint32_t inode) {
+ auto it = gDefectiveNodes.find(inode);
+ if (it != gDefectiveNodes.end()) {
+ gDefectiveNodes.erase(it);
+ }
+}
#endif
struct InodeInfo {
diff --git a/src/master/filesystem_periodic.h b/src/master/filesystem_periodic.h
index 1ef4e40..aa36f6e 100644
--- a/src/master/filesystem_periodic.h
+++ b/src/master/filesystem_periodic.h
@@ -33,3 +33,4 @@ void fs_periodic_master_init();
void fs_test_getdata(uint32_t &loopstart, uint32_t &loopend, uint32_t &files, uint32_t &ugfiles,
uint32_t &mfiles, uint32_t &chunks, uint32_t &ugchunks, uint32_t &mchunks,
std::string &report);
+void fsnodes_periodic_remove(uint32_t inode);
--
2.9.4