Verified Commit d878127a authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Metadata class lost path property

The metadata class needs to represent metadata of a file,
thus it shouldn't contain the path itself. In fact we actually didn't
use it at all.

This will make further refactoring easier and it save some memory copies.
parent 5692115d
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -18,14 +18,12 @@ private:
    size_t size_;               // size_ in bytes, might be computed instead of stored
    blkcnt_t blocks_;          // allocated file system blocks_

    std::string path_;

public:
    Metadata();

    Metadata(const std::string& path, mode_t mode);
    Metadata(mode_t mode);

    Metadata(const std::string& path, std::string db_val);
    Metadata(std::string db_val);

    void init_ACM_time();

@@ -74,10 +72,6 @@ public:

    void blocks(blkcnt_t blocks_);

    const std::string& path() const;

    void path(const std::string& path);

};


+3 −3
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ ino_t generate_inode_no() {
 */
void create_metadentry(const std::string& path, mode_t mode) {

    Metadata md{path, mode};
    Metadata md{mode};
    // update metadata object based on what metadata is needed
    if (ADAFS_DATA->atime_state() || ADAFS_DATA->mtime_state() || ADAFS_DATA->ctime_state()) {
        std::time_t time;
@@ -52,7 +52,7 @@ std::string get_metadentry_str(const std::string& path) {
 * @return
 */
Metadata get_metadentry(const std::string& path) {
    return {path, get_metadentry_str(path)};
    return {get_metadentry_str(path)};
}

/**
@@ -92,7 +92,7 @@ void update_metadentry_size(const string& path, size_t io_size, off64_t offset,
}

void update_metadentry(const string& path, Metadata& md) {
    ADAFS_DATA->mdb()->update(path, md.path(), md.serialize());
    ADAFS_DATA->mdb()->update(path, path, md.serialize());
}

/**
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ bool MetadataMergeOperator::FullMergeV2(
        prev_md_value = merge_in.existing_value->ToString();
    }

    Metadata md{merge_in.key.ToString(), prev_md_value};
    Metadata md{prev_md_value};

    size_t fsize = md.size();

+26 −32
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ static const char MSP = '|'; // metadata separator

// By default create an empty metadata object

Metadata::Metadata() : atime_(),
Metadata::Metadata() :
    atime_(),
    mtime_(),
    ctime_(),
    uid_(),
@@ -16,9 +17,11 @@ Metadata::Metadata() : atime_(),
    inode_no_(INVALID_INODE),
    link_count_(0),
    size_(0),
                       blocks_(0) {}
    blocks_(0)
{}

Metadata::Metadata(const std::string& path, const mode_t mode) : atime_(),
Metadata::Metadata(const mode_t mode) :
    atime_(),
    mtime_(),
    ctime_(),
    uid_(),
@@ -27,18 +30,17 @@ Metadata::Metadata(const std::string& path, const mode_t mode) : atime_(),
    inode_no_(INVALID_INODE),
    link_count_(0),
    size_(0),
                                                                 blocks_(0),
                                                                 path_(path) {}
    blocks_(0)
{}

/**
 * Creates a metadata object from a value from the database
 * @param path
 * @param db_val
 */
Metadata::Metadata(const std::string& path, std::string db_val) {
Metadata::Metadata(std::string db_val) {
    auto pos = db_val.find(MSP);
    if (pos == std::string::npos) { // no delimiter found => no metadata enabled. fill with dummy values
        inode_no_ = std::hash<std::string>{}(path);
        mode_ = static_cast<unsigned int>(stoul(db_val));
        link_count_ = 1;
        uid_ = 0;
@@ -247,11 +249,3 @@ blkcnt_t Metadata::blocks() const {
void Metadata::blocks(blkcnt_t blocks_) {
    Metadata::blocks_ = blocks_;
}

const std::string& Metadata::path() const {
    return path_;
}

void Metadata::path(const std::string& path) {
    Metadata::path_ = path;
}