Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Request reply cache. This was heavily inspired by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * implementation in 4.3BSD/4.4BSD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #ifndef NFSCACHE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define NFSCACHE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/sunrpc/svc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "netns.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * Representation of a reply cache entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * Note that we use a sockaddr_in6 to hold the address instead of the more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * typical sockaddr_storage. This is for space reasons, since sockaddr_storage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  * is much larger than a sockaddr_in6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct svc_cacherep {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		/* Keep often-read xid, csum in the same cache line: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		__be32			k_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		__wsum			k_csum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		u32			k_proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		u32			k_prot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		u32			k_vers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		unsigned int		k_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		struct sockaddr_in6	k_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	} c_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	struct rb_node		c_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	struct list_head	c_lru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	unsigned char		c_state,	/* unused, inprog, done */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 				c_type,		/* status, buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 				c_secure : 1;	/* req came from port < 1024 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	unsigned long		c_timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		struct kvec	u_vec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		__be32		u_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	}			c_u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define c_replvec		c_u.u_vec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define c_replstat		c_u.u_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* cache entry states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	RC_UNUSED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	RC_INPROG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	RC_DONE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* return values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	RC_DROPIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	RC_REPLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	RC_DOIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)  * Cache types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)  * We may want to add more types one day, e.g. for diropres and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)  * attrstat replies. Using cache entries with fixed length instead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)  * of buffer pointers may be more efficient.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	RC_NOCACHE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	RC_REPLSTAT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	RC_REPLBUFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* Cache entries expire after this time period */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define RC_EXPIRE		(120 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* Checksum this amount of the request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define RC_CSUMLEN		(256U)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int	nfsd_drc_slab_create(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void	nfsd_drc_slab_free(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int	nfsd_reply_cache_init(struct nfsd_net *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void	nfsd_reply_cache_shutdown(struct nfsd_net *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int	nfsd_cache_lookup(struct svc_rqst *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) void	nfsd_cache_update(struct svc_rqst *, int, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int	nfsd_reply_cache_stats_open(struct inode *, struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #endif /* NFSCACHE_H */