PERFORCE change 195351 for review
Ilya Putsikau
ilya at FreeBSD.org
Sun Jun 26 09:51:17 UTC 2011
http://p4web.freebsd.org/@@195351?ac=10
Change 195351 by ilya at ilya_triton2011 on 2011/06/26 09:50:11
Reduce diffs against macfuse 2.0
Rename:
fusedev_get_data -> fuse_get_devdata
fusefs_get_data -> fuse_get_mpdata
fdata_kick_set -> fdata_set_dead
fdata_kick_get -> fdata_get_dead (macfuse uses fdata_dead_get)
Affected files ...
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_device.c#7 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_file.c#5 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_file.h#3 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.c#12 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.h#13 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_io.c#11 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_ipc.c#7 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_ipc.h#9 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.c#7 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.h#9 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_param.h#2 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vfsops.c#16 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#24 edit
Differences ...
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_device.c#7 (text+ko) ====
@@ -123,7 +123,7 @@
fdata = fdata_alloc(dev, td->td_ucred);
FUSE_LOCK();
- if (fusedev_get_data(dev)) {
+ if (fuse_get_devdata(dev)) {
FUSE_UNLOCK();
fdata_destroy(fdata);
goto busy;
@@ -131,7 +131,7 @@
#if ! (DO_GIANT_MANUALLY && USE_FUSE_LOCK)
fuse_useco++;
#endif
- fdata->dataflag |= FSESS_OPENED;
+ fdata->dataflags |= FSESS_OPENED;
dev->si_drv1 = fdata;
}
FUSE_UNLOCK();
@@ -163,13 +163,13 @@
mtx_lock(&Giant);
#endif
FUSE_LOCK();
- data = fusedev_get_data(dev);
+ data = fuse_get_devdata(dev);
if (! data)
panic("no fuse data upon fuse device close");
- KASSERT(data->dataflag | FSESS_OPENED,
+ KASSERT(data->dataflags | FSESS_OPENED,
("fuse device is already closed upon close"));
- fdata_kick_set(data);
- data->dataflag &= ~FSESS_OPENED;
+ fdata_set_dead(data);
+ data->dataflags &= ~FSESS_OPENED;
mtx_lock(&data->aw_mtx);
/* wakup poll()ers */
@@ -213,11 +213,11 @@
struct fuse_data *data;
int revents = 0;
- data = fusedev_get_data(dev);
+ data = fuse_get_devdata(dev);
if (events & (POLLIN | POLLRDNORM)) {
mtx_lock(&data->ms_mtx);
- if (fdata_kick_get(data) || STAILQ_FIRST(&data->ms_head))
+ if (fdata_get_dead(data) || STAILQ_FIRST(&data->ms_head))
revents |= events & (POLLIN | POLLRDNORM);
else
selrecord(td, &data->ks_rsel);
@@ -246,13 +246,13 @@
int buflen[3];
int i;
- data = fusedev_get_data(dev);
+ data = fuse_get_devdata(dev);
DEBUG("fuse device being read on thread %d\n", uio->uio_td->td_tid);
mtx_lock(&data->ms_mtx);
again:
- if (fdata_kick_get(data)) {
+ if (fdata_get_dead(data)) {
DEBUG2G("we know early on that reader should be kicked so we don't wait for news\n");
mtx_unlock(&data->ms_mtx);
return (ENODEV);
@@ -269,7 +269,7 @@
err = msleep(data, &data->ms_mtx, PCATCH, "fu_msg", 0);
if (err != 0) {
mtx_unlock(&data->ms_mtx);
- return (fdata_kick_get(data) ? ENODEV : err);
+ return (fdata_get_dead(data) ? ENODEV : err);
}
tick = fuse_ms_pop(data);
}
@@ -286,7 +286,7 @@
}
mtx_unlock(&data->ms_mtx);
- if (fdata_kick_get(data)) {
+ if (fdata_get_dead(data)) {
/*
* somebody somewhere -- eg., umount routine --
* wants this liaison finished off
@@ -331,7 +331,7 @@
* fallacy as loud as possible...
*/
if (uio->uio_resid < buflen[i]) {
- fdata_kick_set(data);
+ fdata_set_dead(data);
DEBUG2G("daemon is stupid, kick it off...\n");
err = ENODEV;
break;
@@ -392,11 +392,11 @@
DEBUG("Fuse write -- resid: %zd, iovcnt: %d, thread: %d\n",
uio->uio_resid, uio->uio_iovcnt, uio->uio_td->td_tid);
- data = fusedev_get_data(dev);
+ data = fuse_get_devdata(dev);
if (uio->uio_resid < sizeof(struct fuse_out_header)) {
DEBUG("got less than a header!\n");
- fdata_kick_set(data);
+ fdata_set_dead(data);
return (EINVAL);
}
@@ -411,7 +411,7 @@
* header.
*/
if ((err = fuse_ohead_audit(&ohead, uio))) {
- fdata_kick_set(data);
+ fdata_set_dead(data);
return (err);
}
@@ -473,7 +473,7 @@
*/
DEBUG("erhm, no handler for this response\n");
- fdata_kick_set(data);
+ fdata_set_dead(data);
return (EINVAL);
}
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_file.c#5 (text+ko) ====
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Google. All Rights Reserved.
+ * Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
@@ -37,33 +37,38 @@
&fuse_fh_upcall_count, 0, "");
int
-fuse_filehandle_get(struct vnode *vp, struct thread *td, struct ucred *cred, fufh_type_t fufh_type)
+fuse_filehandle_get(struct vnode *vp,
+ struct thread *td,
+ struct ucred *cred,
+ fufh_type_t fufh_type)
{
- struct fuse_vnode_data *fvdat = VTOFUD(vp);
struct fuse_dispatcher fdi;
struct fuse_open_in *foi;
struct fuse_open_out *foo;
struct fuse_filehandle *fufh;
+ struct fuse_vnode_data *fvdat = VTOFUD(vp);
- int err = 0;
- int isdir = 0;
- int op = FUSE_OPEN;
+ int err = 0;
+ int isdir = 0;
int oflags = fuse_filehandle_xlate_to_oflags(fufh_type);
+ int op = FUSE_OPEN;
fuse_trace_printf("fuse_filehandle_get(vp=%p, fufh_type=%d)\n",
vp, fufh_type);
fufh = &(fvdat->fufh[fufh_type]);
+
if (fufh->fufh_flags & FUFH_VALID) {
- printf("the given fufh type is already valid ... called in vain\n");
+ printf("FUSE: filehandle_get called despite valid fufh (type=%d)",
+ fufh_type);
return 0;
}
- if (vnode_vtype(vp) == VDIR) {
+ if (vnode_isdir(vp)) {
isdir = 1;
op = FUSE_OPENDIR;
if (fufh_type != FUFH_RDONLY) {
- printf("non-rdonly fh requested for a directory?\n");
+ printf("FUSE: non-rdonly fh requested for a directory?\n");
fufh_type = FUFH_RDONLY;
}
}
@@ -82,12 +87,12 @@
foo = fdi.answ;
+ fufh->fh_id = foo->fh;
fufh->fufh_flags |= (0 | FUFH_VALID);
fufh->open_count = 1;
fufh->open_flags = oflags;
fufh->fuse_open_flags = foo->open_flags;
fufh->type = fufh_type;
- fufh->fh_id = foo->fh;
fuse_ticket_drop(fdi.tick);
@@ -101,11 +106,11 @@
struct fuse_dispatcher fdi;
struct fuse_release_in *fri;
struct fuse_vnode_data *fvdat = VTOFUD(vp);
- struct fuse_filehandle *fufh = NULL;
+ struct fuse_filehandle *fufh = NULL;
- int op = FUSE_RELEASE;
- int err = 0;
+ int err = 0;
int isdir = 0;
+ int op = FUSE_RELEASE;
fuse_trace_printf("fuse_filehandle_put(vp=%p, fufh_type=%d)\n",
vp, fufh_type);
@@ -117,14 +122,16 @@
}
if (fufh->open_count != 0) {
- panic("trying to put fufh with open count %d\n", fufh->open_count);
+ panic("FUSE: filehandle_put called on a valid fufh (type=%d)",
+ fufh_type);
+ /* NOTREACHED */
}
if (fufh->fufh_flags & FUFH_MAPPED) {
panic("trying to put mapped fufh\n");
}
- if (vnode_vtype(vp) == VDIR) {
+ if (vnode_isdir(vp)) {
op = FUSE_RELEASEDIR;
isdir = 1;
}
@@ -149,5 +156,5 @@
out:
fufh->fufh_flags &= ~FUFH_VALID;
- return (err);
+ return err;
}
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_file.h#3 (text+ko) ====
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Google. All Rights Reserved.
+ * Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
@@ -25,16 +25,17 @@
#define FUFH_STRATEGY 0x00000004
struct fuse_filehandle {
- uint64_t fh_id;
+ uint64_t fh_id;
+ int open_count;
+ int open_flags;
+ int fuse_open_flags;
fufh_type_t type;
- int fufh_flags;
- int open_count;
- int open_flags;
- int fuse_open_flags;
+ int fufh_flags;
};
typedef struct fuse_filehandle * fuse_filehandle_t;
-static __inline__ fufh_type_t
+static __inline__
+fufh_type_t
fuse_filehandle_xlate_from_mmap(int fflags)
{
if (fflags & (PROT_READ | PROT_WRITE)) {
@@ -48,7 +49,8 @@
}
}
-static __inline__ fufh_type_t
+static __inline__
+fufh_type_t
fuse_filehandle_xlate_from_fflags(int fflags)
{
if ((fflags & FREAD) && (fflags & FWRITE)) {
@@ -58,25 +60,30 @@
} else if (fflags & (FREAD)) {
return FUFH_RDONLY;
} else {
- panic("What kind of a flag is this?");
+ panic("FUSE: What kind of a flag is this (%x)?", fflags);
}
}
-static __inline__ int
+static __inline__
+int
fuse_filehandle_xlate_to_oflags(fufh_type_t type)
{
int oflags = -1;
switch (type) {
+
case FUFH_RDONLY:
oflags = O_RDONLY;
break;
+
case FUFH_WRONLY:
oflags = O_WRONLY;
break;
+
case FUFH_RDWR:
oflags = O_RDWR;
break;
+
default:
break;
}
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.c#12 (text+ko) ====
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Google. All Rights Reserved.
+ * Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
@@ -50,9 +50,6 @@
/* access */
-static __inline int fuse_match_cred(struct ucred *daemoncred,
- struct ucred *usercred);
-
int
fuse_internal_access(struct vnode *vp,
mode_t mode,
@@ -62,7 +59,7 @@
{
int err = 0;
uint32_t mask = 0;
- int dataflag;
+ int dataflags;
int vtype;
struct mount *mp;
struct fuse_dispatcher fdi;
@@ -78,8 +75,8 @@
mp = vnode_mount(vp);
vtype = vnode_vtype(vp);
- data = fusefs_get_data(mp);
- dataflag = data->dataflag;
+ data = fuse_get_mpdata(mp);
+ dataflags = data->dataflags;
if ((mode & VWRITE) && vfs_isrdonly(mp)) {
return EACCES;
@@ -87,7 +84,7 @@
// Unless explicitly permitted, deny everyone except the fs owner.
if (vnode_isvroot(vp) && !(facp->facc_flags & FACCESS_NOCHECKSPY)) {
- if (!(dataflag & FSESS_DAEMON_CAN_SPY)) {
+ if (!(dataflags & FSESS_DAEMON_CAN_SPY)) {
int denied = fuse_match_cred(data->daemoncred,
cred);
if (denied) {
@@ -111,12 +108,12 @@
#endif
}
- if (fusefs_get_data(mp)->dataflag & FSESS_NOACCESS) {
+ if (fuse_get_mpdata(mp)->dataflags & FSESS_NOACCESS) {
// Let the kernel handle this.
return 0;
}
- if (dataflag & FSESS_DEFAULT_PERMISSIONS) {
+ if (dataflags & FSESS_DEFAULT_PERMISSIONS) {
// Let the kernel handle this.
return 0;
}
@@ -152,35 +149,13 @@
}
if (err == ENOSYS) {
- fusefs_get_data(mp)->dataflag |= FSESS_NOACCESS;
+ fuse_get_mpdata(mp)->dataflags |= FSESS_NOACCESS;
err = 0; // ENOTSUP;
}
return err;
}
-/*
- * An access check routine based on fuse_allow_task() of the Linux module.
- * Now we use this one rather than the more permissive function we used to
- * (and which seemed more logical to me), to ensure uniform behaviour on Linux
- * and FreeBSD.
- *
- * Non-null return value indicates error (ie., "not allowed").
- */
-static __inline int
-fuse_match_cred(struct ucred *basecred, struct ucred *usercred)
-{
- if (basecred->cr_uid == usercred->cr_uid &&
- basecred->cr_uid == usercred->cr_ruid &&
- basecred->cr_uid == usercred->cr_svuid &&
- basecred->cr_groups[0] == usercred->cr_groups[0] &&
- basecred->cr_groups[0] == usercred->cr_rgid &&
- basecred->cr_groups[0] == usercred->cr_svgid)
- return (0);
-
- return (EPERM);
-}
-
/* fsync */
int
@@ -189,7 +164,7 @@
fuse_trace_printf_func();
if (tick->tk_aw_ohead.error == ENOSYS) {
- tick->tk_data->dataflag |= (fticket_opcode(tick) == FUSE_FSYNC) ?
+ tick->tk_data->dataflags |= (fticket_opcode(tick) == FUSE_FSYNC) ?
FSESS_NOFSYNC : FSESS_NOFSYNCDIR;
}
@@ -213,7 +188,7 @@
fdip->iosize = sizeof(*ffsi);
fdip->tick = NULL;
- if (vnode_vtype(vp) == VDIR) {
+ if (vnode_isdir(vp)) {
op = FUSE_FSYNCDIR;
}
@@ -221,7 +196,7 @@
ffsi = fdip->indata;
ffsi->fh = fufh->fh_id;
- ffsi->fsync_flags = 1;
+ ffsi->fsync_flags = 1; /* datasync */
fuse_insert_callback(fdip->tick, fuse_internal_fsync_callback);
fuse_insert_message(fdip->tick);
@@ -243,7 +218,7 @@
struct fuse_read_in *fri;
if (uio_resid(uio) == 0) {
- return (0);
+ return 0;
}
fdisp_init(&fdi, 0);
@@ -293,7 +268,7 @@
struct fuse_iov *cookediov = param;
if (bufsize < FUSE_NAME_OFFSET) {
- return (-1);
+ return -1;
}
for (;;) {
@@ -303,11 +278,11 @@
break;
}
- cou++;
-
fudge = (struct fuse_dirent *)buf;
freclen = FUSE_DIRENT_SIZE(fudge);
+ cou++;
+
if (bufsize < freclen) {
err = ((cou == 1) ? -1 : 0);
break;
@@ -336,9 +311,9 @@
fiov_adjust(cookediov, bytesavail);
de = (struct dirent *)cookediov->base;
- de->d_fileno = fudge->ino; /* XXX cast from 64 to 32 bits */
+ de->d_fileno = fudge->ino; /* XXX: truncation */
de->d_reclen = bytesavail;
- de->d_type = fudge->type;
+ de->d_type = fudge->type;
de->d_namlen = fudge->namelen;
memcpy((char *)cookediov->base + sizeof(struct dirent) - MAXNAMLEN - 1,
(char *)buf + FUSE_NAME_OFFSET, fudge->namelen);
@@ -354,14 +329,14 @@
uio_setoffset(uio, fudge->off);
}
- return (err);
+ return err;
}
/* remove */
#ifdef XXXIP
static int
-fuse_unlink_callback(struct vnode *vp, void *cargs)
+fuse_internal_remove_callback(struct vnode *vp, void *cargs)
{
struct vattr *vap;
uint64_t target_nlink;
@@ -370,7 +345,8 @@
target_nlink = *(uint64_t *)cargs;
- if ((vap->va_nlink == target_nlink) && (vnode_vtype(vp) == VREG)) {
+ /* somewhat lame "heuristics", but you got better ideas? */
+ if ((vap->va_nlink == target_nlink) && vnode_isreg(vp)) {
fuse_invalidate_attr(vp);
}
@@ -386,6 +362,7 @@
enum fuse_opcode op)
{
struct fuse_dispatcher fdi;
+
struct vattr *vap = VTOVA(vp);
#if INVALIDATE_CACHED_VATTRS_UPON_UNLINK
int need_invalidate = 0;
@@ -415,16 +392,24 @@
fuse_invalidate_attr(dvp);
fuse_invalidate_attr(vp);
-#if INVALIDATE_CACHED_VATTRS_UPON_UNLINK
#ifdef XXXIP
+ /*
+ * XXX: INVALIDATE_CACHED_VATTRS_UPON_UNLINK
+ *
+ * Consider the case where vap->va_nlink > 1 for the entity being
+ * removed. In our world, other in-memory vnodes that share a link
+ * count each with this one may not know right way that this one just
+ * got deleted. We should let them know, say, through a vnode_iterate()
+ * here and a callback that does fuse_invalidate_attr(vp) on each
+ * relevant vnode.
+ */
if (need_invalidate && !err) {
- vnode_iterate(vnode_mount(vp), 0, fuse_unlink_callback,
+ vnode_iterate(vnode_mount(vp), 0, fuse_internal_remove_callback,
(void *)&target_nlink);
}
#endif
-#endif
- return (err);
+ return err;
}
/* rename */
@@ -461,7 +446,7 @@
fuse_invalidate_attr(tdvp);
}
- return (err);
+ return err;
}
/* strategy */
@@ -500,10 +485,8 @@
struct fuse_entry_out *feo;
struct mount *mp = vnode_mount(dvp);
- debug_printf("fdip=%p\n", fdip);
-
if ((err = fdisp_wait_answ(fdip))) {
- return (err);
+ return err;
}
feo = fdip->answ;
@@ -512,8 +495,7 @@
goto out;
}
- err = fuse_vnode_get(mp, feo->nodeid, dvp, vpp, cnp,
- vtyp, 0);
+ err = fuse_vnode_get(mp, feo->nodeid, dvp, vpp, cnp, vtyp, 0);
if (err) {
fuse_internal_forget_send(mp, cnp->cn_thread, cnp->cn_cred, feo->nodeid, 1, fdip);
return err;
@@ -534,33 +516,32 @@
enum fuse_opcode op,
void *buf,
size_t bufsize,
- enum vtype vtyp)
+ enum vtype vtype)
{
int err;
struct fuse_dispatcher fdi;
+ struct mount *mp = vnode_mount(dvp);
fdisp_init(&fdi, 0);
- fuse_internal_newentry_makerequest(vnode_mount(dvp), VTOI(dvp), cnp,
- op, buf, bufsize, &fdi);
- err = fuse_internal_newentry_core(dvp, vpp, cnp, vtyp, &fdi);
+ fuse_internal_newentry_makerequest(mp, VTOI(dvp), cnp, op, buf,
+ bufsize, &fdi);
+ err = fuse_internal_newentry_core(dvp, vpp, cnp, vtype, &fdi);
fuse_invalidate_attr(dvp);
- return (err);
+ return err;
}
/* entity destruction */
int
-fuse_internal_forget_callback(struct fuse_ticket *tick, struct uio *uio)
+fuse_internal_forget_callback(struct fuse_ticket *ftick, struct uio *uio)
{
struct fuse_dispatcher fdi;
- debug_printf("tick=%p, uio=%p\n", tick, uio);
+ fdi.tick = ftick;
- fdi.tick = tick;
- fuse_internal_forget_send(tick->tk_data->mp, curthread, NULL,
- ((struct fuse_in_header *)tick->tk_ms_fiov.base)->nodeid,
- 1, &fdi);
+ fuse_internal_forget_send(ftick->tk_data->mp, curthread, NULL,
+ ((struct fuse_in_header *)ftick->tk_ms_fiov.base)->nodeid, 1, &fdi);
return 0;
}
@@ -637,15 +618,15 @@
fuse_ticket_drop(tick);
if (err) {
- fdata_kick_set(data);
+ fdata_set_dead(data);
}
mtx_lock(&data->ticket_mtx);
- data->dataflag |= FSESS_INITED;
+ data->dataflags |= FSESS_INITED;
wakeup(&data->ticketer);
mtx_unlock(&data->ticket_mtx);
- return (0);
+ return 0;
}
void
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.h#13 (text+ko) ====
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Google. All Rights Reserved.
+ * Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
@@ -86,6 +86,46 @@
uio->uio_resid = resid;
}
+/* time */
+
+#define fuse_timespec_add(vvp, uvp) \
+ do { \
+ (vvp)->tv_sec += (uvp)->tv_sec; \
+ (vvp)->tv_nsec += (uvp)->tv_nsec; \
+ if ((vvp)->tv_nsec >= 1000000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_nsec -= 1000000000; \
+ } \
+ } while (0)
+
+#define fuse_timespec_cmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+
+/* miscellaneous */
+
+#define fuse_isdeadfs_nop(vp) 0
+
+static __inline__
+int
+fuse_isdeadfs(struct vnode *vp)
+{
+ struct mount *mp = vnode_mount(vp);
+ struct fuse_data *data = fuse_get_mpdata(mp);
+
+ return (data->dataflags & FSESS_DEAD);
+}
+
+static __inline__
+int
+fuse_isdeadfs_mp(struct mount *mp)
+{
+ struct fuse_data *data = fuse_get_mpdata(mp);
+
+ return (data->dataflags & FSESS_DEAD);
+}
+
/* access */
#define FVP_ACCESS_NOOP 0x01
@@ -100,11 +140,25 @@
#define FACCESS_XQUERIES FACCESS_STICKY | FACCESS_CHOWN | FACCESS_SETGID
struct fuse_access_param {
- uid_t xuid;
- gid_t xgid;
- unsigned facc_flags;
+ uid_t xuid;
+ gid_t xgid;
+ uint32_t facc_flags;
};
+static __inline int
+fuse_match_cred(struct ucred *basecred, struct ucred *usercred)
+{
+ if (basecred->cr_uid == usercred->cr_uid &&
+ basecred->cr_uid == usercred->cr_ruid &&
+ basecred->cr_uid == usercred->cr_svuid &&
+ basecred->cr_groups[0] == usercred->cr_groups[0] &&
+ basecred->cr_groups[0] == usercred->cr_rgid &&
+ basecred->cr_groups[0] == usercred->cr_svgid)
+ return 0;
+
+ return EPERM;
+}
+
int
fuse_internal_access(struct vnode *vp,
mode_t mode,
@@ -152,15 +206,6 @@
vap->va_flags = 0;
}
-#define timespecadd(vvp, uvp) \
- do { \
- (vvp)->tv_sec += (uvp)->tv_sec; \
- (vvp)->tv_nsec += (uvp)->tv_nsec; \
- if ((vvp)->tv_nsec >= 1000000000) { \
- (vvp)->tv_sec++; \
- (vvp)->tv_nsec -= 1000000000; \
- } \
- } while (0)
#define cache_attrs(vp, fuse_out) do { \
struct timespec uptsp_ ## __func__; \
@@ -169,7 +214,7 @@
VTOFUD(vp)->cached_attrs_valid.tv_nsec = (fuse_out)->attr_valid_nsec; \
nanouptime(&uptsp_ ## __func__); \
\
- timespecadd(&VTOFUD(vp)->cached_attrs_valid, &uptsp_ ## __func__); \
+ fuse_timespec_add(&VTOFUD(vp)->cached_attrs_valid, &uptsp_ ## __func__); \
\
fuse_internal_attr_fat2vat(vnode_mount(vp), &(fuse_out)->attr, VTOVA(vp)); \
} while (0)
@@ -235,22 +280,22 @@
if (vtyp != IFTOVT(feo->attr.mode)) {
DEBUGX(FUSE_DEBUG_INTERNAL,
"EINVAL -- %x != %x\n", vtyp, IFTOVT(feo->attr.mode));
- return (EINVAL);
+ return EINVAL;
}
if (feo->nodeid == FUSE_NULL_ID) {
DEBUGX(FUSE_DEBUG_INTERNAL,
"EINVAL -- feo->nodeid is NULL\n");
- return (EINVAL);
+ return EINVAL;
}
if (feo->nodeid == FUSE_ROOT_ID) {
DEBUGX(FUSE_DEBUG_INTERNAL,
"EINVAL -- feo->nodeid is FUSE_ROOT_ID\n");
- return (EINVAL);
+ return EINVAL;
}
- return (0);
+ return 0;
}
int
@@ -296,27 +341,4 @@
int fuse_internal_init_callback(struct fuse_ticket *tick, struct uio *uio);
void fuse_internal_send_init(struct fuse_data *data, struct thread *td);
-/* miscellaneous */
-
-#define fuse_isdeadfs_nop(vp) 0
-
-static __inline__
-int
-fuse_isdeadfs(struct vnode *vp)
-{
- struct mount *mp = vnode_mount(vp);
- struct fuse_data *data = fusefs_get_data(mp);
-
- return (data->dataflag & FSESS_KICK);
-}
-
-static __inline__
-int
-fuse_isdeadfs_mp(struct mount *mp)
-{
- struct fuse_data *data = fusefs_get_data(mp);
-
- return (data->dataflag & FSESS_KICK);
-}
-
#endif /* _FUSE_INTERNAL_H_ */
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_io.c#11 (text+ko) ====
@@ -337,7 +337,7 @@
fri->fh = fufh->fh_id;
fri->offset = uio->uio_offset;
fri->size = MIN(uio->uio_resid,
- fusefs_get_data(vp->v_mount)->max_read);
+ fuse_get_mpdata(vp->v_mount)->max_read);
DEBUG2G("fri->fh %ju, fri->offset %ju, fri->size %ju\n",
(uintmax_t)fri->fh, (uintmax_t)fri->offset, (uintmax_t)fri->size);
@@ -373,8 +373,8 @@
int chunksize = 0;
struct iovec *iov;
int nmax = (uio->uio_rw == UIO_READ) ?
- fusefs_get_data(vp->v_mount)->max_read :
- fusefs_get_data(vp->v_mount)->max_write;
+ fuse_get_mpdata(vp->v_mount)->max_read :
+ fuse_get_mpdata(vp->v_mount)->max_write;
op = fioda->opcode ?:
((uio->uio_rw == UIO_READ) ? FUSE_READ : FUSE_WRITE);
@@ -487,7 +487,7 @@
while (uio->uio_resid > 0) {
chunksize = MIN(uio->uio_resid,
- fusefs_get_data(vp->v_mount)->max_write);
+ fuse_get_mpdata(vp->v_mount)->max_write);
fdi.iosize = sizeof(*fwi) + chunksize;
fdisp_make_vp(&fdi, FUSE_WRITE, vp, td, cred);
@@ -808,7 +808,7 @@
while (bp->b_resid > 0) {
DEBUG2G("starting bio with resid %ld\n", bp->b_resid);
chunksize = MIN(bp->b_resid,
- fusefs_get_data(vp->v_mount)->max_read);
+ fuse_get_mpdata(vp->v_mount)->max_read);
fdi.iosize = sizeof(*fri);
if (! op)
op = vp->v_type == VDIR ? FUSE_READDIR : FUSE_READ;
@@ -878,7 +878,7 @@
bufdat = bp->b_data + bp->b_dirtyoff;
while (bp->b_dirtyend > bp->b_dirtyoff) {
chunksize = MIN(bp->b_dirtyend - bp->b_dirtyoff,
- fusefs_get_data(vp->v_mount)->max_write);
+ fuse_get_mpdata(vp->v_mount)->max_write);
fdi.iosize = sizeof(*fwi);
op = op ?: FUSE_WRITE;
==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_ipc.c#7 (text+ko) ====
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Google. All Rights Reserved.
+ * Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
@@ -32,25 +32,30 @@
#include "fuse_debug.h"
static struct fuse_ticket *fticket_alloc(struct fuse_data *data);
-static void fticket_refresh(struct fuse_ticket *tick);
-static void fticket_destroy(struct fuse_ticket *tick);
-static int fticket_wait_answer(struct fuse_ticket *tick);
-static __inline__ int fticket_aw_pull_uio(struct fuse_ticket *tick, struct uio *uio);
-static __inline__ void fuse_push_freeticks(struct fuse_ticket *tick);
+static void fticket_refresh(struct fuse_ticket *ftick);
+static void fticket_destroy(struct fuse_ticket *ftick);
+static int fticket_wait_answer(struct fuse_ticket *ftick);
+static __inline__ int fticket_aw_pull_uio(struct fuse_ticket *ftick,
+ struct uio *uio);
+static __inline__ void fuse_push_freeticks(struct fuse_ticket *ftick);
static __inline__ struct fuse_ticket *
fuse_pop_freeticks(struct fuse_data *data);
-static __inline__ void fuse_push_allticks(struct fuse_ticket *tick);
-static __inline__ void fuse_remove_allticks(struct fuse_ticket *tick);
+static __inline__ void fuse_push_allticks(struct fuse_ticket *ftick);
+static __inline__ void fuse_remove_allticks(struct fuse_ticket *ftick);
static struct fuse_ticket *fuse_pop_allticks(struct fuse_data *data);
-static int fuse_body_audit(struct fuse_ticket *tick, size_t blen);
+static int fuse_body_audit(struct fuse_ticket *ftick, size_t blen);
static __inline__ void fuse_setup_ihead(struct fuse_in_header *ihead,
- struct fuse_ticket *tick, uint64_t nid,
- enum fuse_opcode op, size_t blen,
- pid_t pid, struct ucred *cred);
-static fuse_handler_t fuse_standard_handler;
+ struct fuse_ticket *ftick,
+ uint64_t nid,
+ enum fuse_opcode op,
+ size_t blen,
+ pid_t pid,
+ struct ucred *cred);
+
+static fuse_handler_t fuse_standard_handler;
SYSCTL_NODE(_vfs, OID_AUTO, fuse, CTLFLAG_RW, 0, "FUSE tunables");
SYSCTL_STRING(_vfs_fuse, OID_AUTO, fuse4bsd_version, CTLFLAG_RD,
@@ -76,11 +81,15 @@
void
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(FU_AT_LEAST(size), M_FUSEMSG, M_WAITOK | M_ZERO);
- fiov->allocated_size = FU_AT_LEAST(size);
+
+ fiov->base = malloc(msize, M_FUSEMSG, M_WAITOK | M_ZERO);
+
+ fiov->allocated_size = msize;
fiov->credit = fuse_iov_credit;
}
@@ -124,172 +133,149 @@
fiov_adjust(fiov, 0);
}
-/*
- * Tickets are carriers of communication with a fuse daemon.
- * Tickets have a unique id, which should be kept unique
- * among synchronously used tickets. The everyday routine:
- * + Syscall handler gets one by fuse_ticket_fetch()
- * (then, behind the scenes, either a fresh one is allocated
- * or a cached old one is put into use again)
- * + Sets up data to be passed to the daemon
- * (there is a message node attached to the ticket)
- * + If she knows that answer will come, sets up the callback node
- * attached to the ticket, and enqueues it to the callback nodes' list
- * + enqueues the message and kicks fusedev_read()
- * + if daemon gives a proper answer, it will contain the unique id, by which
- * fusedev_write() can pick the pre-prepared callback node and run it.
- * There is the standard callback handler which just awakes the syscall
- * handler who then waits for the response, deal with it by herself.
- * Another option is to write a full-fledged callback handler which does all
- * data processing within fusedev_write()'s thread (although we never do
- * this). Or, if the answer is uninteresting, a NULL handler can be used.
- * + After answer has been consumed, the handler or anyone to whom the control
- * has been passed supposed to call ticket_drop()
- * (then, behind the scenes, either the ticket is destroyed, or put into
- * cache)
- */
-
static struct fuse_ticket *
fticket_alloc(struct fuse_data *data)
{
- struct fuse_ticket *tick;
+ struct fuse_ticket *ftick;
debug_printf("data=%p\n", data);
- tick = malloc(sizeof(*tick), M_FUSEMSG, M_WAITOK | M_ZERO);
+ ftick = malloc(sizeof(*ftick), M_FUSEMSG, M_WAITOK | M_ZERO);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list