diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 43b53b832..16ba7aec1 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -3232,6 +3232,10 @@ void Oam::SuspendWrites(GRACEFUL_FLAG gracefulflag, ACK_FLAG ackflag) cout << endl << " Suspension of database writes canceled" << endl << endl; break; + case API_FAILURE: + cout << endl << " Suspension of database writes failed: Filesystem sync failed" << endl << endl; + break; + default: exceptionControl("suspendWrites", returnStatus); break; diff --git a/oam/oamcpp/liboamcpp.h b/oam/oamcpp/liboamcpp.h index ecdd76d50..51317bb14 100644 --- a/oam/oamcpp/liboamcpp.h +++ b/oam/oamcpp/liboamcpp.h @@ -581,7 +581,8 @@ enum PROC_MGT_TYPE_REQUEST DISABLEREP, PROCGLUSTERASSIGN, PROCGLUSTERUNASSIGN, - CONFIGURE + CONFIGURE, + SYNCFSALL }; diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index be3ae085e..d20edc473 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -2794,7 +2794,78 @@ void processMSG(messageqcpp::IOSocket* cfIos) string currentFileName = DBRMroot + "_current"; IDBFileSystem &fs = IDBPolicy::getFs(currentFileName.c_str()); - fs.filesystemSync(); + + if (!fs.filesystemSync()) + { + ackMsg << (ByteStream::byte) oam::ACK; + ackMsg << actionType; + ackMsg << target; + ackMsg << (ByteStream::byte) API_FAILURE; + + try + { + fIos.write(ackMsg); + } + catch (...) {} + + log.writeLog(__LINE__, "SUSPENDWRITES: API_FAILURE filestemSync()",LOG_TYPE_ERROR); + break; + } + //sync fs on all pm nodes if up + for ( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++) + { + if ( systemmoduletypeconfig.moduletypeconfig[i].ModuleType != "pm" ) + continue; + + int moduleCount = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount; + + if ( moduleCount == 0) + continue; + + DeviceNetworkList::iterator pt = systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.begin(); + + for ( ; pt != systemmoduletypeconfig.moduletypeconfig[i].ModuleNetworkList.end(); pt++) + { + int opState = oam::ACTIVE; + bool degraded; + + try + { + oam.getModuleStatus((*pt).DeviceName, opState, degraded); + } + catch (...) + { + log.writeLog(__LINE__, "EXCEPTION ERROR on getModuleStatus on module " + (*pt).DeviceName + ": Caught unknown exception!", LOG_TYPE_ERROR); + } + + if (opState == oam::MAN_DISABLED || opState == oam::AUTO_DISABLED) + continue; + + ByteStream msg; + ByteStream::byte requestID = SYNCFSALL; + + msg << requestID; + + int returnStatus = processManager.sendMsgProcMon( (*pt).DeviceName, msg, requestID ); + + if (returnStatus != API_SUCCESS) + { + ackMsg << (ByteStream::byte) oam::ACK; + ackMsg << actionType; + ackMsg << target; + ackMsg << (ByteStream::byte) API_FAILURE; + + try + { + fIos.write(ackMsg); + } + catch (...) {} + + log.writeLog(__LINE__, "SUSPENDWRITES: API_FAILURE filestemSync() on module " + (*pt).DeviceName,LOG_TYPE_ERROR); + break; + } + } + } } ackMsg.reset(); diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index d8445ab2b..08887c3ff 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -2072,6 +2072,19 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO break; } + case SYNCFSALL: + { + log.writeLog(__LINE__, "MSG RECEIVED: SYNC FileSystem..."); + int requestStatus = API_SUCCESS; + requestStatus = syncFS(); + ackMsg << (ByteStream::byte) ACK; + ackMsg << (ByteStream::byte) SHUTDOWNMODULE; + ackMsg << (ByteStream::byte) API_SUCCESS; + mq.write(ackMsg); + + log.writeLog(__LINE__, "SYNCFSALL: ACK back to ProcMgr, return status = " + oam.itoa((int) API_SUCCESS)); + break; + } default: break; @@ -6188,6 +6201,22 @@ int ProcessMonitor::glusterUnassign(std::string dbrootID) return oam::API_SUCCESS; } + +int ProcessMonitor::syncFS() +{ + Oam oam; + + string DBRMroot; + oam.getSystemConfig("DBRMRoot", DBRMroot); + + string currentFileName = DBRMroot + "_current"; + IDBFileSystem &fs = IDBPolicy::getFs(currentFileName.c_str()); + bool success = fs.filesystemSync(); + if (!success) + return oam::API_FAILURE; + return oam::API_SUCCESS; +} + } //end of namespace // vim:ts=4 sw=4: diff --git a/procmon/processmonitor.h b/procmon/processmonitor.h index 7984ac80c..57e90b1f4 100644 --- a/procmon/processmonitor.h +++ b/procmon/processmonitor.h @@ -542,6 +542,7 @@ public: */ int glusterUnassign(std::string dbrootID); + int syncFS(); /** * return the process list */