linux-stable/include/linux/nfsd/cache.h
Andy Adamson 074fe89753 nfsd41: DRC save, restore, and clear functions
Cache all the result pages, including the rpc header in rq_respages[0],
for a request in the slot table cache entry.

Cache the statp pointer from nfsd_dispatch which points into rq_respages[0]
just past the rpc header. When setting a cache entry, calculate and save the
length of the nfs data minus the rpc header for rq_respages[0].

When replaying a cache entry, replace the cached rpc header with the
replayed request rpc result header, unless there is not enough room in the
cached results first page. In that case, use the cached rpc header.

The sessions fore channel maxresponse size cached is set to NFSD_PAGES_PER_SLOT
* PAGE_SIZE. For compounds we are cacheing with operations such as READDIR
that use the xdr_buf->pages to hold data, we choose to cache the extra page of
data rather than copying data from xdr_buf->pages into the xdr_buf->head page.

[nfsd41: limit cache to maxresponsesize_cached]
[nfsd41: mv nfsd4_set_statp under CONFIG_NFSD_V4_1]
[nfsd41: rename nfsd4_move_pages]
[nfsd41: rename page_no variable]
[nfsd41: rename nfsd4_set_cache_entry]
[nfsd41: fix nfsd41_copy_replay_data comment]
[nfsd41: add to nfsd4_set_cache_entry]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
2009-04-03 17:41:17 -07:00

80 lines
1.6 KiB
C

/*
* include/linux/nfsd/cache.h
*
* Request reply cache. This was heavily inspired by the
* implementation in 4.3BSD/4.4BSD.
*
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
*/
#ifndef NFSCACHE_H
#define NFSCACHE_H
#include <linux/in.h>
#include <linux/uio.h>
/*
* Representation of a reply cache entry. The first two members *must*
* be hash_next and hash_prev.
*/
struct svc_cacherep {
struct hlist_node c_hash;
struct list_head c_lru;
unsigned char c_state, /* unused, inprog, done */
c_type, /* status, buffer */
c_secure : 1; /* req came from port < 1024 */
struct sockaddr_in c_addr;
__be32 c_xid;
u32 c_prot;
u32 c_proc;
u32 c_vers;
unsigned long c_timestamp;
union {
struct kvec u_vec;
__be32 u_status;
} c_u;
};
#define c_replvec c_u.u_vec
#define c_replstat c_u.u_status
/* cache entry states */
enum {
RC_UNUSED,
RC_INPROG,
RC_DONE
};
/* return values */
enum {
RC_DROPIT,
RC_REPLY,
RC_DOIT,
RC_INTR
};
/*
* Cache types.
* We may want to add more types one day, e.g. for diropres and
* attrstat replies. Using cache entries with fixed length instead
* of buffer pointers may be more efficient.
*/
enum {
RC_NOCACHE,
RC_REPLSTAT,
RC_REPLBUFF,
};
/*
* If requests are retransmitted within this interval, they're dropped.
*/
#define RC_DELAY (HZ/5)
int nfsd_reply_cache_init(void);
void nfsd_reply_cache_shutdown(void);
int nfsd_cache_lookup(struct svc_rqst *, int);
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp);
#endif /* NFSCACHE_H */