Jathenst/fuse

Very basic draft for code review

Merge request reports

Loading
+7 −0
Changes for CMake/gkfs-options.cmake: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -248,6 +248,13 @@ gkfs_define_option(
    DEFAULT_VALUE ON
)

# build fuse client for gekkofs
gkfs_define_option(
    GKFS_BUILD_FUSE
    HELP_TEXT "Build FUSE client"
    DEFAULT_VALUE ON
)

# use old resolve function
gkfs_define_option(
    GKFS_USE_LEGACY_PATH_RESOLVE
+141 −0
Changes for include/client/fuse/fuse_client.hpp: 141 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
  Copyright 2018-2025, Barcelona Supercomputing Center (BSC), Spain
  Copyright 2015-2025, Johannes Gutenberg Universitaet Mainz, Germany

  This software was partially supported by the
  EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).

  This software was partially supported by the
  ADA-FS project under the SPPEXA project funded by the DFG.

  This software was partially supported by the
  the European Union’s Horizon 2020 JTI-EuroHPC research and
  innovation programme, by the project ADMIRE (Project ID: 956748,
  admire-eurohpc.eu)

  This project was partially promoted by the Ministry for Digital Transformation
  and the Civil Service, within the framework of the Recovery,
  Transformation and Resilience Plan - Funded by the European Union
  -NextGenerationEU.

  This file is part of GekkoFS' POSIX interface.

  GekkoFS' POSIX interface is free software: you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 3 of the License,
  or (at your option) any later version.

  GekkoFS' POSIX interface is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with GekkoFS' POSIX interface.  If not, see
  <https://www.gnu.org/licenses/>.

  SPDX-License-Identifier: LGPL-3.0-or-later
*/

#ifndef GKFS_CLIENT_FUSE_CONTEXT_HPP
#define GKFS_CLIENT_FUSE_CONTEXT_HPP

#include "fuse_log.h"
#include <utility>
extern "C" {
#define FUSE_USE_VERSION FUSE_MAKE_VERSION(3, 12)
#include <fuse3/fuse_lowlevel.h>
}

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include <dirent.h>
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <pthread.h>
#include <sys/file.h>
#include <sys/xattr.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <filesystem>
#include <unistd.h>
#include <unordered_map>
#include <string>
#include <mutex>
#include <cstdlib>

#ifdef __FreeBSD__
#include <sys/socket.h>
#include <sys/un.h>
#endif

// GekkoFS Project Headers
#include <config.hpp>
#include <common/path_util.hpp>
#include <client/hooks.hpp>
#include <client/logging.hpp> // Assumed to provide LOG and CTX
#include <client/open_dir.hpp>
#include <client/open_file_map.hpp>
#include <client/preload.hpp>
#include <client/preload_context.hpp>
#include <client/user_functions.hpp>

// Pointer trick to save a hash table and the lookup for inodes.
// Only works if the fuse_ino_t has the size of uintptr_t.
// For older compilers, the else case fails during compile time if the size does
// not match. From libfuse passthrough example
#if defined(__GNUC__) &&                                                       \
        (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 6) &&              \
        !defined __cplusplus
_Static_assert(!gkfs::config::fuse::pointertrick ||
                       sizeof(fuse_ino_t) >= sizeof(uintptr_t),
               "fuse_ino_t too small to hold uintptr_t values!");
#else
struct _uintptr_to_must_hold_fuse_ino_t_dummy_struct {
    unsigned _uintptr_to_must_hold_fuse_ino_t
        : (!gkfs::config::fuse::pointertrick ||
                           (sizeof(fuse_ino_t) >= sizeof(uintptr_t))
                   ? 1
                   : -1);
};
#endif

struct Inode {
    std::string path;
    uint64_t lookup_count;
};

enum {
    CACHE_NEVER,
    CACHE_NORMAL,
    CACHE_ALWAYS,
};

struct u_data {
    pthread_mutex_t mutex;
    int debug;
    int writeback;
    int direct_io;
    int max_readahead;
    int max_read2;
    int max_write;
    int max_background;
    int fifo;
    int splice;
    int access;
    int xattr;
    char* mountpoint;
    double timeout;
    int cache;
    int timeout_set;
};

#endif // GKFS_CLIENT_FUSE_CONTEXT_HPP
+10 −0
Changes for include/config.hpp: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -197,6 +197,16 @@ constexpr auto max_stats = 1000000; ///< How many stats will be stored
constexpr auto prometheus_gateway = "127.0.0.1:9091";
} // namespace stats

namespace fuse {

// use pointertrick for fuse client
// only works if sizeof(fuse_ino_t) >= sizeof(uintptr_t)
constexpr auto pointertrick = false;
// on read and write, check existence of the inode for better errors
// not needed
constexpr auto check_inode = true;
} // namespace fuse

} // namespace gkfs::config

#endif // GEKKOFS_CONFIG_HPP

scripts/run/fuse-0.9.6

deleted100644 → 0
+0 −82
Changes for scripts/run/fuse-0.9.6: 0 added lines, 82 removed lines.
Original line number Diff line number Diff line
#%Module1.0
########################################################
#
# Author: Ramon Nou
#
########################################################

set PROG_NAME           GekkoFS
set PROG_VERSION        fuse-0.9.6
set BASE                /apps/GPP/GEKKOFS
set PROG_HOME           $BASE/gkfs-fuse/bin/gkfs_daemon
set PROG_PROXY          $BASE/gkfs-fuse/bin/gkfs_proxy
set PROG_FUSE           $BASE/gkfs-fuse/bin/fuse_client
set PRLD_HOME           $BASE/gkfs-fuse/lib64/libgkfs_intercept.so
set LIBC_HOME           $BASE/gkfs-fuse/lib64/libgkfs_libc_intercept.so
set LIBS                $BASE/deps-master/lib64:$BASE/deps-master/lib:$BASE/gkfs-fuse/lib64
set GKFS_RUN            $BASE/gkfs-master/bin/gkfs_run

proc ModulesHelp { } {
    puts stderr "----------------------------------------------------------------"
    puts stderr "\tGekkoFS Module fuse-0.9.6"
    puts stderr "----------------------------------------------------------------"
    puts stderr "\nDescription:"
    puts stderr "\tThis module loads the environment for GekkoFS (FUSE version)."
    puts stderr "\tIt sets up environment variables and providing helper scripts."
    puts stderr "\nDefined Environment Variables:"
    puts stderr "\tGKFS_DAEMON      : Path to the GekkoFS daemon executable"
    puts stderr "\tGKFS_PROXY       : Path to the GekkoFS proxy executable"
    puts stderr "\tGKFS_FUSE        : Path to the GekkoFS FUSE client executable"
    puts stderr "\tGKFS_INTERCEPT   : Path to the interception library"
    puts stderr "\tGKFS_LIBC        : Path to the libc interception library"
    puts stderr "\tLD_LIBRARY_PATH  : Includes GekkoFS and ADMIRE dependencies"
    puts stderr "\tGKFS_MNT         : Default mount point for GekkoFS (can be overridden)"
    puts stderr "\tGKFS_ROOT        : Default root directory for GekkoFS (can be overridden)"
    puts stderr "\tGKFS_BASE        : Path to the GekkoFS installation directory"
    puts stderr "\nHelper Scripts:"
    puts stderr "\t\$GKFS_RUN start      : Launch GekkoFS servers (requires Slurm allocation)"
    puts stderr "\t\$GKFS_RUN start_fuse : Launch GekkoFS servers AND FUSE clients"
    puts stderr "\t\$GKFS_RUN stop       : Stop GekkoFS servers/clients and cleanup"
    puts stderr "----------------------------------------------------------------"
    puts stderr "\nExample:"
    puts stderr "\t# No LD_PRELOAD needed with FUSE"
    puts stderr "\t./your_application"
    puts stderr "----------------------------------------------------------------"
    puts stderr "\nMore information: https://storage.bsc.es/gitlab/hpc/gekkofs/"
}

module-whatis   "Loads the $PROG_NAME $PROG_VERSION Environment"

# Consistency check
conflict ${PROG_NAME}

# Load required modules
if { [ module-info mode load ] } {
    module unload impi oneapi
    module load ucx/1.16.0-gcc libfabric/1.21.0-gcc gcc/14.1.0_binutils241
}

# Set Environment Variables
setenv          GKFS_DAEMON         $PROG_HOME
setenv          GKFS_PROXY          $PROG_PROXY
setenv          GKFS_FUSE           $PROG_FUSE
setenv          GKFS_INTERCEPT      $PRLD_HOME
setenv          GKFS_LIBC           $LIBC_HOME
setenv          GKFS_LOG_LEVEL      1
setenv          GKFS_DAEMON_LOG_LEVEL 0
setenv          GKFS_RUN            $GKFS_RUN
setenv          GKFS_BASE           $BASE/gkfs-fuse

# Useful defaults (can be overridden by user)
setenv        GKFS_MNT            /dev/shm/gkfs_mnt
setenv        GKFS_ROOT           $env(TMPDIR)/gkfs_root
setenv        GKFS_HOSTS_FILE     $env(HOME)/gkfs_hosts.txt
setenv        LIBGKFS_HOSTS_FILE  $env(HOME)/gkfs_hosts.txt

prepend-path    LD_LIBRARY_PATH     $LIBS
prepend-path    PATH                $BASE/bin

if { [module-info mode] != "whatis" } {
    puts stderr "GekkoFS FUSE environment loaded."
    puts stderr "Run 'module help [module-info name]' for more information."
}
+8 −2
Changes for scripts/run/master-0.9.6: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ set PROG_VERSION master-0.9.6
set BASE                /apps/GPP/GEKKOFS
set PROG_HOME           $BASE/gkfs-master/bin/gkfs_daemon
set PROG_PROXY          $BASE/gkfs-master/bin/gkfs_proxy
set PROG_FUSE           $BASE/gkfs-master/bin/fuse_client
set PRLD_HOME           $BASE/gkfs-master/lib64/libgkfs_intercept.so
set LIBC_HOME           $BASE/gkfs-master/lib64/libgkfs_libc_intercept.so
set LIBS                $BASE/deps-master/lib64:$BASE/deps-master/lib:$BASE/gkfs-master/lib64
@@ -25,6 +26,7 @@ proc ModulesHelp { } {
    puts stderr "\nDefined Environment Variables:"
    puts stderr "\tGKFS_DAEMON      : Path to the GekkoFS daemon executable"
    puts stderr "\tGKFS_PROXY       : Path to the GekkoFS proxy executable"
    puts stderr "\tGKFS_FUSE        : Path to the GekkoFS FUSE client executable"
    puts stderr "\tGKFS_INTERCEPT   : Path to the interception library (preferred)"
    puts stderr "\tGKFS_LIBC        : Path to the libc interception library"
    puts stderr "\tLD_LIBRARY_PATH  : Includes GekkoFS and ADMIRE dependencies"
@@ -33,10 +35,13 @@ proc ModulesHelp { } {
    puts stderr "\tGKFS_BASE        : Path to the GekkoFS installation directory"
    puts stderr "\nHelper Scripts:"
    puts stderr "\t\$GKFS_RUN start      : Launch GekkoFS servers (requires Slurm allocation)"
    puts stderr "\t\$GKFS_RUN start_fuse : Launch GekkoFS servers AND FUSE clients"
    puts stderr "\t\$GKFS_RUN stop       : Stop GekkoFS servers and cleanup"
    puts stderr "\t\$GKFS_RUN stop_fuse  : Stop GekkoFS FUSE clients"
    puts stderr "----------------------------------------------------------------"
    puts stderr "\nExample:"
    puts stderr "\tLD_PRELOAD=\$GKFS_INTERCEPT ./your_application"
    puts stderr "\nExamples:"
    puts stderr "\tInterception: LD_PRELOAD=\$GKFS_INTERCEPT ./your_application"
    puts stderr "\tFUSE:         ./your_application"
    puts stderr "----------------------------------------------------------------"
    puts stderr "\nMore information: https://storage.bsc.es/gitlab/hpc/gekkofs/"
}
@@ -55,6 +60,7 @@ if { [ module-info mode load ] } {
# Set Environment Variables
setenv          GKFS_DAEMON         $PROG_HOME
setenv          GKFS_PROXY          $PROG_PROXY
setenv          GKFS_FUSE           $PROG_FUSE
setenv          GKFS_INTERCEPT      $PRLD_HOME
setenv          GKFS_LIBC           $LIBC_HOME
setenv          GKFS_LOG_LEVEL      1
Loading
Loading