1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
4 #if !defined(__REISER4_FSDATA_H__)
5 #define __REISER4_FSDATA_H__
10 #include "type_safe_hash.h"
11 #include "plugin/file/file.h"
12 #include "readahead.h"
15 * comment about reiser4_dentry_fsdata
21 * locking: fields of per file descriptor readdir_pos and ->f_pos are
22 * protected by ->i_mutex on inode. Under this lock following invariant
25 * file descriptor is "looking" at the entry_no-th directory entry from
26 * the beginning of directory. This entry has key dir_entry_key and is
27 * pos-th entry with duplicate-key sequence.
31 /* logical position within directory */
33 /* key of directory entry (actually, part of a key sufficient to
34 identify directory entry) */
36 /* ordinal number of directory entry among all entries with the same
37 key. (Starting from 0.) */
42 /* f_pos corresponding to this readdir position */
44 /* logical position within directory */
45 struct dir_pos position
;
46 /* logical number of directory entry within
52 * this is used to speed up lookups for directory entry: on initial call to
53 * ->lookup() seal and coord of directory entry (if found, that is) are stored
54 * in struct dentry and reused later to avoid tree traversals.
57 /* seal covering directory entry */
59 /* coord of directory entry */
61 /* ordinal number of directory entry among all entries with the same
62 key. (Starting from 0.) */
67 * reiser4_dentry_fsdata - reiser4-specific data attached to dentries
69 * This is allocated dynamically and released in d_op->d_release()
71 * Currently it only contains cached location (hint) of directory entry, but
72 * it is expected that other information will be accumulated here.
74 struct reiser4_dentry_fsdata
{
76 * here will go fields filled by ->lookup() to speedup next
77 * create/unlink, like blocknr of znode with stat-data, or key of
80 struct de_location dec
;
81 int stateless
; /* created through reiser4_decode_fh, needs
82 * special treatment in readdir. */
85 extern int reiser4_init_dentry_fsdata(void);
86 extern void reiser4_done_dentry_fsdata(void);
87 extern struct reiser4_dentry_fsdata
*reiser4_get_dentry_fsdata(struct dentry
*);
88 extern void reiser4_free_dentry_fsdata(struct dentry
*dentry
);
91 * reiser4_file_fsdata - reiser4-specific data attached to file->private_data
93 * This is allocated dynamically and released in inode->i_fop->release
95 typedef struct reiser4_file_fsdata
{
97 * pointer back to the struct file which this reiser4_file_fsdata is
101 /* detached cursor for stateless readdir. */
102 struct dir_cursor
*cursor
;
104 * We need both directory and regular file parts here, because there
105 * are file system objects that are files and directories.
109 * position in directory. It is updated each time directory is
112 struct readdir_pos readdir
;
113 /* head of this list is reiser4_inode->lists.readdir_list */
114 struct list_head linkage
;
116 /* hints to speed up operations with regular files: read and write. */
120 struct reiser4_file_ra_state ra1
;
122 } reiser4_file_fsdata
;
124 extern int reiser4_init_file_fsdata(void);
125 extern void reiser4_done_file_fsdata(void);
126 extern reiser4_file_fsdata
*reiser4_get_file_fsdata(struct file
*);
127 extern void reiser4_free_file_fsdata(struct file
*);
130 * d_cursor is reiser4_file_fsdata not attached to struct file. d_cursors are
131 * used to address problem reiser4 has with readdir accesses via NFS. See
132 * plugin/file_ops_readdir.c for more details.
140 * define structures d_cursor_hash_table d_cursor_hash_link which are used to
141 * maintain hash table of dir_cursor-s in reiser4's super block
143 typedef struct dir_cursor dir_cursor
;
144 TYPE_SAFE_HASH_DECLARE(d_cursor
, dir_cursor
);
148 reiser4_file_fsdata
*fsdata
;
150 /* link to reiser4 super block hash table of cursors */
151 d_cursor_hash_link hash
;
154 * this is to link cursors to reiser4 super block's radix tree of
155 * cursors if there are more than one cursor of the same objectid
157 struct list_head list
;
158 struct d_cursor_key key
;
159 struct d_cursor_info
*info
;
160 /* list of unused cursors */
161 struct list_head alist
;
164 extern int reiser4_init_d_cursor(void);
165 extern void reiser4_done_d_cursor(void);
167 extern int reiser4_init_super_d_info(struct super_block
*);
168 extern void reiser4_done_super_d_info(struct super_block
*);
170 extern loff_t
reiser4_get_dir_fpos(struct file
*);
171 extern int reiser4_attach_fsdata(struct file
*, struct inode
*);
172 extern void reiser4_detach_fsdata(struct file
*);
174 /* these are needed for "stateless" readdir. See plugin/file_ops_readdir.c for
176 void reiser4_dispose_cursors(struct inode
*inode
);
177 void reiser4_load_cursors(struct inode
*inode
);
178 void reiser4_kill_cursors(struct inode
*inode
);
179 void reiser4_adjust_dir_file(struct inode
*dir
, const struct dentry
*de
,
180 int offset
, int adj
);
183 * this structure is embedded to reise4_super_info_data. It maintains d_cursors
184 * (detached readdir state). See plugin/file_ops_readdir.c for more details.
186 struct d_cursor_info
{
187 d_cursor_hash_table table
;
188 struct radix_tree_root tree
;
191 /* spinlock protecting readdir cursors */
192 extern spinlock_t d_lock
;
194 /* __REISER4_FSDATA_H__ */
199 * c-indentation-style: "K&R"