CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: andvar Date: Wed Aug 11 05:17:48 UTC 2021 Modified Files: src/sys/ufs/chfs: media.h Log Message: s/enrty/entry/ To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/chfs/media.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/ufs/chfs/media.h diff -u src/sys/ufs/chfs/media.h:1.2 src/sys/ufs/chfs/media.h:1.3 --- src/sys/ufs/chfs/media.h:1.2 Fri Oct 19 12:44:39 2012 +++ src/sys/ufs/chfs/media.h Wed Aug 11 05:17:48 2021 @@ -46,7 +46,7 @@ typedef uint64_t le64; enum { CHFS_NODETYPE_VNODE = 1, /* vnode information */ CHFS_NODETYPE_DATA, /* data node */ - CHFS_NODETYPE_DIRENT, /* directory enrty */ + CHFS_NODETYPE_DIRENT, /* directory entry */ CHFS_NODETYPE_PADDING, /* padding node */ };
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: andvar Date: Mon Jul 19 22:24:55 UTC 2021 Modified Files: src/sys/ufs/chfs: chfs_gc.c Log Message: NFC - if/else blocks start with the same mutex_exit, just move it up. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/chfs/chfs_gc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.10 src/sys/ufs/chfs/chfs_gc.c:1.11 --- src/sys/ufs/chfs/chfs_gc.c:1.10 Fri Jul 16 21:18:41 2021 +++ src/sys/ufs/chfs/chfs_gc.c Mon Jul 19 22:24:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.10 2021/07/16 21:18:41 andvar Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.11 2021/07/19 22:24:55 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -232,15 +232,13 @@ chfs_gc_fetch_inode(struct chfs_mount *c mutex_exit(>chm_lock_vnocache); return NULL; } + mutex_exit(>chm_lock_vnocache); if (vc->state != VNO_STATE_CHECKEDABSENT) { -mutex_exit(>chm_lock_vnocache); /* XXX why do we need the delay here?! */ KASSERT(mutex_owned(>chm_lock_mountfields)); cv_timedwait_sig( >chm_gc_thread.gcth_wakeup, >chm_lock_mountfields, mstohz(50)); - } else { -mutex_exit(>chm_lock_vnocache); } return NULL; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: andvar Date: Mon Jul 19 21:04:39 UTC 2021 Modified Files: src/sys/ufs/chfs: chfs_build.c chfs_write.c Log Message: Release mutexes in few more places on failure path. Reviewed them in chfs code after fixing PR kern/56242. ok riastradh To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs_build.c \ src/sys/ufs/chfs/chfs_write.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_build.c diff -u src/sys/ufs/chfs/chfs_build.c:1.5 src/sys/ufs/chfs/chfs_build.c:1.6 --- src/sys/ufs/chfs/chfs_build.c:1.5 Fri Oct 19 12:44:39 2012 +++ src/sys/ufs/chfs/chfs_build.c Mon Jul 19 21:04:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_build.c,v 1.5 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_build.c,v 1.6 2021/07/19 21:04:39 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -252,8 +252,10 @@ chfs_build_filesystem(struct chfs_mount if (chmp->chm_nextblock) { err = chfs_close_eraseblock(chmp, chmp->chm_nextblock); - if (err) + if (err) { + mutex_exit(>chm_lock_mountfields); return err; + } } chmp->chm_nextblock = >chm_blocks[i]; } else { @@ -261,8 +263,10 @@ chfs_build_filesystem(struct chfs_mount * dirty and put it on a list */ err = chfs_close_eraseblock(chmp, >chm_blocks[i]); -if (err) +if (err) { + mutex_exit(>chm_lock_mountfields); return err; +} } break; case CHFS_BLK_STATE_ALLDIRTY: Index: src/sys/ufs/chfs/chfs_write.c diff -u src/sys/ufs/chfs/chfs_write.c:1.5 src/sys/ufs/chfs/chfs_write.c:1.6 --- src/sys/ufs/chfs/chfs_write.c:1.5 Fri Oct 19 12:44:39 2012 +++ src/sys/ufs/chfs/chfs_write.c Mon Jul 19 21:04:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_write.c,v 1.5 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_write.c,v 1.6 2021/07/19 21:04:39 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -438,8 +438,10 @@ chfs_do_link(struct chfs_inode *ip, stru /* update vnode information */ error = chfs_write_flash_vnode(chmp, ip, ALLOC_NORMAL); - if (error) + if (error) { + mutex_exit(>chm_lock_mountfields); return error; + } /* write out the new dirent */ error = chfs_write_flash_dirent(chmp,
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: andvar Date: Fri Jul 16 21:18:41 UTC 2021 Modified Files: src/sys/ufs/chfs: chfs_gc.c chfs_scan.c Log Message: Fix incorrect function name, some grammar and typos in comments. Remove trailing tab symbol. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/chfs/chfs_gc.c \ src/sys/ufs/chfs/chfs_scan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.9 src/sys/ufs/chfs/chfs_gc.c:1.10 --- src/sys/ufs/chfs/chfs_gc.c:1.9 Thu Jun 1 02:45:15 2017 +++ src/sys/ufs/chfs/chfs_gc.c Fri Jul 16 21:18:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.9 2017/06/01 02:45:15 chs Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.10 2021/07/16 21:18:41 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -89,7 +89,7 @@ chfs_gc_thread(void *data) mutex_enter(>chm_lock_mountfields); while (gc->gcth_running) { /* we must call chfs_gc_thread_should_wake with chm_lock_mountfields - * held, which is a bit awkwardly done here, but we cant relly + * held, which is a bit awkwardly done here, but we can't really * do it otherway with the current design... */ if (chfs_gc_thread_should_wake(chmp)) { @@ -127,7 +127,7 @@ chfs_gc_thread_start(struct chfs_mount * "chfsgcth"); } -/* chfs_gc_thread_start - stops GC */ +/* chfs_gc_thread_stop - stops GC */ void chfs_gc_thread_stop(struct chfs_mount *chmp) { @@ -191,7 +191,7 @@ chfs_gc_thread_should_wake(struct chfs_m return 1; } - /* There is too much very dirty blocks. */ + /* There are too much very dirty blocks. */ TAILQ_FOREACH(cheb, >chm_very_dirty_queue, queue) { nr_very_dirty++; if (nr_very_dirty == chmp->chm_vdirty_blocks_gctrigger) { @@ -200,7 +200,7 @@ chfs_gc_thread_should_wake(struct chfs_m } } - /* Everythin OK, GC shouldn't run. */ + /* Everything is OK, GC shouldn't run. */ return 0; } Index: src/sys/ufs/chfs/chfs_scan.c diff -u src/sys/ufs/chfs/chfs_scan.c:1.9 src/sys/ufs/chfs/chfs_scan.c:1.10 --- src/sys/ufs/chfs/chfs_scan.c:1.9 Thu Jul 15 22:39:06 2021 +++ src/sys/ufs/chfs/chfs_scan.c Fri Jul 16 21:18:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_scan.c,v 1.9 2021/07/15 22:39:06 andvar Exp $ */ +/* $NetBSD: chfs_scan.c,v 1.10 2021/07/16 21:18:41 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -225,7 +225,7 @@ chfs_add_fd_to_list(struct chfs_mount *c new->nsize); cheb = >chm_blocks[new->nref->nref_lnr]; - mutex_enter(>chm_lock_sizes); + mutex_enter(>chm_lock_sizes); TAILQ_FOREACH_SAFE(fd, >scan_dirents, fds, tmpfd) { if (fd->nhash > new->nhash) { /* insert new before fd */
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: andvar Date: Thu Jul 15 22:39:06 UTC 2021 Modified Files: src/sys/ufs/chfs: chfs_readinode.c chfs_scan.c Log Message: Make sure that mutex is released before conditional return statements. Fixes PR kern/56242 ok riastradh To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/chfs/chfs_readinode.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/chfs/chfs_scan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.10 src/sys/ufs/chfs/chfs_readinode.c:1.11 --- src/sys/ufs/chfs/chfs_readinode.c:1.10 Thu Jun 1 02:45:15 2017 +++ src/sys/ufs/chfs/chfs_readinode.c Thu Jul 15 22:39:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.10 2017/06/01 02:45:15 chs Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.11 2021/07/15 22:39:06 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -1012,6 +1012,7 @@ retry: (unsigned long long)vc->vno, vc->state); chfs_err("wants to read a nonexistent ino %llu\n", (unsigned long long)vc->vno); + mutex_exit(>chm_lock_vnocache); return ENOENT; default: panic("BUG() Bad vno cache state."); Index: src/sys/ufs/chfs/chfs_scan.c diff -u src/sys/ufs/chfs/chfs_scan.c:1.8 src/sys/ufs/chfs/chfs_scan.c:1.9 --- src/sys/ufs/chfs/chfs_scan.c:1.8 Mon Jun 17 17:14:56 2019 +++ src/sys/ufs/chfs/chfs_scan.c Thu Jul 15 22:39:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_scan.c,v 1.8 2019/06/17 17:14:56 ryoon Exp $ */ +/* $NetBSD: chfs_scan.c,v 1.9 2021/07/15 22:39:06 andvar Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -151,6 +151,7 @@ chfs_scan_check_vnode(struct chfs_mount } else { err = chfs_update_eb_dirty(chmp, cheb, sizeof(struct chfs_flash_vnode)); + mutex_exit(>chm_lock_vnocache); return CHFS_NODE_OK; } } else { @@ -325,6 +326,7 @@ chfs_scan_check_dirent_node(struct chfs_ parentvc = chfs_scan_make_vnode_cache(chmp, le64toh(dirent->pvno)); if (!parentvc) { chfs_free_dirent(fd); + mutex_exit(>chm_lock_vnocache); return ENOMEM; } @@ -381,8 +383,10 @@ chfs_scan_check_data_node(struct chfs_mo vc = chfs_vnode_cache_get(chmp, vno); if (!vc) { vc = chfs_scan_make_vnode_cache(chmp, vno); - if (!vc) + if (!vc) { + mutex_exit(>chm_lock_vnocache); return ENOMEM; + } } chfs_add_node_to_list(chmp, vc, nref, >dnode); mutex_exit(>chm_lock_vnocache);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: dholland Date: Mon Jul 5 21:43:56 UTC 2021 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: whitespace To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.43 src/sys/ufs/chfs/chfs_vnops.c:1.44 --- src/sys/ufs/chfs/chfs_vnops.c:1.43 Tue Jun 29 22:34:09 2021 +++ src/sys/ufs/chfs/chfs_vnops.c Mon Jul 5 21:43:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.43 2021/06/29 22:34:09 dholland Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.44 2021/07/05 21:43:56 dholland Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -1598,7 +1598,7 @@ int const struct vnodeopv_entry_desc chfs_vnodeop_entries[] = { { _default_desc, vn_default_error }, - { _parsepath_desc, genfs_parsepath }, /* parsepath */ + { _parsepath_desc, genfs_parsepath }, /* parsepath */ { _lookup_desc, chfs_lookup }, { _create_desc, chfs_create }, { _mknod_desc, chfs_mknod },
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Wed May 20 17:04:58 UTC 2020 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: fix accessx confusion (thanks hannken@) To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.39 src/sys/ufs/chfs/chfs_vnops.c:1.40 --- src/sys/ufs/chfs/chfs_vnops.c:1.39 Sat May 16 14:31:53 2020 +++ src/sys/ufs/chfs/chfs_vnops.c Wed May 20 13:04:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.39 2020/05/16 18:31:53 christos Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.40 2020/05/20 17:04:58 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -1663,7 +1663,7 @@ const struct vnodeopv_entry_desc chfs_sp { _open_desc, spec_open }, { _close_desc, ufsspec_close }, { _access_desc, chfs_access }, - { _accessx_desc, genfs_access }, + { _accessx_desc, genfs_accessx }, { _getattr_desc, chfs_getattr }, { _setattr_desc, chfs_setattr }, { _read_desc, chfs_read }, @@ -1720,7 +1720,7 @@ const struct vnodeopv_entry_desc chfs_fi { _open_desc, vn_fifo_bypass }, { _close_desc, ufsfifo_close }, { _access_desc, chfs_access }, - { _accessx_desc, genfs_access }, + { _accessx_desc, genfs_accessx }, { _getattr_desc, chfs_getattr }, { _setattr_desc, chfs_setattr }, { _read_desc, ufsfifo_read },
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ozaki-r Date: Wed Feb 7 08:50:13 UTC 2018 Modified Files: src/sys/ufs/chfs: ebh.c Log Message: Remove unnecessary assertions KASSERT(!rw_lock_held()) just before rw_destroy() is useless because rw_destroy does more strict check and provides better information on failure. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/chfs/ebh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/ebh.c diff -u src/sys/ufs/chfs/ebh.c:1.6 src/sys/ufs/chfs/ebh.c:1.7 --- src/sys/ufs/chfs/ebh.c:1.6 Sat Feb 7 04:21:11 2015 +++ src/sys/ufs/chfs/ebh.c Wed Feb 7 08:50:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ebh.c,v 1.6 2015/02/07 04:21:11 christos Exp $ */ +/* $NetBSD: ebh.c,v 1.7 2018/02/07 08:50:13 ozaki-r Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -656,7 +656,6 @@ leb_read_unlock(struct chfs_ebh *ebh, in if (le->users == 0) { le = RB_REMOVE(ltree_rbtree, >ltree, le); if (le) { - KASSERT(!rw_lock_held(>mutex)); rw_destroy(>mutex); kmem_free(le, sizeof(struct chfs_ltree_entry)); @@ -713,7 +712,6 @@ leb_write_unlock(struct chfs_ebh *ebh, i if (le->users == 0) { RB_REMOVE(ltree_rbtree, >ltree, le); - KASSERT(!rw_lock_held(>mutex)); rw_destroy(>mutex); kmem_free(le, sizeof(struct chfs_ltree_entry));
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: sevan Date: Mon Jan 29 15:48:50 UTC 2018 Modified Files: src/sys/ufs/chfs: chfs_pool.c Log Message: Drop commended out include to a hardcoded path in root's home directory. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/chfs/chfs_pool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_pool.c diff -u src/sys/ufs/chfs/chfs_pool.c:1.2 src/sys/ufs/chfs/chfs_pool.c:1.3 --- src/sys/ufs/chfs/chfs_pool.c:1.2 Tue Feb 28 02:48:39 2012 +++ src/sys/ufs/chfs/chfs_pool.c Mon Jan 29 15:48:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_pool.c,v 1.2 2012/02/28 02:48:39 christos Exp $ */ +/* $NetBSD: chfs_pool.c,v 1.3 2018/01/29 15:48:50 sevan Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -43,7 +43,6 @@ #include #include "chfs.h" -//#include /* - */
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: riastradh Date: Tue Nov 14 22:06:40 UTC 2017 Modified Files: src/sys/ufs/chfs: chfs_vfsops.c Log Message: Fix up chfs_mountfs error branches. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/chfs/chfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.16 src/sys/ufs/chfs/chfs_vfsops.c:1.17 --- src/sys/ufs/chfs/chfs_vfsops.c:1.16 Fri Feb 17 08:31:26 2017 +++ src/sys/ufs/chfs/chfs_vfsops.c Tue Nov 14 22:06:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.16 2017/02/17 08:31:26 hannken Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.17 2017/11/14 22:06:40 riastradh Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -227,7 +227,7 @@ chfs_mountfs(struct vnode *devvp, struct err = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0); VOP_UNLOCK(devvp); if (err) - return (err); + goto fail0; /* Setup device. */ flash_major = cdevsw_lookup_major(_cdevsw); @@ -241,10 +241,8 @@ chfs_mountfs(struct vnode *devvp, struct major(dev), flash_major); err = ENODEV; } - if (err) { - vrele(devvp); - return (err); - } + if (err) + goto fail0; /* Connect CHFS to UFS. */ ump = kmem_zalloc(sizeof(struct ufsmount), KM_SLEEP); @@ -262,7 +260,7 @@ chfs_mountfs(struct vnode *devvp, struct err = ebh_open(chmp->chm_ebh, devvp->v_rdev); if (err) { dbg("error while opening flash\n"); - goto fail; + goto fail1; } //TODO check flash sizes @@ -320,10 +318,8 @@ chfs_mountfs(struct vnode *devvp, struct if (err) { /* Armageddon and return. */ - chfs_vnocache_hash_destroy(chmp->chm_vnocache_hash); - ebh_close(chmp->chm_ebh); err = EIO; - goto fail; + goto fail2; } /* Initialize UFS. */ @@ -359,10 +355,31 @@ chfs_mountfs(struct vnode *devvp, struct spec_node_setmountedfs(devvp, mp); return 0; -fail: +fail2: + KASSERT(TAILQ_EMPTY(>chm_erase_pending_queue)); + KASSERT(TAILQ_EMPTY(>chm_erasable_pending_wbuf_queue)); + KASSERT(TAILQ_EMPTY(>chm_very_dirty_queue)); + KASSERT(TAILQ_EMPTY(>chm_dirty_queue)); + KASSERT(TAILQ_EMPTY(>chm_clean_queue)); + KASSERT(TAILQ_EMPTY(>chm_free_queue)); + rw_destroy(>chm_lock_wbuf); + kmem_free(chmp->chm_wbuf, chmp->chm_wbuf_pagesize); + mutex_destroy(>chm_lock_vnocache); + mutex_destroy(>chm_lock_sizes); + mutex_destroy(>chm_lock_mountfields); + kmem_free(chmp->chm_blocks, chmp->chm_ebh->peb_nr * + sizeof(struct chfs_eraseblock)); + chfs_vnocache_hash_destroy(chmp->chm_vnocache_hash); + ebh_close(chmp->chm_ebh); + +fail1: kmem_free(chmp->chm_ebh, sizeof(struct chfs_ebh)); + mutex_destroy(>um_lock); kmem_free(chmp, sizeof(struct chfs_mount)); kmem_free(ump, sizeof(struct ufsmount)); + +fail0: + KASSERT(err); return err; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Thu Nov 9 22:16:39 UTC 2017 Modified Files: src/sys/ufs/chfs: chfs_malloc.c Log Message: use PR_WAITOK everywhere. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_malloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_malloc.c diff -u src/sys/ufs/chfs/chfs_malloc.c:1.4 src/sys/ufs/chfs/chfs_malloc.c:1.5 --- src/sys/ufs/chfs/chfs_malloc.c:1.4 Fri Oct 19 08:44:39 2012 +++ src/sys/ufs/chfs/chfs_malloc.c Thu Nov 9 17:16:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_malloc.c,v 1.4 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_malloc.c,v 1.5 2017/11/09 22:16:38 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -314,7 +314,7 @@ struct chfs_flash_vnode* chfs_alloc_flash_vnode(void) { struct chfs_flash_vnode *ret; - ret = pool_cache_get(chfs_flash_vnode_cache, 0); + ret = pool_cache_get(chfs_flash_vnode_cache, PR_WAITOK); return ret; } @@ -330,7 +330,7 @@ struct chfs_flash_dirent_node* chfs_alloc_flash_dirent(void) { struct chfs_flash_dirent_node *ret; - ret = pool_cache_get(chfs_flash_dirent_cache, 0); + ret = pool_cache_get(chfs_flash_dirent_cache, PR_WAITOK); return ret; } @@ -346,7 +346,7 @@ struct chfs_flash_data_node* chfs_alloc_flash_dnode(void) { struct chfs_flash_data_node *ret; - ret = pool_cache_get(chfs_flash_dnode_cache, 0); + ret = pool_cache_get(chfs_flash_dnode_cache, PR_WAITOK); return ret; } @@ -362,7 +362,7 @@ struct chfs_node_frag* chfs_alloc_node_frag(void) { struct chfs_node_frag *ret; - ret = pool_cache_get(chfs_node_frag_cache, 0); + ret = pool_cache_get(chfs_node_frag_cache, PR_WAITOK); return ret; } @@ -378,7 +378,7 @@ struct chfs_tmp_dnode * chfs_alloc_tmp_dnode(void) { struct chfs_tmp_dnode *ret; - ret = pool_cache_get(chfs_tmp_dnode_cache, 0); + ret = pool_cache_get(chfs_tmp_dnode_cache, PR_WAITOK); ret->next = NULL; return ret; } @@ -395,7 +395,7 @@ struct chfs_tmp_dnode_info * chfs_alloc_tmp_dnode_info(void) { struct chfs_tmp_dnode_info *ret; - ret = pool_cache_get(chfs_tmp_dnode_info_cache, 0); + ret = pool_cache_get(chfs_tmp_dnode_info_cache, PR_WAITOK); ret->tmpnode = NULL; return ret; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:10:47 UTC 2017 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.29 src/sys/ufs/chfs/chfs_vnops.c:1.30 --- src/sys/ufs/chfs/chfs_vnops.c:1.29 Sat Aug 20 12:37:09 2016 +++ src/sys/ufs/chfs/chfs_vnops.c Thu Mar 30 09:10:46 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.29 2016/08/20 12:37:09 hannken Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.30 2017/03/30 09:10:46 hannken Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "chfs.h" @@ -653,8 +652,6 @@ chfs_read(void *v) if (uio->uio_resid == 0) return (0); - fstrans_start(vp->v_mount, FSTRANS_SHARED); - if (uio->uio_offset >= ip->size) goto out; @@ -737,7 +734,6 @@ out: ip->iflag |= IN_ACCESS; if ((ap->a_ioflag & IO_SYNC) == IO_SYNC) { if (error) { -fstrans_done(vp->v_mount); return error; } error = chfs_update(vp, NULL, NULL, UPDATE_WAIT); @@ -745,7 +741,6 @@ out: } dbg("[END]\n"); - fstrans_done(vp->v_mount); return (error); } @@ -833,8 +828,6 @@ chfs_write(void *v) if (uio->uio_resid == 0) return (0); - fstrans_start(vp->v_mount, FSTRANS_SHARED); - flags = ioflag & IO_SYNC ? B_SYNC : 0; async = vp->v_mount->mnt_flag & MNT_ASYNC; origoff = uio->uio_offset; @@ -1003,7 +996,6 @@ out: KASSERT(vp->v_size == ip->size); - fstrans_done(vp->v_mount); mutex_enter(>chm_lock_mountfields); error = chfs_write_flash_vnode(chmp, ip, ALLOC_NORMAL);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: dholland Date: Sat Aug 6 20:42:29 UTC 2016 Modified Files: src/sys/ufs/chfs: ebh.h Log Message: typo in comment To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/ebh.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/ufs/chfs/ebh.h diff -u src/sys/ufs/chfs/ebh.h:1.3 src/sys/ufs/chfs/ebh.h:1.4 --- src/sys/ufs/chfs/ebh.h:1.3 Fri Oct 19 12:44:39 2012 +++ src/sys/ufs/chfs/ebh.h Sat Aug 6 20:42:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ebh.h,v 1.3 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: ebh.h,v 1.4 2016/08/06 20:42:29 dholland Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -105,7 +105,7 @@ enum { struct chfs_ebh; /** - * struct chfs_ltree_entry - an netry in the lock tree + * struct chfs_ltree_entry - an entry in the lock tree * @rb: RB-node of the tree * @lnr: logical eraseblock number * @users: counts the tasks that are using or want to use the eraseblock
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Sat Feb 7 04:21:11 UTC 2015 Modified Files: src/sys/ufs/chfs: ebh.c Log Message: fix leak. Reported by: http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/ebh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/ebh.c diff -u src/sys/ufs/chfs/ebh.c:1.5 src/sys/ufs/chfs/ebh.c:1.6 --- src/sys/ufs/chfs/ebh.c:1.5 Sat Oct 18 04:33:29 2014 +++ src/sys/ufs/chfs/ebh.c Fri Feb 6 23:21:11 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ebh.c,v 1.5 2014/10/18 08:33:29 snj Exp $ */ +/* $NetBSD: ebh.c,v 1.6 2015/02/07 04:21:11 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -1956,8 +1956,10 @@ ebh_map_leb(struct chfs_ebh *ebh, int ln ebhdr = kmem_alloc(sizeof(struct chfs_eb_hdr), KM_SLEEP); err = leb_write_lock(ebh, lnr); - if (err) + if (err) { + kmem_free(ebhdr, sizeof(struct chfs_eb_hdr)); return err; + } retry: pebnr = get_peb(ebh);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Sat Feb 7 04:19:53 UTC 2015 Modified Files: src/sys/ufs/chfs: chfs_scan.c Log Message: fix buf leak. Reported by: http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs_scan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_scan.c diff -u src/sys/ufs/chfs/chfs_scan.c:1.5 src/sys/ufs/chfs/chfs_scan.c:1.6 --- src/sys/ufs/chfs/chfs_scan.c:1.5 Mon Sep 1 12:27:38 2014 +++ src/sys/ufs/chfs/chfs_scan.c Fri Feb 6 23:19:52 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_scan.c,v 1.5 2014/09/01 16:27:38 he Exp $ */ +/* $NetBSD: chfs_scan.c,v 1.6 2015/02/07 04:19:52 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -461,6 +461,7 @@ chfs_scan_eraseblock(struct chfs_mount * read_free += CHFS_NODE_HDR_SIZE; if (read_free = MAX_READ_FREE(chmp)) { dbg(rest of the block is free. Size: %d\n, cheb-free_size); +kmem_free(buf, CHFS_MAX_NODE_SIZE); return chfs_scan_classify_cheb(chmp, cheb); } ofs += CHFS_NODE_HDR_SIZE;
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: hannken Date: Sun Jan 11 17:27:54 UTC 2015 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: Return immediately from successfull cache_lookup(). No need to unlock an unlocked vnode. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.22 src/sys/ufs/chfs/chfs_vnops.c:1.23 --- src/sys/ufs/chfs/chfs_vnops.c:1.22 Fri Jul 25 08:20:53 2014 +++ src/sys/ufs/chfs/chfs_vnops.c Sun Jan 11 17:27:54 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.22 2014/07/25 08:20:53 dholland Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.23 2015/01/11 17:27:54 hannken Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -88,8 +88,7 @@ chfs_lookup(void *v) * directory/name couple is already in the cache. */ if (cache_lookup(dvp, cnp-cn_nameptr, cnp-cn_namelen, cnp-cn_nameiop, cnp-cn_flags, NULL, vpp)) { - error = *vpp == NULLVP ? ENOENT : 0; - goto out; + return (*vpp == NULLVP ? ENOENT : 0); } ip = VTOI(dvp);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: hannken Date: Sun Jan 11 17:28:22 UTC 2015 Modified Files: src/sys/ufs/chfs: chfs_gc.c chfs_vnode.c Log Message: Convert a bogus mnt_vnodelist traversal to vfs_vnode_iterator. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/chfs/chfs_gc.c cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/chfs/chfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.7 src/sys/ufs/chfs/chfs_gc.c:1.8 --- src/sys/ufs/chfs/chfs_gc.c:1.7 Mon Sep 8 17:41:11 2014 +++ src/sys/ufs/chfs/chfs_gc.c Sun Jan 11 17:28:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.7 2014/09/08 17:41:11 joerg Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.8 2015/01/11 17:28:22 hannken Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -251,6 +251,7 @@ chfs_gc_fetch_inode(struct chfs_mount *c dbg_gc(vp to ip\n); ip = VTOI(vp); KASSERT(ip); + vrele(vp); return ip; } @@ -970,6 +971,7 @@ chfs_gcollect_dirent(struct chfs_mount * } ip = VTOI(vnode); + vrele(vnode); /* Remove and obsolete the previous version. */ mutex_enter(chmp-chm_lock_vnocache); @@ -1006,7 +1008,7 @@ chfs_gcollect_deletion_dirent(struct chf nref_len = chfs_nref_len(chmp, cheb, fd-nref); - (void)chfs_vnode_lookup(chmp, fd-vno); + /* XXX This was a noop (void)chfs_vnode_lookup(chmp, fd-vno); */ /* Find it in parent dirents. */ for (nref = parent-chvc-dirents; Index: src/sys/ufs/chfs/chfs_vnode.c diff -u src/sys/ufs/chfs/chfs_vnode.c:1.12 src/sys/ufs/chfs/chfs_vnode.c:1.13 --- src/sys/ufs/chfs/chfs_vnode.c:1.12 Sun Nov 9 18:23:28 2014 +++ src/sys/ufs/chfs/chfs_vnode.c Sun Jan 11 17:28:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnode.c,v 1.12 2014/11/09 18:23:28 maxv Exp $ */ +/* $NetBSD: chfs_vnode.c,v 1.13 2015/01/11 17:28:22 hannken Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -42,18 +42,24 @@ #include miscfs/genfs/genfs.h /* chfs_vnode_lookup - lookup for a vnode */ +static bool +chfs_vnode_lookup_selector(void *ctx, struct vnode *vp) +{ + ino_t *ino = ctx; + + return (VTOI(vp) != NULL VTOI(vp)-ino == *ino); +} struct vnode * chfs_vnode_lookup(struct chfs_mount *chmp, ino_t vno) { + struct vnode_iterator *marker; struct vnode *vp; - struct chfs_inode *ip; - TAILQ_FOREACH(vp, chmp-chm_fsmp-mnt_vnodelist, v_mntvnodes) { - ip = VTOI(vp); - if (ip ip-ino == vno) - return vp; - } - return NULL; + vfs_vnode_iterator_init(chmp-chm_fsmp, marker); + vp = vfs_vnode_iterator_next(marker, chfs_vnode_lookup_selector, vno); + vfs_vnode_iterator_destroy(marker); + + return vp; } /* chfs_readvnode - reads a vnode from the flash and setups its inode */
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: maxv Date: Mon Oct 20 06:41:52 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_vfsops.c Log Message: Memory leak. Found by my code scanner. ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/chfs/chfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.11 src/sys/ufs/chfs/chfs_vfsops.c:1.12 --- src/sys/ufs/chfs/chfs_vfsops.c:1.11 Wed Apr 16 18:55:19 2014 +++ src/sys/ufs/chfs/chfs_vfsops.c Mon Oct 20 06:41:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.11 2014/04/16 18:55:19 maxv Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.12 2014/10/20 06:41:51 maxv Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -152,9 +152,12 @@ chfs_mount(struct mount *mp, } /* Look up the name and verify that it's sane. */ NDINIT(nd, LOOKUP, FOLLOW, pb); - if ((err = namei(nd)) != 0 ) + if ((err = namei(nd)) != 0 ) { + pathbuf_destroy(pb); return (err); + } devvp = nd.ni_vp; + pathbuf_destroy(pb); /* Be sure this is a valid block device */ if (devvp-v_type != VBLK)
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Mon Oct 20 11:57:05 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_vfsops.c Log Message: simplify. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/chfs/chfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.12 src/sys/ufs/chfs/chfs_vfsops.c:1.13 --- src/sys/ufs/chfs/chfs_vfsops.c:1.12 Mon Oct 20 02:41:51 2014 +++ src/sys/ufs/chfs/chfs_vfsops.c Mon Oct 20 07:57:05 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.12 2014/10/20 06:41:51 maxv Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.13 2014/10/20 11:57:05 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -152,12 +152,11 @@ chfs_mount(struct mount *mp, } /* Look up the name and verify that it's sane. */ NDINIT(nd, LOOKUP, FOLLOW, pb); - if ((err = namei(nd)) != 0 ) { - pathbuf_destroy(pb); - return (err); - } - devvp = nd.ni_vp; + err = namei(nd); pathbuf_destroy(pb); + if (err) + return err; + devvp = nd.ni_vp; /* Be sure this is a valid block device */ if (devvp-v_type != VBLK)
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: joerg Date: Mon Sep 8 17:41:11 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_gc.c Log Message: Timestamps are bad sources of entropy, so just use cprng_fast32. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/chfs/chfs_gc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.6 src/sys/ufs/chfs/chfs_gc.c:1.7 --- src/sys/ufs/chfs/chfs_gc.c:1.6 Mon Sep 1 16:46:56 2014 +++ src/sys/ufs/chfs/chfs_gc.c Mon Sep 8 17:41:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.6 2014/09/01 16:46:56 he Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.7 2014/09/08 17:41:11 joerg Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -32,6 +32,7 @@ * SUCH DAMAGE. */ +#include sys/cprng.h #include chfs.h void chfs_gc_release_inode(struct chfs_mount *, @@ -351,10 +352,7 @@ find_gc_block(struct chfs_mount *chmp) KASSERT(mutex_owned(chmp-chm_lock_mountfields)); /* Get a random number. */ - struct timespec now; - vfs_timestamp(now); - - int n = now.tv_nsec % 128; + uint32_t n = cprng_fast32() % 128; again: /* Find an eraseblock queue. */
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: he Date: Mon Sep 1 16:27:38 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_scan.c Log Message: Plug leak in chfs_scan_eraseblock() of the allocated buffer. Make sure to release it both on success and failure returns. OK'ed by ttoth@ To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_scan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_scan.c diff -u src/sys/ufs/chfs/chfs_scan.c:1.4 src/sys/ufs/chfs/chfs_scan.c:1.5 --- src/sys/ufs/chfs/chfs_scan.c:1.4 Fri Oct 19 12:44:39 2012 +++ src/sys/ufs/chfs/chfs_scan.c Mon Sep 1 16:27:38 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_scan.c,v 1.4 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_scan.c,v 1.5 2014/09/01 16:27:38 he Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -443,15 +443,15 @@ chfs_scan_eraseblock(struct chfs_mount * memset(buf, 0 , CHFS_MAX_NODE_SIZE); err = chfs_read_leb(chmp, lnr, buf, ofs, CHFS_NODE_HDR_SIZE, retlen); - if (err) { - return err; - } + if (err) + goto err_return; if (retlen != CHFS_NODE_HDR_SIZE) { chfs_err(Error reading node header: read: %zu instead of: %zu\n, CHFS_NODE_HDR_SIZE, retlen); - return EIO; + err = EIO; + goto err_return; } /* first we check if the buffer we read is full with 0xff, if yes maybe @@ -476,9 +476,8 @@ chfs_scan_eraseblock(struct chfs_mount * if (err) { dbg(node hdr error\n); err = chfs_update_eb_dirty(chmp, cheb, 4); - if (err) { -return err; - } + if (err) +goto err_return; ofs += 4; continue; @@ -486,7 +485,8 @@ chfs_scan_eraseblock(struct chfs_mount * ofs += CHFS_NODE_HDR_SIZE; if (ofs chmp-chm_ebh-eb_size) { chfs_err(Second part of node is on the next eraseblock.\n); - return EIO; + err = EIO; + goto err_return; } switch (le16toh(nhdr-type)) { case CHFS_NODETYPE_VNODE: @@ -496,21 +496,20 @@ chfs_scan_eraseblock(struct chfs_mount * err = chfs_read_leb(chmp, lnr, buf + CHFS_NODE_HDR_SIZE, ofs, len, retlen); - if (err) { -return err; - } + if (err) +goto err_return; if (retlen != len) { chfs_err(Error reading vnode: read: %zu instead of: %zu\n, len, retlen); -return EIO; +err = EIO; +goto err_return; } KASSERT(lnr == cheb-lnr); err = chfs_scan_check_vnode(chmp, cheb, buf, ofs - CHFS_NODE_HDR_SIZE); - if (err) { -return err; - } + if (err) +goto err_return; break; case CHFS_NODETYPE_DIRENT: @@ -521,23 +520,22 @@ chfs_scan_eraseblock(struct chfs_mount * err = chfs_read_leb(chmp, lnr, buf + CHFS_NODE_HDR_SIZE, ofs, len, retlen); - if (err) { -return err; - } + if (err) +goto err_return; if (retlen != len) { chfs_err(Error reading dirent node: read: %zu instead of: %zu\n, len, retlen); -return EIO; +err = EIO; +goto err_return; } KASSERT(lnr == cheb-lnr); err = chfs_scan_check_dirent_node(chmp, cheb, buf, ofs - CHFS_NODE_HDR_SIZE); - if (err) { -return err; - } + if (err) +goto err_return; break; case CHFS_NODETYPE_DATA: @@ -547,20 +545,20 @@ chfs_scan_eraseblock(struct chfs_mount * err = chfs_read_leb(chmp, lnr, buf + CHFS_NODE_HDR_SIZE, ofs, len, retlen); - if (err) { -return err; - } + if (err) +goto err_return; if (retlen != len) { chfs_err(Error reading data node: read: %zu instead of: %zu\n, len, retlen); -return EIO; +err = EIO; +goto err_return; } KASSERT(lnr == cheb-lnr); err = chfs_scan_check_data_node(chmp, cheb, buf, ofs - CHFS_NODE_HDR_SIZE); if (err) -return err; +goto err_return; break; case CHFS_NODETYPE_PADDING: @@ -573,7 +571,7 @@ chfs_scan_eraseblock(struct chfs_mount * err = chfs_update_eb_dirty(chmp, cheb, le32toh(nhdr-length)); if (err) -return err; +goto err_return; break; default: @@ -581,7 +579,7 @@ chfs_scan_eraseblock(struct chfs_mount * err = chfs_update_eb_dirty(chmp, cheb, le32toh(nhdr-length)); if (err) -return err; +goto err_return; break; } @@ -591,5 +589,9 @@ chfs_scan_eraseblock(struct chfs_mount * KASSERT(cheb-used_size + cheb-free_size + cheb-dirty_size + cheb-unchecked_size + cheb-wasted_size == chmp-chm_ebh-eb_size); - return chfs_scan_classify_cheb(chmp, cheb); + err = chfs_scan_classify_cheb(chmp, cheb); + /* FALLTHROUGH */ +err_return: + kmem_free(buf, CHFS_MAX_NODE_SIZE); + return err; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: he Date: Mon Sep 1 16:31:17 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_readinode.c Log Message: Plug memory leak in a corner case in chfs_get_data_nodes(). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/chfs/chfs_readinode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.8 src/sys/ufs/chfs/chfs_readinode.c:1.9 --- src/sys/ufs/chfs/chfs_readinode.c:1.8 Sun Oct 20 17:18:38 2013 +++ src/sys/ufs/chfs/chfs_readinode.c Mon Sep 1 16:31:17 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.8 2013/10/20 17:18:38 christos Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.9 2014/09/01 16:31:17 he Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -801,8 +801,10 @@ chfs_get_data_nodes(struct chfs_mount *c buf = kmem_alloc(len, KM_SLEEP); dnode = kmem_alloc(len, KM_SLEEP); - if (!dnode) + if (!dnode) { + kmem_free(buf, len); return ENOMEM; + } nref = chfs_first_valid_data_ref(ip-chvc-dnode);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: he Date: Mon Sep 1 16:33:20 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_vnode.c Log Message: Plug memory leaks in error returns in chfs_readvnode(). To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/chfs/chfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnode.c diff -u src/sys/ufs/chfs/chfs_vnode.c:1.10 src/sys/ufs/chfs/chfs_vnode.c:1.11 --- src/sys/ufs/chfs/chfs_vnode.c:1.10 Thu Jan 23 10:13:57 2014 +++ src/sys/ufs/chfs/chfs_vnode.c Mon Sep 1 16:33:20 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnode.c,v 1.10 2014/01/23 10:13:57 hannken Exp $ */ +/* $NetBSD: chfs_vnode.c,v 1.11 2014/09/01 16:33:20 he Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -94,11 +94,14 @@ chfs_readvnode(struct mount *mp, ino_t i buf = kmem_alloc(len, KM_SLEEP); err = chfs_read_leb(chmp, chvc-v-nref_lnr, buf, CHFS_GET_OFS(chvc-v-nref_offset), len, retlen); - if (err) + if (err) { + kmem_free(buf, len); return err; + } if (retlen != len) { chfs_err(Error reading vnode: read: %zu insted of: %zu\n, len, retlen); + kmem_free(buf, len); return EIO; } chfvn = (struct chfs_flash_vnode*)buf;
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: he Date: Mon Sep 1 16:46:56 UTC 2014 Modified Files: src/sys/ufs/chfs: chfs_gc.c Log Message: Plug memory leak in error returns and normal operation in chfs_gcollect_pristine(). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs_gc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.5 src/sys/ufs/chfs/chfs_gc.c:1.6 --- src/sys/ufs/chfs/chfs_gc.c:1.5 Sun Oct 20 17:18:38 2013 +++ src/sys/ufs/chfs/chfs_gc.c Mon Sep 1 16:46:56 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.5 2013/10/20 17:18:38 christos Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.6 2014/09/01 16:46:56 he Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -726,23 +726,26 @@ chfs_gcollect_pristine(struct chfs_mount ret = chfs_read_leb(chmp, nref-nref_lnr, data, ofs, totlen, retlen); if (ret) { dbg_gc(reading error\n); - return ret; + goto err_out; } if (retlen != totlen) { dbg_gc(read size error\n); - return EIO; + ret = EIO; + goto err_out; } nhdr = (struct chfs_flash_node_hdr *)data; /* Check the header. */ if (le16toh(nhdr-magic) != CHFS_FS_MAGIC_BITMASK) { dbg_gc(node header magic number error\n); - return EBADF; + ret = EBADF; + goto err_out; } crc = crc32(0, (uint8_t *)nhdr, CHFS_NODE_HDR_SIZE - 4); if (crc != le32toh(nhdr-hdr_crc)) { dbg_gc(node header crc error\n); - return EBADF; + ret = EBADF; + goto err_out; } /* Read the remaining parts. */ @@ -753,7 +756,8 @@ chfs_gcollect_pristine(struct chfs_mount crc = crc32(0, (uint8_t *)fvnode, sizeof(struct chfs_flash_vnode) - 4); if (crc != le32toh(fvnode-node_crc)) { dbg_gc(vnode crc error\n); -return EBADF; +ret = EBADF; +goto err_out; } break; case CHFS_NODETYPE_DIRENT: @@ -762,12 +766,14 @@ chfs_gcollect_pristine(struct chfs_mount crc = crc32(0, (uint8_t *)fdirent, sizeof(struct chfs_flash_dirent_node) - 4); if (crc != le32toh(fdirent-node_crc)) { dbg_gc(dirent crc error\n); -return EBADF; +ret = EBADF; +goto err_out; } crc = crc32(0, fdirent-name, fdirent-nsize); if (crc != le32toh(fdirent-name_crc)) { dbg_gc(dirent name crc error\n); -return EBADF; +ret = EBADF; +goto err_out; } break; case CHFS_NODETYPE_DATA: @@ -776,25 +782,29 @@ chfs_gcollect_pristine(struct chfs_mount crc = crc32(0, (uint8_t *)fdata, sizeof(struct chfs_flash_data_node) - 4); if (crc != le32toh(fdata-node_crc)) { dbg_gc(data node crc error\n); -return EBADF; +ret = EBADF; +goto err_out; } break; default: /* unknown node */ if (chvc) { dbg_gc(unknown node have vnode cache\n); -return EBADF; +ret = EBADF; +goto err_out; } } /* CRC's OK, write node to its new place */ retry: ret = chfs_reserve_space_gc(chmp, totlen); if (ret) - return ret; + goto err_out; newnref = chfs_alloc_node_ref(chmp-chm_nextblock); - if (!newnref) - return ENOMEM; + if (!newnref) { + ret = ENOMEM; + goto err_out; + } ofs = chmp-chm_ebh-eb_size - chmp-chm_nextblock-free_size; newnref-nref_offset = ofs; @@ -814,7 +824,8 @@ retry: chfs_change_size_dirty(chmp, chmp-chm_nextblock, totlen); if (retries) { mutex_exit(chmp-chm_lock_sizes); - return EIO; + ret = EIO; + goto err_out; } /* try again */ @@ -829,7 +840,11 @@ retry: mutex_enter(chmp-chm_lock_vnocache); chfs_add_vnode_ref_to_vc(chmp, chvc, newnref); mutex_exit(chmp-chm_lock_vnocache); - return 0; + ret = 0; + /* FALLTHROUGH */ +err_out: + kmem_free(data, totlen); + return ret; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: he Date: Mon Sep 1 16:48:42 UTC 2014 Modified Files: src/sys/ufs/chfs: ebh.c Log Message: Plug memory leak in add_peb_to_free() and add_peb_to_in_use() in case there's a duplicate in the tree. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/ebh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/ebh.c diff -u src/sys/ufs/chfs/ebh.c:1.3 src/sys/ufs/chfs/ebh.c:1.4 --- src/sys/ufs/chfs/ebh.c:1.3 Fri Aug 10 09:26:58 2012 +++ src/sys/ufs/chfs/ebh.c Mon Sep 1 16:48:42 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ebh.c,v 1.3 2012/08/10 09:26:58 ttoth Exp $ */ +/* $NetBSD: ebh.c,v 1.4 2014/09/01 16:48:42 he Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -828,8 +828,10 @@ add_peb_to_free(struct chfs_ebh *ebh, in peb-erase_cnt = ec; peb-pebnr = pebnr; result = RB_INSERT(peb_free_rbtree, ebh-free, peb); - if (result) + if (result) { + kmem_free(peb, sizeof(struct chfs_peb)); return 1; + } return 0; } @@ -856,8 +858,10 @@ add_peb_to_in_use(struct chfs_ebh *ebh, peb-erase_cnt = ec; peb-pebnr = pebnr; result = RB_INSERT(peb_in_use_rbtree, ebh-in_use, peb); - if (result) + if (result) { + kmem_free(peb, sizeof(struct chfs_peb)); return 1; + } return 0; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Sun Oct 20 17:18:38 UTC 2013 Modified Files: src/sys/ufs/chfs: chfs_gc.c chfs_readinode.c chfs_subr.c chfs_vfsops.c chfs_vnops.c Log Message: remove unused To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_gc.c cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/chfs/chfs_readinode.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/chfs/chfs_subr.c \ src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.4 src/sys/ufs/chfs/chfs_gc.c:1.5 --- src/sys/ufs/chfs/chfs_gc.c:1.4 Fri Oct 19 08:44:39 2012 +++ src/sys/ufs/chfs/chfs_gc.c Sun Oct 20 13:18:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.4 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.5 2013/10/20 17:18:38 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -985,8 +985,6 @@ chfs_gcollect_deletion_dirent(struct chf int ret; - struct vnode *vnode = NULL; - dbg_gc(gcollect_deletion_dirent\n); /* Check node. */ @@ -995,7 +993,7 @@ chfs_gcollect_deletion_dirent(struct chf nref_len = chfs_nref_len(chmp, cheb, fd-nref); - vnode = chfs_vnode_lookup(chmp, fd-vno); + (void)chfs_vnode_lookup(chmp, fd-vno); /* Find it in parent dirents. */ for (nref = parent-chvc-dirents; Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.7 src/sys/ufs/chfs/chfs_readinode.c:1.8 --- src/sys/ufs/chfs/chfs_readinode.c:1.7 Sat Dec 1 06:31:01 2012 +++ src/sys/ufs/chfs/chfs_readinode.c Sun Oct 20 13:18:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.7 2012/12/01 11:31:01 mbalmer Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.8 2013/10/20 17:18:38 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -507,7 +507,6 @@ no_overlapping_node(struct rb_tree *frag } rb_tree_insert_node(fragtree, holefrag); - this = holefrag; } rb_tree_insert_node(fragtree, newfrag); Index: src/sys/ufs/chfs/chfs_subr.c diff -u src/sys/ufs/chfs/chfs_subr.c:1.8 src/sys/ufs/chfs/chfs_subr.c:1.9 --- src/sys/ufs/chfs/chfs_subr.c:1.8 Fri Oct 19 08:44:39 2012 +++ src/sys/ufs/chfs/chfs_subr.c Sun Oct 20 13:18:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_subr.c,v 1.8 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_subr.c,v 1.9 2013/10/20 17:18:38 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -253,14 +253,12 @@ chfs_chsize(struct vnode *vp, u_quad_t s int chfs_chflags(struct vnode *vp, int flags, kauth_cred_t cred) { - struct chfs_mount *chmp; struct chfs_inode *ip; int error = 0; kauth_action_t action = KAUTH_VNODE_WRITE_FLAGS; bool changing_sysflags = false; ip = VTOI(vp); - chmp = ip-chmp; if (vp-v_mount-mnt_flag MNT_RDONLY) return EROFS; Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.8 src/sys/ufs/chfs/chfs_vfsops.c:1.9 --- src/sys/ufs/chfs/chfs_vfsops.c:1.8 Mon Sep 30 14:58:00 2013 +++ src/sys/ufs/chfs/chfs_vfsops.c Sun Oct 20 13:18:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.8 2013/09/30 18:58:00 hannken Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.9 2013/10/20 17:18:38 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -204,7 +204,6 @@ int chfs_mountfs(struct vnode *devvp, struct mount *mp) { struct lwp *l = curlwp; - struct proc *p; kauth_cred_t cred; devmajor_t flash_major; dev_t dev; @@ -216,7 +215,6 @@ chfs_mountfs(struct vnode *devvp, struct dbg(mountfs()\n); dev = devvp-v_rdev; - p = l ? l-l_proc : NULL; cred = l ? l-l_cred : NOCRED; /* Flush out any old buffers remaining from a previous use. */ Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.17 src/sys/ufs/chfs/chfs_vnops.c:1.18 --- src/sys/ufs/chfs/chfs_vnops.c:1.17 Sun Jun 23 03:28:37 2013 +++ src/sys/ufs/chfs/chfs_vnops.c Sun Oct 20 13:18:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.17 2013/06/23 07:28:37 dholland Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.18 2013/10/20 17:18:38 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -217,7 +217,6 @@ chfs_mknod(void *v) struct ufsmount *ump; struct chfs_mount *chmp; - ino_t ino; struct chfs_full_dnode *fd; struct buf *bp; @@ -255,7 +254,6 @@ chfs_mknod(void *v) err = chfs_makeinode(mode, dvp, vp, cnp, vap-va_type); ip = VTOI(vp); - ino = ip-ino; if (vap-va_rdev != VNOVAL) ip-rdev = vap-va_rdev;
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: dholland Date: Wed Jun 19 18:15:35 UTC 2013 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: blkoff - chfs_blkoff blksize - chfs_blksize To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.15 src/sys/ufs/chfs/chfs_vnops.c:1.16 --- src/sys/ufs/chfs/chfs_vnops.c:1.15 Mon Mar 18 19:35:47 2013 +++ src/sys/ufs/chfs/chfs_vnops.c Wed Jun 19 18:15:35 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.15 2013/03/18 19:35:47 plunky Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.16 2013/06/19 18:15:35 dholland Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -583,7 +583,7 @@ chfs_chown(struct vnode *vp, uid_t uid, (((off_t)(blk)) (chmp)-chm_fs_bshift) /* calculates (loc % chmp-chm_chm_fs_bsize) */ -#define blkoff(chmp, loc) \ +#define chfs_blkoff(chmp, loc) \ ((loc) (chmp)-chm_fs_qbmask) /* calculates (loc / chmp-chm_chm_fs_bsize) */ @@ -594,10 +594,10 @@ chfs_chown(struct vnode *vp, uid_t uid, #define fragroundup(chmp, size) \ (((size) + (chmp)-chm_fs_qfmask) (chmp)-chm_fs_fmask) -#define blksize(chmp, ip, lbn) \ +#define chfs_blksize(chmp, ip, lbn) \ (((lbn) = UFS_NDADDR || (ip)-size = lblktosize(chmp, (lbn) + 1)) \ ? (chmp)-chm_fs_bsize \ - : (fragroundup(chmp, blkoff(chmp, (ip)-size + : (fragroundup(chmp, chfs_blkoff(chmp, (ip)-size /* calculates roundup(size, chmp-chm_chm_fs_bsize) */ #define blkroundup(chmp, size) \ @@ -688,8 +688,8 @@ chfs_read(void *v) break; lbn = lblkno(chmp, uio-uio_offset); nextlbn = lbn + 1; - size = blksize(chmp, ip, lbn); - blkoffset = blkoff(chmp, uio-uio_offset); + size = chfs_blksize(chmp, ip, lbn); + blkoffset = chfs_blkoff(chmp, uio-uio_offset); xfersize = MIN(MIN(chmp-chm_fs_bsize - blkoffset, uio-uio_resid), bytesinfile); @@ -697,7 +697,7 @@ chfs_read(void *v) error = bread(vp, lbn, size, NOCRED, 0, bp); dbg(after bread\n); } else { - int nextsize = blksize(chmp, ip, nextlbn); + int nextsize = chfs_blksize(chmp, ip, nextlbn); dbg(size: %ld\n, size); error = breadn(vp, lbn, size, nextlbn, nextsize, 1, NOCRED, 0, bp); @@ -846,7 +846,7 @@ chfs_write(void *v) MAX(osize, uio-uio_offset))); aflag = ioflag IO_SYNC ? B_SYNC : 0; nsize = MAX(osize, uio-uio_offset + uio-uio_resid); - endallocoff = nsize - blkoff(chmp, nsize); + endallocoff = nsize - chfs_blkoff(chmp, nsize); /* * if we're increasing the file size, deal with expanding @@ -882,7 +882,7 @@ chfs_write(void *v) } oldoff = uio-uio_offset; - blkoffset = blkoff(chmp, uio-uio_offset); + blkoffset = chfs_blkoff(chmp, uio-uio_offset); bytelen = MIN(chmp-chm_fs_bsize - blkoffset, uio-uio_resid); if (bytelen == 0) { break; @@ -898,12 +898,12 @@ chfs_write(void *v) overwrite = uio-uio_offset = preallocoff uio-uio_offset endallocoff; if (!overwrite (vp-v_vflag VV_MAPPED) == 0 - blkoff(chmp, uio-uio_offset) == 0 + chfs_blkoff(chmp, uio-uio_offset) == 0 (uio-uio_offset PAGE_MASK) == 0) { vsize_t len; len = trunc_page(bytelen); - len -= blkoff(chmp, len); + len -= chfs_blkoff(chmp, len); if (len 0) { overwrite = true; bytelen = len;
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: mbalmer Date: Sat Dec 1 11:31:02 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_readinode.c Log Message: Fix a typo in debug output. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/chfs/chfs_readinode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.6 src/sys/ufs/chfs/chfs_readinode.c:1.7 --- src/sys/ufs/chfs/chfs_readinode.c:1.6 Fri Oct 19 12:44:39 2012 +++ src/sys/ufs/chfs/chfs_readinode.c Sat Dec 1 11:31:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.6 2012/10/19 12:44:39 ttoth Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.7 2012/12/01 11:31:01 mbalmer Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -164,7 +164,7 @@ chfs_check_td_data(struct chfs_mount *ch } err = chfs_read_leb(chmp, nref-nref_lnr, buf, ofs, len, retlen); if (err) { - dbg(error wile reading: %d\n, err); + dbg(error while reading: %d\n, err); err = 2; goto out; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ttoth Date: Thu Aug 23 11:29:52 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: chfs: uappnd flag patch To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.9 src/sys/ufs/chfs/chfs_vnops.c:1.10 --- src/sys/ufs/chfs/chfs_vnops.c:1.9 Fri Aug 10 09:26:58 2012 +++ src/sys/ufs/chfs/chfs_vnops.c Thu Aug 23 11:29:51 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.9 2012/08/10 09:26:58 ttoth Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.10 2012/08/23 11:29:51 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -467,17 +467,33 @@ chfs_setattr(void *v) return EINVAL; } - if (error == 0 (vap-va_flags != VNOVAL)) + if (error == 0 (vap-va_flags != VNOVAL)) { error = chfs_chflags(vp, vap-va_flags, cred); + return error; + } + + if (ip-flags (IMMUTABLE | APPEND)) { + error = EPERM; + return error; + } - if (error == 0 (vap-va_size != VNOVAL)) + if (error == 0 (vap-va_size != VNOVAL)) { error = chfs_chsize(vp, vap-va_size, cred); + if (error) + return error; + } - if (error == 0 (vap-va_uid != VNOVAL || vap-va_gid != VNOVAL)) + if (error == 0 (vap-va_uid != VNOVAL || vap-va_gid != VNOVAL)) { error = chfs_chown(vp, vap-va_uid, vap-va_gid, cred); + if (error) + return error; + } - if (error == 0 (vap-va_mode != VNOVAL)) + if (error == 0 (vap-va_mode != VNOVAL)) { error = chfs_chmod(vp, vap-va_mode, cred); + if (error) + return error; + } #if 0 /* why do we need that? */ @@ -1054,11 +1070,18 @@ chfs_remove(void *v) struct chfs_inode *parent = VTOI(dvp); int error = 0; + if (vp-v_type == VDIR || (ip-flags (IMMUTABLE | APPEND)) || + (parent-flags APPEND)) { + error = EPERM; + goto out; + } + KASSERT(ip-chvc-vno != ip-chvc-pvno); error = chfs_do_unlink(ip, parent, cnp-cn_nameptr, cnp-cn_namelen); +out: vput(dvp); vput(vp);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ttoth Date: Wed Aug 22 09:20:13 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_readinode.c chfs_subr.c Log Message: chfs: fixed truncating To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_readinode.c cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/chfs/chfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.4 src/sys/ufs/chfs/chfs_readinode.c:1.5 --- src/sys/ufs/chfs/chfs_readinode.c:1.4 Mon Aug 13 13:12:51 2012 +++ src/sys/ufs/chfs/chfs_readinode.c Wed Aug 22 09:20:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.4 2012/08/13 13:12:51 ttoth Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.5 2012/08/22 09:20:13 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -604,6 +604,10 @@ chfs_remove_frags_of_node(struct chfs_mo KASSERT(mutex_owned(chmp-chm_lock_mountfields)); struct chfs_node_frag *this, *next; + if (nref == NULL) { + return; + } + this = (struct chfs_node_frag *)RB_TREE_MIN(fragtree); while (this) { next = frag_next(fragtree, this); @@ -1086,6 +1090,7 @@ chfs_read_data(struct chfs_mount* chmp, frag = (struct chfs_node_frag *)rb_tree_find_node_leq(ip-fragtree, ofs); if (!frag || frag-ofs ofs || frag-ofs + frag-size = ofs) { + bp-b_resid = 0; dbg(not found in frag tree\n); return 0; } Index: src/sys/ufs/chfs/chfs_subr.c diff -u src/sys/ufs/chfs/chfs_subr.c:1.6 src/sys/ufs/chfs/chfs_subr.c:1.7 --- src/sys/ufs/chfs/chfs_subr.c:1.6 Mon Aug 13 13:12:51 2012 +++ src/sys/ufs/chfs/chfs_subr.c Wed Aug 22 09:20:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_subr.c,v 1.6 2012/08/13 13:12:51 ttoth Exp $ */ +/* $NetBSD: chfs_subr.c,v 1.7 2012/08/22 09:20:13 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -216,11 +216,6 @@ chfs_chsize(struct vnode *vp, u_quad_t s { struct chfs_mount *chmp; struct chfs_inode *ip; - struct buf *bp; - int blknum, append; - int error = 0; - char *buf = NULL; - struct chfs_full_dnode *fd; ip = VTOI(vp); chmp = ip-chmp; @@ -246,104 +241,25 @@ chfs_chsize(struct vnode *vp, u_quad_t s vflushbuf(vp, 0); mutex_enter(chmp-chm_lock_mountfields); - chfs_flush_pending_wbuf(chmp); - /* handle truncate to zero as a special case */ - if (size == 0) { - dbg(truncate to zero); - chfs_truncate_fragtree(ip-chmp, - ip-fragtree, size); + if (ip-size size) { + uvm_vnp_setsize(vp, size); chfs_set_vnode_size(vp, size); + ip-iflag |= IN_CHANGE | IN_UPDATE; mutex_exit(chmp-chm_lock_mountfields); - return 0; } - - /* allocate zeros for the new data */ - buf = kmem_zalloc(size, KM_SLEEP); - bp = getiobuf(vp, true); - - if (ip-size != 0) { - /* read the whole data */ - bp-b_blkno = 0; - bp-b_bufsize = bp-b_resid = bp-b_bcount = ip-size; - bp-b_data = kmem_alloc(ip-size, KM_SLEEP); - - error = chfs_read_data(chmp, vp, bp); - if (error) { - mutex_exit(chmp-chm_lock_mountfields); - putiobuf(bp); - - return error; - } - - /* create the new data */ - dbg(create new data vap%llu ip%llu\n, - (unsigned long long)size, (unsigned long long)ip-size); - append = size - ip-size; - if (append 0) { - memcpy(buf, bp-b_data, ip-size); - } else { - memcpy(buf, bp-b_data, size); - chfs_truncate_fragtree(ip-chmp, -ip-fragtree, size); - } - - kmem_free(bp-b_data, ip-size); - - struct chfs_node_frag *lastfrag = frag_last(ip-fragtree); - fd = lastfrag-node; - - // remove from the list - mutex_enter(chmp-chm_lock_vnocache); - chfs_remove_frags_of_node(chmp, ip-fragtree, fd-nref); - // don't obsolete here, because setattr will obsolete this node - chfs_remove_node_from_list(chmp, ip-chvc, fd-nref, ip-chvc-dnode); - mutex_exit(chmp-chm_lock_vnocache); - - blknum = lastfrag-ofs / PAGE_SIZE; - lastfrag-size = append PAGE_SIZE ? PAGE_SIZE : size % PAGE_SIZE; - } else { - fd = chfs_alloc_full_dnode(); - blknum = 0; + if (size != 0) { + ubc_zerorange(vp-v_uobj, size, ip-size - size, UBC_UNMAP_FLAG(vp)); } - + + chfs_truncate_fragtree(ip-chmp, ip-fragtree, size); + uvm_vnp_setsize(vp, size); chfs_set_vnode_size(vp, size); - - // write the new data - for (bp-b_blkno = blknum; bp-b_blkno * PAGE_SIZE size; bp-b_blkno++) { - uint64_t writesize = MIN(size - bp-b_blkno * PAGE_SIZE, PAGE_SIZE); - - bp-b_bufsize = bp-b_resid = bp-b_bcount = writesize; - bp-b_data = kmem_alloc(writesize, KM_SLEEP); - - memcpy(bp-b_data, buf + (bp-b_blkno * PAGE_SIZE), writesize); - - if (bp-b_blkno != blknum) { - fd = chfs_alloc_full_dnode(); - } - - error = chfs_write_flash_dnode(chmp, vp, bp, fd); - if (error) { - mutex_exit(chmp-chm_lock_mountfields); - kmem_free(bp-b_data, writesize); - putiobuf(bp); - - return error; - } - if (bp-b_blkno != blknum) { - chfs_add_full_dnode_to_inode(chmp, ip, fd); -
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ttoth Date: Mon Aug 13 13:12:51 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_readinode.c chfs_subr.c chfs_vnode.c Log Message: chfs fixes 1. nodes are obsoleted only once during truncating a file 2. frags don't stay in pool_cache To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/chfs_readinode.c cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs_subr.c cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/chfs/chfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.3 src/sys/ufs/chfs/chfs_readinode.c:1.4 --- src/sys/ufs/chfs/chfs_readinode.c:1.3 Fri Aug 10 09:26:58 2012 +++ src/sys/ufs/chfs/chfs_readinode.c Mon Aug 13 13:12:51 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.3 2012/08/10 09:26:58 ttoth Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.4 2012/08/13 13:12:51 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -609,6 +609,7 @@ chfs_remove_frags_of_node(struct chfs_mo next = frag_next(fragtree, this); if (this-node-nref == nref) { rb_tree_remove_node(fragtree, this); + chfs_free_node_frag(this); } this = next; } Index: src/sys/ufs/chfs/chfs_subr.c diff -u src/sys/ufs/chfs/chfs_subr.c:1.5 src/sys/ufs/chfs/chfs_subr.c:1.6 --- src/sys/ufs/chfs/chfs_subr.c:1.5 Fri Aug 10 09:26:58 2012 +++ src/sys/ufs/chfs/chfs_subr.c Mon Aug 13 13:12:51 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_subr.c,v 1.5 2012/08/10 09:26:58 ttoth Exp $ */ +/* $NetBSD: chfs_subr.c,v 1.6 2012/08/13 13:12:51 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -299,7 +299,8 @@ chfs_chsize(struct vnode *vp, u_quad_t s // remove from the list mutex_enter(chmp-chm_lock_vnocache); chfs_remove_frags_of_node(chmp, ip-fragtree, fd-nref); - chfs_remove_and_obsolete(chmp, ip-chvc, fd-nref, ip-chvc-dnode); + // don't obsolete here, because setattr will obsolete this node + chfs_remove_node_from_list(chmp, ip-chvc, fd-nref, ip-chvc-dnode); mutex_exit(chmp-chm_lock_vnocache); blknum = lastfrag-ofs / PAGE_SIZE; Index: src/sys/ufs/chfs/chfs_vnode.c diff -u src/sys/ufs/chfs/chfs_vnode.c:1.6 src/sys/ufs/chfs/chfs_vnode.c:1.7 --- src/sys/ufs/chfs/chfs_vnode.c:1.6 Fri Aug 10 09:26:58 2012 +++ src/sys/ufs/chfs/chfs_vnode.c Mon Aug 13 13:12:51 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnode.c,v 1.6 2012/08/10 09:26:58 ttoth Exp $ */ +/* $NetBSD: chfs_vnode.c,v 1.7 2012/08/13 13:12:51 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -83,7 +83,7 @@ chfs_readvnode(struct mount* mp, ino_t i if (chvc ino != CHFS_ROOTINO) { /* debug... */ - printf(readvnode; offset: % PRIu32 , lnr: %d\n, + dbg(offset: % PRIu32 , lnr: %d\n, CHFS_GET_OFS(chvc-v-nref_offset), chvc-v-nref_lnr); KASSERT((void *)chvc != (void *)chvc-v);
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ttoth Date: Fri Aug 10 09:26:58 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs.h chfs_build.c chfs_gc.c chfs_malloc.c chfs_nodeops.c chfs_readinode.c chfs_scan.c chfs_subr.c chfs_vfsops.c chfs_vnode.c chfs_vnode_cache.c chfs_vnops.c chfs_write.c ebh.c Log Message: chfs bugfix [node was obsoleted twice] To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/chfs/chfs.h cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/chfs_build.c \ src/sys/ufs/chfs/chfs_write.c cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/chfs/chfs_gc.c \ src/sys/ufs/chfs/chfs_malloc.c src/sys/ufs/chfs/chfs_readinode.c \ src/sys/ufs/chfs/chfs_scan.c src/sys/ufs/chfs/ebh.c cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/chfs_nodeops.c \ src/sys/ufs/chfs/chfs_vnode_cache.c cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_subr.c \ src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs_vnode.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs.h diff -u src/sys/ufs/chfs/chfs.h:1.6 src/sys/ufs/chfs/chfs.h:1.7 --- src/sys/ufs/chfs/chfs.h:1.6 Fri Apr 13 14:50:35 2012 +++ src/sys/ufs/chfs/chfs.h Fri Aug 10 09:26:58 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs.h,v 1.6 2012/04/13 14:50:35 ttoth Exp $ */ +/* $NetBSD: chfs.h,v 1.7 2012/08/10 09:26:58 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -494,6 +494,10 @@ int chfs_update_eb_dirty(struct chfs_mou struct chfs_eraseblock *, uint32_t); void chfs_add_node_to_list(struct chfs_mount *, struct chfs_vnode_cache *, struct chfs_node_ref *, struct chfs_node_ref **); +void chfs_remove_node_from_list(struct chfs_mount *, struct chfs_vnode_cache *, +struct chfs_node_ref *, struct chfs_node_ref **); +void chfs_remove_and_obsolete(struct chfs_mount *, struct chfs_vnode_cache *, +struct chfs_node_ref *, struct chfs_node_ref **); void chfs_add_fd_to_inode(struct chfs_mount *, struct chfs_inode *, struct chfs_dirent *); void chfs_add_vnode_ref_to_vc(struct chfs_mount *, struct chfs_vnode_cache *, @@ -522,7 +526,6 @@ chfs_nref_to_vc(struct chfs_node_ref *nr dbg(Empty!\n); } } - //dbg(vno: %llu\n, ((struct chfs_vnode_cache *)(nref))-vno); //dbg(NREF_TO_VC: GET IT\n); //dbg(nref_next: %p, lnr: %u, ofs: %u\n, nref-nref_next, nref-nref_lnr, nref-nref_offset); @@ -564,7 +567,9 @@ void chfs_free_tmp_dnode_info(struct chf /* chfs_readinode.c */ int chfs_read_inode(struct chfs_mount *, struct chfs_inode *); int chfs_read_inode_internal(struct chfs_mount *, struct chfs_inode *); -void chfs_kill_fragtree(struct rb_tree *); +void chfs_remove_frags_of_node(struct chfs_mount *, struct rb_tree *, + struct chfs_node_ref *); +void chfs_kill_fragtree(struct chfs_mount *, struct rb_tree *); uint32_t chfs_truncate_fragtree(struct chfs_mount *, struct rb_tree *, uint32_t); int chfs_add_full_dnode_to_inode(struct chfs_mount *, @@ -653,8 +658,6 @@ void chfs_change_size_wasted(struct chfs /* chfs_vnode_cache.c */ struct chfs_vnode_cache **chfs_vnocache_hash_init(void); void chfs_vnocache_hash_destroy(struct chfs_vnode_cache **); -void chfs_vnode_cache_set_state(struct chfs_mount *, -struct chfs_vnode_cache *, int); struct chfs_vnode_cache* chfs_vnode_cache_get(struct chfs_mount *, ino_t); void chfs_vnode_cache_add(struct chfs_mount *, struct chfs_vnode_cache *); void chfs_vnode_cache_remove(struct chfs_mount *, struct chfs_vnode_cache *); Index: src/sys/ufs/chfs/chfs_build.c diff -u src/sys/ufs/chfs/chfs_build.c:1.3 src/sys/ufs/chfs/chfs_build.c:1.4 --- src/sys/ufs/chfs/chfs_build.c:1.3 Thu Apr 12 15:31:01 2012 +++ src/sys/ufs/chfs/chfs_build.c Fri Aug 10 09:26:58 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_build.c,v 1.3 2012/04/12 15:31:01 ttoth Exp $ */ +/* $NetBSD: chfs_build.c,v 1.4 2012/08/10 09:26:58 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -67,11 +67,11 @@ void chfs_build_set_vnodecache_nlink(struct chfs_mount *chmp, struct chfs_vnode_cache *vc) { - struct chfs_dirent *fd; + struct chfs_dirent *fd, *tmpfd; //dbg(set nlink\n); // for (fd = vc-scan_dirents; fd; fd = fd-next) { - TAILQ_FOREACH(fd, vc-scan_dirents, fds) { + TAILQ_FOREACH_SAFE(fd, vc-scan_dirents, fds, tmpfd) { struct chfs_vnode_cache *child_vc; if (!fd-vno) @@ -82,6 +82,7 @@ chfs_build_set_vnodecache_nlink(struct c mutex_exit(chmp-chm_lock_vnocache); if (!child_vc) { chfs_mark_node_obsolete(chmp, fd-nref); + TAILQ_REMOVE(vc-scan_dirents, fd, fds); continue; } if (fd-type == CHT_DIR) { @@ -122,8 +123,8 @@ chfs_build_remove_unlinked_vnode(struct dbg(START\n); dbg(vno: %llu\n, (unsigned long long)vc-vno); - nref = vc-dnode; KASSERT(mutex_owned(chmp-chm_lock_mountfields)); + nref = vc-dnode; // The
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: joerg Date: Wed Apr 18 13:31:10 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_inode.h chfs_vnops.c Log Message: Don't depend on implicit enum casts, be explicit. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_inode.h cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_inode.h diff -u src/sys/ufs/chfs/chfs_inode.h:1.4 src/sys/ufs/chfs/chfs_inode.h:1.5 --- src/sys/ufs/chfs/chfs_inode.h:1.4 Fri Apr 13 14:50:35 2012 +++ src/sys/ufs/chfs/chfs_inode.h Wed Apr 18 13:31:10 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_inode.h,v 1.4 2012/04/13 14:50:35 ttoth Exp $ */ +/* $NetBSD: chfs_inode.h,v 1.5 2012/04/18 13:31:10 joerg Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -58,8 +58,8 @@ enum chtype { }; /* these macros are needed because the compatibility */ -#define CHTTOVT(ch_type) ch_type -#define VTTOCHT(v_type) v_type +#define CHTTOVT(ch_type) (enum vtype)(ch_type) +#define VTTOCHT(v_type) (enum chtype)(v_type) /* vtype replaced with chtype, these are only for compatibility */ static const enum chtype iftocht_tab[16] = { Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.5 src/sys/ufs/chfs/chfs_vnops.c:1.6 --- src/sys/ufs/chfs/chfs_vnops.c:1.5 Tue Apr 17 19:15:16 2012 +++ src/sys/ufs/chfs/chfs_vnops.c Wed Apr 18 13:31:10 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.5 2012/04/17 19:15:16 christos Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.6 2012/04/18 13:31:10 joerg Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -1360,7 +1360,7 @@ chfs_readdir(void *v) offset = uio-uio_offset; if (offset == CHFS_OFFSET_DOT) { - error = chfs_filldir(uio, ip-ino, ., 1, VDIR); + error = chfs_filldir(uio, ip-ino, ., 1, CHT_DIR); if (error == -1) { error = 0; goto outok; @@ -1377,7 +1377,7 @@ chfs_readdir(void *v) chvc = chfs_vnode_cache_get(chmp, ip-ino); mutex_exit(chmp-chm_lock_vnocache); - error = chfs_filldir(uio, chvc-pvno, .., 2, VDIR); + error = chfs_filldir(uio, chvc-pvno, .., 2, CHT_DIR); if (error == -1) { error = 0; goto outok;
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ttoth Date: Fri Apr 13 14:50:35 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs.h chfs_inode.h chfs_vnode.c ebh.h Log Message: prepare for chfs's makefs To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/chfs/chfs.h cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/chfs_inode.h cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/chfs/chfs_vnode.c cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/ebh.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/ufs/chfs/chfs.h diff -u src/sys/ufs/chfs/chfs.h:1.5 src/sys/ufs/chfs/chfs.h:1.6 --- src/sys/ufs/chfs/chfs.h:1.5 Thu Apr 12 15:31:01 2012 +++ src/sys/ufs/chfs/chfs.h Fri Apr 13 14:50:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs.h,v 1.5 2012/04/12 15:31:01 ttoth Exp $ */ +/* $NetBSD: chfs.h,v 1.6 2012/04/13 14:50:35 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -38,6 +38,9 @@ #ifndef __CHFS_H__ #define __CHFS_H__ + +#ifdef _KERNEL + #if 0 #define DBG_MSG #define DBG_MSG_GC @@ -71,13 +74,19 @@ TAILQ_HEAD(chfs_dirent_list, chfs_dirent); #include chfs_pool.h +#endif /* _KERNEL */ + #include ebh.h #include media.h #include chfs_inode.h +#define CHFS_PAD(x) (((x)+3)~3) + +#ifdef _KERNEL + #ifndef MOUNT_CHFS #define MOUNT_CHFS chfs -#endif +#endif /* MOUNT_CHFS */ enum { VNO_STATE_UNCHECKED, /* CRC checks not yet done */ @@ -97,8 +106,6 @@ enum { #define MAX_DIRTY_TO_CLEAN 255 #define VERY_DIRTY(chmp, size) ((size) = (((chmp)-chm_ebh)-eb_size / 2)) -#define CHFS_PAD(x) (((x)+3)~3) - enum { CHFS_NODE_OK = 0, CHFS_NODE_BADMAGIC, @@ -764,4 +771,5 @@ CHFS_PAGES_MAX(struct chfs_mount *chmp) #define IMPLIES(a, b) (!(a) || (b)) #define IFF(a, b) (IMPLIES(a, b) IMPLIES(b, a)) +#endif /* _KERNEL */ #endif /* __CHFS_H__ */ Index: src/sys/ufs/chfs/chfs_inode.h diff -u src/sys/ufs/chfs/chfs_inode.h:1.3 src/sys/ufs/chfs/chfs_inode.h:1.4 --- src/sys/ufs/chfs/chfs_inode.h:1.3 Thu Apr 12 15:31:01 2012 +++ src/sys/ufs/chfs/chfs_inode.h Fri Apr 13 14:50:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_inode.h,v 1.3 2012/04/12 15:31:01 ttoth Exp $ */ +/* $NetBSD: chfs_inode.h,v 1.4 2012/04/13 14:50:35 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -35,10 +35,12 @@ #ifndef __CHFS_INODE_H__ #define __CHFS_INODE_H__ +#ifdef _KERNEL #include sys/vnode.h #include sys/stat.h #include ufs/ufs/ufsmount.h #include miscfs/genfs/genfs_node.h +#endif /* _KERNEL */ #define CHFS_ROOTINO 2 @@ -59,11 +61,17 @@ enum chtype { #define CHTTOVT(ch_type) ch_type #define VTTOCHT(v_type) v_type -extern const enum chtype iftocht_tab[16]; +/* vtype replaced with chtype, these are only for compatibility */ +static 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, +}; #define IFTOCHT(mode) (iftocht_tab[((mode) S_IFMT) 12]) - +#ifdef _KERNEL struct chfs_inode { struct genfs_node gnode; @@ -159,4 +167,5 @@ struct chfs_inode #define IFSOCK 014 /* UNIX domain socket. */ #define IFWHT 016 /* Whiteout. */ +#endif /* _KERNEL */ #endif /* __CHFS_INODE_H__ */ Index: src/sys/ufs/chfs/chfs_vnode.c diff -u src/sys/ufs/chfs/chfs_vnode.c:1.4 src/sys/ufs/chfs/chfs_vnode.c:1.5 --- src/sys/ufs/chfs/chfs_vnode.c:1.4 Thu Apr 12 15:31:01 2012 +++ src/sys/ufs/chfs/chfs_vnode.c Fri Apr 13 14:50:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnode.c,v 1.4 2012/04/12 15:31:01 ttoth Exp $ */ +/* $NetBSD: chfs_vnode.c,v 1.5 2012/04/13 14:50:35 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -42,15 +42,6 @@ #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) { Index: src/sys/ufs/chfs/ebh.h diff -u src/sys/ufs/chfs/ebh.h:1.1 src/sys/ufs/chfs/ebh.h:1.2 --- src/sys/ufs/chfs/ebh.h:1.1 Thu Nov 24 15:51:32 2011 +++ src/sys/ufs/chfs/ebh.h Fri Apr 13 14:50:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ebh.h,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */ +/* $NetBSD: ebh.h,v 1.2 2012/04/13 14:50:35 ttoth Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -42,6 +42,7 @@ #ifndef EBH_H_ #define EBH_H_ +#ifdef _KERNEL #include sys/param.h #include sys/kernel.h #include sys/cdefs.h @@ -57,10 +58,27 @@ #include sys/kthread.h #include dev/flash/flash.h -#include ufs/chfs/ebh_media.h -#include ufs/chfs/debug.h -#include ufs/chfs/ebh_misc.h +#include debug.h +#include ebh_misc.h +#endif /* _KERNEL */ +#include ebh_media.h +
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: christos Date: Tue Feb 28 02:48:39 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_inode.h chfs_malloc.c chfs_pool.c Log Message: Make this compile again. From Paul Fleischer. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/chfs_inode.h \ src/sys/ufs/chfs/chfs_malloc.c src/sys/ufs/chfs/chfs_pool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_inode.h diff -u src/sys/ufs/chfs/chfs_inode.h:1.1 src/sys/ufs/chfs/chfs_inode.h:1.2 --- src/sys/ufs/chfs/chfs_inode.h:1.1 Thu Nov 24 10:51:31 2011 +++ src/sys/ufs/chfs/chfs_inode.h Mon Feb 27 21:48:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_inode.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs_inode.h,v 1.2 2012/02/28 02:48:39 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -42,6 +42,7 @@ struct chfs_inode { + struct genfs_node gnode; kmutex_t inode_lock; /* lock the fields of chfs_inode */ LIST_ENTRY(chfs_inode) hash_entry; /* Hash chain. */ Index: src/sys/ufs/chfs/chfs_malloc.c diff -u src/sys/ufs/chfs/chfs_malloc.c:1.1 src/sys/ufs/chfs/chfs_malloc.c:1.2 --- src/sys/ufs/chfs/chfs_malloc.c:1.1 Thu Nov 24 10:51:31 2011 +++ src/sys/ufs/chfs/chfs_malloc.c Mon Feb 27 21:48:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_malloc.c,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs_malloc.c,v 1.2 2012/02/28 02:48:39 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -45,7 +45,7 @@ pool_cache_t chfs_tmp_dnode_cache; pool_cache_t chfs_tmp_dnode_info_cache; int -chfs_alloc_pool_caches() +chfs_alloc_pool_caches(void) { chfs_vnode_cache = pool_cache_init( sizeof(struct chfs_vnode_cache), @@ -118,7 +118,7 @@ err_vnode: } void -chfs_destroy_pool_caches() +chfs_destroy_pool_caches(void) { if (chfs_vnode_cache) pool_cache_destroy(chfs_vnode_cache); @@ -293,7 +293,7 @@ chfs_free_dirent(struct chfs_dirent *dir } struct chfs_full_dnode* -chfs_alloc_full_dnode() +chfs_alloc_full_dnode(void) { struct chfs_full_dnode *ret; ret = kmem_alloc(sizeof(struct chfs_full_dnode), KM_SLEEP); @@ -307,7 +307,7 @@ chfs_free_full_dnode(struct chfs_full_dn } struct chfs_flash_vnode* -chfs_alloc_flash_vnode() +chfs_alloc_flash_vnode(void) { struct chfs_flash_vnode *ret; ret = pool_cache_get(chfs_flash_vnode_cache, 0); @@ -321,7 +321,7 @@ chfs_free_flash_vnode(struct chfs_flash_ } struct chfs_flash_dirent_node* -chfs_alloc_flash_dirent() +chfs_alloc_flash_dirent(void) { struct chfs_flash_dirent_node *ret; ret = pool_cache_get(chfs_flash_dirent_cache, 0); @@ -335,7 +335,7 @@ chfs_free_flash_dirent(struct chfs_flash } struct chfs_flash_data_node* -chfs_alloc_flash_dnode() +chfs_alloc_flash_dnode(void) { struct chfs_flash_data_node *ret; ret = pool_cache_get(chfs_flash_dnode_cache, 0); @@ -350,7 +350,7 @@ chfs_free_flash_dnode(struct chfs_flash_ struct chfs_node_frag* -chfs_alloc_node_frag() +chfs_alloc_node_frag(void) { struct chfs_node_frag *ret; ret = pool_cache_get(chfs_node_frag_cache, 0); @@ -365,7 +365,7 @@ chfs_free_node_frag(struct chfs_node_fra } struct chfs_tmp_dnode * -chfs_alloc_tmp_dnode() +chfs_alloc_tmp_dnode(void) { struct chfs_tmp_dnode *ret; ret = pool_cache_get(chfs_tmp_dnode_cache, 0); @@ -380,7 +380,7 @@ chfs_free_tmp_dnode(struct chfs_tmp_dnod } struct chfs_tmp_dnode_info * -chfs_alloc_tmp_dnode_info() +chfs_alloc_tmp_dnode_info(void) { struct chfs_tmp_dnode_info *ret; ret = pool_cache_get(chfs_tmp_dnode_info_cache, 0); Index: src/sys/ufs/chfs/chfs_pool.c diff -u src/sys/ufs/chfs/chfs_pool.c:1.1 src/sys/ufs/chfs/chfs_pool.c:1.2 --- src/sys/ufs/chfs/chfs_pool.c:1.1 Thu Nov 24 10:51:31 2011 +++ src/sys/ufs/chfs/chfs_pool.c Mon Feb 27 21:48:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_pool.c,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs_pool.c,v 1.2 2012/02/28 02:48:39 christos Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -50,9 +50,6 @@ void * chfs_pool_page_alloc(struct pool *, int); void chfs_pool_page_free(struct pool *, void *); -extern void* pool_page_alloc_nointr(struct pool *, int); -extern void pool_page_free_nointr(struct pool *, void *); - /* - */ struct pool_allocator chfs_pool_allocator = { @@ -104,7 +101,7 @@ chfs_pool_page_alloc(struct pool *pp, in atomic_dec_uint(chmp-chm_pages_used); return NULL; } - page = pool_page_alloc_nointr(pp, flags | PR_WAITOK); + page = pool_get(pp, flags | PR_WAITOK); if (page == NULL) { atomic_dec_uint(chmp-chm_pages_used); } @@ -125,7 +122,7 @@ chfs_pool_page_free(struct pool *pp, voi chmp = chpp-chp_mount; atomic_dec_uint(chmp-chm_pages_used); - pool_page_free_nointr(pp, v); + pool_put(pp,v); } /*
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ahoka Date: Mon Jan 16 12:17:56 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_wbuf.c Log Message: cleanup macros To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/chfs/chfs_wbuf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_wbuf.c diff -u src/sys/ufs/chfs/chfs_wbuf.c:1.2 src/sys/ufs/chfs/chfs_wbuf.c:1.3 --- src/sys/ufs/chfs/chfs_wbuf.c:1.2 Thu Nov 24 20:50:33 2011 +++ src/sys/ufs/chfs/chfs_wbuf.c Mon Jan 16 12:17:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_wbuf.c,v 1.2 2011/11/24 20:50:33 agc Exp $ */ +/* $NetBSD: chfs_wbuf.c,v 1.3 2012/01/16 12:17:55 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -35,28 +35,19 @@ #include dev/flash/flash.h #include sys/uio.h #include chfs.h -//#include /root/xipffs/netbsd.chfs/chfs.h -#define DBG_WBUF 1 +#define DBG_WBUF 1 /* XXX unused, but should be */ #define PAD(x) (((x)+3)~3) -#define EB_ADDRESS(x) ( ((unsigned long)(x) / chmp-chm_ebh-eb_size) * chmp-chm_ebh-eb_size ) +#define EB_ADDRESS(x) ( rounddown((x), chmp-chm_ebh-eb_size) ) -#define PAGE_DIV(x) ( ((unsigned long)(x) / (unsigned long)(chmp-chm_wbuf_pagesize)) * (unsigned long)(chmp-chm_wbuf_pagesize) ) -#define PAGE_MOD(x) ( (unsigned long)(x) % (unsigned long)(chmp-chm_wbuf_pagesize) ) - -/* -// test functions -int wbuf_test(void); -void wbuf_test_erase_flash(struct chfs_mount*); -void wbuf_test_callback(struct erase_instruction*); -*/ +#define PAGE_DIV(x) ( rounddown((x), chmp-chm_wbuf_pagesize) ) +#define PAGE_MOD(x) ( (x) % (chmp-chm_wbuf_pagesize) ) #define NOPAD 0 #define SETPAD 1 - /** * chfs_flush_wbuf - write wbuf to the flash * @chmp: super block info
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ahoka Date: Mon Jan 16 12:28:47 UTC 2012 Modified Files: src/sys/ufs/chfs: chfs_wbuf.c Log Message: use enum instead of macros add some input validation cleanup To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/chfs_wbuf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_wbuf.c diff -u src/sys/ufs/chfs/chfs_wbuf.c:1.3 src/sys/ufs/chfs/chfs_wbuf.c:1.4 --- src/sys/ufs/chfs/chfs_wbuf.c:1.3 Mon Jan 16 12:17:55 2012 +++ src/sys/ufs/chfs/chfs_wbuf.c Mon Jan 16 12:28:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_wbuf.c,v 1.3 2012/01/16 12:17:55 ahoka Exp $ */ +/* $NetBSD: chfs_wbuf.c,v 1.4 2012/01/16 12:28:47 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -45,54 +45,65 @@ #define PAGE_DIV(x) ( rounddown((x), chmp-chm_wbuf_pagesize) ) #define PAGE_MOD(x) ( (x) % (chmp-chm_wbuf_pagesize) ) -#define NOPAD 0 -#define SETPAD 1 +enum { + WBUF_NOPAD, + WBUF_SETPAD +}; /** * chfs_flush_wbuf - write wbuf to the flash * @chmp: super block info - * @pad: padding (NOPAD / SETPAD) + * @pad: padding (WBUF_NOPAD / WBUF_SETPAD) * Returns zero in case of success. */ static int chfs_flush_wbuf(struct chfs_mount *chmp, int pad) { - int ret=0; - size_t retlen = 0; + int ret; + size_t retlen; + struct chfs_node_ref *nref; + struct chfs_flash_padding_node* padnode; KASSERT(mutex_owned(chmp-chm_lock_mountfields)); KASSERT(mutex_owned(chmp-chm_lock_sizes)); KASSERT(rw_write_held(chmp-chm_lock_wbuf)); + KASSERT(pad == WBUF_SETPAD || pad == WBUF_NOPAD); - if (pad) { + if (pad == WBUF_SETPAD) { chmp-chm_wbuf_len = PAD(chmp-chm_wbuf_len); - memset(chmp-chm_wbuf + chmp-chm_wbuf_len, 0, chmp-chm_wbuf_pagesize - chmp-chm_wbuf_len); + memset(chmp-chm_wbuf + chmp-chm_wbuf_len, 0, + chmp-chm_wbuf_pagesize - chmp-chm_wbuf_len); - struct chfs_flash_padding_node* padnode = (void*)(chmp-chm_wbuf + chmp-chm_wbuf_len); + padnode = (void *)(chmp-chm_wbuf + chmp-chm_wbuf_len); padnode-magic = htole16(CHFS_FS_MAGIC_BITMASK); padnode-type = htole16(CHFS_NODETYPE_PADDING); - padnode-length = htole32(chmp-chm_wbuf_pagesize - chmp-chm_wbuf_len); - padnode-hdr_crc = htole32(crc32(0, (uint8_t *)padnode, sizeof(*padnode)-4)); + padnode-length = htole32(chmp-chm_wbuf_pagesize + - chmp-chm_wbuf_len); + padnode-hdr_crc = htole32(crc32(0, (uint8_t *)padnode, + sizeof(*padnode)-4)); - struct chfs_node_ref *nref; nref = chfs_alloc_node_ref(chmp-chm_nextblock); nref-nref_offset = chmp-chm_wbuf_ofs + chmp-chm_wbuf_len; nref-nref_offset = CHFS_GET_OFS(nref-nref_offset) | CHFS_OBSOLETE_NODE_MASK; chmp-chm_wbuf_len = chmp-chm_wbuf_pagesize; - chfs_change_size_free(chmp, chmp-chm_nextblock, -padnode-length); - chfs_change_size_wasted(chmp, chmp-chm_nextblock, padnode-length); + chfs_change_size_free(chmp, chmp-chm_nextblock, + -padnode-length); + chfs_change_size_wasted(chmp, chmp-chm_nextblock, + padnode-length); } - ret = chfs_write_leb(chmp, chmp-chm_nextblock-lnr, chmp-chm_wbuf, chmp-chm_wbuf_ofs, chmp-chm_wbuf_len, retlen); - if(ret) { + ret = chfs_write_leb(chmp, chmp-chm_nextblock-lnr, chmp-chm_wbuf, + chmp-chm_wbuf_ofs, chmp-chm_wbuf_len, retlen); + if (ret) { return ret; } - memset(chmp-chm_wbuf,0xff,chmp-chm_wbuf_pagesize); + memset(chmp-chm_wbuf, 0xff, chmp-chm_wbuf_pagesize); chmp-chm_wbuf_ofs += chmp-chm_wbuf_pagesize; chmp-chm_wbuf_len = 0; + return 0; } @@ -156,7 +167,7 @@ chfs_write_wbuf(struct chfs_mount* chmp, if (EB_ADDRESS(to) != EB_ADDRESS(chmp-chm_wbuf_ofs)) { if (chmp-chm_wbuf_len) { - ret = chfs_flush_wbuf(chmp, SETPAD); + ret = chfs_flush_wbuf(chmp, WBUF_SETPAD); if (ret) goto outerr; } @@ -179,7 +190,7 @@ chfs_write_wbuf(struct chfs_mount* chmp, /* take care of alignement to next page*/ if (!chmp-chm_wbuf_len) { chmp-chm_wbuf_len += chmp-chm_wbuf_pagesize; - ret = chfs_flush_wbuf(chmp, NOPAD); + ret = chfs_flush_wbuf(chmp, WBUF_NOPAD); if (ret) goto outerr; } @@ -193,7 +204,7 @@ chfs_write_wbuf(struct chfs_mount* chmp, wbuf_retlen = chfs_fill_wbuf(chmp, v, vlen); if (chmp-chm_wbuf_len == chmp-chm_wbuf_pagesize) { - ret = chfs_flush_wbuf(chmp, NOPAD); + ret = chfs_flush_wbuf(chmp, WBUF_NOPAD); if (ret) { goto outerr; } @@ -213,14 +224,14 @@ chfs_write_wbuf(struct chfs_mount* chmp, } wbuf_retlen = chfs_fill_wbuf(chmp, v, vlen); if (chmp-chm_wbuf_len == chmp-chm_wbuf_pagesize) { - ret = chfs_flush_wbuf(chmp, NOPAD); + ret = chfs_flush_wbuf(chmp, WBUF_NOPAD); if (ret) goto outerr; } // if we write the last vector, we flush with padding /*if (invec == count-1) { - ret = chfs_flush_wbuf(chmp, SETPAD); + ret = chfs_flush_wbuf(chmp, WBUF_SETPAD); if (ret) goto outerr; }*/ @@ -243,7
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ahoka Date: Mon Nov 28 12:50:07 UTC 2011 Modified Files: src/sys/ufs/chfs: chfs.h Log Message: cleanup, some style and remove leftover code To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/chfs/chfs.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/ufs/chfs/chfs.h diff -u src/sys/ufs/chfs/chfs.h:1.3 src/sys/ufs/chfs/chfs.h:1.4 --- src/sys/ufs/chfs/chfs.h:1.3 Thu Nov 24 21:38:44 2011 +++ src/sys/ufs/chfs/chfs.h Mon Nov 28 12:50:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs.h,v 1.3 2011/11/24 21:38:44 ahoka Exp $ */ +/* $NetBSD: chfs.h,v 1.4 2011/11/28 12:50:07 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -310,7 +310,8 @@ struct chfs_eraseblock struct chfs_node_ref *first_node; struct chfs_node_ref *last_node; - struct chfs_node_ref *gc_node; /* Next block to be garbage collected */ + /* Next block to be garbage collected */ + struct chfs_node_ref *gc_node; }; TAILQ_HEAD(chfs_eraseblock_queue, chfs_eraseblock); @@ -349,21 +350,15 @@ struct garbage_collector_thread { * @very_dirty_queue: queue of very dirty eraseblocks * @erase_pending_queue: queue of eraseblocks waiting for erasing * @erasable_pending_wbuf_queue: queue of eraseblocks waiting for erasing and - * have data to write to them + * have data to write to them * @nextblock: next eraseblock to write to - * * @nr_free_blocks: number of free blocks on the free_queue * @nr_erasable_blocks: number of blocks that can be erased and are on the - * erasable_queue - * + * erasable_queue */ struct chfs_mount { struct mount *chm_fsmp; -// dev_t dev; -// struct vnode *devvp; - struct chfs_ebh *chm_ebh; -// int chm_fl_index; int chm_fs_version; uint64_t chm_gbl_version; ino_t chm_max_vno; @@ -448,30 +443,15 @@ struct chfs_mount { krwlock_t chm_lock_wbuf; }; -#define sleep_on_spinunlock(s) \ - do { \ - kmutex_t sleep_mtx; \ - kcondvar_t sleep_cnd; \ - cv_init(sleep_cnd, sleep_cnd); \ - mutex_init(sleep_mtx, MUTEX_DEFAULT, IPL_NONE); \ - mutex_spin_exit(s); \ - mutex_enter(sleep_mtx); \ - cv_timedwait(sleep_cnd, sleep_mtx, mstohz(50)); \ - mutex_exit(sleep_mtx); \ - mutex_destroy(sleep_mtx); \ - cv_destroy(sleep_cnd); \ - } while (0) -#undef sleep_on_spinunlock - /* * TODO we should move here all of these from the bottom of the file * Macros/functions to convert from generic data structures to chfs * specific ones. */ -#define CHFS_OFFSET_DOT 0 +#define CHFS_OFFSET_DOT 0 #define CHFS_OFFSET_DOTDOT 1 -#define CHFS_OFFSET_EOF 2 +#define CHFS_OFFSET_EOF 2 #define CHFS_OFFSET_FIRST 3 @@ -480,21 +460,32 @@ struct chfs_mount { /* chfs_build.c */ void chfs_calc_trigger_levels(struct chfs_mount *); int chfs_build_filesystem(struct chfs_mount *); -void chfs_build_set_vnodecache_nlink(struct chfs_mount *chmp,struct chfs_vnode_cache *vc); -void chfs_build_remove_unlinked_vnode(struct chfs_mount *chmp,struct chfs_vnode_cache *vc, struct chfs_dirent_list *unlinked); +void chfs_build_set_vnodecache_nlink(struct chfs_mount *, +struct chfs_vnode_cache *); +void chfs_build_remove_unlinked_vnode(struct chfs_mount *, +struct chfs_vnode_cache *, struct chfs_dirent_list *); /* chfs_scan.c */ int chfs_scan_eraseblock(struct chfs_mount *, struct chfs_eraseblock *); -struct chfs_vnode_cache *chfs_scan_make_vnode_cache(struct chfs_mount *chmp, ino_t vno); -int chfs_scan_check_node_hdr(struct chfs_flash_node_hdr *nhdr); -int chfs_scan_check_vnode(struct chfs_mount *chmp, struct chfs_eraseblock *cheb, void *buf, off_t ofs); -int chfs_scan_mark_dirent_obsolete(struct chfs_mount *chmp,struct chfs_vnode_cache *vc, struct chfs_dirent *fd); -void chfs_add_fd_to_list(struct chfs_mount *chmp,struct chfs_dirent *new, struct chfs_vnode_cache *pvc); -int chfs_scan_check_dirent_node(struct chfs_mount *chmp, struct chfs_eraseblock *cheb, void *buf, off_t ofs); -int chfs_scan_check_data_node(struct chfs_mount *chmp, struct chfs_eraseblock *cheb, void *buf, off_t ofs); -int chfs_scan_classify_cheb(struct chfs_mount *chmp,struct chfs_eraseblock *cheb); +struct chfs_vnode_cache *chfs_scan_make_vnode_cache(struct chfs_mount *, +ino_t); +int chfs_scan_check_node_hdr(struct chfs_flash_node_hdr *); +int chfs_scan_check_vnode(struct chfs_mount *, +struct chfs_eraseblock *, void *, off_t); +int chfs_scan_mark_dirent_obsolete(struct chfs_mount *, +struct chfs_vnode_cache *, struct chfs_dirent *); +void chfs_add_fd_to_list(struct chfs_mount *, +struct chfs_dirent *, struct chfs_vnode_cache *); +int chfs_scan_check_dirent_node(struct chfs_mount *, +struct chfs_eraseblock *, void *, off_t); +int chfs_scan_check_data_node(struct chfs_mount *, +struct
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ahoka Date: Fri Nov 25 11:15:25 UTC 2011 Modified Files: src/sys/ufs/chfs: ebh.c Log Message: Don't shadow some stupid function defined globally in random platforms. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/ebh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/ebh.c diff -u src/sys/ufs/chfs/ebh.c:1.1 src/sys/ufs/chfs/ebh.c:1.2 --- src/sys/ufs/chfs/ebh.c:1.1 Thu Nov 24 15:51:32 2011 +++ src/sys/ufs/chfs/ebh.c Fri Nov 25 11:15:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ebh.c,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */ +/* $NetBSD: ebh.c,v 1.2 2011/11/25 11:15:24 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -1369,16 +1369,17 @@ nand_process_eb(struct chfs_ebh *ebh, st { int err, erase_cnt, leb_status; uint64_t max_serial; - bool isbad; + /* isbad() is defined on some ancient platforms, heh */ + bool is_bad; /* Check block is bad */ err = flash_block_isbad(ebh-flash_dev, - pebnr * ebh-flash_if-erasesize, isbad); + pebnr * ebh-flash_if-erasesize, is_bad); if (err) { chfs_err(checking block is bad failed\n); return err; } - if (isbad) { + if (is_bad) { si-bad_peb_cnt++; return 0; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ahoka Date: Thu Nov 24 19:14:31 UTC 2011 Modified Files: src/sys/ufs/chfs: chfs.h Log Message: fix build failure on amd64 due to incorrect format string To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/chfs.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/ufs/chfs/chfs.h diff -u src/sys/ufs/chfs/chfs.h:1.1 src/sys/ufs/chfs/chfs.h:1.2 --- src/sys/ufs/chfs/chfs.h:1.1 Thu Nov 24 15:51:31 2011 +++ src/sys/ufs/chfs/chfs.h Thu Nov 24 19:14:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs.h,v 1.2 2011/11/24 19:14:30 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -528,7 +528,8 @@ chfs_nref_to_vc(struct chfs_node_ref *nr //dbg(NREF_TO_VC: GET IT\n); //dbg(nref_next: %p, lnr: %u, ofs: %u\n, nref-nref_next, nref-nref_lnr, nref-nref_offset); struct chfs_vnode_cache *vc = (struct chfs_vnode_cache *) nref; - dbg(vno: %llu, pvno: %llu, hv: %llu, nlink: %u\n, vc-vno, vc-pvno, vc-highest_version, vc-nlink); + dbg(vno: %ju, pvno: %ju, hv: %ju, nlink: %u\n, (intmax_t )vc-vno, + (intmax_t )vc-pvno, (intmax_t )vc-highest_version, vc-nlink); //return ((struct chfs_vnode_cache *)nref); return vc; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: agc Date: Thu Nov 24 20:50:33 UTC 2011 Modified Files: src/sys/ufs/chfs: chfs_wbuf.c Log Message: quick workaround for compilation bug on amd64 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/chfs_wbuf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_wbuf.c diff -u src/sys/ufs/chfs/chfs_wbuf.c:1.1 src/sys/ufs/chfs/chfs_wbuf.c:1.2 --- src/sys/ufs/chfs/chfs_wbuf.c:1.1 Thu Nov 24 15:51:32 2011 +++ src/sys/ufs/chfs/chfs_wbuf.c Thu Nov 24 20:50:33 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_wbuf.c,v 1.1 2011/11/24 15:51:32 ahoka Exp $ */ +/* $NetBSD: chfs_wbuf.c,v 1.2 2011/11/24 20:50:33 agc Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -176,7 +176,8 @@ chfs_write_wbuf(struct chfs_mount* chmp, //dbg(3. wbuf ofs: %zu, len: %zu\n, chmp-chm_wbuf_ofs, chmp-chm_wbuf_len); if (to != PAD(chmp-chm_wbuf_ofs + chmp-chm_wbuf_len)) { - dbg(to: %llu != %zu\n, to, PAD(chmp-chm_wbuf_ofs + chmp-chm_wbuf_len)); + dbg(to: %llu != %zu\n, (unsigned long long)to, + PAD(chmp-chm_wbuf_ofs + chmp-chm_wbuf_len)); dbg(Non-contiguous write\n); panic(BUG\n); }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: agc Date: Thu Nov 24 21:09:37 UTC 2011 Modified Files: src/sys/ufs/chfs: chfs_gc.c chfs_readinode.c chfs_scan.c chfs_subr.c chfs_vfsops.c chfs_vnode.c chfs_vnops.c chfs_write.c Log Message: quick workaround to make this compile, with thanks to Hisashi Fujinaka for the nudge. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/chfs_gc.c \ src/sys/ufs/chfs/chfs_readinode.c src/sys/ufs/chfs/chfs_scan.c \ src/sys/ufs/chfs/chfs_subr.c src/sys/ufs/chfs/chfs_vfsops.c \ src/sys/ufs/chfs/chfs_vnode.c src/sys/ufs/chfs/chfs_vnops.c \ src/sys/ufs/chfs/chfs_write.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_gc.c diff -u src/sys/ufs/chfs/chfs_gc.c:1.1 src/sys/ufs/chfs/chfs_gc.c:1.2 --- src/sys/ufs/chfs/chfs_gc.c:1.1 Thu Nov 24 15:51:31 2011 +++ src/sys/ufs/chfs/chfs_gc.c Thu Nov 24 21:09:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_gc.c,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs_gc.c,v 1.2 2011/11/24 21:09:37 agc Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -208,7 +208,7 @@ chfs_gc_fetch_inode(struct chfs_mount *c struct vnode *vp = NULL; struct chfs_vnode_cache *vc; struct chfs_inode *ip; - dbg_gc(fetch inode %llu\n, vno); + dbg_gc(fetch inode %llu\n, (unsigned long long)vno); if (unlinked) { dbg_gc(unlinked\n); @@ -439,14 +439,16 @@ chfs_gcollect_pass(struct chfs_mount *ch mutex_exit(chmp-chm_lock_sizes); mutex_exit(chmp-chm_lock_mountfields); dbg_gc(checked_vno (#%llu) max_vno (#%llu)\n, - chmp-chm_checked_vno, chmp-chm_max_vno); + (unsigned long long)chmp-chm_checked_vno, + (unsigned long long)chmp-chm_max_vno); return ENOSPC; } mutex_exit(chmp-chm_lock_sizes); mutex_enter(chmp-chm_lock_vnocache); - dbg_gc(checking vno #%llu\n, chmp-chm_checked_vno); + dbg_gc(checking vno #%llu\n, + (unsigned long long)chmp-chm_checked_vno); dbg_gc(get vnode cache\n); vc = chfs_vnode_cache_get(chmp, chmp-chm_checked_vno++); @@ -600,7 +602,7 @@ chfs_gcollect_pass(struct chfs_mount *ch mutex_exit(chmp-chm_lock_mountfields); panic(CHFS BUG - vc state unchecked, checking or gc (vno #%llu, num #%d)\n, - vc-vno, vc-state); + (unsigned long long)vc-vno, vc-state); case VNO_STATE_READING: mutex_exit(chmp-chm_lock_vnocache); @@ -896,7 +898,8 @@ chfs_gcollect_live(struct chfs_mount *ch } else { dbg_gc(Nref at leb #%u offset 0x%08x wasn't in node list for ino #%llu\n, - nref-nref_lnr, CHFS_GET_OFS(nref-nref_offset), ip-ino); + nref-nref_lnr, CHFS_GET_OFS(nref-nref_offset), + (unsigned long long)ip-ino); if (CHFS_REF_OBSOLETE(nref)) { dbg_gc(But it's obsolete so we don't mind too much.\n); Index: src/sys/ufs/chfs/chfs_readinode.c diff -u src/sys/ufs/chfs/chfs_readinode.c:1.1 src/sys/ufs/chfs/chfs_readinode.c:1.2 --- src/sys/ufs/chfs/chfs_readinode.c:1.1 Thu Nov 24 15:51:31 2011 +++ src/sys/ufs/chfs/chfs_readinode.c Thu Nov 24 21:09:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_readinode.c,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs_readinode.c,v 1.2 2011/11/24 21:09:37 agc Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -391,8 +391,11 @@ chfs_add_tmp_dnode_to_tree(struct chfs_m tmp_td-node-ofs + tmp_td-node-size = end_ofs) { /* New node entirely overlapped by 'this' */ if (!chfs_check_td_node(chmp, tmp_td)) { - dbg(this version: %llu\n, tmp_td-version); - dbg(this ofs: %llu, size: %u\n, tmp_td-node-ofs, tmp_td-node-size); + dbg(this version: %llu\n, + (unsigned long long)tmp_td-version); + dbg(this ofs: %llu, size: %u\n, + (unsigned long long)tmp_td-node-ofs, + tmp_td-node-size); dbg(calling kill td 4\n); chfs_kill_td(chmp, newtd); return 0; @@ -895,7 +898,7 @@ chfs_build_fragtree(struct chfs_mount *c } else { if (tmp_td-version high_ver) { high_ver = tmp_td-version; - dbg(highver: %llu\n, high_ver); + dbg(highver: %llu\n, (unsigned long long)high_ver); rii-latest_ref = tmp_td-node-nref; } @@ -959,8 +962,10 @@ retry: break; case VNO_STATE_PRESENT: case VNO_STATE_READING: - chfs_err(Reading inode #%llu in state %d!\n, vc-vno, vc-state); - chfs_err(wants to read a nonexistent ino %llu\n, vc-vno); + chfs_err(Reading inode #%llu in state %d!\n, + (unsigned long long)vc-vno, vc-state); + chfs_err(wants to read a nonexistent ino %llu\n, + (unsigned long long)vc-vno); return ENOENT; default: panic(BUG() Bad vno cache state.); Index: src/sys/ufs/chfs/chfs_scan.c diff -u src/sys/ufs/chfs/chfs_scan.c:1.1 src/sys/ufs/chfs/chfs_scan.c:1.2 --- src/sys/ufs/chfs/chfs_scan.c:1.1 Thu Nov 24 15:51:31 2011 +++ src/sys/ufs/chfs/chfs_scan.c Thu Nov 24 21:09:37 2011 @@ -1,4
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: agc Date: Thu Nov 24 21:22:39 UTC 2011 Modified Files: src/sys/ufs/chfs: chfs_build.c Log Message: i missed a file - quick workaround for compilation bugs on amd64 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/chfs/chfs_build.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_build.c diff -u src/sys/ufs/chfs/chfs_build.c:1.1 src/sys/ufs/chfs/chfs_build.c:1.2 --- src/sys/ufs/chfs/chfs_build.c:1.1 Thu Nov 24 15:51:31 2011 +++ src/sys/ufs/chfs/chfs_build.c Thu Nov 24 21:22:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_build.c,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */ +/* $NetBSD: chfs_build.c,v 1.2 2011/11/24 21:22:39 agc Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -91,7 +91,8 @@ chfs_build_set_vnodecache_nlink(struct c if (child_vc-pvno) { chfs_err(found a hard link: child dir: %s , (vno: %llu) of dir vno: %llu\n, -fd-name, fd-vno, vc-vno); +fd-name, (unsigned long long)fd-vno, +(unsigned long long)vc-vno); } else { //dbg(child_vc-pvno = // vc-vno; pvno = %d\n, child_vc-pvno); @@ -119,7 +120,7 @@ chfs_build_remove_unlinked_vnode(struct struct chfs_dirent *fd, *tmpfd; dbg(START\n); - dbg(vno: %llu\n, vc-vno); + dbg(vno: %llu\n, (unsigned long long)vc-vno); nref = vc-dnode; KASSERT(mutex_owned(chmp-chm_lock_mountfields)); @@ -144,8 +145,8 @@ chfs_build_remove_unlinked_vnode(struct struct chfs_vnode_cache *child_vc; // fd = vc-scan_dirents; dbg(dirent dump:\n); - dbg( -vno: %llu\n, fd-vno); - dbg( -version: %llu\n, fd-version); + dbg( -vno: %llu\n, (unsigned long long)fd-vno); + dbg( -version: %llu\n, (unsigned long long)fd-version); dbg( -nhash: 0x%x\n, fd-nhash); dbg( -nsize: %d\n, fd-nsize); dbg( -name:%s\n, fd-name); @@ -310,7 +311,7 @@ chfs_build_filesystem(struct chfs_mount for (i = 0; i VNODECACHE_SIZE; i++) { vc = chmp-chm_vnocache_hash[i]; while (vc) { - dbg(vc-vno: %llu\n, vc-vno); + dbg(vc-vno: %llu\n, (unsigned long long)vc-vno); if (!TAILQ_EMPTY(vc-scan_dirents)) chfs_build_set_vnodecache_nlink(chmp, vc); vc = vc-next;
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: ahoka Date: Thu Nov 24 21:38:44 UTC 2011 Modified Files: src/sys/ufs/chfs: chfs.h Log Message: disable dbg messages (they break the build on amd64) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/chfs/chfs.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/ufs/chfs/chfs.h diff -u src/sys/ufs/chfs/chfs.h:1.2 src/sys/ufs/chfs/chfs.h:1.3 --- src/sys/ufs/chfs/chfs.h:1.2 Thu Nov 24 19:14:30 2011 +++ src/sys/ufs/chfs/chfs.h Thu Nov 24 21:38:44 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs.h,v 1.2 2011/11/24 19:14:30 ahoka Exp $ */ +/* $NetBSD: chfs.h,v 1.3 2011/11/24 21:38:44 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -38,8 +38,10 @@ #ifndef __CHFS_H__ #define __CHFS_H__ +#if 0 #define DBG_MSG #define DBG_MSG_GC +#endif #include sys/param.h #include sys/kernel.h