mm-only debug patch...
[mmotm.git] / fs / reiser4 / kassign.h
blob8de30027ca76c6a0bd00b2b3c87a19926b1e56e4
1 /* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by
2 * reiser4/README */
4 /* Key assignment policy interface. See kassign.c for details. */
6 #if !defined(__KASSIGN_H__)
7 #define __KASSIGN_H__
9 #include "forward.h"
10 #include "key.h"
11 #include "dformat.h"
13 #include <linux/types.h> /* for __u?? */
14 #include <linux/fs.h> /* for struct super_block, etc */
15 #include <linux/dcache.h> /* for struct qstr */
17 /* key assignment functions */
19 /* Information from which key of file stat-data can be uniquely
20 restored. This depends on key assignment policy for
21 stat-data. Currently it's enough to store object id and locality id
22 (60+60==120) bits, because minor packing locality and offset of
23 stat-data key are always known constants: KEY_SD_MINOR and 0
24 respectively. For simplicity 4 bits are wasted in each id, and just
25 two 64 bit integers are stored.
27 This field has to be byte-aligned, because we don't want to waste
28 space in directory entries. There is another side of a coin of
29 course: we waste CPU and bus bandwidth in stead, by copying data back
30 and forth.
32 Next optimization: &obj_key_id is mainly used to address stat data from
33 directory entries. Under the assumption that majority of files only have
34 only name (one hard link) from *the* parent directory it seems reasonable
35 to only store objectid of stat data and take its locality from key of
36 directory item.
38 This requires some flag to be added to the &obj_key_id to distinguish
39 between these two cases. Remaining bits in flag byte are then asking to be
40 used to store file type.
42 This optimization requires changes in directory item handling code.
45 typedef struct obj_key_id {
46 d8 locality[sizeof(__u64)];
47 ON_LARGE_KEY(d8 ordering[sizeof(__u64)];
49 d8 objectid[sizeof(__u64)];
51 obj_key_id;
53 /* Information sufficient to uniquely identify directory entry within
54 compressed directory item.
56 For alignment issues see &obj_key_id above.
58 typedef struct de_id {
59 ON_LARGE_KEY(d8 ordering[sizeof(__u64)];)
60 d8 objectid[sizeof(__u64)];
61 d8 offset[sizeof(__u64)];
63 de_id;
65 extern int inode_onwire_size(const struct inode *obj);
66 extern char *build_inode_onwire(const struct inode *obj, char *area);
67 extern char *locate_obj_key_id_onwire(char *area);
68 extern char *extract_obj_key_id_from_onwire(char *area, obj_key_id * key_id);
70 extern int build_inode_key_id(const struct inode *obj, obj_key_id * id);
71 extern int extract_key_from_id(const obj_key_id * id, reiser4_key * key);
72 extern int build_obj_key_id(const reiser4_key * key, obj_key_id * id);
73 extern oid_t extract_dir_id_from_key(const reiser4_key * de_key);
74 extern int build_de_id(const struct inode *dir, const struct qstr *name,
75 de_id * id);
76 extern int build_de_id_by_key(const reiser4_key * entry_key, de_id * id);
77 extern int extract_key_from_de_id(const oid_t locality, const de_id * id,
78 reiser4_key * key);
79 extern cmp_t de_id_cmp(const de_id * id1, const de_id * id2);
80 extern cmp_t de_id_key_cmp(const de_id * id, const reiser4_key * key);
82 extern int build_readdir_key_common(struct file *dir, reiser4_key * result);
83 extern void build_entry_key_common(const struct inode *dir,
84 const struct qstr *name,
85 reiser4_key * result);
86 extern void build_entry_key_stable_entry(const struct inode *dir,
87 const struct qstr *name,
88 reiser4_key * result);
89 extern int is_dot_key(const reiser4_key * key);
90 extern reiser4_key *build_sd_key(const struct inode *target,
91 reiser4_key * result);
93 extern int is_longname_key(const reiser4_key * key);
94 extern int is_longname(const char *name, int len);
95 extern char *extract_name_from_key(const reiser4_key * key, char *buf);
96 extern char *reiser4_unpack_string(__u64 value, char *buf);
97 extern void complete_entry_key(const struct inode *dir, const char *name,
98 int len, reiser4_key *result);
100 /* __KASSIGN_H__ */
101 #endif
103 /* Make Linus happy.
104 Local variables:
105 c-indentation-style: "K&R"
106 mode-name: "LC"
107 c-basic-offset: 8
108 tab-width: 8
109 fill-column: 120
110 End: