staging: rtl8723bs: os_dep: change return type of rtw_suspend_ap_wow
[linux/fpc-iii.git] / fs / fscache / netfs.c
blobcce92216fa28b7e8bb3a91b66588fa596fb07b87
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* FS-Cache netfs (client) registration
4 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
8 #define FSCACHE_DEBUG_LEVEL COOKIE
9 #include <linux/module.h>
10 #include <linux/slab.h>
11 #include "internal.h"
14 * register a network filesystem for caching
16 int __fscache_register_netfs(struct fscache_netfs *netfs)
18 struct fscache_cookie *candidate, *cookie;
20 _enter("{%s}", netfs->name);
22 /* allocate a cookie for the primary index */
23 candidate = fscache_alloc_cookie(&fscache_fsdef_index,
24 &fscache_fsdef_netfs_def,
25 netfs->name, strlen(netfs->name),
26 &netfs->version, sizeof(netfs->version),
27 netfs, 0);
28 if (!candidate) {
29 _leave(" = -ENOMEM");
30 return -ENOMEM;
33 candidate->flags = 1 << FSCACHE_COOKIE_ENABLED;
35 /* check the netfs type is not already present */
36 cookie = fscache_hash_cookie(candidate);
37 if (!cookie)
38 goto already_registered;
39 if (cookie != candidate) {
40 trace_fscache_cookie(candidate, fscache_cookie_discard, 1);
41 fscache_free_cookie(candidate);
44 fscache_cookie_get(cookie->parent, fscache_cookie_get_register_netfs);
45 atomic_inc(&cookie->parent->n_children);
47 netfs->primary_index = cookie;
49 pr_notice("Netfs '%s' registered for caching\n", netfs->name);
50 trace_fscache_netfs(netfs);
51 _leave(" = 0");
52 return 0;
54 already_registered:
55 fscache_cookie_put(candidate, fscache_cookie_put_dup_netfs);
56 _leave(" = -EEXIST");
57 return -EEXIST;
59 EXPORT_SYMBOL(__fscache_register_netfs);
62 * unregister a network filesystem from the cache
63 * - all cookies must have been released first
65 void __fscache_unregister_netfs(struct fscache_netfs *netfs)
67 _enter("{%s.%u}", netfs->name, netfs->version);
69 fscache_relinquish_cookie(netfs->primary_index, NULL, false);
70 pr_notice("Netfs '%s' unregistered from caching\n", netfs->name);
72 _leave("");
74 EXPORT_SYMBOL(__fscache_unregister_netfs);