Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 67 additions & 50 deletions .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ concurrency:
jobs:
codespell-check:
name: "Check codespell conformance"
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: "Run codespell"
uses: codespell-project/actions-codespell@v2
docker-check:
name: "Check Docker image"
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
cmake-build-type:
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:

format-check:
name: "Check ${{ matrix.path }} clang-format conformance"
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
path:
Expand All @@ -101,60 +101,62 @@ jobs:
extensions: 'h,cpp,c,hpp'
clangFormatVersion: 16
unit-tests:
name: "Build ${{ matrix.build_type }} with ${{ matrix.cxx }}"
runs-on: ubuntu-22.04
name: "Build ${{ matrix.build_type }} with ${{ matrix.compiler }}"
runs-on: ubuntu-24.04
strategy:
matrix:
build_type:
- Debug
- Release
cxx:
- g++-9
- g++-10
- g++-11
- g++-12
- g++-13
- clang-13
- clang-14
- clang-15
- clang-16
- clang-17
- clang-18
compiler:
- gcc:9
- gcc:10
- gcc:11
- gcc:12
- gcc:13
- zhongruoyu/llvm-ports:13.0-trixie
- zhongruoyu/llvm-ports:14.0-trixie
- zhongruoyu/llvm-ports:15.0-trixie
- zhongruoyu/llvm-ports:16.0-trixie
- zhongruoyu/llvm-ports:17.0-trixie
- zhongruoyu/llvm-ports:18-trixie

container:
image: ${{ matrix.compiler }}

steps:
- uses: actions/checkout@v4
- name: "Install packages"
run: |
sudo apt install -y \
libcapstone-dev \
libopenmpi-dev \
ninja-build \
openmpi-bin \
pkg-config
- name: "Get compiler version"
run: |
IFS='-' read -r -a COMPILER <<< "${{ matrix.cxx }}"
echo "CXX_VERSION=${COMPILER[1]}" >> $GITHUB_ENV
- name: "Install Clang"
if: ${{ startsWith(matrix.cxx, 'clang-') }}
run: |
wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh
chmod u+x /tmp/llvm.sh
sudo /tmp/llvm.sh ${{ env.CXX_VERSION }}
rm -f /tmp/llvm.sh
- name: "Fix missing libclang_rt.profile for Clang 14"
if: ${{ matrix.cxx == 'clang-14' }}

- name: "Install gfortran (OpenMPI dependency)"
if: ${{ startsWith(matrix.compiler, 'gcc:') }}
run: |
sudo apt download libclang-rt-14-dev
sudo dpkg --force-all -i libclang-rt-14-dev*
- name: "Install GCC"
if: ${{ startsWith(matrix.cxx, 'g++-') }}
apt update
apt install -y gfortran || true
update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-* 100

- name: "Install packages"
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install -y ${{ matrix.cxx }}
apt update
apt install -y \
libcapstone-dev \
openmpi-bin \
libopenmpi-dev \
ninja-build \
cmake \
make \
sudo \
bash \
git \
jq \
pkg-config \
build-essential \
wget \
tar \
python3 \
python3-pip

- name: "Run CMake"
env:
CXX: ${{ startsWith(matrix.cxx, 'clang-') && 'clang++' || 'g++' }}-${{ env.CXX_VERSION }}
shell: bash
run: |
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCAPIO_LOG=${{ matrix.build_type == 'Debug' && 'ON' || 'OFF' }} \
Expand All @@ -167,6 +169,7 @@ jobs:
sudo cmake --install ../build --prefix /usr/local
- name: "Run tests"
id: run-tests
shell: bash
timeout-minutes: 5
env:
CAPIO_DIR: ${{ github.workspace }}
Expand Down Expand Up @@ -209,27 +212,41 @@ jobs:
- name: "Show server logs on failure"
if: ${{ always() && steps.run-tests.outcome == 'failure' && matrix.build_type == 'Debug' }}
run: tail -v -n +1 capio_logs/server/$(hostname)/server_thread_*.log

- name: "Select gcov tool"
shell: bash
run: |
COMPILER="${{ matrix.compiler }}"

if [[ "$COMPILER" == silkeh/clang:* ]]; then
VERSION="${COMPILER#*:}"
echo "GCOV=llvm-cov-$VERSION gcov" >> "$GITHUB_ENV"
else
VERSION="${COMPILER#*:}"
echo "GCOV=gcov-$VERSION" >> "$GITHUB_ENV"
fi

- name: "Generate coverage report"
if: ${{ matrix.build_type == 'Debug' }}
run: |
pip install --upgrade gcovr
gcovr \
--exclude-throw-branches \
--xml coverage.xml \
--gcov-executable "${{ startsWith(matrix.cxx, 'clang-') && format('llvm-cov-{0} gcov', env.CXX_VERSION) || format('gcov-{0}', env.CXX_VERSION) }}" \
--gcov-executable $GCOV \
../build
- name: "Upload coverage report"
if: ${{ matrix.build_type == 'Debug' }}
uses: actions/upload-artifact@v4
with:
name: ${{ format('{0}-tests', matrix.cxx) }}
name: ${{ format('{0}-tests', matrix.compiler) }}
path: ./coverage.xml
retention-days: 1
if-no-files-found: error
upload-to-codecov:
name: "Codecov report upload"
needs: [ "unit-tests" , "codespell-check" , "format-check" ]
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: "Download artifacts"
Expand Down
5 changes: 5 additions & 0 deletions capio/server/include/handlers/unlink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ void unlink_handler(const char *const str) {
char path[PATH_MAX];
int tid;
sscanf(str, "%d %s", &tid, path);
START_LOG(gettid(), "call(tid=%d, path=%s)", tid, path);
if (CapioCLEngine::get().isExcluded(path)) {
LOG("File is excluded. Skipping removal");
client_manager->replyToClient(tid, CAPIO_POSIX_SYSCALL_REQUEST_SKIP);
return;
}
const auto c_file_opt = storage_manager->tryGet(path);
if (c_file_opt) { // TODO: it works only in the local case
LOG("Found local path");
CapioFile &c_file = c_file_opt->get();
if (c_file.is_deletable()) {
LOG("File is deletable!");
storage_manager->remove(path);
delete_from_files_location(path);
}
client_manager->replyToClient(tid, 0);
} else {
LOG("File not found");
client_manager->replyToClient(tid, -1);
}
}
Expand Down
3 changes: 2 additions & 1 deletion capio/server/include/storage/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ class StorageManager {
* @param tid The thread ID.
* @param fd The file descriptor number.
* @param path The path of the file being opened.
* @param register_open
*/
void _addNewFdToStorage(pid_t tid, int fd, const std::filesystem::path &path);
void _addNewFdToStorage(pid_t tid, int fd, const std::filesystem::path &path, bool register_open);

public:
/**
Expand Down
14 changes: 12 additions & 2 deletions capio/server/include/utils/capio_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ class CapioFile {
}

inline void close() {
START_LOG(gettid(), "call()");
_n_close++;
_n_opens--;
LOG("after: _n_close=%d, n_opens=%d", _n_close, _n_opens);
}

void commit() {
Expand Down Expand Up @@ -369,11 +371,19 @@ class CapioFile {
return _n_close_expected == -1 || _n_close == _n_close_expected;
}

[[nodiscard]] inline bool is_deletable() const { return _n_opens <= 0; }
[[nodiscard]] inline bool is_deletable() const {
START_LOG(gettid(), "call()");
LOG("_n_opens=%d", _n_opens);
return _n_opens <= 0;
}

[[nodiscard]] inline bool is_dir() const { return _directory; }

inline void open() { _n_opens++; }
inline void open() {
START_LOG(gettid(), "call()");
_n_opens++;
LOG("after: _n_opens=%d", _n_opens);
}

/*
* From the manual:
Expand Down
11 changes: 7 additions & 4 deletions capio/server/src/storage_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void StorageManager::clone(const pid_t parent_tid, const pid_t child_tid) {
const auto path = _opened_fd_map[parent_tid][fd]._path;
const auto offset = *_opened_fd_map[parent_tid][fd]._offset;

_addNewFdToStorage(child_tid, fd, path);
_addNewFdToStorage(child_tid, fd, path, false);
_addNewFdToMap(child_tid, fd, path, offset);
}
}
Expand Down Expand Up @@ -276,8 +276,11 @@ void StorageManager::_addNewFdToMap(const pid_t tid, const int fd,
}

void StorageManager::_addNewFdToStorage(const pid_t tid, const int fd,
const std::filesystem::path &path) {
_storage[path].open();
const std::filesystem::path &path,
const bool register_open) {
if (register_open) {
_storage[path].open();
}
_storage[path].add_fd(tid, fd);
}

Expand All @@ -287,7 +290,7 @@ void StorageManager::addFileToTid(const pid_t tid, const int fd, const std::file

{
const std::lock_guard lg(_mutex_storage);
_addNewFdToStorage(tid, fd, path);
_addNewFdToStorage(tid, fd, path, true);
}

{
Expand Down
Loading