Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/fuse/fuse_node.c
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
#include "fuse_io.h" | #include "fuse_io.h" | ||||
#include "fuse_ipc.h" | #include "fuse_ipc.h" | ||||
#define FUSE_DEBUG_MODULE VNOPS | #define FUSE_DEBUG_MODULE VNOPS | ||||
#include "fuse_debug.h" | #include "fuse_debug.h" | ||||
MALLOC_DEFINE(M_FUSEVN, "fuse_vnode", "fuse vnode private data"); | MALLOC_DEFINE(M_FUSEVN, "fuse_vnode", "fuse vnode private data"); | ||||
static int sysctl_fuse_cache_mode(SYSCTL_HANDLER_ARGS); | |||||
static int fuse_node_count = 0; | static int fuse_node_count = 0; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, node_count, CTLFLAG_RD, | SYSCTL_INT(_vfs_fuse, OID_AUTO, node_count, CTLFLAG_RD, | ||||
&fuse_node_count, 0, "Count of FUSE vnodes"); | &fuse_node_count, 0, "Count of FUSE vnodes"); | ||||
int fuse_data_cache_enable = 1; | int fuse_data_cache_mode = FUSE_CACHE_WT; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, data_cache_enable, CTLFLAG_RW, | SYSCTL_PROC(_vfs_fuse, OID_AUTO, data_cache_mode, CTLTYPE_INT|CTLFLAG_RW, | ||||
&fuse_data_cache_enable, 0, | &fuse_data_cache_mode, 0, sysctl_fuse_cache_mode, "I", | ||||
"enable caching of FUSE file data (including dirty data)"); | "Zero: disable caching of FUSE file data; One: write-through caching " | ||||
"(default); Two: write-back caching (generally unsafe)"); | |||||
int fuse_data_cache_invalidate = 0; | int fuse_data_cache_invalidate = 0; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, data_cache_invalidate, CTLFLAG_RW, | SYSCTL_INT(_vfs_fuse, OID_AUTO, data_cache_invalidate, CTLFLAG_RW, | ||||
&fuse_data_cache_invalidate, 0, | &fuse_data_cache_invalidate, 0, | ||||
"If non-zero, discard cached clean file data when there are no active file" | "If non-zero, discard cached clean file data when there are no active file" | ||||
" users"); | " users"); | ||||
int fuse_mmap_enable = 1; | int fuse_mmap_enable = 1; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, mmap_enable, CTLFLAG_RW, | SYSCTL_INT(_vfs_fuse, OID_AUTO, mmap_enable, CTLFLAG_RW, | ||||
&fuse_mmap_enable, 0, | &fuse_mmap_enable, 0, | ||||
"If non-zero, and data_cache_enable is also non-zero, enable mmap(2) of " | "If non-zero, and data_cache_mode is also non-zero, enable mmap(2) of " | ||||
"FUSE files"); | "FUSE files"); | ||||
int fuse_refresh_size = 0; | int fuse_refresh_size = 0; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, refresh_size, CTLFLAG_RW, | SYSCTL_INT(_vfs_fuse, OID_AUTO, refresh_size, CTLFLAG_RW, | ||||
&fuse_refresh_size, 0, | &fuse_refresh_size, 0, | ||||
"If non-zero, and no dirty file extension data is buffered, fetch file " | "If non-zero, and no dirty file extension data is buffered, fetch file " | ||||
"size before write operations"); | "size before write operations"); | ||||
int fuse_sync_resize = 1; | int fuse_sync_resize = 1; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, sync_resize, CTLFLAG_RW, | SYSCTL_INT(_vfs_fuse, OID_AUTO, sync_resize, CTLFLAG_RW, | ||||
&fuse_sync_resize, 0, | &fuse_sync_resize, 0, | ||||
"If a cached write extended a file, inform FUSE filesystem of the changed" | "If a cached write extended a file, inform FUSE filesystem of the changed" | ||||
"size immediately subsequent to the issued writes"); | "size immediately subsequent to the issued writes"); | ||||
int fuse_fix_broken_io = 0; | int fuse_fix_broken_io = 0; | ||||
SYSCTL_INT(_vfs_fuse, OID_AUTO, fix_broken_io, CTLFLAG_RW, | SYSCTL_INT(_vfs_fuse, OID_AUTO, fix_broken_io, CTLFLAG_RW, | ||||
&fuse_fix_broken_io, 0, | &fuse_fix_broken_io, 0, | ||||
"If non-zero, print a diagnostic warning if a userspace filesystem returns" | "If non-zero, print a diagnostic warning if a userspace filesystem returns" | ||||
" EIO on reads of recently extended portions of files"); | " EIO on reads of recently extended portions of files"); | ||||
static int | |||||
sysctl_fuse_cache_mode(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
int val, error; | |||||
val = *(int *)arg1; | |||||
error = sysctl_handle_int(oidp, &val, 0, req); | |||||
if (error || !req->newptr) | |||||
return (error); | |||||
switch (val) { | |||||
case FUSE_CACHE_UC: | |||||
case FUSE_CACHE_WT: | |||||
case FUSE_CACHE_WB: | |||||
*(int *)arg1 = val; | |||||
break; | |||||
default: | |||||
return (EDOM); | |||||
} | |||||
return (0); | |||||
} | |||||
static void | static void | ||||
fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, | fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, | ||||
uint64_t nodeid, enum vtype vtyp) | uint64_t nodeid, enum vtype vtyp) | ||||
{ | { | ||||
int i; | int i; | ||||
fvdat->nid = nodeid; | fvdat->nid = nodeid; | ||||
vattr_null(&fvdat->cached_attrs); | vattr_null(&fvdat->cached_attrs); | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred) | fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred) | ||||
{ | { | ||||
struct fuse_vnode_data *fvdat = VTOFUD(vp); | struct fuse_vnode_data *fvdat = VTOFUD(vp); | ||||
struct vattr va; | struct vattr va; | ||||
if ((fvdat->flag & FN_SIZECHANGE) != 0 || | if ((fvdat->flag & FN_SIZECHANGE) != 0 || | ||||
fuse_data_cache_enable == 0 || | fuse_data_cache_mode == FUSE_CACHE_UC || | ||||
(fuse_refresh_size == 0 && fvdat->filesize != 0)) | (fuse_refresh_size == 0 && fvdat->filesize != 0)) | ||||
return; | return; | ||||
VOP_GETATTR(vp, &va, cred); | VOP_GETATTR(vp, &va, cred); | ||||
FS_DEBUG("refreshed file size: %jd\n", (intmax_t)VTOFUD(vp)->filesize); | FS_DEBUG("refreshed file size: %jd\n", (intmax_t)VTOFUD(vp)->filesize); | ||||
} | } | ||||
int | int | ||||
Show All 21 Lines |