mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-04-12 01:30:21 +00:00
This adds a new notify channel to the transfuse protocol. It is not optional yet but could be made to be optional. A notify protocol and notify channel are required because writing FUSE response messages to the FUSE device has different semantics from writing asynchronous notifications. In particular, response message writes only error on malformed messages, do not take locks, and do not block. In contrast, asynchronous notifications can error under normal conditions (e.g. invalidating a cache entry that doesn't exist), can take locks during the write call, and can block. If responses and notifications occur in the same thread, the file system can become deadlocked when syscalls lock resources waiting for a response and a notification is written that blocks attempting to acquire those same locks. The response that would unlock the contended lock could be queued behind the notification write but the notification write can't unblock until the response is written in the future. This patch enables file systems to avoid that fate by offering a secondary channel on which to send notifications. Signed-off-by: David Sheets <dsheets@docker.com>
62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
#include <pthread.h>
|
|
#include <sys/socket.h>
|
|
|
|
typedef struct {
|
|
char * server;
|
|
char * socket;
|
|
char * fusermount;
|
|
char * pidfile;
|
|
char * logfile;
|
|
int logfile_fd;
|
|
int ctl_sock;
|
|
int data_sock;
|
|
pthread_mutex_t ctl_lock;
|
|
} parameters;
|
|
|
|
typedef struct {
|
|
parameters * params;
|
|
char * type_descr;
|
|
char * mount_point;
|
|
struct sockaddr sa_client;
|
|
socklen_t socklen_client;
|
|
int sock;
|
|
} connection_t;
|
|
|
|
pthread_attr_t detached;
|
|
|
|
void * must_malloc(char *const descr, size_t size);
|
|
|
|
void lock(char *const descr, pthread_mutex_t * mutex);
|
|
|
|
void unlock(char *const descr, pthread_mutex_t * mutex);
|
|
|
|
void write_exactly(char * descr, int fd, void * buf, size_t nbyte);
|
|
|
|
#define IN_BUFSZ ((1 << 20) + 16)
|
|
#define OUT_BUFSZ ((1 << 20) + 64)
|
|
#define EVENT_BUFSZ 4096
|
|
#define CTL_BUFSZ 65536
|
|
|
|
#define DEFAULT_FUSERMOUNT "/bin/fusermount"
|
|
#define DEFAULT_SOCKET "v:_:1525"
|
|
#define DEFAULT_SERVER "v:2:1524"
|
|
|
|
#define PING 128
|
|
#define RMDIR_SYSCALL 0
|
|
#define UNLINK_SYSCALL 1
|
|
#define MKDIR_SYSCALL 2
|
|
#define SYMLINK_SYSCALL 3
|
|
#define TRUNCATE_SYSCALL 4
|
|
#define CHMOD_SYSCALL 5
|
|
#define MKNOD_REG_SYSCALL 6
|
|
// these could be turned into an enum probably but... C standard nausea
|
|
|
|
#define MOUNT_SUITABILITY_REQUEST 1
|
|
#define EXPORT_SUITABILITY_REQUEST 2
|
|
|
|
#define TRANSFUSE_LOG_ERROR 1
|
|
#define TRANSFUSE_LOG_NOTICE 2
|
|
#define PONG_REPLY 3
|
|
#define MOUNT_SUITABILITY_REPLY 4
|
|
#define TRANSFUSE_NOTIFY_CHANNEL 5
|