Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Request reply cache. This was heavily inspired by the
0004  * implementation in 4.3BSD/4.4BSD.
0005  *
0006  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
0007  */
0008 
0009 #ifndef NFSCACHE_H
0010 #define NFSCACHE_H
0011 
0012 #include <linux/sunrpc/svc.h>
0013 #include "netns.h"
0014 
0015 /*
0016  * Representation of a reply cache entry.
0017  *
0018  * Note that we use a sockaddr_in6 to hold the address instead of the more
0019  * typical sockaddr_storage. This is for space reasons, since sockaddr_storage
0020  * is much larger than a sockaddr_in6.
0021  */
0022 struct svc_cacherep {
0023     struct {
0024         /* Keep often-read xid, csum in the same cache line: */
0025         __be32          k_xid;
0026         __wsum          k_csum;
0027         u32         k_proc;
0028         u32         k_prot;
0029         u32         k_vers;
0030         unsigned int        k_len;
0031         struct sockaddr_in6 k_addr;
0032     } c_key;
0033 
0034     struct rb_node      c_node;
0035     struct list_head    c_lru;
0036     unsigned char       c_state,    /* unused, inprog, done */
0037                 c_type,     /* status, buffer */
0038                 c_secure : 1;   /* req came from port < 1024 */
0039     unsigned long       c_timestamp;
0040     union {
0041         struct kvec u_vec;
0042         __be32      u_status;
0043     }           c_u;
0044 };
0045 
0046 #define c_replvec       c_u.u_vec
0047 #define c_replstat      c_u.u_status
0048 
0049 /* cache entry states */
0050 enum {
0051     RC_UNUSED,
0052     RC_INPROG,
0053     RC_DONE
0054 };
0055 
0056 /* return values */
0057 enum {
0058     RC_DROPIT,
0059     RC_REPLY,
0060     RC_DOIT
0061 };
0062 
0063 /*
0064  * Cache types.
0065  * We may want to add more types one day, e.g. for diropres and
0066  * attrstat replies. Using cache entries with fixed length instead
0067  * of buffer pointers may be more efficient.
0068  */
0069 enum {
0070     RC_NOCACHE,
0071     RC_REPLSTAT,
0072     RC_REPLBUFF,
0073 };
0074 
0075 /* Cache entries expire after this time period */
0076 #define RC_EXPIRE       (120 * HZ)
0077 
0078 /* Checksum this amount of the request */
0079 #define RC_CSUMLEN      (256U)
0080 
0081 int nfsd_drc_slab_create(void);
0082 void    nfsd_drc_slab_free(void);
0083 int nfsd_reply_cache_init(struct nfsd_net *);
0084 void    nfsd_reply_cache_shutdown(struct nfsd_net *);
0085 int nfsd_cache_lookup(struct svc_rqst *);
0086 void    nfsd_cache_update(struct svc_rqst *, int, __be32 *);
0087 int nfsd_reply_cache_stats_open(struct inode *, struct file *);
0088 
0089 #endif /* NFSCACHE_H */