]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore,LFNIndex: Bump filestore version
authorSamuel Just <samuel.just@dreamhost.com>
Thu, 1 Sep 2011 23:29:00 +0000 (16:29 -0700)
committerSamuel Just <samuel.just@dreamhost.com>
Fri, 2 Sep 2011 22:06:36 +0000 (15:06 -0700)
Also adds mechanisms for LFNIndex to handle keyed and keyless hobject_t
versions.

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
src/os/CollectionIndex.h
src/os/FileStore.h
src/os/FlatIndex.h
src/os/HashIndex.h
src/os/IndexManager.cc
src/os/LFNIndex.cc
src/os/LFNIndex.h

index f8846a78cd64331dc24f3905bdd4fd4eac0b5c31..2fca26fb0a6e55298b26a92f2d818ef863e4340b 100644 (file)
@@ -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.
    *
index 7f01c8974075cade905157c57151da875cdbb1f3..d17d5e6b82f8eb186d8accf52f7c75474097270c 100644 (file)
@@ -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;
index d94edf3f69e6af862061e7b42840bc94cba03cac..53e27f5ec08ac3a66e64b6c3abe2f656be2a4b11 100644 (file)
@@ -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);
index fb8fde599abb6c03e9cdfa84693f0a4d92d68bea..bbcbc9904adcadd8e929bd0a643742518c6fcd94 100644 (file)
@@ -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();
index 251599b11754505e996431277350c2c2d7bda7d1..504cd8f521758649cbaf7cbed8ebebc56b0e7322 100644 (file)
@@ -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;
   }
index d6903032e3c3d5286b9124300c512819c0c06d58..f739b182facb19ada03d803b27980c255c5e973d 100644 (file)
@@ -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;
index dedd8465a28694efff46476edff00e5f4e08c272..172239fa70727df5586da0c6216d0c627ab758bc 100644 (file)
@@ -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() {}
@@ -358,11 +363,22 @@ private:
     string *demangled_name    ///< [out] Demangled subdir name.
     ); ///< @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