]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - fs/nfsd/netns.h
Merge branch 'for-linus' into for-next
[mirror_ubuntu-jammy-kernel.git] / fs / nfsd / netns.h
CommitLineData
16216333 1/* SPDX-License-Identifier: GPL-2.0-or-later */
7ea34ac1
JL
2/*
3 * per net namespace data structures for nfsd
4 *
5 * Copyright (C) 2012, Jeff Layton <jlayton@redhat.com>
7ea34ac1
JL
6 */
7
8#ifndef __NFSD_NETNS_H__
9#define __NFSD_NETNS_H__
10
11#include <net/net_namespace.h>
12#include <net/netns/generic.h>
e567b98c 13#include <linux/percpu_counter.h>
7ea34ac1 14
52e19c09
SK
15/* Hash tables for nfs4_clientid state */
16#define CLIENT_HASH_BITS 4
17#define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS)
18#define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1)
19
1872de0e
SK
20#define SESSION_HASH_SIZE 512
21
7ea34ac1 22struct cld_net;
9a9c6478 23struct nfsd4_client_tracking_ops;
7ea34ac1 24
e567b98c
AG
25enum {
26 /* cache misses due only to checksum comparison failures */
27 NFSD_NET_PAYLOAD_MISSES,
28 /* amount of memory (in bytes) currently consumed by the DRC */
29 NFSD_NET_DRC_MEM_USAGE,
30 NFSD_NET_COUNTERS_NUM
31};
32
14a571a8
JL
33/*
34 * Represents a nfsd "container". With respect to nfsv4 state tracking, the
35 * fields of interest are the *_id_hashtbls and the *_name_tree. These track
36 * the nfs4_client objects by either short or long form clientid.
37 *
38 * Each nfsd_net runs a nfs4_laundromat workqueue job when necessary to clean
39 * up expired clients and delegations within the container.
40 */
7ea34ac1
JL
41struct nfsd_net {
42 struct cld_net *cld_net;
b3853e0e 43
e5f06f72 44 struct cache_detail *svc_expkey_cache;
b3853e0e 45 struct cache_detail *svc_export_cache;
c2e76ef5
SK
46
47 struct cache_detail *idtoname_cache;
9e75a4de 48 struct cache_detail *nametoid_cache;
5e1533c7
SK
49
50 struct lock_manager nfsd4_manager;
a51c84ed 51 bool grace_ended;
9cc76801 52 time64_t boot_time;
52e19c09 53
e8a79fb1
BF
54 struct dentry *nfsd_client_dir;
55
52e19c09
SK
56 /*
57 * reclaim_str_hashtbl[] holds known client info from previous reset/reboot
58 * used in reboot/reset lease grace period processing
382a62e7
SK
59 *
60 * conf_id_hashtbl[], and conf_name_tree hold confirmed
61 * setclientid_confirmed info.
a99454aa
SK
62 *
63 * unconf_str_hastbl[] and unconf_name_tree hold unconfirmed
64 * setclientid info.
52e19c09
SK
65 */
66 struct list_head *reclaim_str_hashtbl;
67 int reclaim_str_hashtbl_size;
8daae4dc 68 struct list_head *conf_id_hashtbl;
382a62e7 69 struct rb_root conf_name_tree;
0a7ec377 70 struct list_head *unconf_id_hashtbl;
a99454aa 71 struct rb_root unconf_name_tree;
1872de0e 72 struct list_head *sessionid_hashtbl;
5ed58bb2
SK
73 /*
74 * client_lru holds client queue ordered by nfs4_client.cl_time
75 * for lease renewal.
73758fed
SK
76 *
77 * close_lru holds (open) stateowner queue ordered by nfs4_stateowner.so_time
78 * for last close replay.
79 *
80 * All of the above fields are protected by the client_mutex.
5ed58bb2
SK
81 */
82 struct list_head client_lru;
73758fed 83 struct list_head close_lru;
e8c69d17 84 struct list_head del_recall_lru;
0cc11a61
JL
85
86 /* protected by blocked_locks_lock */
7919d0a2 87 struct list_head blocked_locks_lru;
09121281
SK
88
89 struct delayed_work laundromat_work;
c9a49628
SK
90
91 /* client_lock protects the client lru list and session hash table */
92 spinlock_t client_lock;
3a073369 93
0cc11a61
JL
94 /* protects blocked_locks_lru */
95 spinlock_t blocked_locks_lock;
96
3a073369 97 struct file *rec_file;
f141f79d 98 bool in_grace;
7c582e4f 99 const struct nfsd4_client_tracking_ops *client_tracking_ops;
3d733711 100
20b7d86f
AB
101 time64_t nfsd4_lease;
102 time64_t nfsd4_grace;
03f318ca 103 bool somebody_reclaimed;
2c2fe290 104
362063a5
SM
105 bool track_reclaim_completes;
106 atomic_t nr_reclaim_complete;
107
2c2fe290 108 bool nfsd_net_up;
8ef66714 109 bool lockd_up;
b9c0ef85 110
294ac32e 111 /* Time of server startup */
256a89fa 112 struct timespec64 nfssvc_boot;
27c438f5 113 seqlock_t boot_lock;
9dd9845f 114
5b8db00b
JL
115 /*
116 * Max number of connections this nfsd container will allow. Defaults
117 * to '0' which is means that it bases this on the number of threads.
118 */
119 unsigned int max_connections;
120
bf5ed3e3 121 u32 clientid_base;
294ac32e 122 u32 clientid_counter;
19311aa8 123 u32 clverifier_counter;
294ac32e 124
9dd9845f 125 struct svc_serv *nfsd_serv;
2317dc55
VA
126
127 wait_queue_head_t ntf_wq;
128 atomic_t ntf_refcnt;
e0639dc5 129
c6c7f2a8
TM
130 /* Allow umount to wait for nfsd state cleanup */
131 struct completion nfsd_shutdown_complete;
132
e0639dc5
OK
133 /*
134 * clientid and stateid data for construction of net unique COPY
135 * stateids.
136 */
137 u32 s2s_cp_cl_id;
138 struct idr s2s_cp_stateids;
139 spinlock_t s2s_cp_lock;
e333f3bb
TM
140
141 /*
142 * Version information
143 */
144 bool *nfsd_versions;
145 bool *nfsd4_minorversions;
3ba75830
BF
146
147 /*
148 * Duplicate reply cache
149 */
150 struct nfsd_drc_bucket *drc_hashtbl;
3ba75830
BF
151
152 /* max number of entries allowed in the cache */
153 unsigned int max_drc_entries;
154
155 /* number of significant bits in the hash value */
156 unsigned int maskbits;
157 unsigned int drc_hashsize;
158
159 /*
22a46eb4 160 * Stats and other tracking of on the duplicate reply cache.
e567b98c
AG
161 * The longest_chain* fields are modified with only the per-bucket
162 * cache lock, which isn't really safe and should be fixed if we want
163 * these statistics to be completely accurate.
3ba75830
BF
164 */
165
166 /* total number of entries */
167 atomic_t num_drc_entries;
168
e567b98c
AG
169 /* Per-netns stats counters */
170 struct percpu_counter counter[NFSD_NET_COUNTERS_NUM];
3ba75830
BF
171
172 /* longest hash chain seen */
173 unsigned int longest_chain;
174
175 /* size of cache when we saw the longest hash chain */
176 unsigned int longest_chain_cachesize;
177
178 struct shrinker nfsd_reply_cache_shrinker;
94a4beaa 179 /* utsname taken from the process that starts the server */
7627d7dc 180 char nfsd_name[UNX_MAXNODENAME+1];
7ea34ac1
JL
181};
182
44e34da6
BS
183/* Simple check to find out if a given net was properly initialized */
184#define nfsd_netns_ready(nn) ((nn)->sessionid_hashtbl)
185
e333f3bb
TM
186extern void nfsd_netns_free_versions(struct nfsd_net *nn);
187
c7d03a00 188extern unsigned int nfsd_net_id;
27c438f5
TM
189
190void nfsd_copy_boot_verifier(__be32 verf[2], struct nfsd_net *nn);
191void nfsd_reset_boot_verifier(struct nfsd_net *nn);
7ea34ac1 192#endif /* __NFSD_NETNS_H__ */