Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/chfs CHFS comments
details: https://anonhg.NetBSD.org/src/rev/1e2ede38618a
branches: trunk
changeset: 782166:1e2ede38618a
user: ttoth <ttoth%NetBSD.org@localhost>
date: Fri Oct 19 12:44:39 2012 +0000
description:
CHFS comments
diffstat:
sys/ufs/chfs/chfs.h | 383 +++++++++++++++++++--------------------
sys/ufs/chfs/chfs_args.h | 15 +-
sys/ufs/chfs/chfs_build.c | 80 ++------
sys/ufs/chfs/chfs_erase.c | 25 +-
sys/ufs/chfs/chfs_gc.c | 317 ++++++++++++++------------------
sys/ufs/chfs/chfs_ihash.c | 10 +-
sys/ufs/chfs/chfs_inode.h | 45 ++--
sys/ufs/chfs/chfs_malloc.c | 45 ++-
sys/ufs/chfs/chfs_nodeops.c | 100 +++-------
sys/ufs/chfs/chfs_readinode.c | 217 +++++++++++++---------
sys/ufs/chfs/chfs_scan.c | 220 ++++------------------
sys/ufs/chfs/chfs_subr.c | 136 +------------
sys/ufs/chfs/chfs_vfsops.c | 117 +++++------
sys/ufs/chfs/chfs_vnode.c | 102 +++++----
sys/ufs/chfs/chfs_vnode_cache.c | 30 +--
sys/ufs/chfs/chfs_vnops.c | 142 +++++---------
sys/ufs/chfs/chfs_wbuf.c | 60 ++---
sys/ufs/chfs/chfs_write.c | 327 ++++++++++++++++-----------------
sys/ufs/chfs/ebh.h | 9 +-
sys/ufs/chfs/ebh_misc.h | 16 +-
sys/ufs/chfs/media.h | 195 +++++++-------------
21 files changed, 1052 insertions(+), 1539 deletions(-)
diffs (truncated from 6598 to 300 lines):
diff -r 7abffc246e05 -r 1e2ede38618a sys/ufs/chfs/chfs.h
--- a/sys/ufs/chfs/chfs.h Fri Oct 19 12:36:24 2012 +0000
+++ b/sys/ufs/chfs/chfs.h Fri Oct 19 12:44:39 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chfs.h,v 1.7 2012/08/10 09:26:58 ttoth Exp $ */
+/* $NetBSD: chfs.h,v 1.8 2012/10/19 12:44:39 ttoth Exp $ */
/*-
* Copyright (c) 2010 Department of Software Engineering,
@@ -42,8 +42,8 @@
#ifdef _KERNEL
#if 0
-#define DBG_MSG
-#define DBG_MSG_GC
+#define DBG_MSG /* debug messages */
+#define DBG_MSG_GC /* garbage collector's debug messages */
#endif
#include <sys/param.h>
@@ -80,6 +80,7 @@
#include "media.h"
#include "chfs_inode.h"
+/* padding - last two bits used for node masks */
#define CHFS_PAD(x) (((x)+3)&~3)
#ifdef _KERNEL
@@ -88,17 +89,19 @@
#define MOUNT_CHFS "chfs"
#endif /* MOUNT_CHFS */
+/* state of a vnode */
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() */
+ 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() */
};
+/* size of the vnode cache (hashtable) */
#define VNODECACHE_SIZE 128
#define MAX_READ_FREE(chmp) (((chmp)->chm_ebh)->eb_size / 8)
@@ -106,6 +109,7 @@
#define MAX_DIRTY_TO_CLEAN 255
#define VERY_DIRTY(chmp, size) ((size) >= (((chmp)->chm_ebh)->eb_size / 2))
+/* node errors */
enum {
CHFS_NODE_OK = 0,
CHFS_NODE_BADMAGIC,
@@ -113,6 +117,7 @@
CHFS_NODE_BADNAMECRC
};
+/* eraseblock states */
enum {
CHFS_BLK_STATE_FREE = 100,
CHFS_BLK_STATE_CLEAN,
@@ -123,25 +128,23 @@
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 - a reference to a node which is on the media */
struct chfs_node_ref
{
- struct chfs_node_ref *nref_next;
- uint32_t nref_lnr;
- uint32_t nref_offset;
+ struct chfs_node_ref *nref_next; /* next data node which belongs to the same vnode */
+ uint32_t nref_lnr; /* nref's LEB number */
+ uint32_t nref_offset; /* nref's offset */
};
-/* Constants for allocating node refs */
+/*
+ * constants for allocating node refs
+ * they're allocated in blocks
+ */
#define REFS_BLOCK_LEN (255/sizeof(struct chfs_node_ref))
#define REF_EMPTY_NODE (UINT_MAX)
#define REF_LINK_TO_NEXT (UINT_MAX - 1)
+/* node masks - last two bits of the nodes ("state" of an nref) */
enum {
CHFS_NORMAL_NODE_MASK,
CHFS_UNCHECKED_NODE_MASK,
@@ -158,83 +161,84 @@
#define CHFS_GET_OFS(ofs) (ofs & ~ 3)
+/*
+ * Nrefs are allocated in blocks, get the (in-memory) next. Usually the next
+ * doesn't belongs to the same vnode.
+ */
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);
+ /* step to the next nref in the same block */
nref++;
- //dbg("nref++: %u : %u\n", nref->nref_lnr, nref->nref_offset);
+ /* REF_LINK_TO_NEXT means that the next node will be in the next block */
if (nref->nref_lnr == REF_LINK_TO_NEXT) {
- //dbg("link to next\n");
nref = nref->nref_next;
if (!nref)
return nref;
}
+ /* REF_EMPTY_NODE means that this is the last node */
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 - 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 chtype type;
- uint8_t nsize;
- uint8_t name[0];
+ struct chfs_node_ref *nref; /* nref of the dirent */
+ TAILQ_ENTRY(chfs_dirent) fds; /* directory entries */
+ uint64_t version; /* version */
+ ino_t vno; /* vnode number */
+ uint32_t nhash; /* name hash */
+ enum chtype type; /* type of the dirent */
+ uint8_t nsize; /* length of its name */
+ uint8_t name[0]; /* name of the directory */
+};
- /* used by chfs_alloc_dirent and free counterpart */
-// size_t alloc_size;
+/* struct chfs_tmp_dnode - used temporarly while building a data node */
+struct chfs_tmp_dnode {
+ struct chfs_full_dnode *node; /* associated full dnode */
+ uint64_t version; /* version of the tmp node */
+ uint32_t data_crc; /* CRC of the data */
+ uint16_t overlapped; /* is overlapped */
+ struct chfs_tmp_dnode *next; /* next tmp node */
};
-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 - tmp nodes are stored in rb trees */
+struct chfs_tmp_dnode_info {
+ struct rb_node rb_node; /* rb tree entry */
+ struct chfs_tmp_dnode *tmpnode; /* associated tmp node */
};
-struct chfs_tmp_dnode_info {
- struct rb_node rb_node;
- struct chfs_tmp_dnode *tmpnode;
+/* struct chfs_readinode_info - collection of tmp_dnodes */
+struct chfs_readinode_info {
+ struct rb_tree tdi_root; /* root of the rb tree */
+ struct chfs_tmp_dnode_info *mdata_tn; /* metadata (eg: symlink) */
+ uint64_t highest_version; /* highest version of the nodes */
+ struct chfs_node_ref *latest_ref; /* latest node reference */
};
-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 - full data node */
+struct chfs_full_dnode {
+ struct chfs_node_ref *nref; /* nref of the node */
+ uint64_t ofs; /* offset of the data node */
+ uint32_t size; /* size of the data node */
+ uint32_t frags; /* number of fragmentations */
};
-struct chfs_full_dnode {
- struct chfs_node_ref *nref;
- uint64_t ofs;
- uint32_t size;
- uint32_t frags;
+/* struct chfs_node_frag - a fragment of a data node */
+struct chfs_node_frag {
+ struct rb_node rb_node; /* rb tree entry */
+ struct chfs_full_dnode *node; /* associated full dnode */
+ uint32_t size; /* size of the fragment */
+ uint64_t ofs; /* offset of the fragment */
};
-struct chfs_node_frag {
- struct rb_node rb_node;
- struct chfs_full_dnode *node;
- uint32_t size;
- uint64_t ofs;
-};
-
+/* find the first fragment of a data node */
static inline struct chfs_node_frag *
frag_first(struct rb_tree *tree)
{
@@ -245,6 +249,7 @@
return frag;
}
+/* find the last fragment of a data node */
static inline struct chfs_node_frag *
frag_last(struct rb_tree *tree)
{
@@ -255,149 +260,129 @@
return frag;
}
+/* iterate the fragtree */
#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
-*/
-
-/* for prototypes, properly defined in chfs_inode.h */
-//struct chfs_inode_ext;
+/* struct chfs_vnode_cache - in memory representation of a file or directory */
+struct chfs_vnode_cache {
+ /*
+ * void *p must be the first field of the structure
+ * but I can't remember where we use it and exactly for what
+ */
+ void *p;
+ struct chfs_dirent_list scan_dirents; /* used during scanning */
-/**
- * struct chfs_vnode_cache - in memory representation of a vnode
- * @v: pointer to the vnode info node
- * @dnode: pointer to the list of data nodes
- * @dirents: pointer to the list of directory entries
- * @vno_version: used only during scan, holds the current version number of
- * chfs_flash_vnode
- * @scan_dirents: used only during scan, holds the full representation of
- * directory entries of this vnode
- * @pvno: parent vnode number
- * @nlink: number of links to this vnode
- */
-struct chfs_vnode_cache {
-// struct chfs_dirent *scan_dirents;
- void *p;
- struct chfs_dirent_list scan_dirents;
+ struct chfs_node_ref *v; /* list of node informations */
+ struct chfs_node_ref *dnode; /* list of data nodes */
+ struct chfs_node_ref *dirents; /* list of directory entries */
+
+ uint64_t *vno_version; /* version of the vnode */
+ uint64_t highest_version; /* highest version of dnodes */
- struct chfs_node_ref *v;
- struct chfs_node_ref *dnode;
- struct chfs_node_ref *dirents;
-
- uint64_t *vno_version;
Home |
Main Index |
Thread Index |
Old Index