aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfsd/netns.h8
-rw-r--r--fs/nfsd/state.h100
2 files changed, 101 insertions, 7 deletions
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
index 3831ef6e5c75..ea6749a32760 100644
--- a/fs/nfsd/netns.h
+++ b/fs/nfsd/netns.h
@@ -34,6 +34,14 @@
34struct cld_net; 34struct cld_net;
35struct nfsd4_client_tracking_ops; 35struct nfsd4_client_tracking_ops;
36 36
37/*
38 * Represents a nfsd "container". With respect to nfsv4 state tracking, the
39 * fields of interest are the *_id_hashtbls and the *_name_tree. These track
40 * the nfs4_client objects by either short or long form clientid.
41 *
42 * Each nfsd_net runs a nfs4_laundromat workqueue job when necessary to clean
43 * up expired clients and delegations within the container.
44 */
37struct nfsd_net { 45struct nfsd_net {
38 struct cld_net *cld_net; 46 struct cld_net *cld_net;
39 47
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 32a7c290d027..4a89e00d7461 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -72,6 +72,11 @@ struct nfsd4_callback {
72 bool cb_done; 72 bool cb_done;
73}; 73};
74 74
75/*
76 * A core object that represents a "common" stateid. These are generally
77 * embedded within the different (more specific) stateid objects and contain
78 * fields that are of general use to any stateid.
79 */
75struct nfs4_stid { 80struct nfs4_stid {
76 atomic_t sc_count; 81 atomic_t sc_count;
77#define NFS4_OPEN_STID 1 82#define NFS4_OPEN_STID 1
@@ -89,6 +94,27 @@ struct nfs4_stid {
89 void (*sc_free)(struct nfs4_stid *); 94 void (*sc_free)(struct nfs4_stid *);
90}; 95};
91 96
97/*
98 * Represents a delegation stateid. The nfs4_client holds references to these
99 * and they are put when it is being destroyed or when the delegation is
100 * returned by the client:
101 *
102 * o 1 reference as long as a delegation is still in force (taken when it's
103 * alloc'd, put when it's returned or revoked)
104 *
105 * o 1 reference as long as a recall rpc is in progress (taken when the lease
106 * is broken, put when the rpc exits)
107 *
108 * o 1 more ephemeral reference for each nfsd thread currently doing something
109 * with that delegation without holding the cl_lock
110 *
111 * If the server attempts to recall a delegation and the client doesn't do so
112 * before a timeout, the server may also revoke the delegation. In that case,
113 * the object will either be destroyed (v4.0) or moved to a per-client list of
114 * revoked delegations (v4.1+).
115 *
116 * This object is a superset of the nfs4_stid.
117 */
92struct nfs4_delegation { 118struct nfs4_delegation {
93 struct nfs4_stid dl_stid; /* must be first field */ 119 struct nfs4_stid dl_stid; /* must be first field */
94 struct list_head dl_perfile; 120 struct list_head dl_perfile;
@@ -195,6 +221,11 @@ struct nfsd4_conn {
195 unsigned char cn_flags; 221 unsigned char cn_flags;
196}; 222};
197 223
224/*
225 * Representation of a v4.1+ session. These are refcounted in a similar fashion
226 * to the nfs4_client. References are only taken when the server is actively
227 * working on the object (primarily during the processing of compounds).
228 */
198struct nfsd4_session { 229struct nfsd4_session {
199 atomic_t se_ref; 230 atomic_t se_ref;
200 struct list_head se_hash; /* hash by sessionid */ 231 struct list_head se_hash; /* hash by sessionid */
@@ -224,13 +255,30 @@ struct nfsd4_sessionid {
224 255
225/* 256/*
226 * struct nfs4_client - one per client. Clientids live here. 257 * struct nfs4_client - one per client. Clientids live here.
227 * o Each nfs4_client is hashed by clientid.
228 * 258 *
229 * o Each nfs4_clients is also hashed by name 259 * The initial object created by an NFS client using SETCLIENTID (for NFSv4.0)
230 * (the opaque quantity initially sent by the client to identify itself). 260 * or EXCHANGE_ID (for NFSv4.1+). These objects are refcounted and timestamped.
261 * Each nfsd_net_ns object contains a set of these and they are tracked via
262 * short and long form clientid. They are hashed and searched for under the
263 * per-nfsd_net client_lock spinlock.
264 *
265 * References to it are only held during the processing of compounds, and in
266 * certain other operations. In their "resting state" they have a refcount of
267 * 0. If they are not renewed within a lease period, they become eligible for
268 * destruction by the laundromat.
269 *
270 * These objects can also be destroyed prematurely by the fault injection code,
271 * or if the client sends certain forms of SETCLIENTID or EXCHANGE_ID updates.
272 * Care is taken *not* to do this however when the objects have an elevated
273 * refcount.
274 *
275 * o Each nfs4_client is hashed by clientid
276 *
277 * o Each nfs4_clients is also hashed by name (the opaque quantity initially
278 * sent by the client to identify itself).
231 * 279 *
232 * o cl_perclient list is used to ensure no dangling stateowner references 280 * o cl_perclient list is used to ensure no dangling stateowner references
233 * when we expire the nfs4_client 281 * when we expire the nfs4_client
234 */ 282 */
235struct nfs4_client { 283struct nfs4_client {
236 struct list_head cl_idhash; /* hash by cl_clientid.id */ 284 struct list_head cl_idhash; /* hash by cl_clientid.id */
@@ -340,6 +388,12 @@ struct nfs4_stateowner_operations {
340 void (*so_free)(struct nfs4_stateowner *); 388 void (*so_free)(struct nfs4_stateowner *);
341}; 389};
342 390
391/*
392 * A core object that represents either an open or lock owner. The object and
393 * lock owner objects have one of these embedded within them. Refcounts and
394 * other fields common to both owner types are contained within these
395 * structures.
396 */
343struct nfs4_stateowner { 397struct nfs4_stateowner {
344 struct list_head so_strhash; 398 struct list_head so_strhash;
345 struct list_head so_stateids; 399 struct list_head so_stateids;
@@ -354,6 +408,12 @@ struct nfs4_stateowner {
354 bool so_is_open_owner; 408 bool so_is_open_owner;
355}; 409};
356 410
411/*
412 * When a file is opened, the client provides an open state owner opaque string
413 * that indicates the "owner" of that open. These objects are refcounted.
414 * References to it are held by each open state associated with it. This object
415 * is a superset of the nfs4_stateowner struct.
416 */
357struct nfs4_openowner { 417struct nfs4_openowner {
358 struct nfs4_stateowner oo_owner; /* must be first field */ 418 struct nfs4_stateowner oo_owner; /* must be first field */
359 struct list_head oo_perclient; 419 struct list_head oo_perclient;
@@ -371,6 +431,12 @@ struct nfs4_openowner {
371 unsigned char oo_flags; 431 unsigned char oo_flags;
372}; 432};
373 433
434/*
435 * Represents a generic "lockowner". Similar to an openowner. References to it
436 * are held by the lock stateids that are created on its behalf. This object is
437 * a superset of the nfs4_stateowner struct (or would be if it needed any extra
438 * fields).
439 */
374struct nfs4_lockowner { 440struct nfs4_lockowner {
375 struct nfs4_stateowner lo_owner; /* must be first element */ 441 struct nfs4_stateowner lo_owner; /* must be first element */
376}; 442};
@@ -385,7 +451,14 @@ static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)
385 return container_of(so, struct nfs4_lockowner, lo_owner); 451 return container_of(so, struct nfs4_lockowner, lo_owner);
386} 452}
387 453
388/* nfs4_file: a file opened by some number of (open) nfs4_stateowners. */ 454/*
455 * nfs4_file: a file opened by some number of (open) nfs4_stateowners.
456 *
457 * These objects are global. nfsd only keeps one instance of a nfs4_file per
458 * inode (though it may keep multiple file descriptors open per inode). These
459 * are tracked in the file_hashtbl which is protected by the state_lock
460 * spinlock.
461 */
389struct nfs4_file { 462struct nfs4_file {
390 atomic_t fi_ref; 463 atomic_t fi_ref;
391 spinlock_t fi_lock; 464 spinlock_t fi_lock;
@@ -410,7 +483,20 @@ struct nfs4_file {
410 bool fi_had_conflict; 483 bool fi_had_conflict;
411}; 484};
412 485
413/* "ol" stands for "Open or Lock". Better suggestions welcome. */ 486/*
487 * A generic struct representing either a open or lock stateid. The nfs4_client
488 * holds a reference to each of these objects, and they in turn hold a
489 * reference to their respective stateowners. The client's reference is
490 * released in response to a close or unlock (depending on whether it's an open
491 * or lock stateid) or when the client is being destroyed.
492 *
493 * In the case of v4.0 open stateids, these objects are preserved for a little
494 * while after close in order to handle CLOSE replays. Those are eventually
495 * reclaimed via a LRU scheme by the laundromat.
496 *
497 * This object is a superset of the nfs4_stid. "ol" stands for "Open or Lock".
498 * Better suggestions welcome.
499 */
414struct nfs4_ol_stateid { 500struct nfs4_ol_stateid {
415 struct nfs4_stid st_stid; /* must be first field */ 501 struct nfs4_stid st_stid; /* must be first field */
416 struct list_head st_perfile; 502 struct list_head st_perfile;