1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
4 /* Basic plugin data-types.
5 see fs/reiser4/plugin/plugin.c for details */
7 #if !defined(__FS_REISER4_PLUGIN_TYPES_H__)
8 #define __FS_REISER4_PLUGIN_TYPES_H__
10 #include "../forward.h"
12 #include "../dformat.h"
14 #include "compress/compress.h"
15 #include "crypto/cipher.h"
16 #include "plugin_header.h"
17 #include "item/static_stat.h"
18 #include "item/internal.h"
21 #include "item/item.h"
22 #include "node/node.h"
23 #include "node/node40.h"
24 #include "security/perm.h"
25 #include "fibration.h"
27 #include "space/bitmap.h"
28 #include "space/space_allocator.h"
30 #include "disk_format/disk_format40.h"
31 #include "disk_format/disk_format.h"
33 #include <linux/fs.h> /* for struct super_block, address_space */
34 #include <linux/mm.h> /* for struct page */
35 #include <linux/buffer_head.h> /* for struct buffer_head */
36 #include <linux/dcache.h> /* for struct dentry */
37 #include <linux/types.h>
38 #include <linux/crypto.h>
40 typedef struct reiser4_object_on_wire reiser4_object_on_wire
;
43 * File plugin. Defines the set of methods that file plugins implement, some
44 * of which are optional.
46 * A file plugin offers to the caller an interface for IO ( writing to and/or
47 * reading from) to what the caller sees as one sequence of bytes. An IO to it
48 * may affect more than one physical sequence of bytes, or no physical sequence
49 * of bytes, it may affect sequences of bytes offered by other file plugins to
50 * the semantic layer, and the file plugin may invoke other plugins and
51 * delegate work to them, but its interface is structured for offering the
52 * caller the ability to read and/or write what the caller sees as being a
53 * single sequence of bytes.
55 * The file plugin must present a sequence of bytes to the caller, but it does
56 * not necessarily have to store a sequence of bytes, it does not necessarily
57 * have to support efficient tree traversal to any offset in the sequence of
58 * bytes (tail and extent items, whose keys contain offsets, do however provide
59 * efficient non-sequential lookup of any offset in the sequence of bytes).
61 * Directory plugins provide methods for selecting file plugins by resolving a
64 * The functionality other filesystems call an attribute, and rigidly tie
65 * together, we decompose into orthogonal selectable features of files. Using
66 * the terminology we will define next, an attribute is a perhaps constrained,
67 * perhaps static length, file whose parent has a uni-count-intra-link to it,
68 * which might be grandparent-major-packed, and whose parent has a deletion
69 * method that deletes it.
71 * File plugins can implement constraints.
73 * Files can be of variable length (e.g. regular unix files), or of static
74 * length (e.g. static sized attributes).
76 * An object may have many sequences of bytes, and many file plugins, but, it
77 * has exactly one objectid. It is usually desirable that an object has a
78 * deletion method which deletes every item with that objectid. Items cannot
79 * in general be found by just their objectids. This means that an object must
80 * have either a method built into its deletion plugin method for knowing what
81 * items need to be deleted, or links stored with the object that provide the
82 * plugin with a method for finding those items. Deleting a file within an
83 * object may or may not have the effect of deleting the entire object,
84 * depending on the file plugin's deletion method.
88 * Many objects have a reference count, and when the reference count reaches 0
89 * the object's deletion method is invoked. Some links embody a reference
90 * count increase ("countlinks"), and others do not ("nocountlinks").
92 * Some links are bi-directional links ("bilinks"), and some are
93 * uni-directional("unilinks").
95 * Some links are between parts of the same object ("intralinks"), and some are
96 * between different objects ("interlinks").
100 * Some items of an object are stored with a major packing locality based on
101 * their object's objectid (e.g. unix directory items in plan A), and these are
102 * called "self-major-packed".
104 * Some items of an object are stored with a major packing locality based on
105 * their semantic parent object's objectid (e.g. unix file bodies in plan A),
106 * and these are called "parent-major-packed".
108 * Some items of an object are stored with a major packing locality based on
109 * their semantic grandparent, and these are called "grandparent-major-packed".
110 * Now carefully notice that we run into trouble with key length if we have to
111 * store a 8 byte major+minor grandparent based packing locality, an 8 byte
112 * parent objectid, an 8 byte attribute objectid, and an 8 byte offset, all in
113 * a 24 byte key. One of these fields must be sacrificed if an item is to be
114 * grandparent-major-packed, and which to sacrifice is left to the item author
115 * choosing to make the item grandparent-major-packed. You cannot make tail
116 * items and extent items grandparent-major-packed, though you could make them
117 * self-major-packed (usually they are parent-major-packed).
119 * In the case of ACLs (which are composed of fixed length ACEs which consist
120 * of {subject-type, subject, and permission bitmask} triples), it makes sense
121 * to not have an offset field in the ACE item key, and to allow duplicate keys
122 * for ACEs. Thus, the set of ACES for a given file is found by looking for a
123 * key consisting of the objectid of the grandparent (thus grouping all ACLs in
124 * a directory together), the minor packing locality of ACE, the objectid of
127 * IO involves moving data from one location to another, which means that two
128 * locations must be specified, source and destination.
130 * This source and destination can be in the filesystem, or they can be a
131 * pointer in the user process address space plus a byte count.
133 * If both source and destination are in the filesystem, then at least one of
134 * them must be representable as a pure stream of bytes (which we call a flow,
135 * and define as a struct containing a key, a data pointer, and a length).
136 * This may mean converting one of them into a flow. We provide a generic
137 * cast_into_flow() method, which will work for any plugin supporting
138 * read_flow(), though it is inefficiently implemented in that it temporarily
139 * stores the flow in a buffer (Question: what to do with huge flows that
140 * cannot fit into memory? Answer: we must not convert them all at once. )
142 * Performing a write requires resolving the write request into a flow defining
143 * the source, and a method that performs the write, and a key that defines
144 * where in the tree the write is to go.
146 * Performing a read requires resolving the read request into a flow defining
147 * the target, and a method that performs the read, and a key that defines
148 * where in the tree the read is to come from.
150 * There will exist file plugins which have no pluginid stored on the disk for
151 * them, and which are only invoked by other plugins.
154 /* This should be incremented with each new contributed
155 pair (plugin type, plugin id).
156 NOTE: Make sure there is a release of reiser4progs
157 with the corresponding version number */
158 #define PLUGIN_LIBRARY_VERSION 0
160 /* enumeration of fields within plugin_set */
163 PSET_DIR
, /* PSET_FILE and PSET_DIR should be first
164 * elements: inode.c:read_inode() depends on
175 PSET_COMPRESSION_MODE
,
181 /* builtin file-plugins */
186 DIRECTORY_FILE_PLUGIN_ID
,
188 SYMLINK_FILE_PLUGIN_ID
,
189 /* for objects completely handled by the VFS: fifos, devices,
191 SPECIAL_FILE_PLUGIN_ID
,
192 /* regular cryptcompress file */
193 CRYPTCOMPRESS_FILE_PLUGIN_ID
,
194 /* number of file plugins. Used as size of arrays to hold
199 typedef struct file_plugin
{
205 * Must be invariant with respect to plugin conversion.
206 * It can be achieved by using "common" methods, which
207 * are the same for all plugins that take participation in
208 * conversion, or by using "generic" or "careful" methods,
209 * which provide automatic redirection to proper private
210 * plugin methods ("careful" are the same as "generic",
211 * but with protection of pset and other disk structures
212 * from being rebuilt during conversion.
214 struct inode_operations
* inode_ops
;
215 struct file_operations
* file_ops
;
216 struct address_space_operations
* as_ops
;
218 * Private methods. These are optional. If used they will allow you
219 * to minimize the amount of code needed to implement a deviation
220 * from some other method that also uses them.
225 int (*setattr
)(struct dentry
*, struct iattr
*);
229 /* do whatever is necessary to do when object is opened */
230 int (*open
) (struct inode
*inode
, struct file
*file
);
231 ssize_t (*read
) (struct file
*, char __user
*buf
, size_t read_amount
,
233 /* write as much as possible bytes from nominated @write_amount
234 * before plugin scheduling is occurred. Save scheduling state
236 ssize_t (*write
) (struct file
*, const char __user
*buf
,
237 size_t write_amount
, loff_t
* off
,
238 struct dispatch_context
* cont
);
239 int (*ioctl
) (struct inode
*inode
, struct file
*filp
,
240 unsigned int cmd
, unsigned long arg
);
241 int (*mmap
) (struct file
*, struct vm_area_struct
*);
242 int (*release
) (struct inode
*, struct file
*);
246 int (*readpage
) (struct file
*file
, struct page
*page
);
247 int (*readpages
)(struct file
*file
, struct address_space
*mapping
,
248 struct list_head
*pages
, unsigned nr_pages
);
249 int (*writepages
)(struct address_space
*mapping
,
250 struct writeback_control
*wbc
);
251 int (*write_begin
)(struct file
*file
, struct page
*page
,
252 unsigned from
, unsigned to
);
253 int (*write_end
)(struct file
*file
, struct page
*page
,
254 unsigned from
, unsigned to
);
255 sector_t (*bmap
) (struct address_space
* mapping
, sector_t lblock
);
256 /* other private methods */
257 /* save inode cached stat-data onto disk. It was called
258 reiserfs_update_sd() in 3.x */
259 int (*write_sd_by_inode
) (struct inode
*);
261 * Construct flow into @flow according to user-supplied data.
263 * This is used by read/write methods to construct a flow to
264 * write/read. ->flow_by_inode() is plugin method, rather than single
265 * global implementation, because key in a flow used by plugin may
266 * depend on data in a @buf.
268 * NIKITA-FIXME-HANS: please create statistics on what functions are
269 * dereferenced how often for the mongo benchmark. You can supervise
270 * Elena doing this for you if that helps. Email me the list of the
271 * top 10, with their counts, and an estimate of the total number of
272 * CPU cycles spent dereferencing as a percentage of CPU cycles spent
273 * processing (non-idle processing). If the total percent is, say,
274 * less than 1%, it will make our coding discussions much easier, and
275 * keep me from questioning whether functions like the below are too
276 * frequently called to be dereferenced. If the total percent is more
277 * than 1%, perhaps private methods should be listed in a "required"
278 * comment at the top of each plugin (with stern language about how if
279 * the comment is missing it will not be accepted by the maintainer),
280 * and implemented using macros not dereferenced functions. How about
281 * replacing this whole private methods part of the struct with a
282 * thorough documentation of what the standard helper functions are for
283 * use in constructing plugins? I think users have been asking for
284 * that, though not in so many words.
286 int (*flow_by_inode
) (struct inode
*, const char __user
*buf
,
287 int user
, loff_t size
,
288 loff_t off
, rw_op op
, flow_t
*);
290 * Return the key used to retrieve an offset of a file. It is used by
291 * default implementation of ->flow_by_inode() method
292 * (common_build_flow()) and, among other things, to get to the extent
293 * from jnode of unformatted node.
295 int (*key_by_inode
) (struct inode
*, loff_t off
, reiser4_key
*);
297 /* NIKITA-FIXME-HANS: this comment is not as clear to others as you
300 * set the plugin for a file. Called during file creation in creat()
301 * but not reiser4() unless an inode already exists for the file.
303 int (*set_plug_in_inode
) (struct inode
*inode
, struct inode
*parent
,
304 reiser4_object_create_data
*);
306 /* NIKITA-FIXME-HANS: comment and name seem to say different things,
307 * are you setting up the object itself also or just adjusting the
309 /* set up plugins for new @object created in @parent. @root is root
311 int (*adjust_to_parent
) (struct inode
*object
, struct inode
*parent
,
314 * this does whatever is necessary to do when object is created. For
315 * instance, for unix files stat data is inserted. It is supposed to be
316 * called by create of struct inode_operations.
318 int (*create_object
) (struct inode
*object
, struct inode
*parent
,
319 reiser4_object_create_data
*);
321 * this method should check REISER4_NO_SD and set REISER4_NO_SD on
322 * success. Deletion of an object usually includes removal of items
323 * building file body (for directories this is removal of "." and "..")
324 * and removal of stat-data item.
326 int (*delete_object
) (struct inode
*);
328 /* add link from @parent to @object */
329 int (*add_link
) (struct inode
*object
, struct inode
*parent
);
331 /* remove link from @parent to @object */
332 int (*rem_link
) (struct inode
*object
, struct inode
*parent
);
335 * return true if item addressed by @coord belongs to @inode. This is
336 * used by read/write to properly slice flow into items in presence of
337 * multiple key assignment policies, because items of a file are not
338 * necessarily contiguous in a key space, for example, in a plan-b.
340 int (*owns_item
) (const struct inode
*, const coord_t
*);
342 /* checks whether yet another hard links to this object can be
344 int (*can_add_link
) (const struct inode
*);
346 /* checks whether hard links to this object can be removed */
347 int (*can_rem_link
) (const struct inode
*);
349 /* not empty for DIRECTORY_FILE_PLUGIN_ID only currently. It calls
350 detach of directory plugin to remove ".." */
351 int (*detach
) (struct inode
*child
, struct inode
*parent
);
353 /* called when @child was just looked up in the @parent. It is not
354 empty for DIRECTORY_FILE_PLUGIN_ID only where it calls attach of
356 int (*bind
) (struct inode
*child
, struct inode
*parent
);
358 /* process safe-link during mount */
359 int (*safelink
) (struct inode
*object
, reiser4_safe_link_t link
,
362 /* The couple of estimate methods for all file operations */
364 reiser4_block_nr(*create
) (const struct inode
*);
365 reiser4_block_nr(*update
) (const struct inode
*);
366 reiser4_block_nr(*unlink
) (const struct inode
*,
367 const struct inode
*);
371 * reiser4 specific part of inode has a union of structures which are
372 * specific to a plugin. This method is called when inode is read
373 * (read_inode) and when file is created (common_create_child) so that
374 * file plugin could initialize its inode data
376 void (*init_inode_data
) (struct inode
*, reiser4_object_create_data
* ,
380 * This method performs progressive deletion of items and whole nodes
381 * from right to left.
383 * @tap: the point deletion process begins from,
384 * @from_key: the beginning of the deleted key range,
385 * @to_key: the end of the deleted key range,
386 * @smallest_removed: the smallest removed key,
388 * @return: 0 if success, error code otherwise, -E_REPEAT means that
389 * long cut_tree operation was interrupted for allowing atom commit .
391 int (*cut_tree_worker
) (tap_t
*, const reiser4_key
* from_key
,
392 const reiser4_key
* to_key
,
393 reiser4_key
* smallest_removed
, struct inode
*,
396 /* called from ->destroy_inode() */
397 void (*destroy_inode
) (struct inode
*);
400 * methods to serialize object identify. This is used, for example, by
401 * reiser4_{en,de}code_fh().
404 /* store object's identity at @area */
405 char *(*write
) (struct inode
*inode
, char *area
);
406 /* parse object from wire to the @obj */
407 char *(*read
) (char *area
, reiser4_object_on_wire
* obj
);
408 /* given object identity in @obj, find or create its dentry */
409 struct dentry
*(*get
) (struct super_block
*s
,
410 reiser4_object_on_wire
* obj
);
411 /* how many bytes ->wire.write() consumes */
412 int (*size
) (struct inode
*inode
);
413 /* finish with object identify */
414 void (*done
) (reiser4_object_on_wire
* obj
);
418 extern file_plugin file_plugins
[LAST_FILE_PLUGIN_ID
];
420 struct reiser4_object_on_wire
{
430 /* builtin dir-plugins */
432 HASHED_DIR_PLUGIN_ID
,
433 SEEKABLE_HASHED_DIR_PLUGIN_ID
,
437 typedef struct dir_plugin
{
441 struct inode_operations
* inode_ops
;
442 struct file_operations
* file_ops
;
443 struct address_space_operations
* as_ops
;
446 * private methods: These are optional. If used they will allow you to
447 * minimize the amount of code needed to implement a deviation from
448 * some other method that uses them. You could logically argue that
449 * they should be a separate type of plugin.
452 struct dentry
*(*get_parent
) (struct inode
*childdir
);
455 * check whether "name" is acceptable name to be inserted into this
456 * object. Optionally implemented by directory-like objects. Can check
457 * for maximal length, reserved symbols etc
459 int (*is_name_acceptable
) (const struct inode
*inode
, const char *name
,
462 void (*build_entry_key
) (const struct inode
*dir
/* directory where
465 const struct qstr
*name
/* name of file
468 reiser4_key
* result
/* resulting key of
469 * directory entry */ );
470 int (*build_readdir_key
) (struct file
*dir
, reiser4_key
* result
);
471 int (*add_entry
) (struct inode
*object
, struct dentry
*where
,
472 reiser4_object_create_data
* data
,
473 reiser4_dir_entry_desc
* entry
);
474 int (*rem_entry
) (struct inode
*object
, struct dentry
*where
,
475 reiser4_dir_entry_desc
* entry
);
478 * initialize directory structure for newly created object. For normal
479 * unix directories, insert dot and dotdot.
481 int (*init
) (struct inode
*object
, struct inode
*parent
,
482 reiser4_object_create_data
* data
);
484 /* destroy directory */
485 int (*done
) (struct inode
*child
);
487 /* called when @subdir was just looked up in the @dir */
488 int (*attach
) (struct inode
*subdir
, struct inode
*dir
);
489 int (*detach
) (struct inode
*subdir
, struct inode
*dir
);
492 reiser4_block_nr(*add_entry
) (const struct inode
*);
493 reiser4_block_nr(*rem_entry
) (const struct inode
*);
494 reiser4_block_nr(*unlink
) (const struct inode
*,
495 const struct inode
*);
499 extern dir_plugin dir_plugins
[LAST_DIR_ID
];
501 typedef struct formatting_plugin
{
504 /* returns non-zero iff file's tail has to be stored
506 int (*have_tail
) (const struct inode
*inode
, loff_t size
);
509 typedef struct hash_plugin
{
512 /* computes hash of the given name */
513 __u64(*hash
) (const unsigned char *name
, int len
);
516 typedef struct cipher_plugin
{
519 struct crypto_blkcipher
* (*alloc
) (void);
520 void (*free
) (struct crypto_blkcipher
*tfm
);
521 /* Offset translator. For each offset this returns (k * offset), where
522 k (k >= 1) is an expansion factor of the cipher algorithm.
523 For all symmetric algorithms k == 1. For asymmetric algorithms (which
524 inflate data) offset translation guarantees that all disk cluster's
525 units will have keys smaller then next cluster's one.
527 loff_t(*scale
) (struct inode
*inode
, size_t blocksize
, loff_t src
);
528 /* Cipher algorithms can accept data only by chunks of cipher block
529 size. This method is to align any flow up to cipher block size when
530 we pass it to cipher algorithm. To align means to append padding of
531 special format specific to the cipher algorithm */
532 int (*align_stream
) (__u8
*tail
, int clust_size
, int blocksize
);
533 /* low-level key manager (check, install, etc..) */
534 int (*setkey
) (struct crypto_tfm
*tfm
, const __u8
*key
,
535 unsigned int keylen
);
536 /* main text processing procedures */
537 void (*encrypt
) (__u32
*expkey
, __u8
*dst
, const __u8
*src
);
538 void (*decrypt
) (__u32
*expkey
, __u8
*dst
, const __u8
*src
);
541 typedef struct digest_plugin
{
544 /* fingerprint size in bytes */
546 struct crypto_hash
* (*alloc
) (void);
547 void (*free
) (struct crypto_hash
*tfm
);
550 typedef struct compression_plugin
{
554 /* the maximum number of bytes the size of the "compressed" data can
555 * exceed the uncompressed data. */
556 int (*overrun
) (unsigned src_len
);
557 coa_t(*alloc
) (tfm_action act
);
558 void (*free
) (coa_t coa
, tfm_action act
);
559 /* minimal size of the flow we still try to compress */
560 int (*min_size_deflate
) (void);
561 __u32(*checksum
) (char *data
, __u32 length
);
562 /* main transform procedures */
563 void (*compress
) (coa_t coa
, __u8
*src_first
, size_t src_len
,
564 __u8
*dst_first
, size_t *dst_len
);
565 void (*decompress
) (coa_t coa
, __u8
*src_first
, size_t src_len
,
566 __u8
*dst_first
, size_t *dst_len
);
567 } compression_plugin
;
569 typedef struct compression_mode_plugin
{
572 /* this is called when estimating compressibility
573 of a logical cluster by its content */
574 int (*should_deflate
) (struct inode
*inode
, cloff_t index
);
575 /* this is called when results of compression should be saved */
576 int (*accept_hook
) (struct inode
*inode
, cloff_t index
);
577 /* this is called when results of compression should be discarded */
578 int (*discard_hook
) (struct inode
*inode
, cloff_t index
);
579 } compression_mode_plugin
;
581 typedef struct cluster_plugin
{
587 typedef struct sd_ext_plugin
{
590 int (*present
) (struct inode
*inode
, char **area
, int *len
);
591 int (*absent
) (struct inode
*inode
);
592 int (*save_len
) (struct inode
*inode
);
593 int (*save
) (struct inode
*inode
, char **area
);
594 /* alignment requirement for this stat-data part */
598 /* this plugin contains methods to allocate objectid for newly created files,
599 to deallocate objectid when file gets removed, to report number of used and
601 typedef struct oid_allocator_plugin
{
604 int (*init_oid_allocator
) (reiser4_oid_allocator
* map
, __u64 nr_files
,
606 /* used to report statfs->f_files */
607 __u64(*oids_used
) (reiser4_oid_allocator
* map
);
608 /* get next oid to use */
609 __u64(*next_oid
) (reiser4_oid_allocator
* map
);
610 /* used to report statfs->f_ffree */
611 __u64(*oids_free
) (reiser4_oid_allocator
* map
);
612 /* allocate new objectid */
613 int (*allocate_oid
) (reiser4_oid_allocator
* map
, oid_t
*);
614 /* release objectid */
615 int (*release_oid
) (reiser4_oid_allocator
* map
, oid_t
);
616 /* how many pages to reserve in transaction for allocation of new
618 int (*oid_reserve_allocate
) (reiser4_oid_allocator
* map
);
619 /* how many pages to reserve in transaction for freeing of an
621 int (*oid_reserve_release
) (reiser4_oid_allocator
* map
);
622 void (*print_info
) (const char *, reiser4_oid_allocator
*);
623 } oid_allocator_plugin
;
625 /* disk layout plugin: this specifies super block, journal, bitmap (if there
626 are any) locations, etc */
627 typedef struct disk_format_plugin
{
630 /* replay journal, initialize super_info_data, etc */
631 int (*init_format
) (struct super_block
*, void *data
);
633 /* key of root directory stat data */
634 const reiser4_key
* (*root_dir_key
) (const struct super_block
*);
636 int (*release
) (struct super_block
*);
637 jnode
* (*log_super
) (struct super_block
*);
638 int (*check_open
) (const struct inode
*object
);
639 int (*version_update
) (struct super_block
*);
640 } disk_format_plugin
;
642 struct jnode_plugin
{
645 int (*init
) (jnode
* node
);
646 int (*parse
) (jnode
* node
);
647 struct address_space
*(*mapping
) (const jnode
* node
);
648 unsigned long (*index
) (const jnode
* node
);
649 jnode
* (*clone
) (jnode
* node
);
652 /* plugin instance. */
654 /* This is "wrapper" union for all types of plugins. Most of the code uses */
655 /* plugins of particular type (file_plugin, dir_plugin, etc.) rather than */
656 /* operates with pointers to reiser4_plugin. This union is only used in */
657 /* some generic code in plugin/plugin.c that operates on all */
658 /* plugins. Technically speaking purpose of this union is to add type */
659 /* safety to said generic code: each plugin type (file_plugin, for */
660 /* example), contains plugin_header as its first memeber. This first member */
661 /* is located at the same place in memory as .h member of */
662 /* reiser4_plugin. Generic code, obtains pointer to reiser4_plugin and */
663 /* looks in the .h which is header of plugin type located in union. This */
664 /* allows to avoid type-casts. */
665 union reiser4_plugin
{
670 /* directory plugin */
672 /* hash plugin, used by directory plugin */
674 /* fibration plugin used by directory plugin */
675 fibration_plugin fibration
;
676 /* cipher transform plugin, used by file plugin */
677 cipher_plugin cipher
;
678 /* digest transform plugin, used by file plugin */
679 digest_plugin digest
;
680 /* compression transform plugin, used by file plugin */
681 compression_plugin compression
;
682 /* tail plugin, used by file plugin */
683 formatting_plugin formatting
;
684 /* permission plugin */
690 /* stat-data extension plugin */
691 sd_ext_plugin sd_ext
;
692 /* disk layout plugin */
693 disk_format_plugin format
;
694 /* object id allocator plugin */
695 oid_allocator_plugin oid_allocator
;
696 /* plugin for different jnode types */
698 /* compression mode plugin, used by object plugin */
699 compression_mode_plugin compression_mode
;
700 /* cluster plugin, used by object plugin */
701 cluster_plugin clust
;
702 /* place-holder for new plugin types that can be registered
703 dynamically, and used by other dynamically loaded plugins. */
707 struct reiser4_plugin_ops
{
708 /* called when plugin is initialized */
709 int (*init
) (reiser4_plugin
* plugin
);
710 /* called when plugin is unloaded */
711 int (*done
) (reiser4_plugin
* plugin
);
712 /* load given plugin from disk */
713 int (*load
) (struct inode
*inode
,
714 reiser4_plugin
* plugin
, char **area
, int *len
);
715 /* how many space is required to store this plugin's state
717 int (*save_len
) (struct inode
*inode
, reiser4_plugin
* plugin
);
718 /* save persistent plugin-data to disk */
719 int (*save
) (struct inode
*inode
, reiser4_plugin
* plugin
,
721 /* alignment requirement for on-disk state of this plugin
722 in number of bytes */
724 /* install itself into given inode. This can return error
725 (e.g., you cannot change hash of non-empty directory). */
726 int (*change
) (struct inode
*inode
, reiser4_plugin
* plugin
,
728 /* install itself into given inode. This can return error
729 (e.g., you cannot change hash of non-empty directory). */
730 int (*inherit
) (struct inode
*inode
, struct inode
*parent
,
731 reiser4_plugin
* plugin
);
734 /* functions implemented in fs/reiser4/plugin/plugin.c */
736 /* stores plugin reference in reiser4-specific part of inode */
737 extern int set_object_plugin(struct inode
*inode
, reiser4_plugin_id id
);
738 extern int init_plugins(void);
740 /* builtin plugins */
742 /* builtin hash-plugins */
753 /* builtin cipher plugins */
760 /* builtin digest plugins */
767 /* builtin compression mode plugins */
769 NONE_COMPRESSION_MODE_ID
,
770 LATTD_COMPRESSION_MODE_ID
,
771 ULTIM_COMPRESSION_MODE_ID
,
772 FORCE_COMPRESSION_MODE_ID
,
773 CONVX_COMPRESSION_MODE_ID
,
774 LAST_COMPRESSION_MODE_ID
775 } reiser4_compression_mode_id
;
777 /* builtin cluster plugins */
785 } reiser4_cluster_id
;
787 /* builtin tail-plugins */
790 NEVER_TAILS_FORMATTING_ID
,
791 ALWAYS_TAILS_FORMATTING_ID
,
792 SMALL_FILE_FORMATTING_ID
,
793 LAST_TAIL_FORMATTING_ID
794 } reiser4_formatting_id
;
796 /* data type used to pack parameters that we pass to vfs object creation
797 function create_object() */
798 struct reiser4_object_create_data
{
799 /* plugin to control created object */
801 /* mode of regular file, directory or special file */
802 /* what happens if some other sort of perm plugin is in use? */
804 /* rdev of special file */
808 /* add here something for non-standard objects you invent, like
809 query for interpolation file etc. */
811 struct reiser4_crypto_info
*crypto
;
813 struct inode
*parent
;
814 struct dentry
*dentry
;
817 /* description of directory entry being created/destroyed/sought for
819 It is passed down to the directory plugin and farther to the
820 directory item plugin methods. Creation of new directory is done in
821 several stages: first we search for an entry with the same name, then
822 create new one. reiser4_dir_entry_desc is used to store some information
823 collected at some stage of this process and required later: key of
824 item that we want to insert/delete and pointer to an object that will
825 be bound by the new directory entry. Probably some more fields will
829 struct reiser4_dir_entry_desc
{
830 /* key of directory entry */
832 /* object bound by this entry. */
836 #define MAX_PLUGIN_TYPE_LABEL_LEN 32
837 #define MAX_PLUGIN_PLUG_LABEL_LEN 32
839 #define PLUGIN_BY_ID(TYPE, ID, FIELD) \
840 static inline TYPE *TYPE ## _by_id(reiser4_plugin_id id) \
842 reiser4_plugin *plugin = plugin_by_id(ID, id); \
843 return plugin ? &plugin->FIELD : NULL; \
845 static inline TYPE *TYPE ## _by_disk_id(reiser4_tree * tree, d16 *id) \
847 reiser4_plugin *plugin = plugin_by_disk_id(tree, ID, id); \
848 return plugin ? &plugin->FIELD : NULL; \
850 static inline TYPE *TYPE ## _by_unsafe_id(reiser4_plugin_id id) \
852 reiser4_plugin *plugin = plugin_by_unsafe_id(ID, id); \
853 return plugin ? &plugin->FIELD : NULL; \
855 static inline reiser4_plugin* TYPE ## _to_plugin(TYPE* plugin) \
857 return (reiser4_plugin *) plugin; \
859 static inline reiser4_plugin_id TYPE ## _id(TYPE* plugin) \
861 return TYPE ## _to_plugin(plugin)->h.id; \
863 typedef struct { int foo; } TYPE ## _plugin_dummy
865 PLUGIN_BY_ID(item_plugin
, REISER4_ITEM_PLUGIN_TYPE
, item
);
866 PLUGIN_BY_ID(file_plugin
, REISER4_FILE_PLUGIN_TYPE
, file
);
867 PLUGIN_BY_ID(dir_plugin
, REISER4_DIR_PLUGIN_TYPE
, dir
);
868 PLUGIN_BY_ID(node_plugin
, REISER4_NODE_PLUGIN_TYPE
, node
);
869 PLUGIN_BY_ID(sd_ext_plugin
, REISER4_SD_EXT_PLUGIN_TYPE
, sd_ext
);
870 PLUGIN_BY_ID(perm_plugin
, REISER4_PERM_PLUGIN_TYPE
, perm
);
871 PLUGIN_BY_ID(hash_plugin
, REISER4_HASH_PLUGIN_TYPE
, hash
);
872 PLUGIN_BY_ID(fibration_plugin
, REISER4_FIBRATION_PLUGIN_TYPE
, fibration
);
873 PLUGIN_BY_ID(cipher_plugin
, REISER4_CIPHER_PLUGIN_TYPE
, cipher
);
874 PLUGIN_BY_ID(digest_plugin
, REISER4_DIGEST_PLUGIN_TYPE
, digest
);
875 PLUGIN_BY_ID(compression_plugin
, REISER4_COMPRESSION_PLUGIN_TYPE
, compression
);
876 PLUGIN_BY_ID(formatting_plugin
, REISER4_FORMATTING_PLUGIN_TYPE
, formatting
);
877 PLUGIN_BY_ID(disk_format_plugin
, REISER4_FORMAT_PLUGIN_TYPE
, format
);
878 PLUGIN_BY_ID(jnode_plugin
, REISER4_JNODE_PLUGIN_TYPE
, jnode
);
879 PLUGIN_BY_ID(compression_mode_plugin
, REISER4_COMPRESSION_MODE_PLUGIN_TYPE
,
881 PLUGIN_BY_ID(cluster_plugin
, REISER4_CLUSTER_PLUGIN_TYPE
, clust
);
883 extern int save_plugin_id(reiser4_plugin
* plugin
, d16
* area
);
885 extern struct list_head
*get_plugin_list(reiser4_plugin_type type_id
);
887 #define for_all_plugins(ptype, plugin) \
888 for (plugin = list_entry(get_plugin_list(ptype)->next, reiser4_plugin, h.linkage); \
889 get_plugin_list(ptype) != &plugin->h.linkage; \
890 plugin = list_entry(plugin->h.linkage.next, reiser4_plugin, h.linkage))
893 extern int grab_plugin_pset(struct inode
*self
, struct inode
*ancestor
,
895 extern int force_plugin_pset(struct inode
*self
, pset_member memb
,
896 reiser4_plugin
*plug
);
897 extern int finish_pset(struct inode
*inode
);
899 /* defined in fs/reiser4/plugin/object.c */
900 extern file_plugin file_plugins
[LAST_FILE_PLUGIN_ID
];
901 /* defined in fs/reiser4/plugin/object.c */
902 extern dir_plugin dir_plugins
[LAST_DIR_ID
];
903 /* defined in fs/reiser4/plugin/item/static_stat.c */
904 extern sd_ext_plugin sd_ext_plugins
[LAST_SD_EXTENSION
];
905 /* defined in fs/reiser4/plugin/hash.c */
906 extern hash_plugin hash_plugins
[LAST_HASH_ID
];
907 /* defined in fs/reiser4/plugin/fibration.c */
908 extern fibration_plugin fibration_plugins
[LAST_FIBRATION_ID
];
909 /* defined in fs/reiser4/plugin/crypt.c */
910 extern cipher_plugin cipher_plugins
[LAST_CIPHER_ID
];
911 /* defined in fs/reiser4/plugin/digest.c */
912 extern digest_plugin digest_plugins
[LAST_DIGEST_ID
];
913 /* defined in fs/reiser4/plugin/compress/compress.c */
914 extern compression_plugin compression_plugins
[LAST_COMPRESSION_ID
];
915 /* defined in fs/reiser4/plugin/compress/compression_mode.c */
916 extern compression_mode_plugin
917 compression_mode_plugins
[LAST_COMPRESSION_MODE_ID
];
918 /* defined in fs/reiser4/plugin/cluster.c */
919 extern cluster_plugin cluster_plugins
[LAST_CLUSTER_ID
];
920 /* defined in fs/reiser4/plugin/tail.c */
921 extern formatting_plugin formatting_plugins
[LAST_TAIL_FORMATTING_ID
];
922 /* defined in fs/reiser4/plugin/security/security.c */
923 extern perm_plugin perm_plugins
[LAST_PERM_ID
];
924 /* defined in fs/reiser4/plugin/item/item.c */
925 extern item_plugin item_plugins
[LAST_ITEM_ID
];
926 /* defined in fs/reiser4/plugin/node/node.c */
927 extern node_plugin node_plugins
[LAST_NODE_ID
];
928 /* defined in fs/reiser4/plugin/disk_format/disk_format.c */
929 extern disk_format_plugin format_plugins
[LAST_FORMAT_ID
];
931 /* __FS_REISER4_PLUGIN_TYPES_H__ */
936 c-indentation-style: "K&R"