mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-24 17:06:24 -05:00
Rework open file resource management
This commit is contained in:
parent
a47842e2f8
commit
e32985e490
11 changed files with 453 additions and 303 deletions
|
|
@ -29,6 +29,16 @@ EXTERN_C_BEGIN
|
|||
* Basic FUSE API *
|
||||
* ----------------------------------------------------------- */
|
||||
|
||||
#define INVALID_BACKING_ID (0)
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
fuse_backing_id_is_valid(const int backing_id_)
|
||||
{
|
||||
return (backing_id_ > INVALID_BACKING_ID);
|
||||
}
|
||||
|
||||
struct fuse_dirents_t;
|
||||
typedef struct fuse_dirents_t fuse_dirents_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -3878,7 +3878,7 @@ fuse_passthrough_open(const int fd_)
|
|||
|
||||
rv = ::ioctl(dev_fuse_fd,FUSE_DEV_IOC_BACKING_OPEN,&bm);
|
||||
|
||||
return rv;
|
||||
return ((rv < 0) ? INVALID_BACKING_ID : rv);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -3886,6 +3886,9 @@ fuse_passthrough_close(const int backing_id_)
|
|||
{
|
||||
int dev_fuse_fd;
|
||||
|
||||
if(!fuse_backing_id_is_valid(backing_id_))
|
||||
return 0;
|
||||
|
||||
dev_fuse_fd = fuse_chan_fd(f.se->ch);
|
||||
|
||||
return ::ioctl(dev_fuse_fd,FUSE_DEV_IOC_BACKING_CLOSE,&backing_id_);
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ fill_open(struct fuse_open_out *arg_,
|
|||
arg_->open_flags |= FOPEN_PARALLEL_DIRECT_WRITES;
|
||||
if(ffi_->noflush)
|
||||
arg_->open_flags |= FOPEN_NOFLUSH;
|
||||
if(ffi_->passthrough && (ffi_->backing_id > 0))
|
||||
if(ffi_->passthrough && fuse_backing_id_is_valid(ffi_->backing_id))
|
||||
{
|
||||
arg_->open_flags |= FOPEN_PASSTHROUGH;
|
||||
arg_->backing_id = ffi_->backing_id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue