Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Import CHFS, which was formerly known as ChewieFS.
details: https://anonhg.NetBSD.org/src/rev/374afd01dfcf
branches: trunk
changeset: 771534:374afd01dfcf
user: ahoka <ahoka%NetBSD.org@localhost>
date: Thu Nov 24 15:51:30 2011 +0000
description:
Import CHFS, which was formerly known as ChewieFS.
CHFS is a file system for flash devices developed by the
Software Engineering Department at University of Szeged, Hungary.
http://chewiefs.sed.hu/
Thanks for all who made it possible.
diffstat:
sys/sys/vnode.h | 8 +-
sys/ufs/chfs/chfs.h | 910 ++++++++++++++++
sys/ufs/chfs/chfs_args.h | 53 +
sys/ufs/chfs/chfs_build.c | 404 +++++++
sys/ufs/chfs/chfs_erase.c | 137 ++
sys/ufs/chfs/chfs_gc.c | 1235 ++++++++++++++++++++++
sys/ufs/chfs/chfs_ihash.c | 220 ++++
sys/ufs/chfs/chfs_inode.h | 136 ++
sys/ufs/chfs/chfs_malloc.c | 396 +++++++
sys/ufs/chfs/chfs_nodeops.c | 570 ++++++++++
sys/ufs/chfs/chfs_pool.c | 211 +++
sys/ufs/chfs/chfs_pool.h | 84 +
sys/ufs/chfs/chfs_readinode.c | 1131 ++++++++++++++++++++
sys/ufs/chfs/chfs_scan.c | 740 +++++++++++++
sys/ufs/chfs/chfs_subr.c | 539 +++++++++
sys/ufs/chfs/chfs_vfsops.c | 844 +++++++++++++++
sys/ufs/chfs/chfs_vnode.c | 393 +++++++
sys/ufs/chfs/chfs_vnode_cache.c | 165 +++
sys/ufs/chfs/chfs_vnops.c | 1764 ++++++++++++++++++++++++++++++++
sys/ufs/chfs/chfs_wbuf.c | 258 ++++
sys/ufs/chfs/chfs_write.c | 544 +++++++++
sys/ufs/chfs/debug.c | 48 +
sys/ufs/chfs/debug.h | 97 +
sys/ufs/chfs/ebh.c | 2140 +++++++++++++++++++++++++++++++++++++++
sys/ufs/chfs/ebh.h | 318 +++++
sys/ufs/chfs/ebh_media.h | 116 ++
sys/ufs/chfs/ebh_misc.h | 88 +
sys/ufs/chfs/media.h | 200 +++
sys/ufs/files.ufs | 58 +-
sys/ufs/ufs/ufsmount.h | 6 +-
30 files changed, 13788 insertions(+), 25 deletions(-)
diffs (truncated from 13999 to 300 lines):
diff -r 39f4f46642e6 -r 374afd01dfcf sys/sys/vnode.h
--- a/sys/sys/vnode.h Thu Nov 24 15:27:10 2011 +0000
+++ b/sys/sys/vnode.h Thu Nov 24 15:51:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.235 2011/11/21 04:36:06 christos Exp $ */
+/* $NetBSD: vnode.h,v 1.236 2011/11/24 15:51:30 ahoka Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS,
- VT_RUMP, VT_NILFS, VT_V7FS
+ VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS
};
#define VNODE_TAGS \
@@ -114,7 +114,7 @@
"VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
"VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
"VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \
- "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS"
+ "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS"
struct vnode;
struct buf;
@@ -223,7 +223,7 @@
"\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
"\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
"\22LAYER\24CLEAN\25INACTPEND\26INACTREDO" \
- "\30INACTNOW\31DIROP"
+ "\30INACTNOW\31DIROP"
#define VSIZENOTSET ((voff_t)-1)
diff -r 39f4f46642e6 -r 374afd01dfcf sys/ufs/chfs/chfs.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ufs/chfs/chfs.h Thu Nov 24 15:51:30 2011 +0000
@@ -0,0 +1,910 @@
+/* $NetBSD: chfs.h,v 1.1 2011/11/24 15:51:31 ahoka Exp $ */
+
+/*-
+ * Copyright (c) 2010 Department of Software Engineering,
+ * University of Szeged, Hungary
+ * Copyright (C) 2009 Ferenc Havasi <havasi%inf.u-szeged.hu@localhost>
+ * Copyright (C) 2009 Zoltan Sogor <weth%inf.u-szeged.hu@localhost>
+ * Copyright (C) 2009 David Tengeri <dtengeri%inf.u-szeged.hu@localhost>
+ * Copyright (C) 2009 Tamas Toth <ttoth%inf.u-szeged.hu@localhost>
+ * Copyright (C) 2010 Adam Hoka <ahoka%NetBSD.org@localhost>
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by the Department of Software Engineering, University of Szeged, Hungary
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __CHFS_H__
+#define __CHFS_H__
+
+#define DBG_MSG
+#define DBG_MSG_GC
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/cdefs.h>
+#include <sys/stdint.h>
+#include <sys/types.h>
+#include <sys/tree.h>
+#include <sys/queue.h>
+#include <sys/kmem.h>
+#include <sys/endian.h>
+#include <sys/rwlock.h>
+#include <sys/condvar.h>
+#include <sys/mutex.h>
+#include <sys/kthread.h>
+#include <sys/rbtree.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/hash.h>
+#include <sys/module.h>
+#include <sys/dirent.h>
+
+#include <ufs/ufs/quota.h>
+#include <ufs/ufs/ufsmount.h>
+#include <ufs/ufs/dir.h>
+
+/* XXX shouldnt be defined here, but needed by chfs_inode.h */
+TAILQ_HEAD(chfs_dirent_list, chfs_dirent);
+
+#include "chfs_pool.h"
+#include "ebh.h"
+#include "media.h"
+#include "chfs_inode.h"
+
+#ifndef MOUNT_CHFS
+#define MOUNT_CHFS "chfs"
+#endif
+
+#define CHFS_ROOTINO ROOTINO /* ROOTINO == 2 */
+
+enum {
+ VNO_STATE_UNCHECKED, /* CRC checks not yet done */
+ VNO_STATE_CHECKING, /* CRC checks in progress */
+ VNO_STATE_PRESENT, /* In core */
+ VNO_STATE_CHECKEDABSENT,/* Checked, cleared again */
+ VNO_STATE_GC, /* GCing a 'pristine' node */
+ VNO_STATE_READING, /* In read_inode() */
+ VNO_STATE_CLEARING /* In clear_inode() */
+};
+
+#define VNODECACHE_SIZE 128
+
+#define MAX_READ_FREE(chmp) (((chmp)->chm_ebh)->eb_size / 8)
+/* an eraseblock will be clean if its dirty size is smaller than this */
+#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,
+ CHFS_NODE_BADCRC,
+ CHFS_NODE_BADNAMECRC
+};
+
+enum {
+ CHFS_BLK_STATE_FREE = 100,
+ CHFS_BLK_STATE_CLEAN,
+ CHFS_BLK_STATE_PARTDIRTY,
+ CHFS_BLK_STATE_ALLDIRTY
+};
+
+extern struct pool chfs_inode_pool;
+extern const struct genfs_ops chfs_genfsops;
+
+/**
+ * struct chfs_node_ref - a reference to a node
+ * @lnr: logical identifier of the eraseblock where the node is
+ * @offset: offset int hte eraseblock where the node starts
+ * @next: used at data and dirent nodes, it points to the next data node which
+ * belongs to the same vnode
+ */
+struct chfs_node_ref
+{
+ struct chfs_node_ref *nref_next;
+ uint32_t nref_lnr;
+ uint32_t nref_offset;
+};
+
+/* Constants for allocating node refs */
+#define REFS_BLOCK_LEN (255/sizeof(struct chfs_node_ref))
+#define REF_EMPTY_NODE (UINT_MAX)
+#define REF_LINK_TO_NEXT (UINT_MAX - 1)
+
+enum {
+ CHFS_NORMAL_NODE_MASK,
+ CHFS_UNCHECKED_NODE_MASK,
+ CHFS_OBSOLETE_NODE_MASK,
+ CHFS_PRISTINE_NODE_MASK
+};
+
+#define CHFS_REF_FLAGS(ref) ((ref)->nref_offset & 3)
+#define CHFS_REF_OBSOLETE(ref) (((ref)->nref_offset & 3) == CHFS_OBSOLETE_NODE_MASK)
+#define CHFS_MARK_REF_NORMAL(ref) \
+ do { \
+ (ref)->nref_offset = CHFS_GET_OFS((ref)->nref_offset) | CHFS_NORMAL_NODE_MASK; \
+ } while(0)
+
+#define CHFS_GET_OFS(ofs) (ofs & ~ 3)
+
+static inline struct chfs_node_ref *
+node_next(struct chfs_node_ref *nref)
+{
+ //dbg("node next: %u : %u\n", nref->nref_lnr, nref->nref_offset);
+ nref++;
+ //dbg("nref++: %u : %u\n", nref->nref_lnr, nref->nref_offset);
+
+ if (nref->nref_lnr == REF_LINK_TO_NEXT) {
+ //dbg("link to next\n");
+ nref = nref->nref_next;
+ if (!nref)
+ return nref;
+ }
+
+ if (nref->nref_lnr == REF_EMPTY_NODE) {
+ //dbg("empty\n");
+ return NULL;
+ }
+
+ return nref;
+}
+
+/**
+ * struct chfs_dirent - full representation of a directory entry
+ */
+struct chfs_dirent
+{
+ struct chfs_node_ref *nref;
+// struct chfs_dirent *next;
+ TAILQ_ENTRY(chfs_dirent) fds;
+ uint64_t version;
+ ino_t vno;
+ uint32_t nhash;
+ enum vtype type;
+ uint8_t nsize;
+ uint8_t name[0];
+
+ /* used by chfs_alloc_dirent and free counterpart */
+// size_t alloc_size;
+};
+
+struct chfs_tmp_dnode {
+ struct chfs_full_dnode *node;
+ uint64_t version;
+ uint32_t data_crc;
+ //uint32_t partial_crc;
+ //uint16_t csize;
+ uint16_t overlapped;
+ struct chfs_tmp_dnode *next;
+};
+
+struct chfs_tmp_dnode_info {
+ struct rb_node rb_node;
+ struct chfs_tmp_dnode *tmpnode;
+};
+
+struct chfs_readinode_info {
+ struct rb_tree tdi_root;
+ struct chfs_tmp_dnode_info *mdata_tn;
+ uint64_t highest_version;
+ struct chfs_node_ref *latest_ref;
+};
+
+struct chfs_full_dnode {
+ struct chfs_node_ref *nref;
+ uint64_t ofs;
+ uint32_t size;
+ uint32_t frags;
+};
+
+struct chfs_node_frag {
+ struct rb_node rb_node;
+ struct chfs_full_dnode *node;
+ uint32_t size;
+ uint64_t ofs;
+};
+
+static inline struct chfs_node_frag *
+frag_first(struct rb_tree *tree)
+{
+ struct chfs_node_frag *frag;
+
+ frag = (struct chfs_node_frag *)RB_TREE_MIN(tree);
+
+ return frag;
+}
+
+static inline struct chfs_node_frag *
+frag_last(struct rb_tree *tree)
+{
+ struct chfs_node_frag *frag;
+
+ frag = (struct chfs_node_frag *)RB_TREE_MAX(tree);
+
+ return frag;
+}
+
+#define frag_next(tree, frag) (struct chfs_node_frag *)rb_tree_iterate(tree, frag, RB_DIR_RIGHT)
+#define frag_prev(tree, frag) (struct chfs_node_frag *)rb_tree_iterate(tree, frag, RB_DIR_LEFT)
+
+
+/* XXX hack
+ #ifndef CHFS_FRAG_TREE
+ #define CHFS_FRAG_TREE
+ RB_HEAD(chfs_frag_tree, chfs_node_frag);
+ #endif
+*/
+
Home |
Main Index |
Thread Index |
Old Index