mirror of https://github.com/trapexit/mergerfs.git
Browse Source
Merge pull request #1203 from trapexit/append-move
Merge pull request #1203 from trapexit/append-move
Fix move when in append mode + fix read/write direct_io vs cached behaviorpull/1204/head
trapexit
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 625 additions and 246 deletions
-
4README.md
-
2libfuse/include/fuse_common.h
-
143libfuse/include/fuse_kernel.h
-
31libfuse/lib/fuse_lowlevel.c
-
6man/mergerfs.1
-
2src/config.cpp
-
2src/config.hpp
-
12src/fileinfo.hpp
-
10src/fs_copydata_readwrite.cpp
-
38src/fs_dup2.hpp
-
2src/fs_mktemp.cpp
-
154src/fs_movefile.cpp
-
4src/fs_movefile.hpp
-
59src/fs_preadn.hpp
-
42src/fs_pwrite.hpp
-
59src/fs_pwriten.hpp
-
11src/fs_write.hpp
-
43src/fuse_create.cpp
-
42src/fuse_open.cpp
-
32src/fuse_read.cpp
-
173src/fuse_write.cpp
@ -0,0 +1,38 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2023, 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 <unistd.h>
|
|||
|
|||
|
|||
namespace fs |
|||
{ |
|||
static |
|||
inline |
|||
int |
|||
dup2(int const oldfd_, |
|||
int const newfd_) |
|||
{ |
|||
int rv; |
|||
|
|||
rv = ::dup2(oldfd_,newfd_); |
|||
|
|||
return ((rv == -1) ? -errno : rv); |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2023, 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 "fs_pread.hpp"
|
|||
|
|||
|
|||
namespace fs |
|||
{ |
|||
static |
|||
inline |
|||
ssize_t |
|||
preadn(int const fd_, |
|||
void *buf_, |
|||
size_t const count_, |
|||
off_t const offset_, |
|||
int *err_) |
|||
{ |
|||
ssize_t rv; |
|||
ssize_t count = count_; |
|||
off_t offset = offset_; |
|||
char const *buf = (char const *)buf_; |
|||
|
|||
*err_ = 0; |
|||
while(count > 0) |
|||
{ |
|||
rv = fs::pread(fd_,buf,count,offset); |
|||
if(rv == 0) |
|||
return (count_ - count); |
|||
if(rv < 0) |
|||
{ |
|||
*err_ = rv; |
|||
return (count_ - count); |
|||
} |
|||
|
|||
buf += rv; |
|||
count -= rv; |
|||
offset += rv; |
|||
} |
|||
|
|||
return count_; |
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2016, 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 <unistd.h>
|
|||
|
|||
|
|||
namespace fs |
|||
{ |
|||
static |
|||
inline |
|||
ssize_t |
|||
pwrite(int const fd_, |
|||
void const *buf_, |
|||
size_t const count_, |
|||
off_t const offset_) |
|||
{ |
|||
ssize_t rv; |
|||
|
|||
rv = ::pwrite(fd_,buf_,count_,offset_); |
|||
if(rv == -1) |
|||
return -errno; |
|||
|
|||
return rv; |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2023, 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 "fs_pwrite.hpp"
|
|||
|
|||
|
|||
namespace fs |
|||
{ |
|||
static |
|||
inline |
|||
ssize_t |
|||
pwriten(const int fd_, |
|||
const void *buf_, |
|||
const size_t count_, |
|||
const off_t offset_, |
|||
int *err_) |
|||
{ |
|||
ssize_t rv; |
|||
ssize_t count = count_; |
|||
off_t offset = offset_; |
|||
char const *buf = (char const *)buf_; |
|||
|
|||
*err_ = 0; |
|||
while(count > 0) |
|||
{ |
|||
rv = fs::pwrite(fd_,buf,count,offset); |
|||
if(rv == 0) |
|||
return (count_ - count); |
|||
if(rv < 0) |
|||
{ |
|||
*err_ = rv; |
|||
return (count_ - count); |
|||
} |
|||
|
|||
buf += rv; |
|||
count -= rv; |
|||
offset += rv; |
|||
} |
|||
|
|||
return count_; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue