/// 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.
*
// 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;
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);
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();
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();
}
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;
}
} 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;
}
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;
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,
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;
/// 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() {}
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