x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / fs / fscache / netfs.c
bloba8aa00be44442f59d6cf08516ab7403d0c02ab9e
1 /* FS-Cache netfs (client) registration
3 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #define FSCACHE_DEBUG_LEVEL COOKIE
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include "internal.h"
17 static LIST_HEAD(fscache_netfs_list);
20 * register a network filesystem for caching
22 int __fscache_register_netfs(struct fscache_netfs *netfs)
24 struct fscache_netfs *ptr;
25 struct fscache_cookie *cookie;
26 int ret;
28 _enter("{%s}", netfs->name);
30 INIT_LIST_HEAD(&netfs->link);
32 /* allocate a cookie for the primary index */
33 cookie = kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL);
35 if (!cookie) {
36 _leave(" = -ENOMEM");
37 return -ENOMEM;
40 /* initialise the primary index cookie */
41 atomic_set(&cookie->usage, 1);
42 atomic_set(&cookie->n_children, 0);
43 atomic_set(&cookie->n_active, 1);
45 cookie->def = &fscache_fsdef_netfs_def;
46 cookie->parent = &fscache_fsdef_index;
47 cookie->netfs_data = netfs;
48 cookie->flags = 1 << FSCACHE_COOKIE_ENABLED;
50 spin_lock_init(&cookie->lock);
51 spin_lock_init(&cookie->stores_lock);
52 INIT_HLIST_HEAD(&cookie->backing_objects);
54 /* check the netfs type is not already present */
55 down_write(&fscache_addremove_sem);
57 ret = -EEXIST;
58 list_for_each_entry(ptr, &fscache_netfs_list, link) {
59 if (strcmp(ptr->name, netfs->name) == 0)
60 goto already_registered;
63 atomic_inc(&cookie->parent->usage);
64 atomic_inc(&cookie->parent->n_children);
66 netfs->primary_index = cookie;
67 list_add(&netfs->link, &fscache_netfs_list);
68 ret = 0;
70 pr_notice("Netfs '%s' registered for caching\n", netfs->name);
72 already_registered:
73 up_write(&fscache_addremove_sem);
75 if (ret < 0)
76 kmem_cache_free(fscache_cookie_jar, cookie);
78 _leave(" = %d", ret);
79 return ret;
81 EXPORT_SYMBOL(__fscache_register_netfs);
84 * unregister a network filesystem from the cache
85 * - all cookies must have been released first
87 void __fscache_unregister_netfs(struct fscache_netfs *netfs)
89 _enter("{%s.%u}", netfs->name, netfs->version);
91 down_write(&fscache_addremove_sem);
93 list_del(&netfs->link);
94 fscache_relinquish_cookie(netfs->primary_index, 0);
96 up_write(&fscache_addremove_sem);
98 pr_notice("Netfs '%s' unregistered from caching\n",
99 netfs->name);
101 _leave("");
103 EXPORT_SYMBOL(__fscache_unregister_netfs);