Commit 543268ec authored by Christian Mohrbacher's avatar Christian Mohrbacher

updated to release 6.4

parent f573f225
......@@ -7,6 +7,9 @@
#include <errno.h>
#include <fcntl.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
#define BEEGFS_API_MAJOR_VERSION 1 // major version number of the API, different major version
// are incompatible
......
......@@ -2,7 +2,7 @@
export dirname=$(dirname "$0")
export version="6.0-beta"
export version="6"
export logFile=/var/log/beegfs-setup.log
......
......@@ -38,7 +38,7 @@ BEEGFS_DECLARE_FAULT_ATTR(commkit_writefile_senddata_timeout);
bool beegfs_fault_inject_init()
{
debug_dir = debugfs_create_dir("beegfs", NULL);
debug_dir = debugfs_create_dir(BEEGFS_MODULE_NAME_STR, NULL);
if(!debug_dir)
goto err_debug_dir;
......
......@@ -1366,8 +1366,10 @@ int FhgfsOps_unlink(struct inode* dir, struct dentry* dentry)
FhgfsInode_invalidateCache(fhgfsInode);
fileInode->i_ctime = dir->i_ctime;
drop_nlink(fileInode);
spin_lock(&fileInode->i_lock);
drop_nlink(fileInode);
spin_unlock(&fileInode->i_lock);
}
}
......@@ -1542,7 +1544,6 @@ int FhgfsOps_link(struct dentry* fromFileDentry, struct inode* toDirInode,
// TODO: Remove it here once we support inter directory hard-links
ihold(fileInode);
inc_nlink(fileInode);
linkRes = FhgfsOpsRemoting_hardlink(app, fromFileName, fromFileLen, fromFileInfo,
fromDirInfo, toFileName, toFileLen, toDirInfo);
......@@ -1553,10 +1554,13 @@ int FhgfsOps_link(struct dentry* fromFileDentry, struct inode* toDirInode,
{
d_drop(toFileDentry);
iput(fileInode);
drop_nlink(fileInode);
}
else
{
spin_lock(&fileInode->i_lock);
inc_nlink(fileInode);
spin_unlock(&fileInode->i_lock);
d_instantiate(toFileDentry, fileInode);
}
}
......@@ -1838,7 +1842,8 @@ int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
"From: %s; To: %s", oldName, newName);
FhgfsInode_entryInfoReadLock(fhgfsFromDirInode); // LOCK EntryInfo
FhgfsInode_entryInfoReadLock(fhgfsToDirInode); // LOCK EntryInfo
if (fhgfsFromDirInode != fhgfsToDirInode)
FhgfsInode_entryInfoReadLock(fhgfsToDirInode); // LOCK EntryInfo
// note the fileInode also needs to be locked to prevent reference/release during a rename
FhgfsInode_entryInfoWriteLock(fhgfsFromEntryInode); // LOCK EntryInfo (renamed file dir)
......@@ -1881,7 +1886,8 @@ int FhgfsOps_rename(struct inode* inodeDirFrom, struct dentry* dentryFrom,
}
FhgfsInode_entryInfoWriteUnlock(fhgfsFromEntryInode); // UNLOCK EntryInfo (renamed file dir)
FhgfsInode_entryInfoReadUnlock(fhgfsToDirInode); // UNLOCK ToDirEntryInfo
if (fhgfsFromDirInode != fhgfsToDirInode)
FhgfsInode_entryInfoReadUnlock(fhgfsToDirInode); // UNLOCK ToDirEntryInfo
FhgfsInode_entryInfoReadUnlock(fhgfsFromDirInode); // UNLOCK FromDirEntryInfo
LOG_DEBUG_FORMATTED(log, Log_DEBUG, logContext, "remoting complete. result: %d", (int)renameRes);
......
......@@ -562,6 +562,7 @@ long FhgfsOpsIoctl_mkfileWithStripeHints(struct file *file, void __user *argp)
long retVal;
const char __user* userFilename;
char* filename;
int mode; // mode (permission) of the new file
unsigned numtargets; // number of desired targets, 0 for directory default
......@@ -615,6 +616,9 @@ long FhgfsOpsIoctl_mkfileWithStripeHints(struct file *file, void __user *argp)
if(cpRes)
return -EFAULT;
if (get_user(userFilename, &mkfileArg->filename))
return -EFAULT;
{ // check if chunksize is valid
if(unlikely( (chunksize < STRIPEPATTERN_MIN_CHUNKSIZE) ||
!MathTk_isPowerOfTwo(chunksize) ) )
......@@ -630,7 +634,7 @@ long FhgfsOpsIoctl_mkfileWithStripeHints(struct file *file, void __user *argp)
// copy filename
filename = strndup_user(mkfileArg->filename, BEEGFS_IOCTL_FILENAME_MAXLEN);
filename = strndup_user(userFilename, BEEGFS_IOCTL_FILENAME_MAXLEN);
if(IS_ERR(filename) )
{
retVal = PTR_ERR(filename);
......@@ -773,6 +777,12 @@ static long FhgfsOpsIoctl_createFile(struct file *file, void __user *argp, bool
{
EntryInfo newEntryInfo; // only needed as mandatory argument
if (!fileInfo.symlinkTo)
{
retVal = -EINVAL;
goto cleanup;
}
down_read(&inode->i_sb->s_umount);
mkRes = FhgfsOpsHelper_symlink(app, &parentInfo, fileInfo.symlinkTo,
......@@ -808,12 +818,14 @@ cleanup:
SAFE_KFREE(fileInfo.entryName);
SAFE_KFREE(fileInfo.symlinkTo);
SAFE_KFREE(fileInfo.prefTargets);
if(createInfo.preferredStorageTargets != App_getPreferredStorageTargets(app) )
if (createInfo.preferredStorageTargets &&
createInfo.preferredStorageTargets != App_getPreferredStorageTargets(app) )
{
UInt16List_uninit(createInfo.preferredStorageTargets);
SAFE_KFREE(createInfo.preferredStorageTargets);
}
if(createInfo.preferredMetaTargets != App_getPreferredMetaNodes(app) )
if (createInfo.preferredMetaTargets &&
createInfo.preferredMetaTargets != App_getPreferredMetaNodes(app) )
{
UInt16List_uninit(createInfo.preferredMetaTargets);
SAFE_KFREE(createInfo.preferredMetaTargets);
......
......@@ -8,6 +8,8 @@
#define STRDUP_OR_RETURN(target, source, len, name) \
do { \
if ((len) == 0) \
return -EINVAL; \
(target) = strndup_user((const char __user *) (source), (len)); \
if (IS_ERR((target))) \
{ \
......
......@@ -25,6 +25,8 @@ static mempool_t* headerBufferPool;
bool FhgfsOpsCommKit_initEmergencyPools()
{
const char* cacheName = BEEGFS_MODULE_NAME_STR "-msgheaders";
if(BEEGFS_COMMKIT_MSGBUF_SIZE > PAGE_SIZE)
{
WARN_ON(1);
......@@ -32,10 +34,10 @@ bool FhgfsOpsCommKit_initEmergencyPools()
}
#ifdef KERNEL_HAS_KMEMCACHE_DTOR
headerBufferCache = kmem_cache_create("beegfs-msgheaders", BEEGFS_COMMKIT_MSGBUF_SIZE, 0,
headerBufferCache = kmem_cache_create(cacheName, BEEGFS_COMMKIT_MSGBUF_SIZE, 0,
SLAB_MEM_SPREAD, NULL, NULL);
#else
headerBufferCache = kmem_cache_create("beegfs-msgheaders", BEEGFS_COMMKIT_MSGBUF_SIZE, 0,
headerBufferCache = kmem_cache_create(cacheName, BEEGFS_COMMKIT_MSGBUF_SIZE, 0,
SLAB_MEM_SPREAD, NULL);
#endif
......
#include <common/app/log/Logger.h>
#include <common/app/AbstractApp.h>
#include <libgen.h>
#include <new>
#include "TempFileTk.h"
namespace TempFileTk {
/**
* Stores data to a temporary file first, and then moves it over to the final filename. This
* ensures that there's always a consistent file on disk, even if the program is aborted halfway
* through the write process.
* @param filename the name of the final file. If the file exists, it will be overwritten.
* @param contents data to write to the file
*/
FhgfsOpsErr storeTmpAndMove(const std::string& filename, const std::string& contents)
{
// Need a copy of the string, because the Xs will be replaced by mkstemp.
std::string tmpname = filename + ".tmp-XXXXXX\0"; // terminating 0 needed for c library calls
// Open temp file
int fd = mkstemp(&tmpname[0]);
if (fd == -1)
{
FhgfsOpsErr err = FhgfsOpsErrTk::fromSysErr(errno);
LOG(ERR, "Could not open temporary file.", tmpname,
as("sysErr", FhgfsOpsErrTk::toErrString(err)));
return err;
}
// Write to temp file
ssize_t written = 0;
while (written < (ssize_t)contents.length())
{
ssize_t writeRes = write(fd, contents.c_str() + written, contents.length() - written);
if (writeRes == -1)
{
FhgfsOpsErr err = FhgfsOpsErrTk::fromSysErr(errno);
LOG(ERR, "Could not write to temporary file", tmpname,
as("sysErr", FhgfsOpsErrTk::toErrString(err)));
return err;
}
written += writeRes;
}
fsync(fd);
close(fd);
// Move temp file over final file
int renameRes = rename(tmpname.c_str(), filename.c_str());
if (renameRes == -1)
{
FhgfsOpsErr err = FhgfsOpsErrTk::fromSysErr(errno);
LOG(ERR, "Renaming failed.", as("from", tmpname), as("to", filename),
as("sysErr", FhgfsOpsErrTk::toErrString(err)));
return err;
}
// Sync directory
char* dirName = dirname(&tmpname[0]); // manpage says: dirname may modify the contents
int dirFd = open(dirName, O_DIRECTORY | O_RDONLY);
if (dirFd == -1)
{
FhgfsOpsErr err = FhgfsOpsErrTk::fromSysErr(errno);
LOG(ERR, "Could not write to temporary file", tmpname,
as("sysErr", FhgfsOpsErrTk::toErrString(err)));
return err;
}
fsync(dirFd);
close(dirFd);
return FhgfsOpsErr_SUCCESS;
}
};
#ifndef COMMON_TEMPFILETK_H_
#define COMMON_TEMPFILETK_H_
#include <common/storage/StorageErrors.h>
namespace TempFileTk {
FhgfsOpsErr storeTmpAndMove(const std::string& filename, const std::string& contents);
};
#endif /* COMMON_TEMPFILETK_H_ */
......@@ -1034,6 +1034,10 @@ void App::stopComponents()
// changed modification state.
modificationEventFlusher->selfTerminate();
// resyncer wants to control the workers, so any running resync must be finished or aborted
// before the workers are stopped.
buddyResyncer->shutdown();
workersStop();
if(internodeSyncer)
......
......@@ -529,9 +529,12 @@ void InternodeSyncer::syncClients(const std::vector<NodeHandle>& clientsList, bo
if(removedSessionFiles.size() || referencedSessionFiles.size() )
{
std::ostringstream logMsgStream;
logMsgStream << sessionID << ": Removing " << removedSessionFiles.size() <<
" file sessions. " << "(" << referencedSessionFiles.size() << " are unremovable)";
LogContext(logContext).log(Log_NOTICE, logMsgStream.str() );
logMsgStream << "Removing " << removedSessionFiles.size() << " file sessions. ("
<< referencedSessionFiles.size() << " are unremovable). clientNumID: " << sessionID;
if (referencedSessionFiles.empty())
LogContext(logContext).log(Log_SPAM, logMsgStream.str() );
else
LogContext(logContext).log(Log_NOTICE, logMsgStream.str() );
}
......@@ -579,7 +582,7 @@ void InternodeSyncer::syncClients(const std::vector<NodeHandle>& clientsList, bo
MsgHelperClose::closeChunkFile(sessionID, fileHandleID.c_str(),
maxUsedNodesIndex, *inode, entryInfo, NETMSG_DEFAULT_USERID);
LogContext(logContext).log(Log_NOTICE, std::string("closing file ") + "ParentID: " +
LogContext(logContext).log(Log_NOTICE, "closing file. ParentID: " +
entryInfo->getParentEntryID() + " FileName: " + entryInfo->getFileName() );
metaStore->closeFile(entryInfo, std::move(inode), accessFlags, &numHardlinks,
......
......@@ -6,6 +6,7 @@
#include <common/net/message/storage/mirroring/StorageResyncStartedMsg.h>
#include <common/net/message/storage/mirroring/StorageResyncStartedRespMsg.h>
#include <common/threading/Barrier.h>
#include <common/toolkit/DebugVariable.h>
#include <common/toolkit/SynchronizedCounter.h>
#include <app/App.h>
......@@ -67,6 +68,16 @@ void BuddyResyncJob::run()
goto cleanup;
}
DEBUG_ENV_VAR(unsigned, DIE_AT_RESYNC_N, 0, "BEEGFS_RESYNC_DIE_AT_N");
if (DIE_AT_RESYNC_N) {
static unsigned resyncs = 0;
// for #479: terminating a server at this point caused the workers to terminate before the
// resyncer had communicated with them, causing a deadlock on shutdown
if (++resyncs == DIE_AT_RESYNC_N) {
::kill(0, SIGTERM);
sleep(4);
}
}
stopAllWorkersOn(workerBarrier);
{
// Notify buddy that resync started and wait for confirmation
......@@ -86,13 +97,27 @@ void BuddyResyncJob::run()
SAFE_DELETE(respMsg);
SAFE_DELETE(respBuf);
setState(BuddyResyncJobState_RUNNING);
// resync could have been aborted before we got here. if so, exit as soon as possible without
// setting the resync job state to something else.
{
std::unique_lock<Mutex> lock(stateMutex);
if (state == BuddyResyncJobState_INTERRUPTED)
{
lock.unlock();
workerBarrier.wait();
goto cleanup;
}
state = BuddyResyncJobState_RUNNING;
}
internodeSyncer->setResyncInProgress(true);
const bool startGatherSlaveRes = startGatherSlaves();
if (!startGatherSlaveRes)
{
setState(BuddyResyncJobState_FAILURE);
workerBarrier.wait();
goto cleanup;
}
......@@ -100,6 +125,7 @@ void BuddyResyncJob::run()
if (!startResyncSlaveRes)
{
setState(BuddyResyncJobState_FAILURE);
workerBarrier.wait();
goto cleanup;
}
}
......
......@@ -19,6 +19,9 @@ FhgfsOpsErr BuddyResyncer::startResync()
{
std::lock_guard<Mutex> lock(jobMutex);
if (noNewResyncs)
return FhgfsOpsErr_INTERRUPTED;
if (!job)
{
job = new BuddyResyncJob();
......@@ -49,6 +52,25 @@ FhgfsOpsErr BuddyResyncer::startResync()
}
}
void BuddyResyncer::shutdown()
{
std::unique_ptr<BuddyResyncJob> job;
{
std::lock_guard<Mutex> lock(jobMutex);
job.reset(this->job);
this->job = nullptr;
noNewResyncs = true;
}
if (job)
{
job->abort();
job->join();
}
}
void BuddyResyncer::commitThreadChangeSet()
{
BEEGFS_BUG_ON(!currentThreadChangeSet, "no change set active");
......
......@@ -18,12 +18,13 @@ class BuddyResyncer
{
public:
BuddyResyncer()
: job(NULL)
: job(NULL), noNewResyncs(false)
{ }
~BuddyResyncer();
FhgfsOpsErr startResync();
void shutdown();
static void commitThreadChangeSet();
......@@ -60,6 +61,8 @@ class BuddyResyncer
private:
static __thread MetaSyncCandidateFile* currentThreadChangeSet;
bool noNewResyncs;
// No copy allowed
BuddyResyncer(const BuddyResyncer&);
BuddyResyncer& operator=(const BuddyResyncer&);
......
......@@ -117,6 +117,7 @@ FhgfsOpsErr BuddyResyncerModSyncSlave::streamCandidates(Socket& socket)
// reuse the current stream, but terminating a stream that has seen an error is simpler
// to handle than keeping it open. also, bulk resync would like "fail on error"
// semantics very much.
sendResyncPacket(socket, std::tuple<>());
return FhgfsOpsErr_SUCCESS;
}
else
......
......@@ -4,10 +4,11 @@
bool GetFileVersionMsgEx::processIncoming(ResponseContext& ctx)
{
auto& metaStore = *Program::getApp()->getMetaStore();
LOG_DBG(DEBUG, "Received a GetFileVersionMsg.", ctx.peerName());
LOG_DBG(DEBUG, "", getEntryInfo().getEntryID(), getEntryInfo().getIsBuddyMirrored());
auto inode = Program::getApp()->getMetaStore()->referenceFile(&getEntryInfo());
auto inode = metaStore.referenceFile(&getEntryInfo());
if (!inode)
{
ctx.sendResponse(GetFileVersionRespMsg(FhgfsOpsErr_INTERNAL, 0));
......@@ -15,5 +16,6 @@ bool GetFileVersionMsgEx::processIncoming(ResponseContext& ctx)
}
ctx.sendResponse(GetFileVersionRespMsg(FhgfsOpsErr_SUCCESS, inode->getFileVersion()));
metaStore.releaseFile(getEntryInfo().getParentEntryID(), inode);
return true;
}
......@@ -144,7 +144,10 @@ std::unique_ptr<MirroredMessageResponseState> SetAttrMsgEx::executeLocally(Respo
setAttrRes = setChunkFileAttribs(*inode, false);
if (cfg->getQuotaEarlyChownResponse())
{
metaStore->releaseFile(entryInfo->getParentEntryID(), inode);
return {};
}
}
else
{
......
......@@ -336,6 +336,8 @@ void SessionStore::deserializeLockStates(Deserializer& des, MetaStore& metaStore
des % inode->lockState();
metaStore.releaseFile(info.getParentEntryID(), inode);
if (!des.good())
break;
}
......
......@@ -434,7 +434,7 @@ void DiskMetaData::serializeDentryV5(Serializer& ser)
}
/**
* Deserialize dentries, which have the V4 format, which includes inlined inodes and have the new
* Deserialize dentries, which have the V5 format, which includes inlined inodes and have the new
* chunk path (V2, which has UID and parentID)
*/
void DiskMetaData::deserializeDentryV5(Deserializer& des)
......
......@@ -647,6 +647,11 @@ FhgfsOpsErr MetaStore::mkNewMetaFile(DirInode& dir, MkFileDetails* mkDetails,
NumNodeID ownerNodeID = dir.getIsBuddyMirrored() ?
NumNodeID(metaBuddyGroupMapper->getLocalGroupID() ) : localNode.getNumID();
// refuse to create a directory before we even touch the parent. a client could send a request
// to create an S_IFDIR inode via mkfile.
if (S_ISDIR(mkDetails->mode))
return FhgfsOpsErr_INVAL;
// load DirInode on demand if required, we need it now
if (dir.loadIfNotLoadedUnlocked() == false)
return FhgfsOpsErr_PATHNOTEXISTS;
......
......@@ -694,11 +694,9 @@ void InternodeSyncer::saveTargetMappings()
if (metaMirrorGroupMapper->isMapperDirty() )
metaMirrorGroupMapper->saveToFile();
if (targetStateStore->isResyncSetDirty() )
targetStateStore->saveResyncSetToFile();
targetStateStore->saveResyncSetToFile();
if (metaStateStore->isResyncSetDirty() )
metaStateStore->saveResyncSetToFile();
metaStateStore->saveResyncSetToFile();
}
/**
......
......@@ -2,6 +2,7 @@
#include <common/net/message/nodes/SetTargetConsistencyStatesRespMsg.h>
#include <common/threading/RWLockGuard.h>
#include <common/toolkit/MessagingTk.h>
#include <common/toolkit/TempFileTk.h>
#include <common/toolkit/ZipIterator.h>
#include <components/HeartbeatManager.h>
#include <program/Program.h>
......@@ -11,7 +12,6 @@
#define MGMTDTARGETSTATESTORE_TMPFILE_EXT ".tmp"
MgmtdTargetStateStore::MgmtdTargetStateStore(NodeType nodeType) : TargetStateStore(),
resyncSetDirty(false),
nodeType(nodeType)
{
}
......@@ -48,8 +48,6 @@ void MgmtdTargetStateStore::setConsistencyStatesFromLists(const UInt16List& targ
targetState.reachabilityState = newReachabilityState;
targetState.consistencyState = newConsistencyState;
resyncSetUpdate(newConsistencyState, targetID);
statesChanged = true;
}
......@@ -131,8 +129,6 @@ FhgfsOpsErr MgmtdTargetStateStore::changeConsistencyStatesFromLists(const UInt16
// Set target to online if we successfully received a state report.
targetState.reachabilityState = TargetReachabilityState_ONLINE;
resyncSetUpdate(newConsistencyState, targetID);
statesChanged = true;
}
......@@ -585,71 +581,45 @@ bool MgmtdTargetStateStore::setTargetsGood(const UInt16Vector& ids)
}
/**
* Saves the list of targets which need a resync to the targets_need_resync file.
* Saves the list of targets which need a resync to the targets_need_resync file, if the list has
* changed since the last time it was saved.
*/
void MgmtdTargetStateStore::saveResyncSetToFile()
{
const char* logContext = "Save to resync file";
App* app = Program::getApp();
Path mgmtdPath = *app->getMgmtdPath();
Path targetsToResyncPath = mgmtdPath / resyncSetStorePath;
std::string targetsToResyncTmpPath =
targetsToResyncPath.str() + MGMTDTARGETSTATESTORE_TMPFILE_EXT;
std::string targetsToResyncStr;
TargetIDSet targetsToResync;
{
SafeRWLock safeLock(&resyncSetLock, SafeRWLock_READ); // L O C K
for (TargetIDSetCIter targetIter = resyncSet.begin();
targetIter != resyncSet.end(); ++targetIter)
targetsToResyncStr += StringTk::uintToStr(*targetIter) + "\n";
safeLock.unlock(); // U N L O C K
RWLockGuard(rwlock, SafeRWLock_READ);
for (TargetStateInfoMapIter it = statesMap.begin();
it != statesMap.end();
++it)
{
if (it->second.consistencyState == TargetConsistencyState_NEEDS_RESYNC)
targetsToResync.insert(it->first);
}
}
// Create tmp file.
const int openFlags = O_CREAT | O_TRUNC | O_RDWR;
int fd = open(targetsToResyncTmpPath.c_str(), openFlags, 0644);
if (fd == -1)
{ // error
LogContext(logContext).log(Log_ERR, "Could not open temporary file: "
+ targetsToResyncTmpPath + "; SysErr: " + System::getErrString() );
return;
}
if (targetsToResync == tempResyncSet)
return; // Nothing changed - don't write file
ssize_t writeRes = write(fd, targetsToResyncStr.c_str(), targetsToResyncStr.length() );
if (writeRes != (ssize_t)targetsToResyncStr.length() )
std::string targetsToResyncStr;
for (TargetIDSetCIter it = targetsToResync.begin();
it != targetsToResync.end();
++it)
{
LogContext(logContext).log(Log_ERR, "Writing to file " + targetsToResyncTmpPath +
" failed; SysErr: " + System::getErrString() );
close(fd);
return;
targetsToResyncStr += StringTk::uintToStr(*it) + "\n";
}
fsync(fd);
close(fd);
// Write out the set...
Path mgmtdPath = *Program::getApp()->getMgmtdPath();
Path targetsToResyncPath = mgmtdPath / resyncSetStorePath;
// Rename tmp file to actual file name.
int renameRes =
rename(targetsToResyncTmpPath.c_str(), targetsToResyncPath.str().c_str() );
if (renameRes == -1)
{
LogContext(logContext).log(Log_ERR, "Renaming file " + targetsToResyncPath.str()
+ " to " + targetsToResyncPath.str() + " failed; SysErr: "
+ System::getErrString() );
}
FhgfsOpsErr storeRes =
TempFileTk::storeTmpAndMove(targetsToResyncPath.str(), targetsToResyncStr);
{ // Clear dirty flag.
SafeRWLock safeLock(&resyncSetLock, SafeRWLock_READ); // L O C K
resyncSetDirty = false;
safeLock.unlock(); // U N L O C K
}
if (storeRes != FhgfsOpsErr_SUCCESS)
LOG(ERR, "Could not save resync set.", as("NodeType", Node::nodeTypeToStr(nodeType)));
tempResyncSet.swap(targetsToResync);
}
/**
......@@ -675,7 +645,7 @@ bool MgmtdTargetStateStore::loadResyncSetFromFile() throw (InvalidConfigExceptio
ICommonConfig::loadStringListFile(targetsToResyncPath.str().c_str(),
targetsToResyncList);
SafeRWLock safeLock(&resyncSetLock, SafeRWLock_WRITE); // L O C K
TargetIDSet resyncSet;
for (StringListIter targetsIter = targetsToResyncList.begin();
targetsIter != targetsToResyncList.end(); ++targetsIter)
......@@ -689,19 +659,13 @@ bool MgmtdTargetStateStore::loadResyncSetFromFile() throw (InvalidConfigExceptio
"Failed to deserialize " + nodeTypeStr(false) + " ID " + *targetsIter);
}
resyncSetDirty = true;
safeLock.unlock(); // U N L O C K
SafeRWLock safeReadLock(&resyncSetLock, SafeRWLock_READ); // L O C K
// Set targets in the list to NEEDS_RESYNC.
for (TargetIDSetCIter targetIDIter = resyncSet.begin();
targetIDIter != resyncSet.end(); ++targetIDIter)
addOrUpdate(*targetIDIter, CombinedTargetState(TargetReachabilityState_POFFLINE,
TargetConsistencyState_NEEDS_RESYNC) );
safeReadLock.unlock(); // U N L O C K
tempResyncSet.swap(resyncSet);
return true;
}
......@@ -29,9 +29,7 @@ class MgmtdTargetStateStore : public TargetStateStore
typedef TargetIDSet::const_iterator TargetIDSetCIter;
// For persistent storage of storage target / metadata node ids that need resync.
RWLock resyncSetLock;
TargetIDSet resyncSet;
bool resyncSetDirty;
TargetIDSet tempResyncSet;
std::string resyncSetStorePath;
NodeType nodeType; // Meta node state store or storage target state store.
......@@ -43,17 +41,6 @@ class MgmtdTargetStateStore : public TargetStateStore
public:
// getters & setters
bool isResyncSetDirty()
{
SafeRWLock safeLock(&resyncSetLock, SafeRWLock_READ); // L O C K
bool res = resyncSetDirty;
safeLock.unlock(); // U N L O C K
return res;
}
void setResyncSetStorePath(const std::string& storePath)
{
this->resyncSetStorePath = storePath;
......@@ -62,22 +49,6 @@ class MgmtdTargetStateStore : public TargetStateStore
private:
void resyncSetUpdate(TargetConsistencyState consistencyState, uint16_t targetID)
{
SafeRWLock safeLock(&resyncSetLock, SafeRWLock_WRITE); // L O C K
bool changed = false;
if (consistencyState ==