diff options
author | Samuel Just <samuel.just@dreamhost.com> | 2011-09-02 14:32:04 -0700 |
---|---|---|
committer | Samuel Just <samuel.just@dreamhost.com> | 2011-09-02 15:39:14 -0700 |
commit | c16f2603aa156eba3909e96213ea705c13160b06 (patch) | |
tree | fbaec20584fba984faad98a2f6ec31f7b8692327 | |
parent | 8be7f04362bf66a3d02fc42c2cfb6add805c60eb (diff) | |
download | ceph-c16f2603aa156eba3909e96213ea705c13160b06.tar.gz |
LFNIndex: include index_version in the lfn attribute name
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>
-rw-r--r-- | src/os/LFNIndex.cc | 6 | ||||
-rw-r--r-- | src/os/LFNIndex.h | 23 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc index 8674c6a17ec..126a4b9edbd 100644 --- a/src/os/LFNIndex.cc +++ b/src/os/LFNIndex.cc @@ -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)) diff --git a/src/os/LFNIndex.h b/src/os/LFNIndex.h index 172239fa707..e0321b45dbf 100644 --- a/src/os/LFNIndex.h +++ b/src/os/LFNIndex.h @@ -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. * |