Module Name: src Committed By: ttoth Date: Thu Apr 12 15:31:01 UTC 2012
Modified Files: src/sys/modules/chfs: Makefile src/sys/ufs/chfs: chfs.h chfs_build.c chfs_inode.h chfs_subr.c chfs_vfsops.c chfs_vnode.c chfs_vnops.c chfs_write.c debug.h Removed Files: src/sys/ufs/chfs: debug.c Log Message: using chtype on media instead of vtype debug.c deleted To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/modules/chfs/Makefile cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs.h cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/chfs/chfs_build.c \ src/sys/ufs/chfs/chfs_inode.h src/sys/ufs/chfs/chfs_vfsops.c \ src/sys/ufs/chfs/chfs_write.c cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/chfs_subr.c \ src/sys/ufs/chfs/chfs_vnode.c src/sys/ufs/chfs/chfs_vnops.c cvs rdiff -u -r1.1 -r0 src/sys/ufs/chfs/debug.c cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/debug.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/modules/chfs/Makefile diff -u src/sys/modules/chfs/Makefile:1.2 src/sys/modules/chfs/Makefile:1.3 --- src/sys/modules/chfs/Makefile:1.2 Sat Feb 4 18:35:56 2012 +++ src/sys/modules/chfs/Makefile Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2012/02/04 18:35:56 christos Exp $ +# $NetBSD: Makefile,v 1.3 2012/04/12 15:31:01 ttoth Exp $ .include "../Makefile.inc" @@ -7,7 +7,7 @@ CPPFLAGS+= -DDIAGNOSTIC -DDEBUG -DLOCKDEBUG KMOD= chfs -SRCS= ebh.c debug.c chfs_wbuf.c chfs_vnode_cache.c chfs_ihash.c +SRCS= ebh.c chfs_wbuf.c chfs_vnode_cache.c chfs_ihash.c SRCS+= chfs_gc.c SRCS+= chfs_vnode.c chfs_erase.c chfs_write.c chfs_readinode.c SRCS+= chfs_build.c chfs_scan.c chfs_nodeops.c chfs_malloc.c Index: src/sys/ufs/chfs/chfs.h diff -u src/sys/ufs/chfs/chfs.h:1.4 src/sys/ufs/chfs/chfs.h:1.5 --- src/sys/ufs/chfs/chfs.h:1.4 Mon Nov 28 12:50:07 2011 +++ src/sys/ufs/chfs/chfs.h Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs.h,v 1.4 2011/11/28 12:50:07 ahoka Exp $ */ +/* $NetBSD: chfs.h,v 1.5 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -79,8 +79,6 @@ TAILQ_HEAD(chfs_dirent_list, chfs_dirent #define MOUNT_CHFS "chfs" #endif -#define CHFS_ROOTINO ROOTINO /* ROOTINO == 2 */ - enum { VNO_STATE_UNCHECKED, /* CRC checks not yet done */ VNO_STATE_CHECKING, /* CRC checks in progress */ @@ -91,6 +89,7 @@ enum { VNO_STATE_CLEARING /* In clear_inode() */ }; + #define VNODECACHE_SIZE 128 #define MAX_READ_FREE(chmp) (((chmp)->chm_ebh)->eb_size / 8) @@ -185,7 +184,7 @@ struct chfs_dirent uint64_t version; ino_t vno; uint32_t nhash; - enum vtype type; + enum chtype type; uint8_t nsize; uint8_t name[0]; @@ -631,7 +630,7 @@ int chfs_readvnode(struct mount *, ino_t int chfs_readdirent(struct mount *, struct chfs_node_ref *, struct chfs_inode *); int chfs_makeinode(int, struct vnode *, struct vnode **, - struct componentname *, int ); + struct componentname *, enum vtype ); void chfs_set_vnode_size(struct vnode *, size_t); void chfs_change_size_free(struct chfs_mount *, struct chfs_eraseblock *, int); @@ -665,7 +664,7 @@ int chfs_write_flash_dirent(struct chfs_ int chfs_write_flash_dnode(struct chfs_mount *, struct vnode *, struct buf *, struct chfs_full_dnode *); int chfs_do_link(struct chfs_inode *, - struct chfs_inode *, const char *, int, enum vtype); + struct chfs_inode *, const char *, int, enum chtype); int chfs_do_unlink(struct chfs_inode *, struct chfs_inode *, const char *, int); @@ -673,7 +672,7 @@ int chfs_do_unlink(struct chfs_inode *, size_t chfs_mem_info(bool); struct chfs_dirent * chfs_dir_lookup(struct chfs_inode *, struct componentname *); -int chfs_filldir (struct uio *, ino_t, const char *, int, enum vtype); +int chfs_filldir (struct uio *, ino_t, const char *, int, enum chtype); int chfs_chsize(struct vnode *, u_quad_t, kauth_cred_t); int chfs_chflags(struct vnode *, int, kauth_cred_t); void chfs_itimes(struct chfs_inode *, const struct timespec *, Index: src/sys/ufs/chfs/chfs_build.c diff -u src/sys/ufs/chfs/chfs_build.c:1.2 src/sys/ufs/chfs/chfs_build.c:1.3 --- src/sys/ufs/chfs/chfs_build.c:1.2 Thu Nov 24 21:22:39 2011 +++ src/sys/ufs/chfs/chfs_build.c Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_build.c,v 1.2 2011/11/24 21:22:39 agc Exp $ */ +/* $NetBSD: chfs_build.c,v 1.3 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -84,7 +84,7 @@ chfs_build_set_vnodecache_nlink(struct c chfs_mark_node_obsolete(chmp, fd->nref); continue; } - if (fd->type == VDIR) { + if (fd->type == CHT_DIR) { if (child_vc->nlink < 1) child_vc->nlink = 1; @@ -372,7 +372,7 @@ chfs_build_filesystem(struct chfs_mount nref = &fd->nref; *nref = fd->nref->nref_next; //fd->nref->nref_next = NULL; - } else if (fd->type == VDIR) { + } else if (fd->type == CHT_DIR) { //set state every non-VREG file's vc mutex_enter(&chmp->chm_lock_vnocache); notregvc = Index: src/sys/ufs/chfs/chfs_inode.h diff -u src/sys/ufs/chfs/chfs_inode.h:1.2 src/sys/ufs/chfs/chfs_inode.h:1.3 --- src/sys/ufs/chfs/chfs_inode.h:1.2 Tue Feb 28 02:48:39 2012 +++ src/sys/ufs/chfs/chfs_inode.h Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_inode.h,v 1.2 2012/02/28 02:48:39 christos Exp $ */ +/* $NetBSD: chfs_inode.h,v 1.3 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -40,6 +40,30 @@ #include <ufs/ufs/ufsmount.h> #include <miscfs/genfs/genfs_node.h> +#define CHFS_ROOTINO 2 + +/* chfs file types */ +enum chtype { + CHT_BLANK, /* empty type */ + CHT_REG, /* regular file */ + CHT_DIR, /* directory */ + CHT_BLK, /* block device */ + CHT_CHR, /* character device */ + CHT_LNK, /* link */ + CHT_SOCK, /* socket */ + CHT_FIFO, /* fifo */ + CHT_BAD /* bad type */ +}; + +/* these macros are needed because the compatibility */ +#define CHTTOVT(ch_type) ch_type +#define VTTOCHT(v_type) v_type + +extern const enum chtype iftocht_tab[16]; + +#define IFTOCHT(mode) (iftocht_tab[((mode) & S_IFMT) >> 12]) + + struct chfs_inode { struct genfs_node gnode; @@ -68,6 +92,7 @@ struct chfs_inode //uint64_t highest_version; /* highest vers. num. (used at data nodes) */ uint32_t mode; /* mode */ + enum chtype ch_type; /* chfs file type */ //int16_t nlink; /* link count */ uint64_t size; /* file byte count */ uint64_t write_size; /* increasing while write the file out to the flash */ Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.2 src/sys/ufs/chfs/chfs_vfsops.c:1.3 --- src/sys/ufs/chfs/chfs_vfsops.c:1.2 Thu Nov 24 21:09:37 2011 +++ src/sys/ufs/chfs/chfs_vfsops.c Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.2 2011/11/24 21:09:37 agc Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.3 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -511,6 +511,7 @@ retry: memset(ip, 0, sizeof(*ip)); vp->v_data = ip; ip->vp = vp; + ip->ch_type = VTTOCHT(vp->v_type); ip->ump = ump; ip->chmp = chmp = ump->um_chfs; ip->dev = dev; @@ -529,6 +530,7 @@ retry: dbg("SETROOT\n"); vp->v_vflag |= VV_ROOT; vp->v_type = VDIR; + ip->ch_type = CHT_DIR; ip->mode = IFMT | IEXEC | IWRITE | IREAD; ip->iflag |= (IN_ACCESS | IN_CHANGE | IN_UPDATE); chfs_update(vp, NULL, NULL, UPDATE_WAIT); @@ -570,8 +572,8 @@ retry: mutex_enter(&chmp->chm_lock_mountfields); // init type specific things - switch (vp->v_type) { - case VDIR: + switch (ip->ch_type) { + case CHT_DIR: nref = chvc->dirents; while (nref && (struct chfs_vnode_cache *)nref != chvc) { @@ -580,8 +582,8 @@ retry: } chfs_set_vnode_size(vp, 512); break; - case VREG: - case VSOCK: + case CHT_REG: + case CHT_SOCK: //build the fragtree of the vnode dbg("read_inode_internal | ino: %llu\n", (unsigned long long)ip->ino); @@ -593,7 +595,7 @@ retry: return (error); } break; - case VLNK: + case CHT_LNK: //build the fragtree of the vnode dbg("read_inode_internal | ino: %llu\n", (unsigned long long)ip->ino); @@ -620,9 +622,9 @@ retry: putiobuf(bp); break; - case VCHR: - case VBLK: - case VFIFO: + case CHT_CHR: + case CHT_BLK: + case CHT_FIFO: //build the fragtree of the vnode dbg("read_inode_internal | ino: %llu\n", (unsigned long long)ip->ino); @@ -644,16 +646,16 @@ retry: bp->b_data, sizeof(dev_t)); kmem_free(bp->b_data, sizeof(dev_t)); putiobuf(bp); - if (vp->v_type == VFIFO) + if (ip->ch_type == CHT_FIFO) { vp->v_op = chfs_fifoop_p; - else { + } else { vp->v_op = chfs_specop_p; spec_node_init(vp, ip->rdev); } break; - case VNON: - case VBAD: + case CHT_BLANK: + case CHT_BAD: break; } mutex_exit(&chmp->chm_lock_mountfields); Index: src/sys/ufs/chfs/chfs_write.c diff -u src/sys/ufs/chfs/chfs_write.c:1.2 src/sys/ufs/chfs/chfs_write.c:1.3 --- src/sys/ufs/chfs/chfs_write.c:1.2 Thu Nov 24 21:09:37 2011 +++ src/sys/ufs/chfs/chfs_write.c Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_write.c,v 1.2 2011/11/24 21:09:37 agc Exp $ */ +/* $NetBSD: chfs_write.c,v 1.3 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -404,7 +404,7 @@ out: * This function writes the dirent of the new node to the media. */ int -chfs_do_link(struct chfs_inode *ip, struct chfs_inode *parent, const char *name, int namelen, enum vtype type) +chfs_do_link(struct chfs_inode *ip, struct chfs_inode *parent, const char *name, int namelen, enum chtype type) { int error = 0; struct vnode *vp = ITOV(ip); @@ -488,12 +488,12 @@ chfs_do_unlink(struct chfs_inode *ip, if (fd->vno == ip->ino && fd->nsize == namelen && !memcmp(fd->name, name, fd->nsize)) { - if (fd->type == VDIR && ip->chvc->nlink == 2) + if (fd->type == CHT_DIR && ip->chvc->nlink == 2) ip->chvc->nlink = 0; else ip->chvc->nlink--; - fd->type = VNON; + fd->type = CHT_BLANK; TAILQ_REMOVE(&parent->dents, fd, fds); Index: src/sys/ufs/chfs/chfs_subr.c diff -u src/sys/ufs/chfs/chfs_subr.c:1.3 src/sys/ufs/chfs/chfs_subr.c:1.4 --- src/sys/ufs/chfs/chfs_subr.c:1.3 Tue Mar 13 18:41:03 2012 +++ src/sys/ufs/chfs/chfs_subr.c Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_subr.c,v 1.3 2012/03/13 18:41:03 elad Exp $ */ +/* $NetBSD: chfs_subr.c,v 1.4 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -150,7 +150,7 @@ chfs_dir_lookup(struct chfs_inode *ip, s int chfs_filldir(struct uio* uio, ino_t ino, const char *name, - int namelen, enum vtype type) + int namelen, enum chtype type) { struct dirent dent; int error; @@ -159,31 +159,31 @@ chfs_filldir(struct uio* uio, ino_t ino, dent.d_fileno = ino; switch (type) { - case VBLK: + case CHT_BLK: dent.d_type = DT_BLK; break; - case VCHR: + case CHT_CHR: dent.d_type = DT_CHR; break; - case VDIR: + case CHT_DIR: dent.d_type = DT_DIR; break; - case VFIFO: + case CHT_FIFO: dent.d_type = DT_FIFO; break; - case VLNK: + case CHT_LNK: dent.d_type = DT_LNK; break; - case VREG: + case CHT_REG: dent.d_type = DT_REG; break; - case VSOCK: + case CHT_SOCK: dent.d_type = DT_SOCK; break; @@ -227,17 +227,17 @@ chfs_chsize(struct vnode *vp, u_quad_t s dbg("chfs_chsize\n"); - switch (vp->v_type) { - case VDIR: + switch (ip->ch_type) { + case CHT_DIR: return EISDIR; - case VLNK: - case VREG: + case CHT_LNK: + case CHT_REG: if (vp->v_mount->mnt_flag & MNT_RDONLY) return EROFS; break; - case VBLK: - case VCHR: - case VFIFO: + case CHT_BLK: + case CHT_CHR: + case CHT_FIFO: return 0; default: return EOPNOTSUPP; /* XXX why not ENODEV? */ @@ -422,7 +422,7 @@ chfs_chflags(struct vnode *vp, int flags } error = kauth_authorize_vnode(cred, action, vp, NULL, - genfs_can_chflags(cred, vp->v_type, ip->uid, changing_sysflags)); + genfs_can_chflags(cred, CHTTOVT(ip->ch_type), ip->uid, changing_sysflags)); if (error) return error; Index: src/sys/ufs/chfs/chfs_vnode.c diff -u src/sys/ufs/chfs/chfs_vnode.c:1.3 src/sys/ufs/chfs/chfs_vnode.c:1.4 --- src/sys/ufs/chfs/chfs_vnode.c:1.3 Tue Mar 13 18:41:03 2012 +++ src/sys/ufs/chfs/chfs_vnode.c Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnode.c,v 1.3 2012/03/13 18:41:03 elad Exp $ */ +/* $NetBSD: chfs_vnode.c,v 1.4 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -42,6 +42,15 @@ #include <miscfs/genfs/genfs.h> +/* vtype replaced with chtype, these are only for compatibility */ +const enum chtype iftocht_tab[16] = { + CHT_BLANK, CHT_FIFO, CHT_CHR, CHT_BLANK, + CHT_DIR, CHT_BLANK, CHT_BLK, CHT_BLANK, + CHT_REG, CHT_BLANK, CHT_LNK, CHT_BLANK, + CHT_SOCK, CHT_BLANK, CHT_BLANK, CHT_BAD, +}; + + struct vnode * chfs_vnode_lookup(struct chfs_mount *chmp, ino_t vno) { @@ -101,7 +110,8 @@ chfs_readvnode(struct mount* mp, ino_t i chfvn = (struct chfs_flash_vnode*)buf; chfs_set_vnode_size(vp, chfvn->dn_size); ip->mode = chfvn->mode; - vp->v_type = IFTOVT(ip->mode); + ip->ch_type = IFTOCHT(ip->mode); + vp->v_type = CHTTOVT(ip->ch_type); ip->version = chfvn->version; //ip->chvc->highest_version = ip->version; ip->uid = chfvn->uid; @@ -186,7 +196,7 @@ chfs_readdirent(struct mount *mp, struct */ int chfs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp, - struct componentname *cnp, int type) + struct componentname *cnp, enum vtype type) { struct chfs_inode *ip, *pdir; struct vnode *vp; @@ -240,7 +250,8 @@ chfs_makeinode(int mode, struct vnode *d ip->target = NULL; ip->mode = mode; - vp->v_type = type; /* Rest init'd in getnewvnode(). */ + vp->v_type = type; /* Rest init'd in getnewvnode(). */ + ip->ch_type = VTTOCHT(vp->v_type); /* Authorize setting SGID if needed. */ if (ip->mode & ISGID) { @@ -280,7 +291,7 @@ chfs_makeinode(int mode, struct vnode *d nfd = chfs_alloc_dirent(cnp->cn_namelen + 1); nfd->vno = ip->ino; nfd->version = (++pdir->chvc->highest_version); - nfd->type = type; + nfd->type = ip->ch_type; // nfd->next = NULL; nfd->nsize = cnp->cn_namelen; memcpy(&(nfd->name), cnp->cn_nameptr, cnp->cn_namelen); Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.3 src/sys/ufs/chfs/chfs_vnops.c:1.4 --- src/sys/ufs/chfs/chfs_vnops.c:1.3 Tue Mar 13 18:41:03 2012 +++ src/sys/ufs/chfs/chfs_vnops.c Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.3 2012/03/13 18:41:03 elad Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.4 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -102,7 +102,7 @@ chfs_lookup(void *v) mutex_exit(&chmp->chm_lock_vnocache); // We cannot be requesting the parent directory of the root node. - KASSERT(IMPLIES(dvp->v_type == VDIR && chvc->pvno == chvc->vno, + KASSERT(IMPLIES(ip->ch_type == CHT_DIR && chvc->pvno == chvc->vno, !(cnp->cn_flags & ISDOTDOT))); if (cnp->cn_flags & ISDOTDOT) { @@ -140,7 +140,7 @@ chfs_lookup(void *v) // found a non-directory or non-link entry (which // may itself be pointing to a directory), raise // an error. - if ((fd->type != VDIR && fd->type != VLNK) && !(cnp->cn_flags + if ((fd->type != CHT_DIR && fd->type != CHT_LNK) && !(cnp->cn_flags & ISLASTCN)) { error = ENOTDIR; goto out; @@ -411,7 +411,7 @@ chfs_getattr(void *v) vattr_null(vap); CHFS_ITIMES(ip, NULL, NULL, NULL); - vap->va_type = vp->v_type; + vap->va_type = CHTTOVT(ip->ch_type); vap->va_mode = ip->mode & ALLPERMS; vap->va_nlink = ip->chvc->nlink; vap->va_uid = ip->uid; @@ -1096,7 +1096,7 @@ chfs_link(void *v) ip = VTOI(vp); error = chfs_do_link(ip, - parent, cnp->cn_nameptr, cnp->cn_namelen, vp->v_type); + parent, cnp->cn_nameptr, cnp->cn_namelen, ip->ch_type); if (dvp != vp) VOP_UNLOCK(vp); @@ -1159,7 +1159,7 @@ chfs_rename(void *v) // oldfd = oldfd->next); error = chfs_do_link(ip, - newparent, tcnp->cn_nameptr, tcnp->cn_namelen, tvp->v_type); + newparent, tcnp->cn_nameptr, tcnp->cn_namelen, ip->ch_type); error = chfs_do_unlink(old, oldparent, fcnp->cn_nameptr, fcnp->cn_namelen); @@ -1504,9 +1504,11 @@ chfs_reclaim(void *v) chfs_update(vp, NULL, NULL, UPDATE_CLOSE); - if (vp->v_type == VREG || vp->v_type == VLNK || vp->v_type == VCHR || - vp->v_type == VBLK || vp->v_type == VFIFO || vp->v_type == VSOCK) + if (ip->ch_type == CHT_REG || ip->ch_type == CHT_LNK || + ip->ch_type == CHT_CHR || ip->ch_type == CHT_BLK || + ip->ch_type == CHT_FIFO || ip->ch_type == CHT_SOCK) { chfs_kill_fragtree(&ip->fragtree); + } fd = TAILQ_FIRST(&ip->dents); while(fd) { Index: src/sys/ufs/chfs/debug.h diff -u src/sys/ufs/chfs/debug.h:1.1 src/sys/ufs/chfs/debug.h:1.2 --- src/sys/ufs/chfs/debug.h:1.1 Thu Nov 24 15:51:32 2011 +++ src/sys/ufs/chfs/debug.h Thu Apr 12 15:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */ +/* $NetBSD: debug.h,v 1.2 2012/04/12 15:31:01 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -30,19 +30,6 @@ * SUCH DAMAGE. */ -/* - * XipFFS -- Xip Flash File System - * - * Copyright (C) 2009 Ferenc Havasi <hav...@inf.u-szeged.hu>, - * Zoltan Sogor <w...@inf.u-szeged.hu>, - * ... - * University of Szeged, Hungary - * - * - * For licensing information, see the file 'LICENCE' in this directory. - * - */ - #ifndef __CHFS_DEBUG_H__ #define __CHFS_DEBUG_H__