]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
LFNIndex: include index_version in the lfn attribute name
authorSamuel Just <samuel.just@dreamhost.com>
Fri, 2 Sep 2011 21:32:04 +0000 (14:32 -0700)
committerSamuel Just <samuel.just@dreamhost.com>
Fri, 2 Sep 2011 22:39:14 +0000 (15:39 -0700)
While updating, we use hard links to populate the new directory.  We
need to change the lfn attribute to allow unlinking from the old
directory to continue to work.

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

index 8674c6a17eca4b1edb04da8f122bc49dc2930110..126a4b9edbdb4579d7c43ee5206e685bf33bba0a 100644 (file)
@@ -555,7 +555,7 @@ int LFNIndex::lfn_get_name(const vector<string> &path,
   for ( ; ; ++i) {
     candidate = lfn_get_short_name(hoid, i);
     candidate_path = get_full_path(path, candidate);
-    r = do_getxattr(candidate_path.c_str(), LFN_ATTR.c_str(), buf, sizeof(buf));
+    r = do_getxattr(candidate_path.c_str(), get_lfn_attr().c_str(), buf, sizeof(buf));
     if (r < 0) {
       if (errno != ENODATA && errno != ENOENT)
        return -errno;
@@ -596,7 +596,7 @@ int LFNIndex::lfn_created(const vector<string> &path,
     return 0;
   string full_path = get_full_path(path, mangled_name);
   string full_name = lfn_generate_object_name(hoid);
-  return do_setxattr(full_path.c_str(), LFN_ATTR.c_str(), 
+  return do_setxattr(full_path.c_str(), get_lfn_attr().c_str(), 
                     full_name.c_str(), full_name.size());
 }
 
@@ -661,7 +661,7 @@ int LFNIndex::lfn_translate(const vector<string> &path,
   // Get lfn_attr
   string full_path = get_full_path(path, short_name);
   char attr[PATH_MAX];
-  int r = do_getxattr(full_path.c_str(), LFN_ATTR.c_str(), attr, sizeof(attr) - 1);
+  int r = do_getxattr(full_path.c_str(), get_lfn_attr().c_str(), attr, sizeof(attr) - 1);
   if (r < 0)
     return -errno;
   if (r < (int)sizeof(attr))
index 172239fa70727df5586da0c6216d0c627ab758bc..e0321b45dbfed2748b00fcef8b0f6ea2949f6b48 100644 (file)
@@ -79,12 +79,23 @@ class LFNIndex : public CollectionIndex {
 protected:
   const uint32_t index_version;
 
+private:
+  string lfn_attribute;
+
 public:
   /// Constructor
   LFNIndex(
     const char *base_path, ///< [in] path to Index root
-    int index_version)
-    : base_path(base_path), index_version(index_version) {}
+    uint32_t index_version)
+    : base_path(base_path), index_version(index_version) {
+    if (index_version == HASH_INDEX_TAG) {
+      lfn_attribute = LFN_ATTR;
+    } else {
+      char buf[100];
+      snprintf(buf, sizeof(buf), "%d", index_version);
+      lfn_attribute = LFN_ATTR + string(buf);
+    }
+  }
 
   /// Virtual destructor
   virtual ~LFNIndex() {}
@@ -311,6 +322,14 @@ protected:
 
 private:
   /* lfn translation functions */
+
+  /**
+   * Gets the version specific lfn attribute tag
+   */
+  const string &get_lfn_attr() const {
+    return lfn_attribute;
+  }
+
   /**
    * Gets the filename corresponsing to hoid in path.
    *