2 #define DEBUG_SUBSYSTEM S_FILTER
6 #include <linux/module.h>
7 #include <linux/kmod.h>
8 #include <linux/slab.h>
9 #include <linux/kp30.h>
10 #include <linux/lustre_fsfilt.h>
12 LIST_HEAD(fsfilt_types);
14 static struct fsfilt_operations *fsfilt_search_type(const char *type)
16 struct fsfilt_operations *found;
19 list_for_each(p, &fsfilt_types) {
20 found = list_entry(p, struct fsfilt_operations, fs_list);
21 if (!strcmp(found->fs_type, type)) {
28 int fsfilt_register_ops(struct fsfilt_operations *fs_ops)
30 struct fsfilt_operations *found;
32 /* lock fsfilt_types list */
33 if ((found = fsfilt_search_type(fs_ops->fs_type))) {
34 if (found != fs_ops) {
35 CERROR("different operations for type %s\n",
37 /* unlock fsfilt_types list */
42 list_add(&fs_ops->fs_list, &fsfilt_types);
45 /* unlock fsfilt_types list */
49 void fsfilt_unregister_ops(struct fsfilt_operations *fs_ops)
53 /* lock fsfilt_types list */
54 list_for_each(p, &fsfilt_types) {
55 struct fsfilt_operations *found;
57 found = list_entry(p, typeof(*found), fs_list);
58 if (found == fs_ops) {
64 /* unlock fsfilt_types list */
67 struct fsfilt_operations *fsfilt_get_ops(char *type)
69 struct fsfilt_operations *fs_ops;
71 /* lock fsfilt_types list */
72 if (!(fs_ops = fsfilt_search_type(type))) {
76 snprintf(name, sizeof(name) - 1, "fsfilt_%s", type);
77 name[sizeof(name) - 1] = '\0';
79 if ((rc = request_module(name))) {
80 fs_ops = fsfilt_search_type(type);
81 CDEBUG(D_INFO, "Loaded module '%s'\n", name);
87 CERROR("Can't find fsfilt_%s interface\n", name);
89 /* unlock fsfilt_types list */
92 __MOD_INC_USE_COUNT(fs_ops->fs_owner);
93 /* unlock fsfilt_types list */
98 void fsfilt_put_ops(struct fsfilt_operations *fs_ops)
100 __MOD_DEC_USE_COUNT(fs_ops->fs_owner);
104 EXPORT_SYMBOL(fsfilt_register_ops);
105 EXPORT_SYMBOL(fsfilt_unregister_ops);
106 EXPORT_SYMBOL(fsfilt_get_ops);
107 EXPORT_SYMBOL(fsfilt_put_ops);