Commit 99530473 by Elvin Sindrilaru

FST: Drop the clean/dirty mode for the local db. Fixes EOS-2600

parent 8d25d984
......@@ -29,7 +29,6 @@
#include "fst/io/FileIoPluginCommon.hh"
#include "fst/Config.hh"
#include "XrdCl/XrdClFileSystem.hh"
#include "namespace/utils/StringConvertion.hh"
#include "namespace/ns_quarkdb/persistency/FileMDSvc.hh"
#include "namespace/ns_quarkdb/persistency/MetadataFetcher.hh"
#include "namespace/ns_quarkdb/accounting/FileSystemView.hh"
......@@ -48,6 +47,19 @@ FmdDbMapHandler gFmdDbMapHandler;
using eos::common::LayoutId;
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
FmdDbMapHandler::FmdDbMapHandler()
{
using eos::common::FileSystem;
SetLogId("CommonFmdDbMapHandler");
lvdboption.CacheSizeMb = 0;
lvdboption.BloomFilterNbits = 0;
mFsMtxMap.set_deleted_key(std::numeric_limits<FileSystem::fsid_t>::max() - 2);
mFsMtxMap.set_empty_key(std::numeric_limits<FileSystem::fsid_t>::max() - 1);
}
//------------------------------------------------------------------------------
// Convert an MGM env representation to an Fmd struct
//------------------------------------------------------------------------------
bool
......@@ -334,20 +346,6 @@ FmdDbMapHandler::CallAutoRepair(const char* manager,
}
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
FmdDbMapHandler::FmdDbMapHandler()
{
using eos::common::FileSystem;
SetLogId("CommonFmdDbMapHandler");
lvdboption.CacheSizeMb = 0;
lvdboption.BloomFilterNbits = 0;
mFsMtxMap.set_deleted_key(std::numeric_limits<FileSystem::fsid_t>::max() - 2);
mFsMtxMap.set_empty_key(std::numeric_limits<FileSystem::fsid_t>::max() - 1);
}
//------------------------------------------------------------------------------
// Get number of file systems
//------------------------------------------------------------------------------
uint32_t
......@@ -386,11 +384,6 @@ FmdDbMapHandler::SetDBFile(const char* meta_dir, int fsid)
mDbMap[fsid] = new eos::common::DbMap();
}
// @note
// * when we successfully attach to a DB we set the mode to S_IRWXU & ~S_IRGRP
// * when we shutdown the daemon clean we set the mode back to S_IRWXU | S_IRGRP
// * when we attach and the mode is S_IRWXU & ~S_IRGRP we know that the DB has
// not been shutdown properly and we set a 'dirty' flag to force a full resync
char fsDBFileName[1024];
sprintf(fsDBFileName, "%s/fmd.%04d.%s", meta_dir, fsid,
eos::common::DbMap::getDbType().c_str());
......@@ -398,28 +391,6 @@ FmdDbMapHandler::SetDBFile(const char* meta_dir, int fsid)
fsDBFileName);
// Store the DB file name
DBfilename[fsid] = fsDBFileName;
// Check the mode of the DB
struct stat buf;
int src = 0;
if ((src = stat(fsDBFileName, &buf)) || ((buf.st_mode & S_IRGRP) != S_IRGRP)) {
eos_warning("setting %s file dirty - unclean shutdown detected",
eos::common::DbMap::getDbType().c_str());
mIsDirty[fsid] = true;
mStayDirty[fsid] = true;
if (!src) {
if (chmod(fsDBFileName, S_IRWXU | S_IRGRP)) {
eos_crit("failed to switch the %s database file mode to S_IRWXU | "
"S_IRGRP errno=%d", eos::common::DbMap::getDbType().c_str(),
errno);
}
}
} else {
mIsDirty[fsid] = false;
mStayDirty[fsid] = false;
}
// Create / or attach the db (try to repair if needed)
eos::common::LvDbDbMapInterface::Option* dbopt = &lvdboption;
......@@ -437,14 +408,6 @@ FmdDbMapHandler::SetDBFile(const char* meta_dir, int fsid)
mDbMap[fsid]->outOfCore(true);
}
// Set the mode to S_IRWXU & ~S_IRGRP
if (chmod(fsDBFileName, S_IRWXU & ~S_IRGRP)) {
eos_crit("failed to switch the %s database file mode to S_IRWXU & "
"~S_IRGRP errno=%d", eos::common::DbMap::getDbType().c_str(),
errno);
return false;
}
return true;
}
......@@ -454,20 +417,11 @@ FmdDbMapHandler::SetDBFile(const char* meta_dir, int fsid)
bool
FmdDbMapHandler::ShutdownDB(eos::common::FileSystem::fsid_t fsid)
{
eos_info("%s DB shutdown for fsid=%lu",
eos::common::DbMap::getDbType().c_str(), (unsigned long) fsid);
eos_info("%s DB shutdown for fsid=%d",
eos::common::DbMap::getDbType().c_str(), fsid);
eos::common::RWMutexWriteLock lock(mMapMutex);
if (mDbMap.count(fsid)) {
if (!mStayDirty[fsid]) {
// If there was a complete boot procedure done, we remove the dirty flag
// set the mode back to S_IRWXU | S_IRGRP
if (chmod(DBfilename[fsid].c_str(), S_IRWXU | S_IRGRP)) {
eos_crit("failed to switch the %s database file to S_IRWXU | S_IRGRP errno=%d",
eos::common::DbMap::getDbType().c_str(), errno);
}
}
if (mDbMap[fsid]->detachDb()) {
delete mDbMap[fsid];
mDbMap.erase(fsid);
......
......@@ -343,34 +343,21 @@ public:
return mIsSyncing[fsid];
}
//----------------------------------------------------------------------------
//! Return's the dirty flag indicating a non-clean shutdown
//----------------------------------------------------------------------------
inline bool IsDirty(eos::common::FileSystem::fsid_t fsid)
{
return mIsDirty[fsid];
}
//----------------------------------------------------------------------------
//! Set the stay dirty flag indicating a non completed bootup
//----------------------------------------------------------------------------
void StayDirty(eos::common::FileSystem::fsid_t fsid, bool dirty)
{
mStayDirty[fsid] = dirty;
}
inline void FsLockRead(const eos::common::FileSystem::fsid_t& fsid)
{
_FsLock(fsid, false);
}
inline void FsLockWrite(const eos::common::FileSystem::fsid_t& fsid)
{
_FsLock(fsid, true);
}
inline void FsUnlockRead(const eos::common::FileSystem::fsid_t& fsid)
{
_FsUnlock(fsid, false);
}
inline void FsUnlockWrite(const eos::common::FileSystem::fsid_t& fsid)
{
_FsUnlock(fsid, true);
......@@ -411,8 +398,6 @@ private:
mutable eos::common::RWMutex mMapMutex;//< Mutex protecting the Fmd handler
eos::common::LvDbDbMapInterface::Option lvdboption;
std::map<eos::common::FileSystem::fsid_t, std::string> DBfilename;
std::map<eos::common::FileSystem::fsid_t, bool> mIsDirty;
std::map<eos::common::FileSystem::fsid_t, bool> mStayDirty;
std::map<eos::common::FileSystem::fsid_t, bool> mIsSyncing;
///! Map containing mutexes for each file system id
google::dense_hash_map<eos::common::FileSystem::fsid_t, eos::common::RWMutex>
......
......@@ -430,14 +430,11 @@ Storage::Boot(FileSystem* fs)
return;
}
bool is_dirty = gFmdDbMapHandler.IsDirty(fsid);
bool resyncmgm = ((is_dirty) ||
(fs->GetLongLong("bootcheck") == eos::common::FileSystem::kBootResync));
bool resyncdisk = ((is_dirty) ||
(fs->GetLongLong("bootcheck") >= eos::common::FileSystem::kBootForced));
bool resyncmgm = (fs->GetLongLong("bootcheck") ==
eos::common::FileSystem::kBootResync);
bool resyncdisk = (fs->GetLongLong("bootcheck") >=
eos::common::FileSystem::kBootForced);
eos_info("msg=\"start disk synchronisation\"");
// Resync the DB - indicate the flag to keep the DP dirty
gFmdDbMapHandler.StayDirty(fsid, true);
// Sync only local disks
if (resyncdisk && (fs->GetPath()[0] == '/')) {
......@@ -490,7 +487,7 @@ Storage::Boot(FileSystem* fs)
eos_info("msg=\"finished mgm synchronization\" fsid=%lu", (unsigned long) fsid);
} else {
eos_info("msg=\"skip mgm resynchronization - had clean shutdown\" fsid=%lu",
eos_info("msg=\"skip mgm resynchronization\" fsid=%lu",
(unsigned long) fsid);
}
......@@ -498,8 +495,6 @@ Storage::Boot(FileSystem* fs)
// present on disk but not tracked by the MGM are still accounted in EOS. They
// are tracked in the local database and also show up in the "used_files" info
// displayed per file system.
// Indicate the flag to unset the DB dirty flag at shutdown
gFmdDbMapHandler.StayDirty(fsid, false);
// Check if there is a label on the disk and if the configuration shows the
// same fsid + uuid
......
......@@ -30,7 +30,6 @@
#include "common/RWMutex.hh"
#include "fst/Load.hh"
#include "fst/Health.hh"
// #include "fst/FmdDbMap.hh"
#include "fst/txqueue/TransferMultiplexer.hh"
#include <vector>
#include <list>
......
......@@ -21,22 +21,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/
/*----------------------------------------------------------------------------*/
#include "fst/storage/Storage.hh"
#include "fst/XrdFstOfs.hh"
#include "fst/FmdDbMap.hh"
/*----------------------------------------------------------------------------*/
EOSFSTNAMESPACE_BEGIN
/*----------------------------------------------------------------------------*/
void
Storage::Trim()
{
// this thread trim's the SQLITE DB every 30 days
while (1) {
// sleep for a month
// Trim the DB every 30 days
while (true) {
XrdSysTimer sleeper;
sleeper.Snooze(30 * 86400);
gFmdDbMapHandler.TrimDB();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment