summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <samuel.just@dreamhost.com>2011-09-01 16:29:00 -0700
committerSamuel Just <samuel.just@dreamhost.com>2011-09-02 15:06:36 -0700
commit3b8614a818ec8c45f0e8c98714ced5b8e9a041e2 (patch)
treeac941ce054d305c33ad98fc25e3cb490aa3a7454
parent9956e52eaf1856b72381fbf2891fccd890edf211 (diff)
downloadceph-3b8614a818ec8c45f0e8c98714ced5b8e9a041e2.tar.gz
FileStore,LFNIndex: Bump filestore version
Also adds mechanisms for LFNIndex to handle keyed and keyless hobject_t versions. Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
-rw-r--r--src/os/CollectionIndex.h3
-rw-r--r--src/os/FileStore.h2
-rw-r--r--src/os/FlatIndex.h2
-rw-r--r--src/os/HashIndex.h7
-rw-r--r--src/os/IndexManager.cc13
-rw-r--r--src/os/LFNIndex.cc12
-rw-r--r--src/os/LFNIndex.h20
7 files changed, 45 insertions, 14 deletions
diff --git a/src/os/CollectionIndex.h b/src/os/CollectionIndex.h
index f8846a78cd6..2fca26fb0a6 100644
--- a/src/os/CollectionIndex.h
+++ b/src/os/CollectionIndex.h
@@ -58,6 +58,9 @@ protected:
/// Type of returned paths
typedef std::tr1::shared_ptr<Path> IndexedPath;
+ static const uint32_t FLAT_INDEX_TAG = 0;
+ static const uint32_t HASH_INDEX_TAG = 1;
+ static const uint32_t HASH_INDEX_TAG_2 = 2;
/**
* For tracking Filestore collection versions.
*
diff --git a/src/os/FileStore.h b/src/os/FileStore.h
index 7f01c897407..d17d5e6b82f 100644
--- a/src/os/FileStore.h
+++ b/src/os/FileStore.h
@@ -39,7 +39,7 @@ using namespace __gnu_cxx;
// fake attributes in memory, if we need to.
class FileStore : public JournalingObjectStore {
- static const uint32_t on_disk_version = 1;
+ static const uint32_t on_disk_version = 2;
string basedir, journalpath;
std::string current_fn;
std::string current_op_seq_fn;
diff --git a/src/os/FlatIndex.h b/src/os/FlatIndex.h
index d94edf3f69e..53e27f5ec08 100644
--- a/src/os/FlatIndex.h
+++ b/src/os/FlatIndex.h
@@ -35,7 +35,7 @@ public:
FlatIndex(string base_path) : base_path(base_path) {}
/// @see CollectionIndex
- uint32_t collection_version() { return 0; }
+ uint32_t collection_version() { return FLAT_INDEX_TAG; }
/// @see CollectionIndex
void set_ref(std::tr1::shared_ptr<CollectionIndex> ref);
diff --git a/src/os/HashIndex.h b/src/os/HashIndex.h
index fb8fde599ab..bbcbc9904ad 100644
--- a/src/os/HashIndex.h
+++ b/src/os/HashIndex.h
@@ -128,12 +128,13 @@ public:
HashIndex(
const char *base_path, ///< [in] Path to the index root.
int merge_at, ///< [in] Merge threshhold.
- int split_at) ///< [in] Split threshhold.
- : LFNIndex(base_path), merge_threshold(merge_at),
+ int split_at, ///< [in] Split threshhold.
+ uint32_t index_version)///< [in] Index version
+ : LFNIndex(base_path, index_version), merge_threshold(merge_at),
split_threshold(split_at) {}
/// @see CollectionIndex
- uint32_t collection_version() { return 1; }
+ uint32_t collection_version() { return index_version; }
/// @see CollectionIndex
int cleanup();
diff --git a/src/os/IndexManager.cc b/src/os/IndexManager.cc
index 251599b1175..504cd8f5217 100644
--- a/src/os/IndexManager.cc
+++ b/src/os/IndexManager.cc
@@ -70,7 +70,8 @@ int IndexManager::init_index(coll_t c, const char *path, uint32_t version) {
if (r < 0)
return r;
HashIndex index(path, g_conf->filestore_merge_threshold,
- g_conf->filestore_split_multiple);
+ g_conf->filestore_split_multiple,
+ CollectionIndex::HASH_INDEX_TAG_2);
return index.init();
}
@@ -84,15 +85,16 @@ int IndexManager::build_index(coll_t c, const char *path, Index *index) {
return r;
switch (version) {
- case 0: {
+ case CollectionIndex::FLAT_INDEX_TAG: {
*index = Index(new FlatIndex(path),
RemoveOnDelete(c, this));
return 0;
}
- case 1: {
+ case CollectionIndex::HASH_INDEX_TAG: // fall through
+ case CollectionIndex::HASH_INDEX_TAG_2: {
// Must be a HashIndex
*index = Index(new HashIndex(path, g_conf->filestore_merge_threshold,
- g_conf->filestore_split_multiple),
+ g_conf->filestore_split_multiple, version),
RemoveOnDelete(c, this));
return 0;
}
@@ -102,7 +104,8 @@ int IndexManager::build_index(coll_t c, const char *path, Index *index) {
} else {
// No need to check
*index = Index(new HashIndex(path, g_conf->filestore_merge_threshold,
- g_conf->filestore_split_multiple),
+ g_conf->filestore_split_multiple,
+ CollectionIndex::HASH_INDEX_TAG_2),
RemoveOnDelete(c, this));
return 0;
}
diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc
index d6903032e3c..f739b182fac 100644
--- a/src/os/LFNIndex.cc
+++ b/src/os/LFNIndex.cc
@@ -413,7 +413,7 @@ int LFNIndex::remove_attr_path(const vector<string> &path,
return do_removexattr(full_path.c_str(), mangled_attr_name.c_str());
}
-string LFNIndex::lfn_generate_object_name(const hobject_t &hoid) {
+string LFNIndex::lfn_generate_object_name_keyless(const hobject_t &hoid) {
char s[FILENAME_MAX_LEN];
char *end = s + sizeof(s);
char *t = s;
@@ -451,6 +451,10 @@ string LFNIndex::lfn_generate_object_name(const hobject_t &hoid) {
return string(s);
}
+string LFNIndex::lfn_generate_object_name(const hobject_t &hoid) {
+ return lfn_generate_object_name_keyless(hoid);
+}
+
int LFNIndex::lfn_get_name(const vector<string> &path,
const hobject_t &hoid,
string *mangled_name, string *out_path,
@@ -666,13 +670,17 @@ static int parse_object(const char *s, hobject_t& o)
return 0;
}
-bool LFNIndex::lfn_parse_object_name(const string &long_name, hobject_t *out) {
+bool LFNIndex::lfn_parse_object_name_keyless(const string &long_name, hobject_t *out) {
bool r = parse_object(long_name.c_str(), *out);
if (!r) return r;
string temp = lfn_generate_object_name(*out);
return r;
}
+bool LFNIndex::lfn_parse_object_name(const string &long_name, hobject_t *out) {
+ return lfn_parse_object_name_keyless(long_name, out);
+}
+
bool LFNIndex::lfn_is_hashed_filename(const string &name) {
if (name.size() < (unsigned)FILENAME_SHORT_LEN) {
return 0;
diff --git a/src/os/LFNIndex.h b/src/os/LFNIndex.h
index dedd8465a28..172239fa707 100644
--- a/src/os/LFNIndex.h
+++ b/src/os/LFNIndex.h
@@ -76,10 +76,15 @@ class LFNIndex : public CollectionIndex {
/// For reference counting the collection @see Path
std::tr1::weak_ptr<CollectionIndex> self_ref;
+protected:
+ const uint32_t index_version;
+
public:
/// Constructor
- LFNIndex(const char *base_path) ///< [in] path to Index root
- : base_path(base_path) {}
+ LFNIndex(
+ const char *base_path, ///< [in] path to Index root
+ int index_version)
+ : base_path(base_path), index_version(index_version) {}
/// Virtual destructor
virtual ~LFNIndex() {}
@@ -359,11 +364,22 @@ private:
); ///< @return True if short_name is a subdir, false otherwise
/// Generate object name
+ string lfn_generate_object_name_keyless(
+ const hobject_t &hoid ///< [in] Object for which to generate.
+ ); ///< @return Generated object name.
+
+ /// Generate object name
string lfn_generate_object_name(
const hobject_t &hoid ///< [in] Object for which to generate.
); ///< @return Generated object name.
/// Parse object name
+ bool lfn_parse_object_name_keyless(
+ const string &long_name, ///< [in] Name to parse
+ hobject_t *out ///< [out] Resulting Object
+ ); ///< @return True if successfull, False otherwise.
+
+ /// Parse object name
bool lfn_parse_object_name(
const string &long_name, ///< [in] Name to parse
hobject_t *out ///< [out] Resulting Object