Unverified Commit 7c6b6bbe authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

Each file has its own unique ID

The OpenFile and Metadata class have now a fuid field that is a unique file identifier. The fuid is generated by a metadata daemon when the new node is created.
parent c1ad04b8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ std::shared_ptr<Metadata> adafs_metadata(const std::string& path, bool follow_li

int adafs_open(const std::string& path, mode_t mode, int flags);

int adafs_mk_node(const std::string& path, mode_t mode, fuid_t& fuid);
int adafs_mk_node(const std::string& path, mode_t mode);

int adafs_rm_node(const std::string& path);
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class OpenDir: public OpenFile {


    public:
        OpenDir(const std::string& path);
        OpenDir(const fuid_t fuid, const std::string& path);
        void add(const std::string& name, const FileType& type);
        struct dirent * readdir();
        size_t size();
+7 −1
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
#include <memory>
#include <atomic>

#include "global/global_defs.hpp"


/* Forward declaration */
class OpenDir;

@@ -30,6 +33,7 @@ enum class FileType {
class OpenFile {
protected:
    FileType type_;
    fuid_t fuid_;
    std::string path_;
    std::array<bool, static_cast<int>(OpenFile_flags::flag_count)> flags_ = {false};
    off64_t pos_;
@@ -39,11 +43,13 @@ protected:
public:
    // multiple threads may want to update the file position if fd has been duplicated by dup()

    OpenFile(const std::string& path, int flags, FileType type = FileType::regular);
    OpenFile(const fuid_t fuid, const std::string& path, int flags, FileType type = FileType::regular);

    ~OpenFile();

    // getter/setter
    fuid_t fuid() const;

    std::string path() const;

    void path(const std::string& path_);
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ class Metadata;
namespace rpc_send {


int mk_node(const std::string& path, mode_t mode);
int mk_node(const std::string& path, mode_t mode, fuid_t& fuid);

int stat(const std::string& path, std::string& attr);

+8 −0
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@
#ifndef LFS_FS_DATA_H
#define LFS_FS_DATA_H

#include "daemon/classes/uids_manager.hpp"
#include <daemon/adafs_daemon.hpp>

/* Forward declarations */
class MetadataDB;
class ChunkStorage;
class Distributor;
class UidsManager;

#include <unordered_map>
#include <map>
@@ -49,6 +51,8 @@ private:
    std::shared_ptr<ChunkStorage> storage_;
    // Distributor
    std::shared_ptr<Distributor> distributor_;
    // FUIDs manager
    std::shared_ptr<UidsManager> fuids_manager_;

    // configurable metadata
    bool atime_state_;
@@ -115,6 +119,10 @@ public:

    std::shared_ptr<Distributor> distributor() const;

    void fuids_manager(std::shared_ptr<UidsManager> fuids_manager);

    std::shared_ptr<UidsManager> fuids_manager() const;

    const std::string& hosts_raw() const;

    void hosts_raw(const std::string& hosts_raw);
Loading