~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs/module.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: module.c,v 1.28 2008/03/31 07:42:42 sfjro Exp $ */
 
19
/*
 
20
 * module global variables and operations
 
21
 *
 
22
 * $Id: module.c,v 1.30 2008/04/13 23:43:45 sfjro Exp $
 
23
 */
20
24
 
21
 
//#include <linux/init.h>
22
25
#include <linux/module.h>
23
26
#include "aufs.h"
24
27
 
27
30
/*
28
31
 * aufs caches
29
32
 */
30
 
struct kmem_cache *aufs_cachep[AuCache_Last];
 
33
struct kmem_cache *au_cachep[AuCache_Last];
31
34
static int __init create_cache(void)
32
35
{
33
 
        void *p;
34
 
 
35
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
36
 
#define Args(type, sz)  (type), (sz), 0, SLAB_RECLAIM_ACCOUNT, NULL
37
 
#else
38
 
#define Args(type, sz)  (type), (sz), 0, SLAB_RECLAIM_ACCOUNT, NULL, NULL
39
 
#endif
40
 
#define CacheX(type, extra) \
41
 
        kmem_cache_create(Args(#type, sizeof(struct type) + extra))
42
 
#define Cache(type)             CacheX(type, 0)
43
 
 
44
 
        p = NULL;
45
 
        aufs_cachep[AuCache_DINFO] = Cache(aufs_dinfo);
46
 
        if (aufs_cachep[AuCache_DINFO])
47
 
                aufs_cachep[AuCache_ICNTNR] = Cache(aufs_icntnr);
48
 
        if (aufs_cachep[AuCache_ICNTNR])
49
 
                aufs_cachep[AuCache_FINFO] = Cache(aufs_finfo);
50
 
        //aufs_cachep[AuCache_FINFO] = NULL;
51
 
        if (aufs_cachep[AuCache_FINFO])
52
 
                aufs_cachep[AuCache_VDIR] = Cache(aufs_vdir);
53
 
        if (aufs_cachep[AuCache_VDIR]) {
54
 
                aufs_cachep[AuCache_DEHSTR] = Cache(aufs_dehstr);
55
 
                p = aufs_cachep[AuCache_DEHSTR];
56
 
        }
57
 
 
58
 
#ifdef CONFIG_AUFS_HINOTIFY
59
 
        AuDebugOn(!au_hin_nignore);
60
 
        if (p) {
61
 
                aufs_cachep[AuCache_HINOTIFY]
62
 
                        = CacheX(aufs_hinotify,
63
 
                                 sizeof(atomic_t) * au_hin_nignore);
64
 
                p = aufs_cachep[AuCache_HINOTIFY];
65
 
        }
66
 
#endif
67
 
 
68
 
        if (p)
 
36
        au_cachep[AuCache_DINFO] = AuCache(au_dinfo);
 
37
        if (au_cachep[AuCache_DINFO])
 
38
                au_cachep[AuCache_ICNTNR] = AuCache(aufs_icntnr);
 
39
        if (au_cachep[AuCache_ICNTNR])
 
40
                au_cachep[AuCache_FINFO] = AuCache(au_finfo);
 
41
        //au_cachep[AuCache_FINFO] = NULL;
 
42
        if (au_cachep[AuCache_FINFO])
 
43
                au_cachep[AuCache_VDIR] = AuCache(au_vdir);
 
44
        if (au_cachep[AuCache_VDIR])
 
45
                au_cachep[AuCache_DEHSTR] = AuCache(au_vdir_dehstr);
 
46
        if (au_cachep[AuCache_DEHSTR])
69
47
                return 0;
 
48
 
70
49
        return -ENOMEM;
71
 
 
72
 
#undef CacheX
73
 
#undef Cache
74
 
#undef Args
75
50
}
76
51
 
77
52
static void destroy_cache(void)
78
53
{
79
54
        int i;
80
55
        for (i = 0; i < AuCache_Last; i++)
81
 
                if (aufs_cachep[i])
82
 
                        kmem_cache_destroy(aufs_cachep[i]);
 
56
                if (au_cachep[i]) {
 
57
                        kmem_cache_destroy(au_cachep[i]);
 
58
                        au_cachep[i] = NULL;
 
59
                }
83
60
}
84
61
 
85
62
/* ---------------------------------------------------------------------- */
86
63
 
87
 
#ifdef CONFIG_AUFS_HINOTIFY
88
 
/* the size of an array for ignore counter */
89
 
int au_hin_nignore;
90
 
#endif
91
 
 
92
 
/* super_blocks list is not exported */
93
 
DEFINE_MUTEX(au_sbilist_mtx);
94
 
LIST_HEAD(au_sbilist);
95
 
 
96
64
char au_esc_chars[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
97
65
int au_dir_roflags;
98
66
 
99
 
#ifdef DbgDlgt
100
 
#include <linux/security.h>
101
 
#include "dbg_dlgt.c"
102
 
#else
103
 
#define dbg_dlgt_init() 0
104
 
#define dbg_dlgt_fin()  do {} while (0)
105
 
#endif
106
 
 
107
67
/*
108
68
 * functions for module interface.
109
69
 */
121
81
MODULE_PARM_DESC(brs, "use <sysfs>/fs/aufs/sbi_*/brN");
122
82
module_param_named(brs, sysaufs_brs, int, S_IRUGO);
123
83
 
124
 
#ifdef AuMagicSysRq
125
 
char *aufs_sysrq_key = "a";
126
 
MODULE_PARM_DESC(sysrq, "MagicSysRq key for " AUFS_NAME);
127
 
module_param_named(sysrq, aufs_sysrq_key, charp, S_IRUGO);
128
 
#endif
 
84
/* ---------------------------------------------------------------------- */
129
85
 
130
86
static int __init aufs_init(void)
131
87
{
132
88
        int err, i;
133
89
        char *p;
134
90
 
135
 
#ifdef CONFIG_AUFS_DEBUG
136
 
        {
137
 
                aufs_bindex_t bindex = -1;
138
 
                AuDebugOn(bindex >= 0);
139
 
        }
140
 
        {
141
 
                struct aufs_destr destr;
142
 
                destr.len = -1;
143
 
                AuDebugOn(destr.len < NAME_MAX);
144
 
        }
145
 
 
146
 
#ifdef CONFIG_4KSTACKS
147
 
        AuWarn("CONFIG_4KSTACKS is defined.\n");
148
 
#endif
149
 
#if 0 // verbose debug
150
 
        {
151
 
                union {
152
 
                        struct aufs_branch *br;
153
 
                        struct aufs_dinfo *di;
154
 
                        struct aufs_finfo *fi;
155
 
                        struct aufs_iinfo *ii;
156
 
                        struct aufs_hinode *hi;
157
 
                        struct aufs_sbinfo *si;
158
 
                        struct aufs_destr *destr;
159
 
                        struct aufs_de *de;
160
 
                        struct aufs_wh *wh;
161
 
                        struct aufs_vdir *vd;
162
 
                } u;
163
 
 
164
 
                pr_info("br{"
165
 
                        "xino %d, "
166
 
                        "id %d, perm %d, mnt %d, count %d, "
167
 
                        "wh_sem %d, wh %d, run %d, plink %d, gen %d} %d\n",
168
 
                        offsetof(typeof(*u.br), br_xino),
169
 
                        offsetof(typeof(*u.br), br_id),
170
 
                        offsetof(typeof(*u.br), br_perm),
171
 
                        offsetof(typeof(*u.br), br_mnt),
172
 
                        offsetof(typeof(*u.br), br_count),
173
 
                        offsetof(typeof(*u.br), br_wh_rwsem),
174
 
                        offsetof(typeof(*u.br), br_wh),
175
 
                        offsetof(typeof(*u.br), br_wh_running),
176
 
                        offsetof(typeof(*u.br), br_plink),
177
 
                        offsetof(typeof(*u.br), br_generation),
178
 
                        sizeof(*u.br));
179
 
                pr_info("di{gen %d, rwsem %d, bstart %d, bend %d, bwh %d, "
180
 
                        "bdiropq %d, hdentry %d} %d\n",
181
 
                        offsetof(typeof(*u.di), di_generation),
182
 
                        offsetof(typeof(*u.di), di_rwsem),
183
 
                        offsetof(typeof(*u.di), di_bstart),
184
 
                        offsetof(typeof(*u.di), di_bend),
185
 
                        offsetof(typeof(*u.di), di_bwh),
186
 
                        offsetof(typeof(*u.di), di_bdiropq),
187
 
                        offsetof(typeof(*u.di), di_hdentry),
188
 
                        sizeof(*u.di));
189
 
                pr_info("fi{gen %d, rwsem %d, hfile %d, bstart %d, bend %d, "
190
 
                        "h_vm_ops %d, vdir_cach %d} %d\n",
191
 
                        offsetof(typeof(*u.fi), fi_generation),
192
 
                        offsetof(typeof(*u.fi), fi_rwsem),
193
 
                        offsetof(typeof(*u.fi), fi_hfile),
194
 
                        offsetof(typeof(*u.fi), fi_bstart),
195
 
                        offsetof(typeof(*u.fi), fi_bend),
196
 
                        offsetof(typeof(*u.fi), fi_h_vm_ops),
197
 
                        offsetof(typeof(*u.fi), fi_vdir_cache),
198
 
                        sizeof(*u.fi));
199
 
                pr_info("ii{gen %d, hsb %d, "
200
 
                        "rwsem %d, bstart %d, bend %d, hinode %d, vdir %d} "
201
 
                        "%d\n",
202
 
                        offsetof(typeof(*u.ii), ii_generation),
203
 
                        offsetof(typeof(*u.ii), ii_hsb1),
204
 
                        offsetof(typeof(*u.ii), ii_rwsem),
205
 
                        offsetof(typeof(*u.ii), ii_bstart),
206
 
                        offsetof(typeof(*u.ii), ii_bend),
207
 
                        offsetof(typeof(*u.ii), ii_hinode),
208
 
                        offsetof(typeof(*u.ii), ii_vdir),
209
 
                        sizeof(*u.ii));
210
 
                pr_info("hi{inode %d, id %d, notify %d, wh %d} %d\n",
211
 
                        offsetof(typeof(*u.hi), hi_inode),
212
 
                        offsetof(typeof(*u.hi), hi_id),
213
 
                        offsetof(typeof(*u.hi), hi_notify),
214
 
                        offsetof(typeof(*u.hi), hi_whdentry),
215
 
                        sizeof(*u.hi));
216
 
                pr_info("si{nwt %d, rwsem %d, gen %d, "
217
 
                        "bend %d, last id %d, br %d, "
218
 
                        "flags %d, "
219
 
                        "xread %d, xwrite %d, xib %d, xmtx %d, buf %d, "
220
 
                        "xlast %d, xnext %d, "
221
 
                        "rdcache %d, "
222
 
                        "dirwh %d, "
223
 
                        "pl_lock %d, pl %d, "
224
 
                        "l %d, mnt %d, "
225
 
                        "sys %d, "
226
 
                        "} %d\n",
227
 
                        offsetof(typeof(*u.si), si_nowait),
228
 
                        offsetof(typeof(*u.si), si_rwsem),
229
 
                        offsetof(typeof(*u.si), si_generation),
230
 
                        offsetof(typeof(*u.si), si_bend),
231
 
                        offsetof(typeof(*u.si), si_last_br_id),
232
 
                        offsetof(typeof(*u.si), si_branch),
233
 
                        offsetof(typeof(*u.si), au_si_flags),
234
 
                        offsetof(typeof(*u.si), si_xread),
235
 
                        offsetof(typeof(*u.si), si_xwrite),
236
 
                        offsetof(typeof(*u.si), si_xib),
237
 
                        offsetof(typeof(*u.si), si_xib_mtx),
238
 
                        offsetof(typeof(*u.si), si_xib_buf),
239
 
                        offsetof(typeof(*u.si), si_xib_last_pindex),
240
 
                        offsetof(typeof(*u.si), si_xib_next_bit),
241
 
                        offsetof(typeof(*u.si), si_rdcache),
242
 
                        offsetof(typeof(*u.si), si_dirwh),
243
 
                        offsetof(typeof(*u.si), si_plink_lock),
244
 
                        offsetof(typeof(*u.si), si_plink),
245
 
                        offsetof(typeof(*u.si), si_list),
246
 
                        offsetof(typeof(*u.si), si_mnt),
247
 
                        offsetof(typeof(*u.si), si_sysaufs),
248
 
                        sizeof(*u.si));
249
 
                pr_info("destr{len %d, name %d} %d\n",
250
 
                        offsetof(typeof(*u.destr), len),
251
 
                        offsetof(typeof(*u.destr), name),
252
 
                        sizeof(*u.destr));
253
 
                pr_info("de{ino %d, type %d, str %d} %d\n",
254
 
                        offsetof(typeof(*u.de), de_ino),
255
 
                        offsetof(typeof(*u.de), de_type),
256
 
                        offsetof(typeof(*u.de), de_str),
257
 
                        sizeof(*u.de));
258
 
                pr_info("wh{hash %d, bindex %d, str %d} %d\n",
259
 
                        offsetof(typeof(*u.wh), wh_hash),
260
 
                        offsetof(typeof(*u.wh), wh_bindex),
261
 
                        offsetof(typeof(*u.wh), wh_str),
262
 
                        sizeof(*u.wh));
263
 
                pr_info("vd{deblk %d, nblk %d, last %d, ver %d, jiffy %d} %d\n",
264
 
                        offsetof(typeof(*u.vd), vd_deblk),
265
 
                        offsetof(typeof(*u.vd), vd_nblk),
266
 
                        offsetof(typeof(*u.vd), vd_last),
267
 
                        offsetof(typeof(*u.vd), vd_version),
268
 
                        offsetof(typeof(*u.vd), vd_jiffy),
269
 
                        sizeof(*u.vd));
270
 
        }
271
 
#endif
272
 
#endif /* CONFIG_AUFS_DEBUG */
 
91
        au_debug_init();
273
92
 
274
93
        p = au_esc_chars;
275
94
        for (i = 1; i <= ' '; i++)
279
98
        *p = 0;
280
99
 
281
100
        au_dir_roflags = au_file_roflags(O_DIRECTORY | O_LARGEFILE);
282
 
#ifndef CONFIG_AUFS_SYSAUFS
283
 
        sysaufs_brs = 0;
284
 
#endif
285
101
 
286
102
        err = -EINVAL;
287
103
        if (unlikely(aufs_nwkq <= 0))
304
120
        if (unlikely(err))
305
121
                goto out_sysrq;
306
122
 
307
 
        err = dbg_dlgt_init();
 
123
        err = register_filesystem(&aufs_fs_type);
308
124
        if (unlikely(err))
309
125
                goto out_cache;
310
 
 
311
 
        err = register_filesystem(&aufs_fs_type);
312
 
        if (unlikely(err))
313
 
                goto out_dlgt;
314
126
        pr_info(AUFS_NAME " " AUFS_VERSION "\n");
315
127
        return 0; /* success */
316
128
 
317
 
 out_dlgt:
318
 
        dbg_dlgt_fin();
319
129
 out_cache:
320
130
        destroy_cache();
321
131
 out_sysrq:
334
144
static void __exit aufs_exit(void)
335
145
{
336
146
        unregister_filesystem(&aufs_fs_type);
337
 
        dbg_dlgt_fin();
338
147
        destroy_cache();
339
148
 
340
149
        au_sysrq_fin();