Unverified Commit 23c5faf1 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

improved statfs and statvfs

 - improved statfs system call
 - intercepted statvfs library call

Both of the above function now report the aggregated real size
of all the data-nodes.

You can test this with `df "/tmp/gekkofs_mountpoint"` command
parent 17438e71
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12,6 +12,12 @@ namespace spdlog {
}


struct ChunkStat {
    unsigned long chunk_size;
    unsigned long chunk_total;
    unsigned long chunk_free;
};

class ChunkStorage {
    private:
        static constexpr const char * LOGGER_NAME = "ChunkStorage";
@@ -38,6 +44,7 @@ class ChunkStorage {
        void delete_chunk(const std::string& file_path, unsigned int chunk_id);
        void truncate_chunk(const std::string& file_path, unsigned int chunk_id, off_t length);
        void destroy_chunk_space(const std::string& file_path) const;
        ChunkStat chunk_stat() const;
};

#endif //IFS_CHUNK_STORAGE_HPP
+2 −0
Original line number Diff line number Diff line
@@ -35,4 +35,6 @@ DECLARE_MARGO_RPC_HANDLER(rpc_srv_write_data)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_trunc_data)

DECLARE_MARGO_RPC_HANDLER(rpc_srv_chunk_stat)

#endif //LFS_RPC_DEFS_HPP
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ namespace hg_tag {
    constexpr auto write_data = "rpc_srv_write_data";
    constexpr auto read_data = "rpc_srv_read_data";
    constexpr auto trunc_data = "rpc_srv_trunc_data";
    constexpr auto chunk_stat = "rpc_srv_chunk_stat";
}

// typedefs
+11 −0
Original line number Diff line number Diff line
@@ -114,4 +114,15 @@ MERCURY_GEN_PROC(rpc_config_out_t, ((hg_const_string_t) (mountdir))
((hg_uint64_t) (host_id)) \
((hg_uint64_t) (host_size)))


MERCURY_GEN_PROC(rpc_chunk_stat_in_t,
        ((hg_int32_t) (dummy))
)

MERCURY_GEN_PROC(rpc_chunk_stat_out_t,
        ((hg_uint64_t) (chunk_size))
        ((hg_uint64_t) (chunk_total))
        ((hg_uint64_t) (chunk_free))
)

#endif //LFS_RPC_TYPES_HPP
+3 −23
Original line number Diff line number Diff line
@@ -3,28 +3,6 @@

#include <preload/open_file_map.hpp>
#include <global/metadata.hpp>
/*
 * See include/linux/statfs.h (not includable)
 *
 * Definitions for the flag in f_flag.
 *
 * Generally these flags are equivalent to the MS_ flags used in the mount
 * ABI.  The exception is ST_VALID which has the same value as MS_REMOUNT
 * which doesn't make any sense for statfs.
 */
#define ST_RDONLY    0x0001    /* mount read-only */
#define ST_NOSUID    0x0002    /* ignore suid and sgid bits */
#define ST_NODEV    0x0004    /* disallow access to device special files */
#define ST_NOEXEC    0x0008    /* disallow program execution */
#define ST_SYNCHRONOUS    0x0010    /* writes are synced at once */
#define ST_VALID    0x0020    /* f_flags support is implemented */
#define ST_MANDLOCK    0x0040    /* allow mandatory locks on an FS */
/* 0x0080 used for ST_WRITE in glibc */
/* 0x0100 used for ST_APPEND in glibc */
/* 0x0200 used for ST_IMMUTABLE in glibc */
#define ST_NOATIME    0x0400    /* do not update access times */
#define ST_NODIRATIME    0x0800    /* do not update directory access times */
#define ST_RELATIME    0x1000    /* update atime relative to mtime/ctime */

std::shared_ptr<Metadata> adafs_metadata(const std::string& path);

@@ -40,7 +18,9 @@ int adafs_stat(const std::string& path, struct stat* buf);

int adafs_stat64(const std::string& path, struct stat64* buf);

int adafs_statfs(const std::string& path, struct statfs* adafs_buf, struct statfs& realfs_buf);
int adafs_statvfs(struct statvfs* buf);

int adafs_statfs(struct statfs* buf);

off64_t adafs_lseek(int fd, off64_t offset, int whence);

Loading