Browse Source

node.cpp

allocs
Antonio SJ Musumeci 2 weeks ago
parent
commit
e9bfa96f26
  1. 9
      libfuse/include/fuse.h
  2. 24
      libfuse/include/fuse_common.h
  3. 12
      libfuse/include/fuse_conn_info.hpp
  4. 22
      libfuse/include/fuse_lowlevel.hpp
  5. 14
      libfuse/include/fuse_pollhandle.h
  6. 4
      libfuse/include/fuse_req.hpp
  7. 77
      libfuse/lib/fuse.cpp
  8. 22
      libfuse/lib/fuse_i.h
  9. 1
      libfuse/lib/fuse_loop.cpp
  10. 523
      libfuse/lib/fuse_lowlevel.cpp
  11. 36
      libfuse/lib/fuse_req.cpp
  12. 18
      libfuse/lib/fuse_session.cpp
  13. 1
      libfuse/lib/node.cpp
  14. 89
      src/fixed_mem_pool.hpp
  15. 12
      src/fuse_init.cpp
  16. 2
      src/fuse_init.hpp
  17. 38
      src/fuse_poll.cpp
  18. 31
      src/fuse_poll.hpp
  19. 21
      src/mempools.cpp
  20. 23
      src/mempools.hpp
  21. 2
      src/mergerfs.cpp

9
libfuse/include/fuse.h

