bool CreateDefDirInodesMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock, char* respBuf, size_t bufLen, HighResolutionStats* stats) { std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername(); LOG_DEBUG("CreateDefDirInodesMsg incoming", 4, std::string("Received a CreateDefDirInodesMsg from: ") + peer); LogContext log("CreateDefDirInodesMsg incoming"); App* app = Program::getApp(); Config* cfg = app->getConfig(); uint16_t localNodeNumID = app->getLocalNode()->getNumID(); StringList inodeIDs; StringList failedInodeIDs; FsckDirInodeList createdInodes; this->parseInodeIDs(&inodeIDs); for ( StringListIter iter = inodeIDs.begin(); iter != inodeIDs.end(); iter++ ) { std::string inodeID = *iter; int mode = S_IFDIR | S_IRWXU; unsigned userID = 0; // root unsigned groupID = 0; // root uint16_t ownerNodeID = localNodeNumID; UInt16Vector stripeTargets; unsigned defaultChunkSize = cfg->getTuneDefaultChunkSize(); unsigned defaultNumStripeTargets = cfg->getTuneDefaultNumStripeTargets(); Raid0Pattern stripePattern(defaultChunkSize, stripeTargets, defaultNumStripeTargets); // we try to create a new directory inode, with default values DirInode dirInode(inodeID, mode, userID, groupID, ownerNodeID, stripePattern); if ( dirInode.storeAsReplacementFile(inodeID) == FhgfsOpsErr_SUCCESS ) { // try to refresh the metainfo (maybe a .cont directory was already present) dirInode.refreshMetaInfo(); StatData statData; dirInode.getStatData(statData); FsckDirInode fsckDirInode(inodeID, "", 0, localNodeNumID, statData.getFileSize(), statData.getNumHardlinks(), stripeTargets, FsckStripePatternType_RAID0, localNodeNumID); createdInodes.push_back(fsckDirInode); } else failedInodeIDs.push_back(inodeID); } CreateDefDirInodesRespMsg respMsg(&failedInodeIDs, &createdInodes); respMsg.serialize(respBuf, bufLen); sock->sendto(respBuf, respMsg.getMsgLength(), 0, (struct sockaddr*) fromAddr, sizeof(struct sockaddr_in)); return true; }
void Spiral::draw() { ofPushMatrix; ofTranslate (ofGetWidth()/2, ofGetHeight()/2); //---- stripePattern (1/tan(ofGetElapsedTimef())*2500); //---- } ;
bool AdjustChunkPermissionsMsgEx::processIncoming(struct sockaddr_in* fromAddr, Socket* sock, char* respBuf, size_t bufLen, HighResolutionStats* stats) { LogContext log("Incoming AdjustChunkPermissionsMsg"); std::string peer = fromAddr ? Socket::ipaddrToStr(&fromAddr->sin_addr) : sock->getPeername(); LOG_DEBUG_CONTEXT(log, 4, std::string("Received a AdjustChunkPermissionsMsg from: ") + peer); MetaStore *metaStore = Program::getApp()->getMetaStore(); unsigned hashDirNum = this->getHashDirNum(); unsigned maxEntries = this->getMaxEntries(); int64_t lastHashDirOffset = this->getLastHashDirOffset(); int64_t lastContDirOffset = this->getLastContDirOffset(); std::string currentContDirID = this->getCurrentContDirID(); int64_t newHashDirOffset = 0; int64_t newContDirOffset = 0; unsigned errorCount = 0; unsigned readOutEntries = 0; bool hasNext; if ( currentContDirID.empty() ) { hasNext = StorageTkEx::getNextContDirID(hashDirNum, lastHashDirOffset, ¤tContDirID, &newHashDirOffset); if ( hasNext ) { lastHashDirOffset = newHashDirOffset; } } else hasNext = true; while ( hasNext ) { std::string parentID = currentContDirID; unsigned remainingEntries = maxEntries - readOutEntries; StringList entryNames; bool parentDirInodeIsTemp = false; DirInode* parentDirInode = metaStore->referenceDir(parentID, true); // it could be, that parentDirInode does not exist // in fsck we create a temporary inode for this case if ( unlikely(!parentDirInode) ) { log.log( Log_NOTICE, "Could not reference directory. EntryID: " + parentID + " => using temporary directory inode "); // create temporary inode int mode = S_IFDIR | S_IRWXU; UInt16Vector stripeTargets; Raid0Pattern stripePattern(0, stripeTargets, 0); parentDirInode = new DirInode(parentID, mode, 0, 0, Program::getApp()->getLocalNode()->getNumID(), stripePattern); parentDirInodeIsTemp = true; } if ( parentDirInode->listIncremental(lastContDirOffset, remainingEntries, &entryNames, &newContDirOffset) == FhgfsOpsErr_SUCCESS ) { lastContDirOffset = newContDirOffset; readOutEntries += entryNames.size(); } else { log.log(Log_WARNING, "Could not list contents of directory. EntryID: " + parentID); } // actually process the entries; for the dentry part we only need to know if it is a file // with inlined inode data for ( StringListIter namesIter = entryNames.begin(); namesIter != entryNames.end(); namesIter++ ) { std::string filename = MetaStorageTk::getMetaDirEntryPath( Program::getApp()->getDentriesPath()->getPathAsStrConst(), parentID) + "/" + *namesIter; EntryInfo entryInfo; FileInodeStoreData inodeDiskData; FhgfsOpsErr getEntryRes = metaStore->getEntryData(parentDirInode, *namesIter, &entryInfo, &inodeDiskData); inodeDiskData.setDynamicOrigParentEntryID(parentID); if (getEntryRes == FhgfsOpsErr_SUCCESS || getEntryRes == FhgfsOpsErr_DYNAMICATTRIBSOUTDATED ) { DirEntryType entryType = entryInfo.getEntryType(); // we only care if inode data is present if ( (DirEntryType_ISFILE(entryType)) && (entryInfo.getIsInlined() ) ) { std::string inodeID = inodeDiskData.getEntryID(); unsigned userID = inodeDiskData.getInodeStatData()->getUserID(); unsigned groupID = inodeDiskData.getInodeStatData()->getGroupID(); StripePattern* pattern = inodeDiskData.getStripePattern(); PathInfo pathInfo; inodeDiskData.getPathInfo(&pathInfo); if ( !this->sendSetAttrMsg(inodeID, userID, groupID, &pathInfo, pattern) ) errorCount++; } } else { log.log(Log_WARNING, "Unable to create dir entry from entry with name " + *namesIter + " in directory with ID " + parentID); } } if ( parentDirInodeIsTemp ) SAFE_DELETE(parentDirInode); else metaStore->releaseDir(parentID); if ( entryNames.size() < remainingEntries ) { // directory is at the end => proceed with next hasNext = StorageTkEx::getNextContDirID(hashDirNum, lastHashDirOffset, ¤tContDirID, &newHashDirOffset); if ( hasNext ) { lastHashDirOffset = newHashDirOffset; lastContDirOffset = 0; } } else { // there are more to come, but we need to exit the loop now, because maxCount is reached hasNext = false; } } AdjustChunkPermissionsRespMsg respMsg(readOutEntries, currentContDirID, lastHashDirOffset, lastContDirOffset, errorCount); respMsg.serialize(respBuf, bufLen); sock->sendto(respBuf, respMsg.getMsgLength(), 0, (struct sockaddr*) fromAddr, sizeof(struct sockaddr_in)); return true; }