mirror of
https://github.com/ceph/ceph
synced 2025-01-18 09:02:08 +00:00
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>
This commit is contained in:
parent
875bec29a4
commit
56cf461e45
@ -23,6 +23,7 @@
|
||||
using namespace std;
|
||||
|
||||
#include "osd/OSD.h"
|
||||
#include "os/FileStore.h"
|
||||
#include "include/ceph_features.h"
|
||||
|
||||
#include "common/config.h"
|
||||
@ -252,14 +253,16 @@ int main(int argc, const char **argv)
|
||||
}
|
||||
|
||||
|
||||
if (convertfilestore) {
|
||||
if (convertfilestore ||
|
||||
g_conf->filestore_update_to >= (int)FileStore::on_disk_version) {
|
||||
int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
|
||||
if (err < 0) {
|
||||
derr << TEXT_RED << " ** ERROR: error converting store " << g_conf->osd_data
|
||||
<< ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
if (convertfilestore)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
string magic;
|
||||
|
@ -362,8 +362,7 @@ OPTION(filestore_commit_timeout, OPT_FLOAT, 600)
|
||||
OPTION(filestore_fiemap_threshold, OPT_INT, 4096)
|
||||
OPTION(filestore_merge_threshold, OPT_INT, 10)
|
||||
OPTION(filestore_split_multiple, OPT_INT, 2)
|
||||
OPTION(filestore_update_collections, OPT_BOOL, false)
|
||||
OPTION(filestore_update_omap, OPT_BOOL, false)
|
||||
OPTION(filestore_update_to, OPT_INT, 0)
|
||||
OPTION(filestore_blackhole, OPT_BOOL, false) // drop any new transactions on the floor
|
||||
OPTION(filestore_dump_file, OPT_STR, "") // file onto which store transaction dumps
|
||||
OPTION(filestore_kill_at, OPT_INT, 0) // inject a failure at the n'th opportunity
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -246,17 +246,10 @@ static int do_convertfs(ObjectStore *store)
|
||||
|
||||
int OSD::convertfs(const std::string &dev, const std::string &jdev)
|
||||
{
|
||||
// N.B. at some point we should rewrite this to avoid playing games with
|
||||
// g_conf here
|
||||
char buf[16] = { 0 };
|
||||
char *b = buf;
|
||||
g_ceph_context->_conf->get_val("filestore_update_collections", &b, sizeof(buf));
|
||||
g_ceph_context->_conf->set_val_or_die("filestore_update_collections", "true");
|
||||
g_ceph_context->_conf->apply_changes(NULL);
|
||||
boost::scoped_ptr<ObjectStore> store(new FileStore(dev, jdev));
|
||||
boost::scoped_ptr<ObjectStore> store(
|
||||
new FileStore(dev, jdev, "filestore",
|
||||
true));
|
||||
int r = do_convertfs(store.get());
|
||||
g_ceph_context->_conf->set_val_or_die("filestore_update_collections", buf);
|
||||
g_ceph_context->_conf->apply_changes(NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user