summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2012-05-30 16:01:38 -0700
committerSamuel Just <sam.just@inktank.com>2012-06-05 16:09:50 -0700
commit56cf461e45a23c3055d452e04b72a81278ae6f62 (patch)
tree581b55bc69ef89fb5a64a47989945dfe26953f27 /src/os
parent875bec29a42ddc2acb057af83cfa564421ddea85 (diff)
downloadceph-56cf461e45a23c3055d452e04b72a81278ae6f62.tar.gz
OSD,FileStore: clean up filestore convsersion
Previously, we messed with the filestore_update_collections config option to enable upgrades in the filestore. We now pass that in as a parameter to the FileStore,IndexManager constructors. Further, the user must now specify the version to which to update in order to prevent accidental updates. Signed-off-by: Samuel Just <sam.just@inktank.com>
Diffstat (limited to 'src/os')
-rw-r--r--src/os/DBObjectMap.cc3
-rw-r--r--src/os/FileStore.cc13
-rw-r--r--src/os/FileStore.h6
-rw-r--r--src/os/IndexManager.cc2
-rw-r--r--src/os/IndexManager.h4
5 files changed, 17 insertions, 11 deletions
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc
index da2f3cd938d..4852b2aac76 100644
--- a/src/os/DBObjectMap.cc
+++ b/src/os/DBObjectMap.cc
@@ -998,7 +998,8 @@ int DBObjectMap::init(bool do_upgrade)
state.decode(bliter);
if (state.v < 1) { // Needs upgrade
if (!do_upgrade) {
- dout(1) << "DOBjbectMap requires an upgrade, set filestore_update_omap"
+ dout(1) << "DOBjbectMap requires an upgrade,"
+ << " set filestore_update_to"
<< dendl;
return -ENOTSUP;
} else {
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index 540ecdcdaa3..3faaa76f6ab 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -659,7 +659,7 @@ done:
return r;
}
-FileStore::FileStore(const std::string &base, const std::string &jdev, const char *name) :
+FileStore::FileStore(const std::string &base, const std::string &jdev, const char *name, bool do_update) :
internal_name(name),
basedir(base), journalpath(jdev),
btrfs(false),
@@ -673,6 +673,7 @@ FileStore::FileStore(const std::string &base, const std::string &jdev, const cha
ioctl_fiemap(false),
fsid_fd(-1), op_fd(-1),
basedir_fd(-1), current_fd(-1),
+ index_manager(do_update),
ondisk_finisher(g_ceph_context),
lock("FileStore::lock"),
force_sync(false), sync_epoch(0),
@@ -701,7 +702,7 @@ FileStore::FileStore(const std::string &base, const std::string &jdev, const cha
m_filestore_flusher_max_fds(g_conf->filestore_flusher_max_fds),
m_filestore_max_sync_interval(g_conf->filestore_max_sync_interval),
m_filestore_min_sync_interval(g_conf->filestore_min_sync_interval),
- m_filestore_update_collections(g_conf->filestore_update_collections),
+ do_update(do_update),
m_journal_dio(g_conf->journal_dio),
m_journal_aio(g_conf->journal_aio),
m_osd_rollback_to_cluster_snap(g_conf->osd_rollback_to_cluster_snap),
@@ -1672,10 +1673,10 @@ int FileStore::mount()
<< cpp_strerror(ret) << dendl;
goto close_fsid_fd;
} else if (ret == 0) {
- if (m_filestore_update_collections) {
+ if (do_update) {
derr << "FileStore::mount : stale version stamp detected: "
<< version_stamp
- << ". Proceeding, m_filestore_update_collections "
+ << ". Proceeding, do_update "
<< "is set, DO NOT USE THIS OPTION IF YOU DO NOT KNOW WHAT IT DOES."
<< " More details can be found on the wiki."
<< dendl;
@@ -1683,7 +1684,7 @@ int FileStore::mount()
ret = -EINVAL;
derr << "FileStore::mount : stale version stamp " << version_stamp
<< ". Please run the FileStore update script before starting the "
- << "OSD."
+ << "OSD, or set filestore_update_to to " << on_disk_version
<< dendl;
goto close_fsid_fd;
}
@@ -1882,7 +1883,7 @@ int FileStore::mount()
goto close_current_fd;
}
DBObjectMap *dbomap = new DBObjectMap(omap_store);
- ret = dbomap->init(m_filestore_update_collections);
+ ret = dbomap->init(do_update);
if (ret < 0) {
derr << "Error initializing DBObjectMap: " << ret << dendl;
goto close_current_fd;
diff --git a/src/os/FileStore.h b/src/os/FileStore.h
index ef9bc7bde0f..ba333adbb56 100644
--- a/src/os/FileStore.h
+++ b/src/os/FileStore.h
@@ -47,7 +47,9 @@ using namespace __gnu_cxx;
class FileStore : public JournalingObjectStore,
public md_config_obs_t
{
+public:
static const uint32_t on_disk_version = 3;
+private:
string internal_name; ///< internal name, used to name the perfcounter instance
string basedir, journalpath;
std::string current_fn;
@@ -283,7 +285,7 @@ public:
int lfn_unlink(coll_t cid, const hobject_t& o);
public:
- FileStore(const std::string &base, const std::string &jdev, const char *internal_name = "filestore");
+ FileStore(const std::string &base, const std::string &jdev, const char *internal_name = "filestore", bool update_to=false);
~FileStore();
int _test_fiemap();
@@ -475,7 +477,7 @@ private:
int m_filestore_flusher_max_fds;
double m_filestore_max_sync_interval;
double m_filestore_min_sync_interval;
- bool m_filestore_update_collections;
+ int do_update;
bool m_journal_dio, m_journal_aio;
std::string m_osd_rollback_to_cluster_snap;
bool m_osd_use_stale_snap;
diff --git a/src/os/IndexManager.cc b/src/os/IndexManager.cc
index a9343dbdb46..82120ebf7b0 100644
--- a/src/os/IndexManager.cc
+++ b/src/os/IndexManager.cc
@@ -83,7 +83,7 @@ int IndexManager::init_index(coll_t c, const char *path, uint32_t version) {
int IndexManager::build_index(coll_t c, const char *path, Index *index) {
int r;
- if (g_conf->filestore_update_collections) {
+ if (upgrade) {
// Need to check the collection generation
uint32_t version = 0;
r = get_version(path, &version);
diff --git a/src/os/IndexManager.h b/src/os/IndexManager.h
index a630eba6a69..43de7ee49c8 100644
--- a/src/os/IndexManager.h
+++ b/src/os/IndexManager.h
@@ -47,6 +47,7 @@ typedef std::tr1::shared_ptr<CollectionIndex> Index;
class IndexManager {
Mutex lock; ///< Lock for Index Manager
Cond cond; ///< Cond for waiters on col_indices
+ bool upgrade;
/// Currently in use CollectionIndices
map<coll_t,std::tr1::weak_ptr<CollectionIndex> > col_indices;
@@ -84,7 +85,8 @@ class IndexManager {
int build_index(coll_t c, const char *path, Index *index);
public:
/// Constructor
- IndexManager() : lock("IndexManager lock") {}
+ IndexManager(bool upgrade) : lock("IndexManager lock"),
+ upgrade(upgrade) {}
/**
* Reserve and return index for c