revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / fs / reiser4 / plugin / tail_policy.c
blob43f4ae752c0f0b9b2177025f69eb624ac81780c6
1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
2 * reiser4/README */
4 /* Formatting policy plugins */
6 /*
7 * Formatting policy plugin is used by object plugin (of regular file) to
8 * convert file between two representations.
10 * Currently following policies are implemented:
11 * never store file in formatted nodes
12 * always store file in formatted nodes
13 * store file in formatted nodes if file is smaller than 4 blocks (default)
16 #include "../tree.h"
17 #include "../inode.h"
18 #include "../super.h"
19 #include "object.h"
20 #include "plugin.h"
21 #include "node/node.h"
22 #include "plugin_header.h"
24 #include <linux/pagemap.h>
25 #include <linux/fs.h> /* For struct inode */
27 /**
28 * have_formatting_never -
29 * @inode:
30 * @size:
34 /* Never store file's tail as direct item */
35 /* Audited by: green(2002.06.12) */
36 static int have_formatting_never(const struct inode *inode UNUSED_ARG
37 /* inode to operate on */ ,
38 loff_t size UNUSED_ARG /* new object size */ )
40 return 0;
43 /* Always store file's tail as direct item */
44 /* Audited by: green(2002.06.12) */
45 static int
46 have_formatting_always(const struct inode *inode UNUSED_ARG
47 /* inode to operate on */ ,
48 loff_t size UNUSED_ARG /* new object size */ )
50 return 1;
53 /* This function makes test if we should store file denoted @inode as tails only or
54 as extents only. */
55 static int
56 have_formatting_default(const struct inode *inode UNUSED_ARG
57 /* inode to operate on */ ,
58 loff_t size /* new object size */ )
60 assert("umka-1253", inode != NULL);
62 if (size > inode->i_sb->s_blocksize * 4)
63 return 0;
65 return 1;
68 /* tail plugins */
69 formatting_plugin formatting_plugins[LAST_TAIL_FORMATTING_ID] = {
70 [NEVER_TAILS_FORMATTING_ID] = {
71 .h = {
72 .type_id = REISER4_FORMATTING_PLUGIN_TYPE,
73 .id = NEVER_TAILS_FORMATTING_ID,
74 .pops = NULL,
75 .label = "never",
76 .desc = "Never store file's tail",
77 .linkage = {NULL, NULL}
79 .have_tail = have_formatting_never
81 [ALWAYS_TAILS_FORMATTING_ID] = {
82 .h = {
83 .type_id = REISER4_FORMATTING_PLUGIN_TYPE,
84 .id = ALWAYS_TAILS_FORMATTING_ID,
85 .pops = NULL,
86 .label = "always",
87 .desc = "Always store file's tail",
88 .linkage = {NULL, NULL}
90 .have_tail = have_formatting_always
92 [SMALL_FILE_FORMATTING_ID] = {
93 .h = {
94 .type_id = REISER4_FORMATTING_PLUGIN_TYPE,
95 .id = SMALL_FILE_FORMATTING_ID,
96 .pops = NULL,
97 .label = "4blocks",
98 .desc = "store files shorter than 4 blocks in tail items",
99 .linkage = {NULL, NULL}
101 .have_tail = have_formatting_default
106 * Local variables:
107 * c-indentation-style: "K&R"
108 * mode-name: "LC"
109 * c-basic-offset: 8
110 * tab-width: 8
111 * fill-column: 79
112 * End: