mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 21:00:13 -05:00
- moveonenospc copied from the branch stored when the file was opened, which a move never updates, so a second ENOSPC on the same handle tried to copy a path that no longer existed. Find the source branch from the fd's device and inode at the start of each move, trying the stored branch first. No match leaves the write's ENOSPC in place. - The source branch was dropped from the create policy's result, so a policy returning one branch (ff, mfs, lfs, lus, pfrd) left nothing when it picked the source, and a destination that was the source by another path (bind mount) was renamed over the file and unlinked. Remove every alias of the source before the policy runs, so it picks another branch; with no candidate left the move is refused. - Refuse relocation if a duplicate on another branch could become visible once the source is removed, and publish without replacing a destination that appeared meanwhile. When the no-replace rename is unsupported, publish with link(); a staging name that cannot be removed afterwards is logged instead of silently left behind. - Ask the create policy by the parent directory, as create does. The existing-path policies and newest only pick a branch that has the path they are given, and the destination has the directory but not the file yet. - TEST_movefile_enospc moves a handle twice and checks duplicates through the pool. tests.cpp covers the source by its own path and an alias, and every existing-path policy for nested and root files.
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
/*
|
|
ISC License
|
|
|
|
Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "branches.hpp"
|
|
#include "fs_path.hpp"
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
namespace fs
|
|
{
|
|
// Find the branch where `fusepath` is the file open as `fd`, trying
|
|
// `*basepath` first. Device and inode must both match so branches
|
|
// sharing a filesystem are told apart. `*fd_st` receives fd's stat.
|
|
int
|
|
findonfs(const Branches::Ptr &branches,
|
|
const fs::path &fusepath,
|
|
const int fd,
|
|
fs::path *basepath,
|
|
struct stat *fd_st);
|
|
}
|