fusefs: convert debug printfs into dtrace probes

fuse(4) was heavily instrumented with debug printf statements that could
only be enabled with compile-time flags. They fell into three basic groups:

1. Totally redundant with dtrace FBT probes. These I deleted.
2. Print textual information, usually error messages. These I converted to
   SDT probes of the form fuse:fuse:FILE:trace. They work just like the old
   printf statements except they can be enabled at runtime with dtrace. They
   can be filtered by FILE and/or by priority.
3. More complicated probes that print detailed information. These I
   converted into ad-hoc SDT probes.

Also, de-inline fuse_internal_cache_attrs.  It's big enough to be a regular
function, and this way it gets a dtrace FBT probe.

This commit is a merge of r345304, r344914, r344703, and r344664 from
projects/fuse2.

Reviewed by:	cem
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19667
This commit is contained in:
Alan Somers 2019-03-29 02:13:06 +00:00
commit 080518d810
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345675
13 changed files with 294 additions and 549 deletions

View File

@ -159,65 +159,8 @@ do { \
(cred) = (td)->td_ucred; \
} while (0)
/* Debug related stuff */
#ifndef FUSE_DEBUG_DEVICE
#define FUSE_DEBUG_DEVICE 0
#endif
#ifndef FUSE_DEBUG_FILE
#define FUSE_DEBUG_FILE 0
#endif
#ifndef FUSE_DEBUG_INTERNAL
#define FUSE_DEBUG_INTERNAL 0
#endif
#ifndef FUSE_DEBUG_IO
#define FUSE_DEBUG_IO 0
#endif
#ifndef FUSE_DEBUG_IPC
#define FUSE_DEBUG_IPC 0
#endif
#ifndef FUSE_DEBUG_LOCK
#define FUSE_DEBUG_LOCK 0
#endif
#ifndef FUSE_DEBUG_VFSOPS
#define FUSE_DEBUG_VFSOPS 0
#endif
#ifndef FUSE_DEBUG_VNOPS
#define FUSE_DEBUG_VNOPS 0
#endif
#ifndef FUSE_TRACE
#define FUSE_TRACE 0
#endif
#define DEBUGX(cond, fmt, ...) do { \
if (((cond))) { \
printf("%s: " fmt, __func__, ## __VA_ARGS__); \
} \
} while (0)
#define fuse_lck_mtx_lock(mtx) do { \
DEBUGX(FUSE_DEBUG_LOCK, "0: lock(%s): %s@%d by %d\n", \
__STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
mtx_lock(&(mtx)); \
DEBUGX(FUSE_DEBUG_LOCK, "1: lock(%s): %s@%d by %d\n", \
__STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
} while (0)
#define fuse_lck_mtx_unlock(mtx) do { \
DEBUGX(FUSE_DEBUG_LOCK, "0: unlock(%s): %s@%d by %d\n", \
__STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
mtx_unlock(&(mtx)); \
DEBUGX(FUSE_DEBUG_LOCK, "1: unlock(%s): %s@%d by %d\n", \
__STRING(mtx), __func__, __LINE__, curthread->td_proc->p_pid); \
} while (0)
#define fuse_lck_mtx_lock(mtx) mtx_lock(&(mtx))
#define fuse_lck_mtx_unlock(mtx) mtx_unlock(&(mtx))
void fuse_ipc_init(void);
void fuse_ipc_destroy(void);

View File

@ -1,81 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2007-2009 Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright (C) 2005 Csaba Henk.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
/* Debug related stuff */
#ifndef FUSE_DEBUG_MODULE
#error "FUSE_DEBUG_MODULE is not defined"
#else
#define FUSE_DEBUG_VAR __CONCAT(FUSE_DEBUG_,FUSE_DEBUG_MODULE)
#endif
#define FS_DEBUG(fmt, ...) DEBUGX(FUSE_DEBUG_VAR >= 1, fmt, ## __VA_ARGS__)
#define FS_DEBUG2G(fmt, ...) DEBUGX(FUSE_DEBUG_VAR >= 2, fmt, ## __VA_ARGS__)
#define debug_printf(fmt, ...) FS_DEBUG(fmt, ## __VA_ARGS__)
#define kdebug_printf(fmt, ...) FS_DEBUG(fmt, ## __VA_ARGS__)
#define fuse_trace_printf(fmt, ...) \
DEBUGX(FUSE_DEBUG_VAR && FUSE_TRACE, fmt, ## __VA_ARGS__)
#define fuse_trace_printf_func() \
fuse_trace_printf("%s:%d\n", __FILE__, __LINE__)
#define fuse_trace_printf_vfsop() fuse_trace_printf_func()
#define fuse_trace_printf_vnop() fuse_trace_printf_func()

View File

@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/mount.h>
#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <sys/sysctl.h>
@ -82,8 +83,13 @@ __FBSDID("$FreeBSD$");
#include "fuse.h"
#include "fuse_ipc.h"
#define FUSE_DEBUG_MODULE DEVICE
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , device, trace, "int", "char*");
static struct cdev *fuse_dev;
@ -127,15 +133,14 @@ fuse_device_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
struct fuse_data *fdata;
int error;
FS_DEBUG("device %p\n", dev);
SDT_PROBE2(fuse, , device, trace, 1, "device open");
fdata = fdata_alloc(dev, td->td_ucred);
error = devfs_set_cdevpriv(fdata, fdata_dtor);
if (error != 0)
fdata_trydestroy(fdata);
else
FS_DEBUG("%s: device opened by thread %d.\n", dev->si_name,
td->td_tid);
SDT_PROBE2(fuse, , device, trace, 1, "device open success");
return (error);
}
@ -170,7 +175,7 @@ fuse_device_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
fuse_lck_mtx_unlock(data->aw_mtx);
FUSE_UNLOCK();
FS_DEBUG("%s: device closed by thread %d.\n", dev->si_name, td->td_tid);
SDT_PROBE2(fuse, , device, trace, 1, "device close");
return (0);
}
@ -214,7 +219,7 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
int buflen[3];
int i;
FS_DEBUG("fuse device being read on thread %d\n", uio->uio_td->td_tid);
SDT_PROBE2(fuse, , device, trace, 1, "fuse device read");
err = devfs_get_cdevpriv((void **)&data);
if (err != 0)
@ -223,7 +228,9 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
fuse_lck_mtx_lock(data->ms_mtx);
again:
if (fdata_get_dead(data)) {
FS_DEBUG2G("we know early on that reader should be kicked so we don't wait for news\n");
SDT_PROBE2(fuse, , device, trace, 2,
"we know early on that reader should be kicked so we "
"don't wait for news");
fuse_lck_mtx_unlock(data->ms_mtx);
return (ENODEV);
}
@ -249,7 +256,7 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
* -- and some other cases, too, tho not totally clear, when
* (cv_signal/wakeup_one signals the whole process ?)
*/
FS_DEBUG("no message on thread #%d\n", uio->uio_td->td_tid);
SDT_PROBE2(fuse, , device, trace, 1, "no message on thread");
goto again;
}
fuse_lck_mtx_unlock(data->ms_mtx);
@ -259,16 +266,18 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
* somebody somewhere -- eg., umount routine --
* wants this liaison finished off
*/
FS_DEBUG2G("reader is to be sacked\n");
SDT_PROBE2(fuse, , device, trace, 2, "reader is to be sacked");
if (tick) {
FS_DEBUG2G("weird -- \"kick\" is set tho there is message\n");
SDT_PROBE2(fuse, , device, trace, 2, "weird -- "
"\"kick\" is set tho there is message");
FUSE_ASSERT_MS_DONE(tick);
fuse_ticket_drop(tick);
}
return (ENODEV); /* This should make the daemon get off
* of us */
}
FS_DEBUG("message got on thread #%d\n", uio->uio_td->td_tid);
SDT_PROBE2(fuse, , device, trace, 1,
"fuse device read message successfully");
KASSERT(tick->tk_ms_bufdata || tick->tk_ms_bufsize == 0,
("non-null buf pointer with positive size"));
@ -302,7 +311,8 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
*/
if (uio->uio_resid < buflen[i]) {
fdata_set_dead(data);
FS_DEBUG2G("daemon is stupid, kick it off...\n");
SDT_PROBE2(fuse, , device, trace, 2,
"daemon is stupid, kick it off...");
err = ENODEV;
break;
}
@ -320,16 +330,14 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
static inline int
fuse_ohead_audit(struct fuse_out_header *ohead, struct uio *uio)
{
FS_DEBUG("Out header -- len: %i, error: %i, unique: %llu; iovecs: %d\n",
ohead->len, ohead->error, (unsigned long long)ohead->unique,
uio->uio_iovcnt);
if (uio->uio_resid + sizeof(struct fuse_out_header) != ohead->len) {
FS_DEBUG("Format error: body size differs from size claimed by header\n");
SDT_PROBE2(fuse, , device, trace, 1, "Format error: body size "
"differs from size claimed by header");
return (EINVAL);
}
if (uio->uio_resid && ohead->error) {
FS_DEBUG("Format error: non zero error but message had a body\n");
SDT_PROBE2(fuse, , device, trace, 1,
"Format error: non zero error but message had a body");
return (EINVAL);
}
/* Sanitize the linuxism of negative errnos */
@ -338,6 +346,8 @@ fuse_ohead_audit(struct fuse_out_header *ohead, struct uio *uio)
return (0);
}
SDT_PROBE_DEFINE1(fuse, , device, fuse_device_write_bumped_into_callback,
"uint64_t");
/*
* fuse_device_write first reads the header sent by the daemon.
* If that's OK, looks up ticket/callback node by the unique id seen in header.
@ -353,15 +363,13 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag)
struct fuse_ticket *tick, *x_tick;
int found = 0;
FS_DEBUG("resid: %zd, iovcnt: %d, thread: %d\n",
uio->uio_resid, uio->uio_iovcnt, uio->uio_td->td_tid);
err = devfs_get_cdevpriv((void **)&data);
if (err != 0)
return (err);
if (uio->uio_resid < sizeof(struct fuse_out_header)) {
FS_DEBUG("got less than a header!\n");
SDT_PROBE2(fuse, , device, trace, 1,
"fuse_device_write got less than a header!");
fdata_set_dead(data);
return (EINVAL);
}
@ -385,8 +393,9 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag)
fuse_lck_mtx_lock(data->aw_mtx);
TAILQ_FOREACH_SAFE(tick, &data->aw_head, tk_aw_link,
x_tick) {
FS_DEBUG("bumped into callback #%llu\n",
(unsigned long long)tick->tk_unique);
SDT_PROBE1(fuse, , device,
fuse_device_write_bumped_into_callback,
tick->tk_unique);
if (tick->tk_unique == ohead.unique) {
found = 1;
fuse_aw_remove(tick);
@ -405,12 +414,14 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag)
* via ticket_drop(), so no manual mucking
* around...)
*/
FS_DEBUG("pass ticket to a callback\n");
SDT_PROBE2(fuse, , device, trace, 1,
"pass ticket to a callback");
memcpy(&tick->tk_aw_ohead, &ohead, sizeof(ohead));
err = tick->tk_aw_handler(tick, uio);
} else {
/* pretender doesn't wanna do anything with answer */
FS_DEBUG("stuff devalidated, so we drop it\n");
SDT_PROBE2(fuse, , device, trace, 1,
"stuff devalidated, so we drop it");
}
/*
@ -421,7 +432,8 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag)
fuse_ticket_drop(tick);
} else {
/* no callback at all! */
FS_DEBUG("erhm, no handler for this response\n");
SDT_PROBE2(fuse, , device, trace, 1,
"erhm, no handler for this response");
err = EINVAL;
}

View File

@ -58,11 +58,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/uio.h>
@ -74,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/sdt.h>
#include <sys/sysctl.h>
#include "fuse.h"
@ -82,8 +82,13 @@ __FBSDID("$FreeBSD$");
#include "fuse_ipc.h"
#include "fuse_node.h"
#define FUSE_DEBUG_MODULE FILE
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , file, trace, "int", "char*");
static int fuse_fh_count = 0;
@ -102,9 +107,6 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type,
int oflags = 0;
int op = FUSE_OPEN;
fuse_trace_printf("fuse_filehandle_open(vp=%p, fufh_type=%d)\n",
vp, fufh_type);
if (fuse_filehandle_valid(vp, fufh_type)) {
panic("FUSE: filehandle_open called despite valid fufh (type=%d)",
fufh_type);
@ -118,6 +120,8 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type,
if (vnode_isdir(vp)) {
op = FUSE_OPENDIR;
if (fufh_type != FUFH_RDONLY) {
SDT_PROBE2(fuse, , file, trace, 1,
"non-rdonly fh requested for a directory?");
printf("FUSE:non-rdonly fh requested for a directory?\n");
fufh_type = FUFH_RDONLY;
}
@ -129,7 +133,8 @@ fuse_filehandle_open(struct vnode *vp, fufh_type_t fufh_type,
foi->flags = oflags;
if ((err = fdisp_wait_answ(&fdi))) {
debug_printf("OUCH ... daemon didn't give fh (err = %d)\n", err);
SDT_PROBE2(fuse, , file, trace, 1,
"OUCH ... daemon didn't give fh");
if (err == ENOENT) {
fuse_internal_vnode_disappear(vp);
}
@ -167,9 +172,6 @@ fuse_filehandle_close(struct vnode *vp, fufh_type_t fufh_type,
int err = 0;
int op = FUSE_RELEASE;
fuse_trace_printf("fuse_filehandle_put(vp=%p, fufh_type=%d)\n",
vp, fufh_type);
fufh = &(fvdat->fufh[fufh_type]);
if (!FUFH_IS_VALID(fufh)) {
panic("FUSE: filehandle_put called on invalid fufh (type=%d)",
@ -266,7 +268,6 @@ fuse_filehandle_init(struct vnode *vp, fufh_type_t fufh_type,
struct fuse_vnode_data *fvdat = VTOFUD(vp);
struct fuse_filehandle *fufh;
FS_DEBUG("id=%jd type=%d\n", (intmax_t)fh_id, fufh_type);
fufh = &(fvdat->fufh[fufh_type]);
MPASS(!FUFH_IS_VALID(fufh));
fufh->fh_id = fh_id;

View File

@ -58,11 +58,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/uio.h>
@ -70,6 +69,7 @@ __FBSDID("$FreeBSD$");
#include <sys/queue.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sdt.h>
#include <sys/sx.h>
#include <sys/proc.h>
#include <sys/mount.h>
@ -94,8 +94,13 @@ __FBSDID("$FreeBSD$");
#include "fuse_file.h"
#include "fuse_param.h"
#define FUSE_DEBUG_MODULE INTERNAL
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , internal, trace, "int", "char*");
#ifdef ZERO_PAD_INCOMPLETE_BUFS
static int isbzero(void *buf, size_t len);
@ -127,8 +132,6 @@ fuse_internal_access(struct vnode *vp,
*/
/* return 0;*/
fuse_trace_printf_func();
mp = vnode_mount(vp);
vtype = vnode_vtype(vp);
@ -204,13 +207,71 @@ fuse_internal_access(struct vnode *vp,
return err;
}
/*
* Cache FUSE attributes from feo, in attr cache associated with vnode 'vp'.
* Optionally, if argument 'vap' is not NULL, store a copy of the converted
* attributes there as well.
*
* If the nominal attribute cache TTL is zero, do not cache on the 'vp' (but do
* return the result to the caller).
*/
void
fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr,
uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap)
{
struct mount *mp;
struct fuse_vnode_data *fvdat;
struct vattr *vp_cache_at;
mp = vnode_mount(vp);
fvdat = VTOFUD(vp);
/* Honor explicit do-not-cache requests from user filesystems. */
if (attr_valid == 0 && attr_valid_nsec == 0)
fvdat->valid_attr_cache = false;
else
fvdat->valid_attr_cache = true;
vp_cache_at = VTOVA(vp);
if (vap == NULL && vp_cache_at == NULL)
return;
if (vap == NULL)
vap = vp_cache_at;
vattr_null(vap);
vap->va_fsid = mp->mnt_stat.f_fsid.val[0];
vap->va_fileid = attr->ino;
vap->va_mode = attr->mode & ~S_IFMT;
vap->va_nlink = attr->nlink;
vap->va_uid = attr->uid;
vap->va_gid = attr->gid;
vap->va_rdev = attr->rdev;
vap->va_size = attr->size;
/* XXX on i386, seconds are truncated to 32 bits */
vap->va_atime.tv_sec = attr->atime;
vap->va_atime.tv_nsec = attr->atimensec;
vap->va_mtime.tv_sec = attr->mtime;
vap->va_mtime.tv_nsec = attr->mtimensec;
vap->va_ctime.tv_sec = attr->ctime;
vap->va_ctime.tv_nsec = attr->ctimensec;
vap->va_blocksize = PAGE_SIZE;
vap->va_type = IFTOVT(attr->mode);
vap->va_bytes = attr->blocks * S_BLKSIZE;
vap->va_flags = 0;
if (vap != vp_cache_at && vp_cache_at != NULL)
memcpy(vp_cache_at, vap, sizeof(*vap));
}
/* fsync */
int
fuse_internal_fsync_callback(struct fuse_ticket *tick, struct uio *uio)
{
fuse_trace_printf_func();
if (tick->tk_aw_ohead.error == ENOSYS) {
fsess_set_notimpl(tick->tk_data->mp, fticket_opcode(tick));
}
@ -227,8 +288,6 @@ fuse_internal_fsync(struct vnode *vp,
struct fuse_fsync_in *ffsi;
struct fuse_dispatcher fdi;
fuse_trace_printf_func();
if (vnode_isdir(vp)) {
op = FUSE_FSYNCDIR;
}
@ -386,8 +445,6 @@ fuse_internal_remove(struct vnode *dvp,
err = 0;
fvdat = VTOFUD(vp);
debug_printf("dvp=%p, cnp=%p, op=%d\n", vp, cnp, op);
fdisp_init(&fdi, cnp->cn_namelen + 1);
fdisp_make_vp(&fdi, op, dvp, cnp->cn_thread, cnp->cn_cred);
@ -442,8 +499,6 @@ fuse_internal_newentry_makerequest(struct mount *mp,
size_t bufsize,
struct fuse_dispatcher *fdip)
{
debug_printf("fdip=%p\n", fdip);
fdip->iosize = bufsize + cnp->cn_namelen + 1;
fdisp_make(fdip, op, mp, dnid, cnp->cn_thread, cnp->cn_cred);
@ -477,7 +532,8 @@ fuse_internal_newentry_core(struct vnode *dvp,
feo->nodeid, 1);
return err;
}
cache_attrs(*vpp, feo, NULL);
fuse_internal_cache_attrs(*vpp, &feo->attr, feo->attr_valid,
feo->attr_valid_nsec, NULL);
return err;
}
@ -526,9 +582,6 @@ fuse_internal_forget_send(struct mount *mp,
struct fuse_dispatcher fdi;
struct fuse_forget_in *ffi;
debug_printf("mp=%p, nodeid=%ju, nlookup=%ju\n",
mp, (uintmax_t)nodeid, (uintmax_t)nlookup);
/*
* KASSERT(nlookup > 0, ("zero-times forget for vp #%llu",
* (long long unsigned) nodeid));
@ -574,7 +627,8 @@ fuse_internal_init_callback(struct fuse_ticket *tick, struct uio *uio)
/* XXX: Do we want to check anything further besides this? */
if (fiio->major < 7) {
debug_printf("userpace version too low\n");
SDT_PROBE2(fuse, , internal, trace, 1,
"userpace version too low");
err = EPROTONOSUPPORT;
goto out;
}

View File

@ -193,74 +193,8 @@ int fuse_internal_access(struct vnode *vp, mode_t mode,
struct fuse_access_param *facp, struct thread *td, struct ucred *cred);
/* attributes */
/*
* Cache FUSE attributes 'fat', with nominal expiration
* 'attr_valid'.'attr_valid_nsec', in attr cache associated with vnode 'vp'.
* Optionally, if argument 'vap' is not NULL, store a copy of the converted
* attributes there as well.
*
* If the nominal attribute cache TTL is zero, do not cache on the 'vp' (but do
* return the result to the caller).
*/
static inline void
fuse_internal_attr_fat2vat(struct vnode *vp, struct fuse_attr *fat,
uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap)
{
struct mount *mp;
struct fuse_vnode_data *fvdat;
struct vattr *vp_cache_at;
mp = vnode_mount(vp);
fvdat = VTOFUD(vp);
DEBUGX(FUSE_DEBUG_INTERNAL, "node #%ju, mode 0%o\n",
(uintmax_t)fat->ino, fat->mode);
/* Honor explicit do-not-cache requests from user filesystems. */
if (attr_valid == 0 && attr_valid_nsec == 0)
fvdat->valid_attr_cache = false;
else
fvdat->valid_attr_cache = true;
vp_cache_at = VTOVA(vp);
if (vap == NULL && vp_cache_at == NULL)
return;
if (vap == NULL)
vap = vp_cache_at;
vattr_null(vap);
vap->va_fsid = mp->mnt_stat.f_fsid.val[0];
vap->va_fileid = fat->ino;
vap->va_mode = fat->mode & ~S_IFMT;
vap->va_nlink = fat->nlink;
vap->va_uid = fat->uid;
vap->va_gid = fat->gid;
vap->va_rdev = fat->rdev;
vap->va_size = fat->size;
/* XXX on i386, seconds are truncated to 32 bits */
vap->va_atime.tv_sec = fat->atime;
vap->va_atime.tv_nsec = fat->atimensec;
vap->va_mtime.tv_sec = fat->mtime;
vap->va_mtime.tv_nsec = fat->mtimensec;
vap->va_ctime.tv_sec = fat->ctime;
vap->va_ctime.tv_nsec = fat->ctimensec;
vap->va_blocksize = PAGE_SIZE;
vap->va_type = IFTOVT(fat->mode);
vap->va_bytes = fat->blocks * S_BLKSIZE;
vap->va_flags = 0;
if (vap != vp_cache_at && vp_cache_at != NULL)
memcpy(vp_cache_at, vap, sizeof(*vap));
}
#define cache_attrs(vp, fuse_out, vap_out) \
fuse_internal_attr_fat2vat((vp), &(fuse_out)->attr, \
(fuse_out)->attr_valid, (fuse_out)->attr_valid_nsec, (vap_out))
void fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr,
uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap);
/* fsync */
@ -300,24 +234,15 @@ void fuse_internal_vnode_disappear(struct vnode *vp);
static inline int
fuse_internal_checkentry(struct fuse_entry_out *feo, enum vtype vtyp)
{
DEBUGX(FUSE_DEBUG_INTERNAL,
"feo=%p, vtype=%d\n", feo, vtyp);
if (vtyp != IFTOVT(feo->attr.mode)) {
DEBUGX(FUSE_DEBUG_INTERNAL,
"EINVAL -- %x != %x\n", vtyp, IFTOVT(feo->attr.mode));
return (EINVAL);
}
if (feo->nodeid == FUSE_NULL_ID) {
DEBUGX(FUSE_DEBUG_INTERNAL,
"EINVAL -- feo->nodeid is NULL\n");
return (EINVAL);
}
if (feo->nodeid == FUSE_ROOT_ID) {
DEBUGX(FUSE_DEBUG_INTERNAL,
"EINVAL -- feo->nodeid is FUSE_ROOT_ID\n");
return (EINVAL);
}

View File

@ -98,9 +98,13 @@ __FBSDID("$FreeBSD$");
#include "fuse_ipc.h"
#include "fuse_io.h"
#define FUSE_DEBUG_MODULE IO
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , io, trace, "int", "char*");
static int
fuse_read_directbackend(struct vnode *vp, struct uio *uio,
@ -115,6 +119,8 @@ static int
fuse_write_biobackend(struct vnode *vp, struct uio *uio,
struct ucred *cred, struct fuse_filehandle *fufh, int ioflag);
SDT_PROBE_DEFINE5(fuse, , io, io_dispatch, "struct vnode*", "struct uio*",
"int", "struct ucred*", "struct fuse_filehandle*");
int
fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag,
struct ucred *cred)
@ -130,6 +136,8 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag,
printf("FUSE: io dispatch: filehandles are closed\n");
return err;
}
SDT_PROBE5(fuse, , io, io_dispatch, vp, uio, ioflag, cred, fufh);
/*
* Ideally, when the daemon asks for direct io at open time, the
* standard file flag should be set according to this, so that would
@ -145,12 +153,12 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag,
switch (uio->uio_rw) {
case UIO_READ:
if (directio) {
FS_DEBUG("direct read of vnode %ju via file handle %ju\n",
(uintmax_t)VTOILLU(vp), (uintmax_t)fufh->fh_id);
SDT_PROBE2(fuse, , io, trace, 1,
"direct read of vnode");
err = fuse_read_directbackend(vp, uio, cred, fufh);
} else {
FS_DEBUG("buffered read of vnode %ju\n",
(uintmax_t)VTOILLU(vp));
SDT_PROBE2(fuse, , io, trace, 1,
"buffered read of vnode");
err = fuse_read_biobackend(vp, uio, cred, fufh);
}
break;
@ -162,12 +170,12 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag,
* cached.
*/
if (directio || fuse_data_cache_mode == FUSE_CACHE_WT) {
FS_DEBUG("direct write of vnode %ju via file handle %ju\n",
(uintmax_t)VTOILLU(vp), (uintmax_t)fufh->fh_id);
SDT_PROBE2(fuse, , io, trace, 1,
"direct write of vnode");
err = fuse_write_directbackend(vp, uio, cred, fufh, ioflag);
} else {
FS_DEBUG("buffered write of vnode %ju\n",
(uintmax_t)VTOILLU(vp));
SDT_PROBE2(fuse, , io, trace, 1,
"buffered write of vnode");
err = fuse_write_biobackend(vp, uio, cred, fufh, ioflag);
}
break;
@ -178,6 +186,9 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag,
return (err);
}
SDT_PROBE_DEFINE3(fuse, , io, read_bio_backend_start, "int", "int", "int");
SDT_PROBE_DEFINE2(fuse, , io, read_bio_backend_feed, "int", "int");
SDT_PROBE_DEFINE3(fuse, , io, read_bio_backend_end, "int", "ssize_t", "int");
static int
fuse_read_biobackend(struct vnode *vp, struct uio *uio,
struct ucred *cred, struct fuse_filehandle *fufh)
@ -190,9 +201,6 @@ fuse_read_biobackend(struct vnode *vp, struct uio *uio,
const int biosize = fuse_iosize(vp);
FS_DEBUG("resid=%zx offset=%jx fsize=%jx\n",
uio->uio_resid, uio->uio_offset, VTOFUD(vp)->filesize);
if (uio->uio_resid == 0)
return (0);
if (uio->uio_offset < 0)
@ -209,7 +217,8 @@ fuse_read_biobackend(struct vnode *vp, struct uio *uio,
lbn = uio->uio_offset / biosize;
on = uio->uio_offset & (biosize - 1);
FS_DEBUG2G("biosize %d, lbn %d, on %d\n", biosize, (int)lbn, on);
SDT_PROBE3(fuse, , io, read_bio_backend_start,
biosize, (int)lbn, on);
/*
* Obtain the buffer cache block. Figure out the buffer size
@ -258,19 +267,22 @@ fuse_read_biobackend(struct vnode *vp, struct uio *uio,
if (on < bcount)
n = MIN((unsigned)(bcount - on), uio->uio_resid);
if (n > 0) {
FS_DEBUG2G("feeding buffeater with %d bytes of buffer %p,"
" saying %d was asked for\n",
n, bp->b_data + on, n + (int)bp->b_resid);
SDT_PROBE2(fuse, , io, read_bio_backend_feed,
n, n + (int)bp->b_resid);
err = uiomove(bp->b_data + on, n, uio);
}
brelse(bp);
FS_DEBUG2G("end of turn, err %d, uio->uio_resid %zd, n %d\n",
err, uio->uio_resid, n);
SDT_PROBE3(fuse, , io, read_bio_backend_end, err,
uio->uio_resid, n);
} while (err == 0 && uio->uio_resid > 0 && n > 0);
return (err);
}
SDT_PROBE_DEFINE1(fuse, , io, read_directbackend_start, "struct fuse_read_in*");
SDT_PROBE_DEFINE2(fuse, , io, read_directbackend_complete,
"struct fuse_dispatcher*", "struct uio*");
static int
fuse_read_directbackend(struct vnode *vp, struct uio *uio,
struct ucred *cred, struct fuse_filehandle *fufh)
@ -301,17 +313,13 @@ fuse_read_directbackend(struct vnode *vp, struct uio *uio,
fri->size = MIN(uio->uio_resid,
fuse_get_mpdata(vp->v_mount)->max_read);
FS_DEBUG2G("fri->fh %ju, fri->offset %ju, fri->size %ju\n",
(uintmax_t)fri->fh, (uintmax_t)fri->offset,
(uintmax_t)fri->size);
SDT_PROBE1(fuse, , io, read_directbackend_start, fri);
if ((err = fdisp_wait_answ(&fdi)))
goto out;
FS_DEBUG2G("complete: got iosize=%d, requested fri.size=%zd; "
"resid=%zd offset=%ju\n",
fri->size, fdi.iosize, uio->uio_resid,
(uintmax_t)uio->uio_offset);
SDT_PROBE2(fuse, , io, read_directbackend_complete,
fdi.iosize, uio);
if ((err = uiomove(fdi.answ, MIN(fri->size, fdi.iosize), uio)))
break;
@ -361,13 +369,24 @@ fuse_write_directbackend(struct vnode *vp, struct uio *uio,
if ((err = fdisp_wait_answ(&fdi)))
break;
/* Adjust the uio in the case of short writes */
diff = chunksize - ((struct fuse_write_out *)fdi.answ)->size;
if (diff < 0) {
err = EINVAL;
break;
} else if (diff > 0 && !(ioflag & IO_DIRECT)) {
/*
* XXX We really should be directly checking whether
* the file was opened with FOPEN_DIRECT_IO, not
* IO_DIRECT. IO_DIRECT can be set in multiple ways.
*/
SDT_PROBE2(fuse, , io, trace, 1,
"misbehaving filesystem: short writes are only "
"allowed with direct_io");
}
uio->uio_resid += diff;
uio->uio_offset -= diff;
if (uio->uio_offset > fvdat->filesize &&
fuse_data_cache_mode != FUSE_CACHE_UC) {
fuse_vnode_setsize(vp, cred, uio->uio_offset);
@ -380,6 +399,10 @@ fuse_write_directbackend(struct vnode *vp, struct uio *uio,
return (err);
}
SDT_PROBE_DEFINE6(fuse, , io, write_biobackend_start, "int64_t", "int", "int",
"struct uio*", "int", "bool");
SDT_PROBE_DEFINE2(fuse, , io, write_biobackend_append_race, "long", "int");
static int
fuse_write_biobackend(struct vnode *vp, struct uio *uio,
struct ucred *cred, struct fuse_filehandle *fufh, int ioflag)
@ -393,8 +416,6 @@ fuse_write_biobackend(struct vnode *vp, struct uio *uio,
const int biosize = fuse_iosize(vp);
KASSERT(uio->uio_rw == UIO_WRITE, ("ncl_write mode"));
FS_DEBUG("resid=%zx offset=%jx fsize=%jx\n",
uio->uio_resid, uio->uio_offset, fvdat->filesize);
if (vp->v_type != VREG)
return (EIO);
if (uio->uio_offset < 0)
@ -421,10 +442,6 @@ fuse_write_biobackend(struct vnode *vp, struct uio *uio,
on = uio->uio_offset & (biosize - 1);
n = MIN((unsigned)(biosize - on), uio->uio_resid);
FS_DEBUG2G("lbn %ju, on %d, n %d, uio offset %ju, uio resid %zd\n",
(uintmax_t)lbn, on, n,
(uintmax_t)uio->uio_offset, uio->uio_resid);
again:
/*
* Handle direct append and file extension cases, calculate
@ -438,7 +455,8 @@ fuse_write_biobackend(struct vnode *vp, struct uio *uio,
* readers from reading garbage.
*/
bcount = on;
FS_DEBUG("getting block from OS, bcount %d\n", bcount);
SDT_PROBE6(fuse, , io, write_biobackend_start,
lbn, on, n, uio, bcount, true);
bp = getblk(vp, lbn, bcount, PCATCH, 0, 0);
if (bp != NULL) {
@ -468,7 +486,8 @@ fuse_write_biobackend(struct vnode *vp, struct uio *uio,
bcount = fvdat->filesize -
(off_t)lbn *biosize;
}
FS_DEBUG("getting block from OS, bcount %d\n", bcount);
SDT_PROBE6(fuse, , io, write_biobackend_start,
lbn, on, n, uio, bcount, false);
bp = getblk(vp, lbn, bcount, PCATCH, 0, 0);
if (bp && uio->uio_offset + n > fvdat->filesize) {
err = fuse_vnode_setsize(vp, cred,
@ -530,7 +549,7 @@ fuse_write_biobackend(struct vnode *vp, struct uio *uio,
*/
if (bp->b_dirtyend > bcount) {
FS_DEBUG("FUSE append race @%lx:%d\n",
SDT_PROBE2(fuse, , io, write_biobackend_append_race,
(long)bp->b_blkno * biosize,
bp->b_dirtyend - bcount);
bp->b_dirtyend = bcount;
@ -626,9 +645,6 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp)
MPASS(vp->v_type == VREG || vp->v_type == VDIR);
MPASS(bp->b_iocmd == BIO_READ || bp->b_iocmd == BIO_WRITE);
FS_DEBUG("inode=%ju offset=%jd resid=%ld\n",
(uintmax_t)VTOI(vp), (intmax_t)(((off_t)bp->b_blkno) * biosize),
bp->b_bcount);
error = fuse_filehandle_getrw(vp,
(bp->b_iocmd == BIO_READ) ? FUFH_RDONLY : FUFH_WRONLY, &fufh);
@ -701,7 +717,8 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp)
* If we only need to commit, try to commit
*/
if (bp->b_flags & B_NEEDCOMMIT) {
FS_DEBUG("write: B_NEEDCOMMIT flags set\n");
SDT_PROBE2(fuse, , io, trace, 1,
"write: B_NEEDCOMMIT flags set");
}
/*
* Setup for actual write

View File

@ -58,11 +58,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/uio.h>
@ -73,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/mount.h>
#include <sys/sdt.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
#include <sys/syscallsubr.h>
@ -84,8 +84,13 @@ __FBSDID("$FreeBSD$");
#include "fuse_ipc.h"
#include "fuse_internal.h"
#define FUSE_DEBUG_MODULE IPC
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , ipc, trace, "int", "char*");
static struct fuse_ticket *fticket_alloc(struct fuse_data *data);
static void fticket_refresh(struct fuse_ticket *ftick);
@ -146,8 +151,6 @@ fiov_init(struct fuse_iov *fiov, size_t size)
{
uint32_t msize = FU_AT_LEAST(size);
debug_printf("fiov=%p, size=%zd\n", fiov, size);
fiov->len = 0;
fiov->base = malloc(msize, M_FUSEMSG, M_WAITOK | M_ZERO);
@ -159,8 +162,6 @@ fiov_init(struct fuse_iov *fiov, size_t size)
void
fiov_teardown(struct fuse_iov *fiov)
{
debug_printf("fiov=%p\n", fiov);
MPASS(fiov->base != NULL);
free(fiov->base, M_FUSEMSG);
}
@ -168,8 +169,6 @@ fiov_teardown(struct fuse_iov *fiov)
void
fiov_adjust(struct fuse_iov *fiov, size_t size)
{
debug_printf("fiov=%p, size=%zd\n", fiov, size);
if (fiov->allocated_size < size ||
(fuse_iov_permanent_bufsize >= 0 &&
fiov->allocated_size - size > fuse_iov_permanent_bufsize &&
@ -189,8 +188,6 @@ fiov_adjust(struct fuse_iov *fiov, size_t size)
void
fiov_refresh(struct fuse_iov *fiov)
{
debug_printf("fiov=%p\n", fiov);
bzero(fiov->base, fiov->len);
fiov_adjust(fiov, 0);
}
@ -201,8 +198,6 @@ fticket_ctor(void *mem, int size, void *arg, int flags)
struct fuse_ticket *ftick = mem;
struct fuse_data *data = arg;
debug_printf("ftick=%p data=%p\n", ftick, data);
FUSE_ASSERT_MS_DONE(ftick);
FUSE_ASSERT_AW_DONE(ftick);
@ -227,8 +222,6 @@ fticket_dtor(void *mem, int size, void *arg)
{
struct fuse_ticket *ftick = mem;
debug_printf("ftick=%p\n", ftick);
FUSE_ASSERT_MS_DONE(ftick);
FUSE_ASSERT_AW_DONE(ftick);
@ -240,8 +233,6 @@ fticket_init(void *mem, int size, int flags)
{
struct fuse_ticket *ftick = mem;
FS_DEBUG("ftick=%p\n", ftick);
bzero(ftick, sizeof(struct fuse_ticket));
fiov_init(&ftick->tk_ms_fiov, sizeof(struct fuse_in_header));
@ -259,8 +250,6 @@ fticket_fini(void *mem, int size)
{
struct fuse_ticket *ftick = mem;
FS_DEBUG("ftick=%p\n", ftick);
fiov_teardown(&ftick->tk_ms_fiov);
fiov_teardown(&ftick->tk_aw_fiov);
mtx_destroy(&ftick->tk_aw_mtx);
@ -282,8 +271,6 @@ static inline
void
fticket_refresh(struct fuse_ticket *ftick)
{
debug_printf("ftick=%p\n", ftick);
FUSE_ASSERT_MS_DONE(ftick);
FUSE_ASSERT_AW_DONE(ftick);
@ -310,7 +297,6 @@ fticket_wait_answer(struct fuse_ticket *ftick)
int err = 0;
struct fuse_data *data;
debug_printf("ftick=%p\n", ftick);
fuse_lck_mtx_lock(ftick->tk_aw_mtx);
if (fticket_answered(ftick)) {
@ -338,7 +324,8 @@ fticket_wait_answer(struct fuse_ticket *ftick)
}
out:
if (!(err || fticket_answered(ftick))) {
debug_printf("FUSE: requester was woken up but still no answer");
SDT_PROBE2(fuse, , ipc, trace, 1,
"FUSE: requester was woken up but still no answer");
err = ENXIO;
}
fuse_lck_mtx_unlock(ftick->tk_aw_mtx);
@ -353,29 +340,16 @@ fticket_aw_pull_uio(struct fuse_ticket *ftick, struct uio *uio)
int err = 0;
size_t len = uio_resid(uio);
debug_printf("ftick=%p, uio=%p\n", ftick, uio);
if (len) {
switch (ftick->tk_aw_type) {
case FT_A_FIOV:
fiov_adjust(fticket_resp(ftick), len);
err = uiomove(fticket_resp(ftick)->base, len, uio);
if (err) {
debug_printf("FUSE: FT_A_FIOV: error is %d"
" (%p, %zd, %p)\n",
err, fticket_resp(ftick)->base,
len, uio);
}
break;
case FT_A_BUF:
ftick->tk_aw_bufsize = len;
err = uiomove(ftick->tk_aw_bufdata, len, uio);
if (err) {
debug_printf("FUSE: FT_A_BUF: error is %d"
" (%p, %zd, %p)\n",
err, ftick->tk_aw_bufdata, len, uio);
}
break;
default:
@ -390,8 +364,6 @@ fticket_pull(struct fuse_ticket *ftick, struct uio *uio)
{
int err = 0;
debug_printf("ftick=%p, uio=%p\n", ftick, uio);
if (ftick->tk_aw_ohead.error) {
return 0;
}
@ -407,8 +379,6 @@ fdata_alloc(struct cdev *fdev, struct ucred *cred)
{
struct fuse_data *data;
debug_printf("fdev=%p\n", fdev);
data = malloc(sizeof(struct fuse_data), M_FUSEMSG, M_WAITOK | M_ZERO);
data->fdev = fdev;
@ -427,10 +397,6 @@ fdata_alloc(struct cdev *fdev, struct ucred *cred)
void
fdata_trydestroy(struct fuse_data *data)
{
FS_DEBUG("data=%p data.mp=%p data.fdev=%p data.flags=%04x\n",
data, data->mp, data->fdev, data->dataflags);
FS_DEBUG("destroy: data=%p\n", data);
data->ref--;
MPASS(data->ref >= 0);
if (data->ref != 0)
@ -449,8 +415,6 @@ fdata_trydestroy(struct fuse_data *data)
void
fdata_set_dead(struct fuse_data *data)
{
debug_printf("data=%p\n", data);
FUSE_LOCK();
if (fdata_get_dead(data)) {
FUSE_UNLOCK();
@ -471,8 +435,6 @@ fuse_ticket_fetch(struct fuse_data *data)
int err = 0;
struct fuse_ticket *ftick;
debug_printf("data=%p\n", data);
ftick = fticket_alloc(data);
if (!(data->dataflags & FSESS_INITED)) {
@ -495,7 +457,6 @@ fuse_ticket_drop(struct fuse_ticket *ftick)
int die;
die = refcount_release(&ftick->tk_refcount);
debug_printf("ftick=%p refcount=%d\n", ftick, ftick->tk_refcount);
if (die)
fticket_destroy(ftick);
@ -505,9 +466,6 @@ fuse_ticket_drop(struct fuse_ticket *ftick)
void
fuse_insert_callback(struct fuse_ticket *ftick, fuse_handler_t * handler)
{
debug_printf("ftick=%p, handler=%p data=%p\n", ftick, ftick->tk_data,
handler);
if (fdata_get_dead(ftick->tk_data)) {
return;
}
@ -521,8 +479,6 @@ fuse_insert_callback(struct fuse_ticket *ftick, fuse_handler_t * handler)
void
fuse_insert_message(struct fuse_ticket *ftick)
{
debug_printf("ftick=%p\n", ftick);
if (ftick->tk_flag & FT_DIRTY) {
panic("FUSE: ticket reused without being refreshed");
}
@ -544,8 +500,6 @@ fuse_body_audit(struct fuse_ticket *ftick, size_t blen)
int err = 0;
enum fuse_opcode opcode;
debug_printf("ftick=%p, blen = %zu\n", ftick, blen);
opcode = fticket_opcode(ftick);
switch (opcode) {
@ -719,9 +673,6 @@ fuse_setup_ihead(struct fuse_in_header *ihead, struct fuse_ticket *ftick,
ihead->nodeid = nid;
ihead->opcode = op;
debug_printf("ihead=%p, ftick=%p, nid=%ju, op=%d, blen=%zu\n",
ihead, ftick, (uintmax_t)nid, op, blen);
ihead->pid = pid;
ihead->uid = cred->cr_uid;
ihead->gid = cred->cr_rgid;
@ -738,8 +689,6 @@ fuse_standard_handler(struct fuse_ticket *ftick, struct uio *uio)
{
int err = 0;
debug_printf("ftick=%p, uio=%p\n", ftick, uio);
err = fticket_pull(ftick, uio);
fuse_lck_mtx_lock(ftick->tk_aw_mtx);
@ -760,9 +709,6 @@ fdisp_make_pid(struct fuse_dispatcher *fdip, enum fuse_opcode op,
{
struct fuse_data *data = fuse_get_mpdata(mp);
debug_printf("fdip=%p, op=%d, mp=%p, nid=%ju\n",
fdip, op, mp, (uintmax_t)nid);
if (fdip->tick) {
fticket_refresh(fdip->tick);
} else {
@ -788,12 +734,13 @@ void
fdisp_make_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op,
struct vnode *vp, struct thread *td, struct ucred *cred)
{
debug_printf("fdip=%p, op=%d, vp=%p\n", fdip, op, vp);
RECTIFY_TDCR(td, cred);
return fdisp_make_pid(fdip, op, vnode_mount(vp), VTOI(vp),
td->td_proc->p_pid, cred);
}
SDT_PROBE_DEFINE2(fuse, , ipc, fdisp_wait_answ_error, "char*", "int");
int
fdisp_wait_answ(struct fuse_dispatcher *fdip)
{
@ -804,8 +751,6 @@ fdisp_wait_answ(struct fuse_dispatcher *fdip)
fuse_insert_message(fdip->tick);
if ((err = fticket_wait_answer(fdip->tick))) {
debug_printf("IPC: interrupted, err = %d\n", err);
fuse_lck_mtx_lock(fdip->tick->tk_aw_mtx);
if (fticket_answered(fdip->tick)) {
@ -814,7 +759,8 @@ fdisp_wait_answ(struct fuse_dispatcher *fdip)
* the standard handler has completed his job.
* So we drop the ticket and exit as usual.
*/
debug_printf("IPC: already answered\n");
SDT_PROBE2(fuse, , ipc, fdisp_wait_answ_error,
"IPC: interrupted, already answered", err);
fuse_lck_mtx_unlock(fdip->tick->tk_aw_mtx);
goto out;
} else {
@ -823,23 +769,23 @@ fdisp_wait_answ(struct fuse_dispatcher *fdip)
* Then by setting the answered flag we get *him*
* to drop the ticket.
*/
debug_printf("IPC: setting to answered\n");
SDT_PROBE2(fuse, , ipc, fdisp_wait_answ_error,
"IPC: interrupted, setting to answered", err);
fticket_set_answered(fdip->tick);
fuse_lck_mtx_unlock(fdip->tick->tk_aw_mtx);
return err;
}
}
debug_printf("IPC: not interrupted, err = %d\n", err);
if (fdip->tick->tk_aw_errno) {
debug_printf("IPC: explicit EIO-ing, tk_aw_errno = %d\n",
fdip->tick->tk_aw_errno);
SDT_PROBE2(fuse, , ipc, fdisp_wait_answ_error,
"IPC: explicit EIO-ing", fdip->tick->tk_aw_errno);
err = EIO;
goto out;
}
if ((err = fdip->tick->tk_aw_ohead.error)) {
debug_printf("IPC: setting status to %d\n",
fdip->tick->tk_aw_ohead.error);
SDT_PROBE2(fuse, , ipc, fdisp_wait_answ_error,
"IPC: setting status", fdip->tick->tk_aw_ohead.error);
/*
* This means a "proper" fuse syscall error.
* We record this value so the caller will
@ -855,13 +801,9 @@ fdisp_wait_answ(struct fuse_dispatcher *fdip)
fdip->answ = fticket_resp(fdip->tick)->base;
fdip->iosize = fticket_resp(fdip->tick)->len;
debug_printf("IPC: all is well\n");
return 0;
out:
debug_printf("IPC: dropping ticket, err = %d\n", err);
return err;
}

View File

@ -136,7 +136,6 @@ fticket_resp(struct fuse_ticket *ftick)
static inline bool
fticket_answered(struct fuse_ticket *ftick)
{
DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick);
mtx_assert(&ftick->tk_aw_mtx, MA_OWNED);
return (ftick->tk_flag & FT_ANSW);
}
@ -144,7 +143,6 @@ fticket_answered(struct fuse_ticket *ftick)
static inline void
fticket_set_answered(struct fuse_ticket *ftick)
{
DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick);
mtx_assert(&ftick->tk_aw_mtx, MA_OWNED);
ftick->tk_flag |= FT_ANSW;
}
@ -152,7 +150,6 @@ fticket_set_answered(struct fuse_ticket *ftick)
static inline enum fuse_opcode
fticket_opcode(struct fuse_ticket *ftick)
{
DEBUGX(FUSE_DEBUG_IPC, "-> ftick=%p\n", ftick);
return (((struct fuse_in_header *)(ftick->tk_ms_fiov.base))->opcode);
}
@ -273,8 +270,6 @@ fsess_opt_brokenio(struct mount *mp)
static inline void
fuse_ms_push(struct fuse_ticket *ftick)
{
DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick,
ftick->tk_refcount + 1);
mtx_assert(&ftick->tk_data->ms_mtx, MA_OWNED);
refcount_acquire(&ftick->tk_refcount);
STAILQ_INSERT_TAIL(&ftick->tk_data->ms_head, ftick, tk_ms_link);
@ -293,8 +288,6 @@ fuse_ms_pop(struct fuse_data *data)
ftick->tk_ms_link.stqe_next = NULL;
#endif
}
DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick,
ftick ? ftick->tk_refcount : -1);
return (ftick);
}
@ -302,8 +295,6 @@ fuse_ms_pop(struct fuse_data *data)
static inline void
fuse_aw_push(struct fuse_ticket *ftick)
{
DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick,
ftick->tk_refcount + 1);
mtx_assert(&ftick->tk_data->aw_mtx, MA_OWNED);
refcount_acquire(&ftick->tk_refcount);
TAILQ_INSERT_TAIL(&ftick->tk_data->aw_head, ftick, tk_aw_link);
@ -312,8 +303,6 @@ fuse_aw_push(struct fuse_ticket *ftick)
static inline void
fuse_aw_remove(struct fuse_ticket *ftick)
{
DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n",
ftick, ftick->tk_refcount);
mtx_assert(&ftick->tk_data->aw_mtx, MA_OWNED);
TAILQ_REMOVE(&ftick->tk_data->aw_head, ftick, tk_aw_link);
#ifdef INVARIANTS
@ -331,8 +320,6 @@ fuse_aw_pop(struct fuse_data *data)
if ((ftick = TAILQ_FIRST(&data->aw_head)) != NULL)
fuse_aw_remove(ftick);
DEBUGX(FUSE_DEBUG_IPC, "ftick=%p refcount=%d\n", ftick,
ftick ? ftick->tk_refcount : -1);
return (ftick);
}
@ -374,7 +361,6 @@ struct fuse_dispatcher {
static inline void
fdisp_init(struct fuse_dispatcher *fdisp, size_t iosize)
{
DEBUGX(FUSE_DEBUG_IPC, "-> fdisp=%p, iosize=%zx\n", fdisp, iosize);
fdisp->iosize = iosize;
fdisp->tick = NULL;
}
@ -382,7 +368,6 @@ fdisp_init(struct fuse_dispatcher *fdisp, size_t iosize)
static inline void
fdisp_destroy(struct fuse_dispatcher *fdisp)
{
DEBUGX(FUSE_DEBUG_IPC, "-> fdisp=%p, ftick=%p\n", fdisp, fdisp->tick);
fuse_ticket_drop(fdisp->tick);
#ifdef INVARIANTS
fdisp->tick = NULL;
@ -404,7 +389,6 @@ static inline int
fdisp_simple_putget_vp(struct fuse_dispatcher *fdip, enum fuse_opcode op,
struct vnode *vp, struct thread *td, struct ucred *cred)
{
DEBUGX(FUSE_DEBUG_IPC, "-> fdip=%p, opcode=%d, vp=%p\n", fdip, op, vp);
fdisp_make_vp(fdip, op, vp, td, cred);
return (fdisp_wait_answ(fdip));
}

View File

@ -67,11 +67,13 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/buf.h>
#include <sys/sdt.h>
#include <sys/sysctl.h>
#include "fuse.h"
@ -98,6 +100,7 @@ SYSCTL_INT(_vfs_fusefs, OID_AUTO, kernelabi_major, CTLFLAG_RD,
SYSCTL_NULL_INT_PTR, FUSE_KERNEL_VERSION, "FUSE kernel abi major version");
SYSCTL_INT(_vfs_fusefs, OID_AUTO, kernelabi_minor, CTLFLAG_RD,
SYSCTL_NULL_INT_PTR, FUSE_KERNEL_MINOR_VERSION, "FUSE kernel abi minor version");
SDT_PROVIDER_DEFINE(fuse);
/******************************
*

View File

@ -89,8 +89,13 @@ __FBSDID("$FreeBSD$");
#include "fuse_io.h"
#include "fuse_ipc.h"
#define FUSE_DEBUG_MODULE VNOPS
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , node, trace, "int", "char*");
MALLOC_DEFINE(M_FUSEVN, "fuse_vnode", "fuse vnode private data");
@ -219,8 +224,6 @@ fuse_vnode_alloc(struct mount *mp,
struct vnode *vp2;
int err = 0;
FS_DEBUG("been asked for vno #%ju\n", (uintmax_t)nodeid);
if (vtyp == VNON) {
return EINVAL;
}
@ -232,7 +235,7 @@ fuse_vnode_alloc(struct mount *mp,
if (*vpp) {
MPASS((*vpp)->v_type == vtyp && (*vpp)->v_data != NULL);
FS_DEBUG("vnode taken from hash\n");
SDT_PROBE2(fuse, , node, trace, 1, "vnode taken from hash");
return (0);
}
fvdat = malloc(sizeof(*fvdat), M_FUSEVN, M_WAITOK | M_ZERO);
@ -276,8 +279,6 @@ fuse_vnode_get(struct mount *mp,
struct thread *td = (cnp != NULL ? cnp->cn_thread : curthread);
int err = 0;
debug_printf("dvp=%p\n", dvp);
err = fuse_vnode_alloc(mp, td, nodeid, vtyp, vpp);
if (err) {
return err;
@ -354,8 +355,6 @@ fuse_vnode_savesize(struct vnode *vp, struct ucred *cred)
struct fuse_setattr_in *fsai;
int err = 0;
FS_DEBUG("inode=%ju size=%ju\n", (uintmax_t)VTOI(vp),
(uintmax_t)fvdat->filesize);
ASSERT_VOP_ELOCKED(vp, "fuse_io_extend");
if (fuse_isdeadfs(vp)) {
@ -405,7 +404,7 @@ fuse_vnode_refreshsize(struct vnode *vp, struct ucred *cred)
return;
VOP_GETATTR(vp, &va, cred);
FS_DEBUG("refreshed file size: %jd\n", (intmax_t)VTOFUD(vp)->filesize);
SDT_PROBE2(fuse, , node, trace, 1, "refreshed file size");
}
int
@ -415,9 +414,6 @@ fuse_vnode_setsize(struct vnode *vp, struct ucred *cred, off_t newsize)
off_t oldsize;
int err = 0;
FS_DEBUG("inode=%ju oldsize=%ju newsize=%ju\n",
(uintmax_t)VTOI(vp), (uintmax_t)fvdat->filesize,
(uintmax_t)newsize);
ASSERT_VOP_ELOCKED(vp, "fuse_vnode_setsize");
oldsize = fvdat->filesize;

View File

@ -89,8 +89,13 @@ __FBSDID("$FreeBSD$");
#include <sys/priv.h>
#include <security/mac/mac_framework.h>
#define FUSE_DEBUG_MODULE VFSOPS
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , vfsops, trace, "int", "char*");
/* This will do for privilege types for now */
#ifndef PRIV_VFS_FUSE_ALLOWOTHER
@ -203,6 +208,10 @@ fuse_getdevice(const char *fspec, struct thread *td, struct cdev **fdevp)
vfs_flagopt(opts, "__" #fnam, &__mntopts, fval); \
} while (0)
SDT_PROBE_DEFINE1(fuse, , vfsops, mntopts, "uint64_t");
SDT_PROBE_DEFINE4(fuse, , vfsops, mount_err, "char*", "struct fuse_data*",
"struct mount*", "int");
static int
fuse_vfsop_mount(struct mount *mp)
{
@ -229,8 +238,6 @@ fuse_vfsop_mount(struct mount *mp)
__mntopts = 0;
td = curthread;
fuse_trace_printf_vfsop();
if (mp->mnt_flag & MNT_UPDATE)
return EOPNOTSUPP;
@ -286,11 +293,12 @@ fuse_vfsop_mount(struct mount *mp)
}
subtype = vfs_getopts(opts, "subtype=", &err);
FS_DEBUG2G("mntopts 0x%jx\n", (uintmax_t)mntopts);
SDT_PROBE1(fuse, , vfsops, mntopts, mntopts);
err = fget(td, fd, &cap_read_rights, &fp);
if (err != 0) {
FS_DEBUG("invalid or not opened device: data=%p\n", data);
SDT_PROBE2(fuse, , vfsops, trace, 1,
"invalid or not opened device");
goto out;
}
fptmp = td->td_fpop;
@ -300,15 +308,16 @@ fuse_vfsop_mount(struct mount *mp)
fdrop(fp, td);
FUSE_LOCK();
if (err != 0 || data == NULL || data->mp != NULL) {
FS_DEBUG("invalid or not opened device: data=%p data.mp=%p\n",
data, data != NULL ? data->mp : NULL);
err = ENXIO;
SDT_PROBE4(fuse, , vfsops, mount_err,
"invalid or not opened device", data, mp, err);
FUSE_UNLOCK();
goto out;
}
if (fdata_get_dead(data)) {
FS_DEBUG("device is dead during mount: data=%p\n", data);
err = ENOTCONN;
SDT_PROBE4(fuse, , vfsops, mount_err,
"device is dead during mount", data, mp, err);
FUSE_UNLOCK();
goto out;
}
@ -345,7 +354,6 @@ fuse_vfsop_mount(struct mount *mp)
}
copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &len);
bzero(mp->mnt_stat.f_mntfromname + len, MNAMELEN - len);
FS_DEBUG2G("mp %p: %s\n", mp, mp->mnt_stat.f_mntfromname);
/* Now handshaking with daemon */
fuse_internal_send_init(data, td);
@ -358,9 +366,8 @@ fuse_vfsop_mount(struct mount *mp)
* Destroy device only if we acquired reference to
* it
*/
FS_DEBUG("mount failed, destroy device: data=%p mp=%p"
" err=%d\n",
data, mp, err);
SDT_PROBE4(fuse, , vfsops, mount_err,
"mount failed, destroy device", data, mp, err);
data->mp = NULL;
fdata_trydestroy(data);
}
@ -381,8 +388,6 @@ fuse_vfsop_unmount(struct mount *mp, int mntflags)
struct fuse_dispatcher fdi;
struct thread *td = curthread;
fuse_trace_printf_vfsop();
if (mntflags & MNT_FORCE) {
flags |= FORCECLOSE;
}
@ -402,7 +407,6 @@ fuse_vfsop_unmount(struct mount *mp, int mntflags)
FUSE_UNLOCK();
err = vflush(mp, 0, flags, td);
if (err) {
debug_printf("vflush failed");
return err;
}
if (fdata_get_dead(data)) {
@ -450,12 +454,14 @@ fuse_vfsop_root(struct mount *mp, int lkflags, struct vnode **vpp)
FUSE_LOCK();
MPASS(data->vroot == NULL || data->vroot == *vpp);
if (data->vroot == NULL) {
FS_DEBUG("new root vnode\n");
SDT_PROBE2(fuse, , vfsops, trace, 1,
"new root vnode");
data->vroot = *vpp;
FUSE_UNLOCK();
vref(*vpp);
} else if (data->vroot != *vpp) {
FS_DEBUG("root vnode race\n");
SDT_PROBE2(fuse, , vfsops, trace, 1,
"root vnode race");
FUSE_UNLOCK();
VOP_UNLOCK(*vpp, 0);
vrele(*vpp);
@ -477,7 +483,6 @@ fuse_vfsop_statfs(struct mount *mp, struct statfs *sbp)
struct fuse_statfs_out *fsfo;
struct fuse_data *data;
FS_DEBUG2G("mp %p: %s\n", mp, mp->mnt_stat.f_mntfromname);
data = fuse_get_mpdata(mp);
if (!(data->dataflags & FSESS_INITED))
@ -508,15 +513,6 @@ fuse_vfsop_statfs(struct mount *mp, struct statfs *sbp)
sbp->f_namemax = fsfo->st.namelen;
sbp->f_bsize = fsfo->st.frsize; /* cast from uint32_t to uint64_t */
FS_DEBUG("fuse_statfs_out -- blocks: %llu, bfree: %llu, bavail: %llu, "
"fil es: %llu, ffree: %llu, bsize: %i, namelen: %i\n",
(unsigned long long)fsfo->st.blocks,
(unsigned long long)fsfo->st.bfree,
(unsigned long long)fsfo->st.bavail,
(unsigned long long)fsfo->st.files,
(unsigned long long)fsfo->st.ffree, fsfo->st.bsize,
fsfo->st.namelen);
fdisp_destroy(&fdi);
return 0;

View File

@ -58,11 +58,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/uio.h>
@ -108,8 +107,13 @@ __FBSDID("$FreeBSD$");
#include <sys/priv.h>
#define FUSE_DEBUG_MODULE VNOPS
#include "fuse_debug.h"
SDT_PROVIDER_DECLARE(fuse);
/*
* Fuse trace probe:
* arg0: verbosity. Higher numbers give more verbose messages
* arg1: Textual message
*/
SDT_PROBE_DEFINE2(fuse, , vnops, trace, "int", "char*");
/* vnode ops */
static vop_access_t fuse_vnop_access;
@ -232,8 +236,6 @@ fuse_vnop_access(struct vop_access_args *ap)
int err;
FS_DEBUG2G("inode=%ju\n", (uintmax_t)VTOI(vp));
if (fuse_isdeadfs(vp)) {
if (vnode_isvroot(vp)) {
return 0;
@ -255,7 +257,6 @@ fuse_vnop_access(struct vop_access_args *ap)
bzero(&facp, sizeof(facp));
err = fuse_internal_access(vp, accmode, &facp, ap->a_td, ap->a_cred);
FS_DEBUG2G("err=%d accmode=0x%x\n", err, accmode);
return err;
}
@ -275,8 +276,6 @@ fuse_vnop_close(struct vop_close_args *ap)
int fflag = ap->a_fflag;
fufh_type_t fufh_type;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp)) {
return 0;
}
@ -339,8 +338,6 @@ fuse_vnop_create(struct vop_create_args *ap)
uint64_t x_fh_id;
uint32_t x_open_flags;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(dvp)) {
return ENXIO;
}
@ -352,12 +349,11 @@ fuse_vnop_create(struct vop_create_args *ap)
vap->va_type);
return (EINVAL);
}
debug_printf("parent nid = %ju, mode = %x\n", (uintmax_t)parentnid,
mode);
fdisp_init(fdip, sizeof(*foi) + cnp->cn_namelen + 1);
if (!fsess_isimpl(mp, FUSE_CREATE)) {
debug_printf("eh, daemon doesn't implement create?\n");
SDT_PROBE2(fuse, , vnops, trace, 1,
"eh, daemon doesn't implement create?");
return (EINVAL);
}
fdisp_make(fdip, FUSE_CREATE, vnode_mount(dvp), parentnid, td, cred);
@ -375,7 +371,6 @@ fuse_vnop_create(struct vop_create_args *ap)
if (err) {
if (err == ENOSYS)
fsess_set_notimpl(mp, FUSE_CREATE);
debug_printf("create: got err=%d from daemon\n", err);
goto out;
}
@ -446,8 +441,6 @@ fuse_vnop_fsync(struct vop_fsync_args *ap)
int type, err = 0;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp)) {
return 0;
}
@ -485,13 +478,12 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
struct ucred *cred = ap->a_cred;
struct thread *td = curthread;
struct fuse_vnode_data *fvdat = VTOFUD(vp);
struct fuse_attr_out *fao;
int err = 0;
int dataflags;
struct fuse_dispatcher fdi;
FS_DEBUG2G("inode=%ju\n", (uintmax_t)VTOI(vp));
dataflags = fuse_get_mpdata(vnode_mount(vp))->dataflags;
/* Note that we are not bailing out on a dead file system just yet. */
@ -500,7 +492,6 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
if (!vnode_isvroot(vp)) {
fdata_set_dead(fuse_get_mpdata(vnode_mount(vp)));
err = ENOTCONN;
debug_printf("fuse_getattr b: returning ENOTCONN\n");
return err;
} else {
goto fake;
@ -509,7 +500,7 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
fdisp_init(&fdi, 0);
if ((err = fdisp_simple_putget_vp(&fdi, FUSE_GETATTR, vp, td, cred))) {
if ((err == ENOTCONN) && vnode_isvroot(vp)) {
/* see comment at similar place in fuse_statfs() */
/* see comment in fuse_vfsop_statfs() */
fdisp_destroy(&fdi);
goto fake;
}
@ -519,7 +510,9 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
goto out;
}
cache_attrs(vp, (struct fuse_attr_out *)fdi.answ, vap);
fao = (struct fuse_attr_out *)fdi.answ;
fuse_internal_cache_attrs(vp, &fao->attr, fao->attr_valid,
fao->attr_valid_nsec, vap);
if (vap->va_type != vnode_vtype(vp)) {
fuse_internal_vnode_disappear(vp);
err = ENOENT;
@ -541,7 +534,6 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
fvdat->flag &= ~FN_SIZECHANGE;
}
}
debug_printf("fuse_getattr e: returning 0\n");
out:
fdisp_destroy(&fdi);
@ -571,8 +563,6 @@ fuse_vnop_inactive(struct vop_inactive_args *ap)
int type, need_flush = 1;
FS_DEBUG("inode=%ju\n", (uintmax_t)VTOI(vp));
for (type = 0; type < FUFH_MAXTYPE; type++) {
fufh = &(fvdat->fufh[type]);
if (FUFH_IS_VALID(fufh)) {
@ -619,8 +609,6 @@ fuse_vnop_link(struct vop_link_args *ap)
int err;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -685,9 +673,6 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
uint64_t nid;
struct fuse_access_param facp;
FS_DEBUG2G("parent_inode=%ju - %*s\n",
(uintmax_t)VTOI(dvp), (int)cnp->cn_namelen, cnp->cn_nameptr);
if (fuse_isdeadfs(dvp)) {
*vpp = NULL;
return ENXIO;
@ -815,7 +800,8 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
*/
#if 0
if ((cnp->cn_flags & MAKEENTRY) != 0) {
FS_DEBUG("inserting NULL into cache\n");
SDT_PROBE2(fuse, , vnops, trace, 1,
"inserting NULL into cache");
cache_enter(dvp, NULL, cnp);
}
#endif
@ -992,11 +978,17 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
}
if (op == FUSE_GETATTR) {
cache_attrs(*vpp, (struct fuse_attr_out *)fdi.answ,
NULL);
struct fuse_attr_out *fao =
(struct fuse_attr_out*)fdi.answ;
fuse_internal_cache_attrs(*vpp,
&fao->attr, fao->attr_valid,
fao->attr_valid_nsec, NULL);
} else {
cache_attrs(*vpp, (struct fuse_entry_out *)fdi.answ,
NULL);
struct fuse_entry_out *feo =
(struct fuse_entry_out*)fdi.answ;
fuse_internal_cache_attrs(*vpp,
&feo->attr, feo->attr_valid,
feo->attr_valid_nsec, NULL);
}
/* Insert name into cache if appropriate. */
@ -1088,7 +1080,9 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
}
if (err) {
if (tmpvtype == VLNK)
FS_DEBUG("weird, permission error with a symlink?\n");
SDT_PROBE2(fuse, , vnops, trace,
1, "weird, permission "
"error with a symlink?");
vput(*vpp);
*vpp = NULL;
}
@ -1119,8 +1113,6 @@ fuse_vnop_mkdir(struct vop_mkdir_args *ap)
struct fuse_mkdir_in fmdi;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(dvp)) {
return ENXIO;
}
@ -1169,8 +1161,6 @@ fuse_vnop_open(struct vop_open_args *ap)
int error, isdir = 0;
int32_t fuse_open_flags;
FS_DEBUG2G("inode=%ju mode=0x%x\n", (uintmax_t)VTOI(vp), mode);
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1248,9 +1238,6 @@ fuse_vnop_read(struct vop_read_args *ap)
int ioflag = ap->a_ioflag;
struct ucred *cred = ap->a_cred;
FS_DEBUG2G("inode=%ju offset=%jd resid=%zd\n",
(uintmax_t)VTOI(vp), uio->uio_offset, uio->uio_resid);
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1285,8 +1272,6 @@ fuse_vnop_readdir(struct vop_readdir_args *ap)
int err = 0;
int freefufh = 0;
FS_DEBUG2G("inode=%ju\n", (uintmax_t)VTOI(vp));
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1296,7 +1281,8 @@ fuse_vnop_readdir(struct vop_readdir_args *ap)
}
if (!fuse_filehandle_valid(vp, FUFH_RDONLY)) {
FS_DEBUG("calling readdir() before open()");
SDT_PROBE2(fuse, , vnops, trace, 1,
"calling readdir() before open()");
err = fuse_filehandle_open(vp, FUFH_RDONLY, &fufh, NULL, cred);
freefufh = 1;
} else {
@ -1334,8 +1320,6 @@ fuse_vnop_readlink(struct vop_readlink_args *ap)
struct fuse_dispatcher fdi;
int err;
FS_DEBUG2G("inode=%ju\n", (uintmax_t)VTOI(vp));
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1381,8 +1365,6 @@ fuse_vnop_reclaim(struct vop_reclaim_args *ap)
if (!fvdat) {
panic("FUSE: no vnode data during recycling");
}
FS_DEBUG("inode=%ju\n", (uintmax_t)VTOI(vp));
for (type = 0; type < FUFH_MAXTYPE; type++) {
fufh = &(fvdat->fufh[type]);
if (FUFH_IS_VALID(fufh)) {
@ -1421,9 +1403,6 @@ fuse_vnop_remove(struct vop_remove_args *ap)
int err;
FS_DEBUG2G("inode=%ju name=%*s\n",
(uintmax_t)VTOI(vp), (int)cnp->cn_namelen, cnp->cn_nameptr);
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1462,18 +1441,12 @@ fuse_vnop_rename(struct vop_rename_args *ap)
int err = 0;
FS_DEBUG2G("from: inode=%ju name=%*s -> to: inode=%ju name=%*s\n",
(uintmax_t)VTOI(fvp), (int)fcnp->cn_namelen, fcnp->cn_nameptr,
(uintmax_t)(tvp == NULL ? -1 : VTOI(tvp)),
(int)tcnp->cn_namelen, tcnp->cn_nameptr);
if (fuse_isdeadfs(fdvp)) {
return ENXIO;
}
if (fvp->v_mount != tdvp->v_mount ||
(tvp && fvp->v_mount != tvp->v_mount)) {
FS_DEBUG("cross-device rename: %s -> %s\n",
fcnp->cn_nameptr, (tcnp != NULL ? tcnp->cn_nameptr : "(NULL)"));
SDT_PROBE2(fuse, , vnops, trace, 1, "cross-device rename");
err = EXDEV;
goto out;
}
@ -1534,8 +1507,6 @@ fuse_vnop_rmdir(struct vop_rmdir_args *ap)
int err;
FS_DEBUG2G("inode=%ju\n", (uintmax_t)VTOI(vp));
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1574,8 +1545,6 @@ fuse_vnop_setattr(struct vop_setattr_args *ap)
int sizechanged = 0;
uint64_t newsize = 0;
FS_DEBUG2G("inode=%ju\n", (uintmax_t)VTOI(vp));
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1661,21 +1630,26 @@ fuse_vnop_setattr(struct vop_setattr_args *ap)
if (vnode_vtype(vp) != vtyp) {
if (vnode_vtype(vp) == VNON && vtyp != VNON) {
debug_printf("FUSE: Dang! vnode_vtype is VNON and vtype isn't.\n");
SDT_PROBE2(fuse, , vnops, trace, 1, "FUSE: Dang! "
"vnode_vtype is VNON and vtype isn't.");
} else {
/*
* STALE vnode, ditch
*
* The vnode has changed its type "behind our back". There's
* nothing really we can do, so let us just force an internal
* revocation and tell the caller to try again, if interested.
* The vnode has changed its type "behind our back".
* There's nothing really we can do, so let us just
* force an internal revocation and tell the caller to
* try again, if interested.
*/
fuse_internal_vnode_disappear(vp);
err = EAGAIN;
}
}
if (err == 0)
cache_attrs(vp, (struct fuse_attr_out *)fdi.answ, NULL);
if (err == 0) {
struct fuse_attr_out *fao = (struct fuse_attr_out*)fdi.answ;
fuse_internal_cache_attrs(vp, &fao->attr, fao->attr_valid,
fao->attr_valid_nsec, NULL);
}
out:
fdisp_destroy(&fdi);
@ -1698,8 +1672,6 @@ fuse_vnop_strategy(struct vop_strategy_args *ap)
struct vnode *vp = ap->a_vp;
struct buf *bp = ap->a_bp;
fuse_trace_printf_vnop();
if (!vp || fuse_isdeadfs(vp)) {
bp->b_ioflags |= BIO_ERROR;
bp->b_error = ENXIO;
@ -1746,9 +1718,6 @@ fuse_vnop_symlink(struct vop_symlink_args *ap)
int err;
size_t len;
FS_DEBUG2G("inode=%ju name=%*s\n",
(uintmax_t)VTOI(dvp), (int)cnp->cn_namelen, cnp->cn_nameptr);
if (fuse_isdeadfs(dvp)) {
return ENXIO;
}
@ -1789,8 +1758,6 @@ fuse_vnop_write(struct vop_write_args *ap)
int ioflag = ap->a_ioflag;
struct ucred *cred = ap->a_cred;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp)) {
return ENXIO;
}
@ -1803,6 +1770,7 @@ fuse_vnop_write(struct vop_write_args *ap)
return fuse_io_dispatch(vp, uio, ioflag, cred);
}
SDT_PROBE_DEFINE1(fuse, , vnops, vnop_getpages_error, "int");
/*
struct vnop_getpages_args {
struct vnode *a_vp;
@ -1824,8 +1792,6 @@ fuse_vnop_getpages(struct vop_getpages_args *ap)
struct ucred *cred;
vm_page_t *pages;
FS_DEBUG2G("heh\n");
vp = ap->a_vp;
KASSERT(vp->v_object, ("objectless vp passed to getpages"));
td = curthread; /* XXX */
@ -1834,7 +1800,8 @@ fuse_vnop_getpages(struct vop_getpages_args *ap)
npages = ap->a_count;
if (!fsess_opt_mmap(vnode_mount(vp))) {
FS_DEBUG("called on non-cacheable vnode??\n");
SDT_PROBE2(fuse, , vnops, trace, 1,
"called on non-cacheable vnode??\n");
return (VM_PAGER_ERROR);
}
@ -1879,7 +1846,7 @@ fuse_vnop_getpages(struct vop_getpages_args *ap)
uma_zfree(fuse_pbuf_zone, bp);
if (error && (uio.uio_resid == count)) {
FS_DEBUG("error %d\n", error);
SDT_PROBE1(fuse, , vnops, vnop_getpages_error, error);
return VM_PAGER_ERROR;
}
/*
@ -1957,8 +1924,6 @@ fuse_vnop_putpages(struct vop_putpages_args *ap)
vm_page_t *pages;
vm_ooffset_t fsize;
FS_DEBUG2G("heh\n");
vp = ap->a_vp;
KASSERT(vp->v_object, ("objectless vp passed to putpages"));
fsize = vp->v_object->un_pager.vnp.vnp_size;
@ -1971,7 +1936,8 @@ fuse_vnop_putpages(struct vop_putpages_args *ap)
offset = IDX_TO_OFF(pages[0]->pindex);
if (!fsess_opt_mmap(vnode_mount(vp))) {
FS_DEBUG("called on non-cacheable vnode??\n");
SDT_PROBE2(fuse, , vnops, trace, 1,
"called on non-cacheable vnode??\n");
}
for (i = 0; i < npages; i++)
rtvals[i] = VM_PAGER_AGAIN;
@ -2054,8 +2020,6 @@ fuse_vnop_getextattr(struct vop_getextattr_args *ap)
size_t len;
int err;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp))
return (ENXIO);
@ -2091,7 +2055,6 @@ fuse_vnop_getextattr(struct vop_getextattr_args *ap)
if (err != 0) {
if (err == ENOSYS)
fsess_set_notimpl(mp, FUSE_GETXATTR);
debug_printf("getxattr: got err=%d from daemon\n", err);
goto out;
}
@ -2134,8 +2097,6 @@ fuse_vnop_setextattr(struct vop_setextattr_args *ap)
char *attr_str;
int err;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp))
return (ENXIO);
@ -2161,7 +2122,6 @@ fuse_vnop_setextattr(struct vop_setextattr_args *ap)
err = uiomove((char *)fdi.indata + sizeof(*set_xattr_in) + len,
uio->uio_resid, uio);
if (err != 0) {
debug_printf("setxattr: got error %d from uiomove\n", err);
goto out;
}
@ -2170,7 +2130,6 @@ fuse_vnop_setextattr(struct vop_setextattr_args *ap)
if (err != 0) {
if (err == ENOSYS)
fsess_set_notimpl(mp, FUSE_SETXATTR);
debug_printf("setxattr: got err=%d from daemon\n", err);
goto out;
}
@ -2265,8 +2224,6 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap)
int linux_list_len;
int err;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp))
return (ENXIO);
@ -2296,7 +2253,6 @@ fuse_vnop_listextattr(struct vop_listextattr_args *ap)
if (err != 0) {
if (err == ENOSYS)
fsess_set_notimpl(mp, FUSE_LISTXATTR);
debug_printf("listextattr: got err=%d from daemon\n", err);
goto out;
}
@ -2371,8 +2327,6 @@ fuse_vnop_deleteextattr(struct vop_deleteextattr_args *ap)
char *attr_str;
int err;
fuse_trace_printf_vnop();
if (fuse_isdeadfs(vp))
return (ENXIO);
@ -2396,7 +2350,6 @@ fuse_vnop_deleteextattr(struct vop_deleteextattr_args *ap)
if (err != 0) {
if (err == ENOSYS)
fsess_set_notimpl(mp, FUSE_REMOVEXATTR);
debug_printf("removexattr: got err=%d from daemon\n", err);
}
fdisp_destroy(&fdi);