@ -13,6 +13,7 @@
#include "fuse_common.h" #include "fuse_common.h"
#include "fuse_kernel.h" #include "fuse_kernel.h"
#include "fuse_req_ctx.h" #include "fuse_req_ctx.h"
#include "fuse_conn_info.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
@ -150,7 +151,7 @@ struct fuse_operations
int (*fsyncdir)(const fuse_req_ctx_t *, int (*fsyncdir)(const fuse_req_ctx_t *,
const fuse_file_info_t *, const fuse_file_info_t *,
int); int);
void *(*init)(struct fuse_conn_info *conn);
void *(*init)(struct fuse_conn_info_t *conn);
void (*destroy)(void); void (*destroy)(void);
int (*access)(const fuse_req_ctx_t *, int (*access)(const fuse_req_ctx_t *,
const char *, const char *,
@ -187,10 +188,6 @@ struct fuse_operations
unsigned int flags, unsigned int flags,
void *data, void *data,
uint32_t *out_bufsz); uint32_t *out_bufsz);
int (*poll)(const fuse_req_ctx_t *,
const fuse_file_info_t *ffi,
fuse_pollhandle_t *ph,
unsigned *reventsp);
int (*write)(const fuse_req_ctx_t *, int (*write)(const fuse_req_ctx_t *,
const fuse_file_info_t *ffi, const fuse_file_info_t *ffi,
const char *data, const char *data,
@ -387,8 +384,6 @@ int fuse_clean_cache(struct fuse *fuse);
* fuse_fs_releasedir and fuse_fs_statfs, which return 0. * fuse_fs_releasedir and fuse_fs_statfs, which return 0.
*/ */
int fuse_notify_poll(fuse_pollhandle_t *ph);
/* ----------------------------------------------------------- * /* ----------------------------------------------------------- *
* Advanced API for event handling, don't worry about this... * * Advanced API for event handling, don't worry about this... *
* ----------------------------------------------------------- */ * ----------------------------------------------------------- */

24
libfuse/include/fuse_common.h

@ -128,25 +128,8 @@ struct fuse_file_info_t
#define FUSE_IOCTL_MAX_IOV 256 #define FUSE_IOCTL_MAX_IOV 256
/**
* Connection information, passed to the ->init() method
*
* Some of the elements are read-write, these can be changed to
* indicate the value requested by the filesystem. The requested
* value must usually be smaller than the indicated value.
*/
struct fuse_conn_info
{
unsigned proto_major;
unsigned proto_minor;
uint64_t capable;
uint64_t want;
};
struct fuse_session; struct fuse_session;
struct fuse_chan; struct fuse_chan;
struct fuse_pollhandle_t;
typedef struct fuse_pollhandle_t fuse_pollhandle_t;
/** /**
* Create a FUSE mountpoint * Create a FUSE mountpoint
@ -207,13 +190,6 @@ int fuse_daemonize(int foreground);
*/ */
int fuse_version(void); int fuse_version(void);
/**
* Destroy poll handle
*
* @param ph the poll handle
*/
void fuse_pollhandle_destroy(fuse_pollhandle_t *ph);
/* ----------------------------------------------------------- * /* ----------------------------------------------------------- *
* Data buffer * * Data buffer *
* ----------------------------------------------------------- */ * ----------------------------------------------------------- */

12
libfuse/include/fuse_conn_info.hpp

@ -0,0 +1,12 @@
#pragma once
#include "int_types.h"
typedef struct fuse_conn_info_t fuse_conn_info_t;
struct fuse_conn_info_t
{
u32 proto_major;
u32 proto_minor;
u64 capable;
u64 want;
};

22
libfuse/include/fuse_lowlevel.hpp

@ -119,7 +119,7 @@ struct fuse_lowlevel_ops
void (*getattr)(fuse_req_t *req, struct fuse_in_header *hdr); void (*getattr)(fuse_req_t *req, struct fuse_in_header *hdr);
void (*getlk)(fuse_req_t *req, const struct fuse_in_header *hdr); void (*getlk)(fuse_req_t *req, const struct fuse_in_header *hdr);
void (*getxattr)(fuse_req_t *req, struct fuse_in_header *hdr); void (*getxattr)(fuse_req_t *req, struct fuse_in_header *hdr);
void (*init)(void *userdata, struct fuse_conn_info *conn);
void (*init)(void *userdata, fuse_conn_info_t *conn);
void (*ioctl)(fuse_req_t *req, const struct fuse_in_header *hdr); void (*ioctl)(fuse_req_t *req, const struct fuse_in_header *hdr);
void (*link)(fuse_req_t *req, struct fuse_in_header *hdr); void (*link)(fuse_req_t *req, struct fuse_in_header *hdr);
void (*listxattr)(fuse_req_t *req, struct fuse_in_header *hdr); void (*listxattr)(fuse_req_t *req, struct fuse_in_header *hdr);
@ -401,27 +401,10 @@ int fuse_reply_ioctl(fuse_req_t *req, int result, const void *buf, uint32_t size
int fuse_reply_ioctl_iov(fuse_req_t *req, int result, const struct iovec *iov, int fuse_reply_ioctl_iov(fuse_req_t *req, int result, const struct iovec *iov,
int count); int count);
/**
* Reply with poll result event mask
*
* @param req request handle
* @param revents poll result event mask
*/
int fuse_reply_poll(fuse_req_t *req, unsigned revents);
/* ----------------------------------------------------------- * /* ----------------------------------------------------------- *
* Notification * * Notification *
* ----------------------------------------------------------- */ * ----------------------------------------------------------- */
/**
* Notify IO readiness event
*
* For more information, please read comment for poll operation.
*
* @param ph poll handle to notify IO readiness event for
*/
int fuse_lowlevel_notify_poll(fuse_pollhandle_t *ph);
/** /**
* Notify to invalidate cache for an inode * Notify to invalidate cache for an inode
* *
@ -574,8 +557,7 @@ struct fuse_session *fuse_lowlevel_new(struct fuse_args *args,
* Session interface * * Session interface *
* ----------------------------------------------------------- */ * ----------------------------------------------------------- */
struct fuse_session *fuse_session_new(void *data,
void *receive_buf,
struct fuse_session *fuse_session_new(void *receive_buf,
void *process_buf, void *process_buf,
void *destroy); void *destroy);
void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch); void fuse_session_add_chan(struct fuse_session *se, struct fuse_chan *ch);

14
libfuse/include/fuse_pollhandle.h

@ -1,14 +0,0 @@
#pragma once
#include <stdint.h>
struct fuse_chan;
struct fuse_ll;
typedef struct fuse_pollhandle_t fuse_pollhandle_t;
struct fuse_pollhandle_t
{
uint64_t kh;
struct fuse_chan *ch;
struct fuse_ll *f;
};

4
libfuse/include/fuse_req.hpp

@ -1,17 +1,17 @@
#pragma once #pragma once
#include "fuse_req_ctx.h" #include "fuse_req_ctx.h"
#include "fuse_conn_info.hpp"
struct fuse_ll;
struct fuse_chan; struct fuse_chan;
typedef struct fuse_req_t fuse_req_t; typedef struct fuse_req_t fuse_req_t;
struct fuse_req_t struct fuse_req_t
{ {
fuse_req_ctx_t ctx; fuse_req_ctx_t ctx;
struct fuse_ll *f;
struct fuse_chan *ch; struct fuse_chan *ch;
unsigned int ioctl_64bit : 1; unsigned int ioctl_64bit : 1;
fuse_conn_info_t conn;
}; };
fuse_req_t* fuse_req_alloc(); fuse_req_t* fuse_req_alloc();

77
libfuse/lib/fuse.cpp

@ -26,7 +26,6 @@
#include "fuse_kernel.h" #include "fuse_kernel.h"
#include "fuse_lowlevel.hpp" #include "fuse_lowlevel.hpp"
#include "fuse_opt.h" #include "fuse_opt.h"
#include "fuse_pollhandle.h"
#include "fuse_msgbuf.hpp" #include "fuse_msgbuf.hpp"
#include "maintenance_thread.hpp" #include "maintenance_thread.hpp"
@ -40,7 +39,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h> #include <inttypes.h>
#include <limits.h> #include <limits.h>
#include <poll.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
@ -69,10 +67,6 @@
static int g_LOG_METRICS = 0; static int g_LOG_METRICS = 0;
struct fuse_config
{
};
struct lock_queue_element struct lock_queue_element
{ {
struct lock_queue_element *next; struct lock_queue_element *next;
@ -125,7 +119,6 @@ struct fuse
nodeid_gen_t nodeid_gen; nodeid_gen_t nodeid_gen;
unsigned int hidectr; unsigned int hidectr;
pthread_mutex_t lock; pthread_mutex_t lock;
struct fuse_config conf;
fuse_operations ops; fuse_operations ops;
struct lock_queue_element *lockq; struct lock_queue_element *lockq;
@ -1367,7 +1360,7 @@ reply_entry(fuse_req_t *req_,
static static
void void
fuse_lib_init(void *data, fuse_lib_init(void *data,
struct fuse_conn_info *conn)
fuse_conn_info_t *conn)
{ {
f.ops.init(conn); f.ops.init(conn);
} }
@ -1790,7 +1783,7 @@ fuse_lib_mknod(fuse_req_t *req_,
arg = (fuse_mknod_in*)fuse_hdr_arg(hdr_); arg = (fuse_mknod_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg); name = (const char*)PARAM(arg);
if(req_->f->conn.proto_minor >= 12)
if(req_->conn.proto_minor >= 12)
req_->ctx.umask = arg->umask; req_->ctx.umask = arg->umask;
else else
name = (char*)arg + FUSE_COMPAT_MKNOD_IN_SIZE; name = (char*)arg + FUSE_COMPAT_MKNOD_IN_SIZE;
@ -1846,7 +1839,7 @@ fuse_lib_mkdir(fuse_req_t *req_,
arg = (fuse_mkdir_in*)fuse_hdr_arg(hdr_); arg = (fuse_mkdir_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg); name = (const char*)PARAM(arg);
if(req_->f->conn.proto_minor >= 12)
if(req_->conn.proto_minor >= 12)
req_->ctx.umask = arg->umask; req_->ctx.umask = arg->umask;
err = get_path_name(hdr_->nodeid,name,&fusepath); err = get_path_name(hdr_->nodeid,name,&fusepath);
@ -2083,7 +2076,7 @@ fuse_lib_create(fuse_req_t *req_,
ffi.flags = arg->flags; ffi.flags = arg->flags;
if(req_->f->conn.proto_minor >= 12)
if(req_->conn.proto_minor >= 12)
req_->ctx.umask = arg->umask; req_->ctx.umask = arg->umask;
else else
name = ((char*)arg + sizeof(struct fuse_open_in)); name = ((char*)arg + sizeof(struct fuse_open_in));
@ -2237,7 +2230,7 @@ fuse_lib_read(fuse_req_t *req_,
arg = (fuse_read_in*)fuse_hdr_arg(hdr_); arg = (fuse_read_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh; ffi.fh = arg->fh;
if(req_->f->conn.proto_minor >= 9)
if(req_->conn.proto_minor >= 9)
{ {
ffi.flags = arg->flags; ffi.flags = arg->flags;
ffi.lock_owner = arg->lock_owner; ffi.lock_owner = arg->lock_owner;
@ -2272,7 +2265,7 @@ fuse_lib_write(fuse_req_t *req_,
arg = (fuse_write_in*)fuse_hdr_arg(hdr_); arg = (fuse_write_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh; ffi.fh = arg->fh;
ffi.writepage = !!(arg->write_flags & 1); ffi.writepage = !!(arg->write_flags & 1);
if(req_->f->conn.proto_minor < 9)
if(req_->conn.proto_minor < 9)
{ {
data = ((char*)arg) + FUSE_COMPAT_WRITE_IN_SIZE; data = ((char*)arg) + FUSE_COMPAT_WRITE_IN_SIZE;
} }
@ -2592,8 +2585,8 @@ fuse_lib_setxattr(fuse_req_t *req_,
struct fuse_setxattr_in *arg; struct fuse_setxattr_in *arg;
arg = (fuse_setxattr_in*)fuse_hdr_arg(hdr_); arg = (fuse_setxattr_in*)fuse_hdr_arg(hdr_);
if((req_->f->conn.capable & FUSE_SETXATTR_EXT) &&
(req_->f->conn.want & FUSE_SETXATTR_EXT))
if((req_->conn.capable & FUSE_SETXATTR_EXT) &&
(req_->conn.want & FUSE_SETXATTR_EXT))
name = (const char*)PARAM(arg); name = (const char*)PARAM(arg);
else else
name = (((char*)arg) + FUSE_COMPAT_SETXATTR_IN_SIZE); name = (((char*)arg) + FUSE_COMPAT_SETXATTR_IN_SIZE);
@ -2834,7 +2827,7 @@ fuse_lib_tmpfile(fuse_req_t *req_,
ffi.flags = arg->flags; ffi.flags = arg->flags;
if(req_->f->conn.proto_minor >= 12)
if(req_->conn.proto_minor >= 12)
req_->ctx.umask = arg->umask; req_->ctx.umask = arg->umask;
else else
name = (char*)arg + sizeof(struct fuse_open_in); name = (char*)arg + sizeof(struct fuse_open_in);
@ -3078,7 +3071,7 @@ fuse_lib_release(fuse_req_t *req_,
arg = (fuse_release_in*)fuse_hdr_arg(hdr_); arg = (fuse_release_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh; ffi.fh = arg->fh;
ffi.flags = arg->flags; ffi.flags = arg->flags;
if(req_->f->conn.proto_minor >= 8)
if(req_->conn.proto_minor >= 8)
{ {
ffi.flush = !!(arg->release_flags & FUSE_RELEASE_FLUSH); ffi.flush = !!(arg->release_flags & FUSE_RELEASE_FLUSH);
ffi.lock_owner = arg->lock_owner; ffi.lock_owner = arg->lock_owner;
@ -3116,7 +3109,7 @@ fuse_lib_flush(fuse_req_t *req_,
ffi.fh = arg->fh; ffi.fh = arg->fh;
ffi.flush = 1; ffi.flush = 1;
if(req_->f->conn.proto_minor >= 7)
if(req_->conn.proto_minor >= 7)
ffi.lock_owner = arg->lock_owner; ffi.lock_owner = arg->lock_owner;
err = fuse_flush_common(req_,hdr_->nodeid,&ffi); err = fuse_flush_common(req_,hdr_->nodeid,&ffi);
@ -3276,14 +3269,15 @@ fuse_lib_ioctl(fuse_req_t *req_,
const struct fuse_ioctl_in *arg; const struct fuse_ioctl_in *arg;
arg = (fuse_ioctl_in*)fuse_hdr_arg(hdr_); arg = (fuse_ioctl_in*)fuse_hdr_arg(hdr_);
if((arg->flags & FUSE_IOCTL_DIR) && !(req_->f->conn.want & FUSE_CAP_IOCTL_DIR))
if((arg->flags & FUSE_IOCTL_DIR) &&
!(req_->conn.want & FUSE_CAP_IOCTL_DIR))
{ {
fuse_reply_err(req_,ENOTTY); fuse_reply_err(req_,ENOTTY);
return; return;
} }
if((sizeof(void*) == 4) && if((sizeof(void*) == 4) &&
(req_->f->conn.proto_minor >= 16) &&
(req_->conn.proto_minor >= 16) &&
!(arg->flags & FUSE_IOCTL_32BIT)) !(arg->flags & FUSE_IOCTL_32BIT))
{ {
req_->ioctl_64bit = 1; req_->ioctl_64bit = 1;
@ -3337,38 +3331,7 @@ void
fuse_lib_poll(fuse_req_t *req_, fuse_lib_poll(fuse_req_t *req_,
const struct fuse_in_header *hdr_) const struct fuse_in_header *hdr_)
{ {
int err;
unsigned revents = 0;
fuse_file_info_t ffi = {0};
fuse_pollhandle_t *ph = NULL;
const struct fuse_poll_in *arg;
arg = (fuse_poll_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
if(arg->flags & FUSE_POLL_SCHEDULE_NOTIFY)
{
ph = (fuse_pollhandle_t*)malloc(sizeof(fuse_pollhandle_t));
if(ph == NULL)
{
fuse_reply_err(req_,ENOMEM);
return;
}
ph->kh = arg->kh;
ph->ch = req_->ch;
ph->f = req_->f;
}
err = f.ops.poll(&req_->ctx,
&ffi,
ph,
&revents);
if(!err)
fuse_reply_poll(req_,revents);
else
fuse_reply_err(req_,err);
fuse_reply_err(req_,-ENOSYS);
} }
static static
@ -3555,12 +3518,6 @@ static struct fuse_lowlevel_ops fuse_path_ops =
.write = fuse_lib_write, .write = fuse_lib_write,
}; };
int
fuse_notify_poll(fuse_pollhandle_t *ph)
{
return fuse_lowlevel_notify_poll(ph);
}
int int
fuse_exited() fuse_exited()
{ {
@ -3584,8 +3541,6 @@ enum
KEY_HELP, KEY_HELP,
}; };
#define FUSE_LIB_OPT(t,p,v) { t,offsetof(struct fuse_config,p),v }
static const struct fuse_opt fuse_lib_opts[] = static const struct fuse_opt fuse_lib_opts[] =
{ {
FUSE_OPT_END FUSE_OPT_END
@ -3805,7 +3760,7 @@ fuse_new(struct fuse_chan *ch,
llop.setlk = NULL; llop.setlk = NULL;
} }
if(fuse_opt_parse(args,&f.conf,fuse_lib_opts,fuse_lib_opt_proc) == -1)
if(fuse_opt_parse(args,NULL,fuse_lib_opts,fuse_lib_opt_proc) == -1)
goto out_free_fs; goto out_free_fs;
g_LOG_METRICS = fuse_cfg.debug; g_LOG_METRICS = fuse_cfg.debug;

22
libfuse/lib/fuse_i.h

@ -27,7 +27,6 @@ struct fuse_session
void (*destroy)(void *data); void (*destroy)(void *data);
struct fuse_ll *f;
volatile int exited; volatile int exited;
struct fuse_chan *ch; struct fuse_chan *ch;
}; };
@ -43,27 +42,6 @@ struct fuse_notify_req
struct fuse_notify_req *prev; struct fuse_notify_req *prev;
}; };
struct fuse_ll
{
struct fuse_lowlevel_ops op;
void *userdata;
uid_t owner;
struct fuse_conn_info conn;
pthread_mutex_t lock;
int got_init;
int got_destroy;
int broken_splice_nonblock;
uint64_t notify_ctr;
struct fuse_notify_req notify_list;
};
struct fuse_cmd
{
char *buf;
size_t buflen;
struct fuse_chan *ch;
};
EXTERN_C_BEGIN EXTERN_C_BEGIN
struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse *fuse_new_common(struct fuse_chan *ch,

1
libfuse/lib/fuse_loop.cpp

@ -16,7 +16,6 @@
#include "fuse_cfg.hpp" #include "fuse_cfg.hpp"
#include "fuse_msgbuf.hpp" #include "fuse_msgbuf.hpp"
#include "fuse_ll.hpp"
#include <cassert> #include <cassert>
#include <memory> #include <memory>

523
libfuse/lib/fuse_lowlevel.cpp
File diff suppressed because it is too large
View File

36
libfuse/lib/fuse_req.cpp

@ -0,0 +1,36 @@
#include "fuse_req.hpp"
#include <cstddef>
#include <cstdlib>
typedef struct stack_t stack_t;
struct stack_t
{
stack_t *next;
};
thread_local static stack_t *g_stack = NULL;
fuse_req_t*
fuse_req_alloc()
{
if(g_stack == NULL)
return (fuse_req_t*)calloc(1,sizeof(fuse_req_t));
fuse_req_t *req;
req = (fuse_req_t*)g_stack;
g_stack = g_stack->next;
return req;
}
void
fuse_req_free(fuse_req_t *req_)
{
stack_t *stack;
stack = (stack_t*)req_;
stack->next = g_stack;
g_stack = stack;
}

18
libfuse/lib/fuse_session.cpp

@ -26,19 +26,17 @@ struct fuse_chan
}; };
struct fuse_session * struct fuse_session *
fuse_session_new(void *data,
void *receive_buf,
fuse_session_new(void *receive_buf,
void *process_buf, void *process_buf,
void *destroy) void *destroy)
{ {
struct fuse_session *se = (struct fuse_session *) malloc(sizeof(*se));
if (se == NULL) {
struct fuse_session *se = (struct fuse_session *)calloc(1,sizeof(*se));
if(se == NULL)
{
fprintf(stderr, "fuse: failed to allocate session\n"); fprintf(stderr, "fuse: failed to allocate session\n");
return NULL; return NULL;
} }
memset(se, 0, sizeof(*se));
se->f = (fuse_ll*)data;
se->receive_buf = (int(*)(fuse_session*,fuse_msgbuf_t*))receive_buf; se->receive_buf = (int(*)(fuse_session*,fuse_msgbuf_t*))receive_buf;
se->process_buf = (void(*)(fuse_session*,const fuse_msgbuf_t*))process_buf; se->process_buf = (void(*)(fuse_session*,const fuse_msgbuf_t*))process_buf;
se->destroy = (void(*)(void*))destroy; se->destroy = (void(*)(void*))destroy;
@ -67,7 +65,7 @@ void fuse_session_remove_chan(struct fuse_chan *ch)
void void
fuse_session_destroy(struct fuse_session *se) fuse_session_destroy(struct fuse_session *se)
{ {
se->destroy(se->f);
se->destroy(NULL);
if(se->ch != NULL) if(se->ch != NULL)
fuse_chan_destroy(se->ch); fuse_chan_destroy(se->ch);
free(se); free(se);
@ -90,12 +88,6 @@ fuse_session_exit(struct fuse_session *se_)
se_->exited = 1; se_->exited = 1;
} }
void*
fuse_session_data(struct fuse_session *se)
{
return se->f;
}
struct fuse_chan * struct fuse_chan *
fuse_chan_new(int fd, fuse_chan_new(int fd,
size_t bufsize) size_t bufsize)

1
libfuse/lib/node.cpp

@ -9,6 +9,7 @@ struct stack_t
}; };
thread_local static stack_t *g_stack = NULL; thread_local static stack_t *g_stack = NULL;
thread_local bool gc = false;
node_t* node_t*
node_alloc() node_alloc()

89
src/fixed_mem_pool.hpp

@ -1,89 +0,0 @@
/*
ISC License
Copyright (c) 2020, 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 <cstdint>
#include <stdlib.h>
typedef struct fixed_mem_pool_t fixed_mem_pool_t;
struct fixed_mem_pool_t
{
fixed_mem_pool_t *next;
};
template<uint64_t SIZE>
class FixedMemPool
{
public:
FixedMemPool()
{
list.next = NULL;
}
~FixedMemPool()
{
void *mem;
while(!empty())
{
mem = alloc();
::free(mem);
}
}
bool
empty(void)
{
return (list.next == NULL);
}
uint64_t
size(void)
{
return SIZE;
}
void*
alloc(void)
{
void *rv;
if(list.next == NULL)
return malloc(SIZE);
rv = (void*)list.next;
list.next = list.next->next;
return rv;
}
void
free(void *mem_)
{
fixed_mem_pool_t *next;
next = (fixed_mem_pool_t*)mem_;
next->next = list.next;
list.next = next;
}
private:
fixed_mem_pool_t list;
};

12
src/fuse_init.cpp

@ -35,7 +35,7 @@
static static
void void
_want(fuse_conn_info *conn_,
_want(fuse_conn_info_t *conn_,
const int flag_) const int flag_)
{ {
conn_->want |= flag_; conn_->want |= flag_;
@ -43,7 +43,7 @@ _want(fuse_conn_info *conn_,
static static
bool bool
_capable(fuse_conn_info *conn_,
_capable(fuse_conn_info_t *conn_,
const int flag_) const int flag_)
{ {
return !!(conn_->capable & flag_); return !!(conn_->capable & flag_);
@ -51,7 +51,7 @@ _capable(fuse_conn_info *conn_,
static static
void void
_want_if_capable(fuse_conn_info *conn_,
_want_if_capable(fuse_conn_info_t *conn_,
const int flag_) const int flag_)
{ {
if(::_capable(conn_,flag_)) if(::_capable(conn_,flag_))
@ -60,7 +60,7 @@ _want_if_capable(fuse_conn_info *conn_,
static static
void void
_want_if_capable(fuse_conn_info *conn_,
_want_if_capable(fuse_conn_info_t *conn_,
const int flag_, const int flag_,
ConfigBOOL *want_) ConfigBOOL *want_)
{ {
@ -78,7 +78,7 @@ static const char MAX_PAGES_LIMIT_FILEPATH[] = "/proc/sys/fs/fuse/max_pages_limi
static static
void void
_want_if_capable_max_pages(fuse_conn_info *conn_,
_want_if_capable_max_pages(fuse_conn_info_t *conn_,
Config &cfg_) Config &cfg_)
{ {
std::fstream f; std::fstream f;
@ -184,7 +184,7 @@ _spawn_thread_to_set_readahead()
} }
void * void *
FUSE::init(fuse_conn_info *conn_)
FUSE::init(fuse_conn_info_t *conn_)
{ {
procfs::init(); procfs::init();
ugid::init(); ugid::init();

2
src/fuse_init.hpp

@ -22,5 +22,5 @@
namespace FUSE namespace FUSE
{ {
void * void *
init(fuse_conn_info *conn);
init(fuse_conn_info_t *conn);
} }

38
src/fuse_poll.cpp

@ -1,38 +0,0 @@
/*
ISC License
Copyright (c) 2021, 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.
*/
#include "fuse_poll.hpp"
#include "errno.hpp"
#include "fuse.h"
int
FUSE::poll(const fuse_req_ctx_t *ctx_,
const fuse_file_info_t *ffi_,
fuse_pollhandle_t *ph_,
unsigned *reventsp_)
{
(void)ctx_;
(void)ffi_;
(void)ph_;
(void)reventsp_;
return -ENOSYS;
}

31
src/fuse_poll.hpp

@ -1,31 +0,0 @@
/*
ISC License
Copyright (c) 2021, 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 "fuse.h"
namespace FUSE
{
int
poll(const fuse_req_ctx_t *ctx,
const fuse_file_info_t *ffi,
fuse_pollhandle_t *ph,
unsigned *reventsp);
}

21
src/mempools.cpp

@ -1,21 +0,0 @@
/*
ISC License
Copyright (c) 2020, 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.
*/
#include "locked_fixed_mem_pool.hpp"
LockedFixedMemPool<128 * 1024> g_DENTS_BUF_POOL;

23
src/mempools.hpp

@ -1,23 +0,0 @@
/*
ISC License
Copyright (c) 2020, 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 "locked_fixed_mem_pool.hpp"
extern LockedFixedMemPool<128 * 1024> g_DENTS_BUF_POOL;

2
src/mergerfs.cpp

@ -61,7 +61,6 @@
#include "fuse_mknod.hpp" #include "fuse_mknod.hpp"
#include "fuse_open.hpp" #include "fuse_open.hpp"
#include "fuse_opendir.hpp" #include "fuse_opendir.hpp"
#include "fuse_poll.hpp"
#include "fuse_read.hpp" #include "fuse_read.hpp"
#include "fuse_readdir.hpp" #include "fuse_readdir.hpp"
#include "fuse_readdir_plus.hpp" #include "fuse_readdir_plus.hpp"
@ -126,7 +125,6 @@ _get_fuse_operations(struct fuse_operations &ops_,
ops_.mknod = FUSE::mknod; ops_.mknod = FUSE::mknod;
ops_.open = FUSE::open; ops_.open = FUSE::open;
ops_.opendir = FUSE::opendir; ops_.opendir = FUSE::opendir;
ops_.poll = FUSE::poll;;
ops_.read = (nullrw_ ? FUSE::read_null : FUSE::read); ops_.read = (nullrw_ ? FUSE::read_null : FUSE::read);
ops_.readdir = FUSE::readdir; ops_.readdir = FUSE::readdir;
ops_.readdir_plus = FUSE::readdir_plus; ops_.readdir_plus = FUSE::readdir_plus;

Loading…
Cancel
Save