Date: Thu, 13 Oct 2005 21:56:47 GMT From: soc-chenk <soc-chenk@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 85234 for review Message-ID: <200510132156.j9DLulBW088434@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=85234 Change 85234 by soc-chenk@soc-chenk_leavemealone on 2005/10/13 21:55:53 * vnode identification cleaned up - use the VV_ROOT flag for identifying root node instead of inode number - do not truncate 64 bit nodedids Submitted by: soc-chenk Affected files ... .. //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#13 edit .. //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.h#6 edit Differences ... ==== //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#13 (text+ko) ==== @@ -538,10 +538,7 @@ static __inline int fdata_kick_get(struct fuse_data *data) { -#if _DEBUG - DEBUG2G("0x%x\n", data->dataflag & FDAT_KICK); - kdb_backtrace(); -#endif + DEBUG("0x%x\n", data->dataflag & FDAT_KICK); return (data->dataflag & FDAT_KICK); } @@ -1517,11 +1514,12 @@ typedef int fuse_buffeater_t(struct uio *uio, size_t reqsize, void *buf, size_t bufsize, void *param); typedef int fuse_metrics_t(struct vnode *vp, struct thread *td, struct ucred *cred, int mode, struct fuse_filehandle *fufh, void *param); -static __inline void fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, enum vtype vtyp); +static __inline void fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, uint64_t nodeid, enum vtype vtyp); static vfs_mount_t fuse_mount; static vfs_unmount_t fuse_unmount; static vfs_root_t fuse_root; static vfs_statfs_t fuse_statfs; +static vfs_hash_cmp_t fuse_vnode_cmp; /* static vfs_vget_t fuse_vget; */ static int fuse_vget_i(struct mount *mp, struct thread *td, uint64_t nodeid, enum vtype vtyp, struct vnode **vpp); static __inline void fat2vat(struct mount *mp, struct fuse_attr *fat, struct vattr *vap); @@ -1634,14 +1632,14 @@ */ #define GETPARENT(pvp, vp) \ do { \ - KASSERT((vp)->v_dd != (vp) || VTOI((vp)) == FUSE_ROOT_INODE, \ + KASSERT((vp)->v_dd != (vp) || (vp)->v_vflag & VV_ROOT, \ ("self-parented non-root")); \ (pvp) = (vp)->v_dd; \ } while (0) #define SETPARENT(vp, pvp) \ do { \ - KASSERT((vp) != (pvp) || VTOI((vp)) == FUSE_ROOT_INODE, \ + KASSERT((vp) != (pvp) || (vp)->v_vflag & VV_ROOT, \ ("attempt to make non-root node parented by itself")); \ (vp)->v_dd = (pvp); \ } while (0) @@ -1861,9 +1859,8 @@ * without resorting to the vfs hashing mechanism, thus it also * can be inserted directly to the v_hash slot. */ - rvp->v_hash = FUSE_ROOT_INODE; fmnt->rvp = rvp; - fuse_vnode_init(rvp, fvdat, VDIR); + fuse_vnode_init(rvp, fvdat, FUSE_ROOT_INODE, VDIR); rvp->v_vflag |= VV_ROOT; rootdone: @@ -1915,7 +1912,7 @@ if (err ) { data->mntco--; FUSE_LOCK; - if (data->mntco == 0 && (! data->dataflag & FDAT_OPENED)) { + if (data->mntco == 0 && ! (data->dataflag & FDAT_OPENED)) { fdev->si_drv1 = NULL; fdata_destroy(data); } @@ -2101,6 +2098,12 @@ return (0); } +static int +fuse_vnode_cmp(struct vnode *vp, void *nidp) +{ + return (((struct fuse_vnode_data *)vp->v_data)->nid != *((uint64_t *)nidp)); +} + /* ..._i, as "internal" */ static int @@ -2125,8 +2128,7 @@ DEBUG2G("mp %p: %s\n", mp, mp->mnt_stat.f_mntfromname); - /* XXX nodeid: cast from 64 bytes to 32 */ - if ((err = vfs_hash_get(mp, nodeid, /*flags*/ myflags, td, vpp, NULL, NULL))) + if ((err = vfs_hash_get(mp, 0, /*flags*/ myflags, td, vpp, fuse_vnode_cmp, &nodeid))) return (err); audit: @@ -2156,7 +2158,7 @@ } /* XXX nodeid: cast from 64 bytes to 32 */ - err = vfs_hash_insert(*vpp, nodeid, /*flags*/ myflags, td, &vp2, NULL, NULL); + err = vfs_hash_insert(*vpp, 0, /*flags*/ myflags, td, &vp2, fuse_vnode_cmp, &nodeid); if (err) { FREE(fvdat, M_FUSEFS); @@ -2172,7 +2174,7 @@ goto audit; } - fuse_vnode_init(*vpp, fvdat, vtyp); + fuse_vnode_init(*vpp, fvdat, nodeid, vtyp); #if _DEBUG DEBUG2G("\n"); vn_printf(*vpp, " * "); @@ -2193,11 +2195,11 @@ static __inline void fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, - enum vtype vtyp) + uint64_t nodeid, enum vtype vtyp) { - KASSERT(VTOI(vp), ("vnode tried to be inited before getting an inode for it")); + fvdat->nid = nodeid; vp->v_data = fvdat; - SETPARENT(vp, (VTOI(vp) == FUSE_ROOT_INODE) ? vp : NULL); + SETPARENT(vp, (vp->v_vflag & VV_ROOT) ? vp : NULL); vp->v_type = vtyp; sx_init(&fvdat->fh_lock, "lock for fuse filehandles"); @@ -2211,20 +2213,17 @@ fuse_recyc_backend(struct vnode *vp, struct thread *td) { struct fuse_vnode_data *fvdat; - ino_t ino; if (! vp->v_data) { DEBUG("got a dataless node\n"); return (0); } - DEBUG("getting at vnode of ino %d\n", VTOI(vp)); + DEBUG("getting at vnode of ino %llu\n", VTOI(vp)); - ino = VTOI(vp); fvdat = vp->v_data; - vp->v_data = NULL; - if (VTOI(vp) != FUSE_ROOT_INODE) { + if (! (vp->v_vflag & VV_ROOT)) { vfs_hash_remove(vp); if (fvdat && fvdat->nlookup) { @@ -2241,6 +2240,7 @@ fvdat->nlookup, &fdi); } } + vp->v_data = NULL; /* * Taking down fuse_vnode_data structures is just hooked in here... @@ -2262,7 +2262,7 @@ KASSERT(fufh->useco >= 0, ("negative use count for fuse filehandle")); KASSERT(! fufh->fp || fufh->useco > 0, ("filehandle bound with 0 use counter")); - DEBUG2G("vnode #%d, fufh owner %p, useco %d\n", VTOI(vp), fufh->fp, fufh->useco); + DEBUG2G("vnode #%llu, fufh owner %p, useco %d\n", VTOI(vp), fufh->fp, fufh->useco); if (! fufh->fp && fufh->useco == 0) { LIST_REMOVE(fufh, fh_link); fuse_send_release(vp, td, cred, fufh, fufh->mode); @@ -2307,7 +2307,7 @@ int err; - DEBUG("getting at vnode of ino %d\n", VTOI(vp)); + DEBUG("getting at vnode of ino %llu\n", VTOI(vp)); #if _DEBUG DEBUG2G("=============>\n"); kdb_backtrace(); @@ -2478,7 +2478,7 @@ return (EIO); } - DEBUG("node #%d, type %d\n", VTOI(vp), vap->va_type); + DEBUG("node #%llu, type %d\n", VTOI(vp), vap->va_type); #if _DEBUG DEBUG2G("\n"); vn_printf(vp, " * "); @@ -2582,7 +2582,7 @@ #endif if (dvp->v_type != VDIR) { - DEBUG("vnode #%d of vtype %d is not a dir\n", VTOI(dvp), + DEBUG("vnode #%llu of vtype %d is not a dir\n", VTOI(dvp), dvp->v_type); return (ENOTDIR); } @@ -2602,14 +2602,14 @@ #if NO_EARLY_PERM_CHECK_HACK 1 #else - VTOI(dvp) == FUSE_ROOT_INODE + dvp->v_vflag & VV_ROOT #endif ) { if ((err = VOP_ACCESS(dvp, VEXEC, cred, td))) return (err); } - DEBUG2G("lookup in #%d, with flags 0x%x\n", VTOI(dvp), flags); + DEBUG2G("lookup in #%llu, with flags 0x%x\n", VTOI(dvp), flags); /* fetching data from "storage" */ @@ -2993,13 +2993,13 @@ sx_sunlock(&fvdat->fh_lock); if (err == -1) { - DEBUG2G("suitable fh of vnode #%d found\n", VTOI(vp)); + DEBUG2G("suitable fh of vnode #%llu found\n", VTOI(vp)); return (fufh); } else if (err) return (NULL); - DEBUG2G("we need to fetch a new filehandle for vnode #%d\n", VTOI(vp)); + DEBUG2G("we need to fetch a new filehandle for vnode #%llu\n", VTOI(vp)); fdi.iosize = sizeof(*foi); if ((err = fdisp_prepare_all(&fdi, @@ -3255,7 +3255,7 @@ KASSERT(! fufh->fp && fufh->useco == 0, ("active-looking fuse filehandle was attempted to release")); fvdat->fh_counter--; - DEBUG2G("filehandle of vnode #%d being released, fh counter now is %d\n", + DEBUG2G("filehandle of vnode #%llu being released, fh counter now is %d\n", VTOI(vp), fvdat->fh_counter); fdi.iosize = sizeof(*fri); @@ -3287,7 +3287,7 @@ */ #define BREAK_IF_BAD(fp) \ if (! (fp)->f_vnode->v_data) { \ - DEBUG("bad fileop on vnode no. %d\n", VTOI((fp)->f_vnode)); \ + DEBUG("bad fileop on vnode no. %llu\n", VTOI((fp)->f_vnode)); \ return (EBADF); \ } @@ -3319,7 +3319,7 @@ fvdat = fp->f_vnode->v_data; fufh = fp->f_data; KASSERT(fufh->fp == fp, ("file's filehandle is stolen")); - DEBUG2G("vnode #%d, fufh owner %p, useco %d\n", + DEBUG2G("vnode #%llu, fufh owner %p, useco %d\n", VTOI(fp->f_vnode), fp, fufh->useco); fufh->useco--; @@ -3536,13 +3536,13 @@ */ if (fp->f_flag & O_DIRECT || fufh->flags & FUSEFH_DIRECTIO) { - DEBUG2G("direct read of vnode %d via file handle %llu\n", + DEBUG2G("direct read of vnode %llu via file handle %llu\n", VTOI(fp->f_vnode), fufh->fh_id); err = fuse_read_directbackend(fp->f_vnode, fufh, uio, cred, td, FUSE_READ, fuse_std_buffeater, NULL); } else { - DEBUG2G("buffered read of vnode %d\n", VTOI(fp->f_vnode)); + DEBUG2G("buffered read of vnode %llu\n", VTOI(fp->f_vnode)); err = fuse_read_biobackend(fp->f_vnode, fufh, uio, cred, td, FUSE_READ, fuse_std_buffeater, NULL); } @@ -4214,8 +4214,8 @@ struct vnode *pdp2; DEBUG("trying at chenkpath\n"); do { - DEBUG("checkpath bumped into node %d\n", VTOI(pdp)); - if (VTOI(pdp) == FUSE_ROOT_INODE) + DEBUG("checkpath bumped into node %llu\n", VTOI(pdp)); + if (pdp->v_vflag & VV_ROOT) err = -1; if (pdp == fvp) { DEBUG("huh, we caught a move-into-subdir-of-itself attempt\n"); @@ -4850,12 +4850,12 @@ if (fp->f_flag & O_DIRECT || fufh->flags & FUSEFH_DIRECTIO) { - DEBUG2G("direct write of vnode %d via file handle %llu\n", + DEBUG2G("direct write of vnode %llu via file handle %llu\n", VTOI(fp->f_vnode), fufh->fh_id); err = fuse_write_directbackend(fp->f_vnode, fufh->fh_id, uio, cred, td); } else { - DEBUG2G("buffered write of vnode %d\n", VTOI(fp->f_vnode)); + DEBUG2G("buffered write of vnode %llu\n", VTOI(fp->f_vnode)); err = fuse_write_biobackend(fp->f_vnode, uio, cred, td); } @@ -4893,13 +4893,13 @@ #endif if (! (vp->v_type == VREG || vp->v_type == VDIR)) { - DEBUG("for vnode #%d v_type is %d, dropping\n", + DEBUG("for vnode #%llu v_type is %d, dropping\n", VTOI(vp), vp->v_type); return (EOPNOTSUPP); } if (bp->b_iocmd != BIO_READ && bp->b_iocmd != BIO_WRITE) { - DEBUG("for vnode #%d bio tried with biocmd 0x%x, dropping\n", + DEBUG("for vnode #%llu bio tried with biocmd 0x%x, dropping\n", VTOI(vp), bp->b_iocmd); return (EOPNOTSUPP); } @@ -4939,7 +4939,7 @@ if (err) goto out; - DEBUG2G("vp #%d, fufh #%llu\n", VTOI(vp), fufh->fh_id); + DEBUG2G("vp #%llu, fufh #%llu\n", VTOI(vp), fufh->fh_id); if (bp->b_iocmd == BIO_READ) { struct fuse_read_in *fri; @@ -5091,7 +5091,7 @@ { struct fuse_vnode_data *fvdat = ap->a_vp->v_data; - printf("nodeid: %d, fh_counter: %d, nlookup: %llu\n", + printf("nodeid: %llu, fh_counter: %d, nlookup: %llu\n", VTOI(ap->a_vp), fvdat->fh_counter, fvdat->nlookup); return (0); } @@ -5102,9 +5102,9 @@ struct vnode *vp; int rc; - DEBUG("vnode #%d\n", VTOI((struct vnode *)bo->bo_private)); + DEBUG("vnode #%llu\n", VTOI((struct vnode *)bo->bo_private)); vp = bo->bo_private; - KASSERT(bo == &vp->v_bufobj, ("BO/VP mismatch: vp %p #(%d) bo %p != %p", + KASSERT(bo == &vp->v_bufobj, ("BO/VP mismatch: vp %p (#%llu) bo %p != %p", vp, VTOI(vp), &vp->v_bufobj, bo)); rc = VOP_STRATEGY(vp, bp); KASSERT(rc == 0, ("Fuse VOP_STRATEGY failed: bp=%p, " ==== //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.h#6 (text+ko) ==== @@ -136,7 +136,7 @@ #define FUSE_ROOT_INODE 1 /* Fuse convention: node id of root node is 1 */ -#define VTOI(vp) (vp)->v_hash +#define VTOI(vp) ((struct fuse_vnode_data *)(vp)->v_data)->nid /** Max number of pages that can be used in a single read request */ /* (taken from Linux Fuse) */ @@ -173,7 +173,7 @@ }; struct fuse_vnode_data { - //uint64_t nid; + uint64_t nid; uint64_t nlookup; //struct vnode *parent; /* Timeout related stuff, etc. will come here */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510132156.j9DLulBW088434>