| changeset 581: |
8eb99e3d9904 |
| parent 580: | 05354dc10bec |
| child 582: | 1ade293577b0 |
| author: |
daniel@moonbase.phunq.net |
| date: |
Wed Dec 03 14:56:56 2008 -0800 (20 months ago) |
| files: |
user/kernel/tux3.h |
| description: |
The "Dmitri Asimov" patch. Start commenting structure fields. Naturally, found an unused field, deleted. No need for bit fields in struct root. |
1--- a/user/kernel/tux3.h Tue Dec 02 23:12:28 2008 -0800
2+++ b/user/kernel/tux3.h Wed Dec 03 14:56:56 2008 -0800
3@@ -171,26 +171,35 @@ static inline void *decode48(void *at, u
4
5 struct disksuper
6 {
7+ /* Update magic on any incompatible format change */
8 char magic[SB_MAGIC_SIZE];
9- be_u64 birthdate;
10- be_u64 flags;
11- be_u64 iroot;
12- be_u64 aroot;
13- be_u16 blockbits;
14- be_u16 unused1;
15- be_u32 unused2;
16- be_u64 volblocks, freeblocks, nextalloc;
17+ be_u64 birthdate; /* Volume creation date */
18+ be_u64 flags; /* Need to assign some flags */
19+ be_u64 iroot; /* Root of the inode table btree */
20+ be_u64 aroot; /* The atime table is a file now, delete on next format rev */
21+ be_u16 blockbits; /* Shift to get volume block size */
22+ be_u16 unused1; /* Throw away on next format rev */
23+ be_u32 unused2; /* Throw away on next format rev */
24+ be_u64 volblocks; /* Volume size */
25+ /* The rest should be moved to a "metablock" that is updated frequently */
26+ be_u64 freeblocks; /* Should match total of zero bits in allocation bitmap */
27+ be_u64 nextalloc; /* Get rid of this when we have a real allocation policy */
28 be_u32 freeatom, atomgen;
29 };
30
31-struct root { u64 depth:16, block:48; };
32+struct root {
33+ unsigned depth; /* btree levels not including leaf level */
34+ block_t block; /* disk location of btree root */
35+};
36
37 struct btree {
38- struct sb *sb;
39- struct btree_ops *ops;
40- struct root root;
41- u16 entries_per_leaf;
42+ struct sb *sb; /* Convenience to reduce parameter list size */
43+ struct btree_ops *ops; /* Generic btree low level operations */
44+ struct root root; /* Cached description of btree root */
45+ u16 entries_per_leaf; /* Used in btree leaf splitting */
46 };
47+
48+/* Define layout of btree root on disk, endian conversion is elsewhere. */
49
50 static inline u64 pack_root(struct root *root)
51 {
52@@ -201,6 +210,8 @@ static inline struct root unpack_root(u6
53 {
54 return (struct root){ .depth = v >> 48, .block = v & (-1ULL >> 16), };
55 }
56+
57+/* Path cursor for btree traversal */
58
59 struct cursor {
60 #define CURSOR_DEBUG
61@@ -216,31 +227,47 @@ struct cursor {
62 } path[];
63 };
64
65+/* Tux3-specific sb is a handle for the entire volume state */
66+
67 struct sb {
68 struct disksuper super;
69-
70- struct btree itable;
71- struct buffer_head *rootbuf;
72- struct inode *bitmap, *rootdir, *vtable, *atable;
73+ struct btree itable; /* Cached root of the inode table */
74+ struct inode *bitmap; /* allocation bitmap special file */
75+ struct inode *rootdir; /* root directory special file */
76+ struct inode *vtable; /* version table special file */
77+ struct inode *atable; /* xattr atom special file */
78 unsigned blocksize, blockbits, blockmask;
79 block_t volblocks, freeblocks, nextalloc;
80- unsigned entries_per_node, max_inodes_per_block;
81- unsigned version, atomref_base, unatom_base;
82- unsigned freeatom, atomgen;
83+ unsigned entries_per_node; /* must be per-btree type, get rid of this */
84+ unsigned max_inodes_per_block; /* get rid of this and use entries per leaf */
85+ unsigned version; /* Currently mounted volume version view */
86+ unsigned atomref_base, unatom_base; /* layout of atom table */
87+ unsigned freeatom; /* Start of free atom list in atom table */
88+ unsigned atomgen; /* Next atom number to allocate if no free atoms */
89 #ifdef __KERNEL__
90- struct super_block *vfs_sb;
91+ struct super_block *vfs_sb; /* Generic kernel superblock */
92 #else
93- map_t *devmap;
94+ map_t *devmap; /* Userspace device block cache */
95 #endif
96 };
97
98 #ifdef __KERNEL__
99+/*
100+ * In kernel an inode has a generic part and a filesystem-specific part
101+ * with conversions between them, in order to support multiple different
102+ * kinds of filesystem. In userspace there is only one kind of filesystem,
103+ * Tux3, so no need for two kinds of inodes, and a big pain to initialize
104+ * inodes for testing if there were. We use a typedef here so that the
105+ * filesystem-specific type can be transparently aliased to the generic
106+ * inode type in userspace and be a separate type in kernel.
107+ */
108+
109 typedef struct {
110 struct btree btree;
111- inum_t inum;
112- unsigned present;
113- struct xcache *xcache;
114- struct inode vfs_inode;
115+ inum_t inum; /* Inode number. Fixme: also in generic inode */
116+ unsigned present; /* Attributes decoded from or to be encoded to inode table */
117+ struct xcache *xcache; /* Extended attribute cache */
118+ struct inode vfs_inode; /* Generic kernel inode */
119 } tuxnode_t;
120
121 static inline struct sb *tux_sb(struct super_block *sb)