patch-1.3.82 linux/include/linux/rpcsock.h

Next file: linux/include/linux/sysctl.h
Previous file: linux/include/linux/nfsiod.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.81/linux/include/linux/rpcsock.h linux/include/linux/rpcsock.h
@@ -1,54 +1,118 @@
 /*
  *  rpcsock.h	Declarations for the RPC call interface.
  *
- *  Coypright (C) 1995 Olaf Kirch <okir@monad.swb.de>
- *
+ *  Coypright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
 
 #ifndef _LINUX_RPCSOCK_H
 #define _LINUX_RPCSOCK_H
 
-/* Maximum number of outstanding RPCs per socket.
- * With 32 slots, IP fragment reassembly would frequently
- * fail due to low memory.
+/*
+ * The rpcsock code maintains an estimate on the maximum number of out-
+ * standing RPC requests, using the congestion avoidance implemented in
+ * 44BSD. This is basically the Van Jacobson slow start algorithm: If a
+ * retransmit occurs, the congestion window is halved; otherwise, it is
+ * incremented by 1/cwnd when a reply is received and a full number of
+ * requests are outstanding.
+ *
+ * Upper procedures may check whether a request would block waiting for
+ * a free RPC slot by using the RPC_CONGESTED() macro.
+ *
+ * Note: on machines with low memory we should probably use a smaller
+ * MAXREQS value: At 32 outstanding reqs with 8 megs of RAM, fragment
+ * reassembly will frequently run out of memory.
  */
-#define NRREQS		16
+#define RPC_MAXREQS		32
+#define RPC_CWNDSCALE		256
+#define RPC_MAXCWND		(RPC_MAXREQS * RPC_CWNDSCALE)
+/* #define RPC_INITCWND		(RPC_MAXCWND / 2) */
+#define RPC_INITCWND		RPC_CWNDSCALE
+#define RPC_CONGESTED(rsock)	((rsock)->cong >= (rsock)->cwnd)
 
-/* This describes a timeout strategy */
+/* RPC reply header size: xid, direction, status, accept_status (verifier
+ * size computed separately)
+ */
+#define RPC_HDRSIZE		(4 * 4)
+
+/*
+ * This describes a timeout strategy
+ */
 struct rpc_timeout {
-	unsigned long		init_timeout,
-				max_timeout,
-				increment;
-	int			retries;
-	char			exponential;
+	unsigned long		to_initval,
+				to_maxval,
+				to_increment;
+	int			to_retries;
+	char			to_exponential;
 };
 
-/* Wait information */
+/*
+ * This describes a complete RPC request
+ */
+struct rpc_ioreq {
+	struct rpc_wait *	rq_slot;
+	struct sockaddr	*	rq_addr;
+	int			rq_alen;
+	struct iovec		rq_svec[MAX_IOVEC];
+	unsigned int		rq_snr;
+	unsigned long		rq_slen;
+	struct iovec		rq_rvec[MAX_IOVEC];
+	unsigned int		rq_rnr;
+	unsigned long		rq_rlen;
+};
+
+/*
+ * This is the callback handler for async RPC.
+ */
+struct rpc_wait;
+typedef void	(*rpc_callback_fn_t)(int, struct rpc_wait *, void *);
+
+/*
+ * Wait information. This struct defines all the state of an RPC
+ * request currently in flight.
+ */
 struct rpc_wait {
-	struct rpc_wait		*prev, *next;
-	struct wait_queue	*wait;
-	int			*buf;
-	int			len;
-	char			gotit;
-	__u32			xid;
+	struct rpc_sock *	w_sock;
+	struct rpc_wait *	w_prev;
+	struct rpc_wait *	w_next;
+	struct rpc_ioreq *	w_req;
+	int			w_result;
+	struct wait_queue *	w_wait;
+	rpc_callback_fn_t	w_handler;
+	void *			w_cdata;
+	char			w_queued;
+	char			w_gotit;
+	__u32			w_xid;
 };
 
 struct rpc_sock {
-	struct file		*file;
-	struct socket		*sock;
-	struct rpc_wait		waiting[NRREQS];
-	struct rpc_wait		*head, *tail, *free;
-	struct wait_queue	*backlog;
-	struct wait_queue	*shutwait;
+	struct file *		file;
+	struct socket *		sock;
+	struct sock *		inet;
+	struct rpc_wait		waiting[RPC_MAXREQS];
+	unsigned long		cong;
+	unsigned long		cwnd;
+	struct rpc_wait *	pending;
+	struct rpc_wait *	free;
+	struct wait_queue *	backlog;
+	struct wait_queue *	shutwait;
 	int			shutdown;
 };
 
 #ifdef __KERNEL__
 
-int			rpc_call(struct rpc_sock *, struct sockaddr *, int,
-				const int *, int, int *, int,
-				struct rpc_timeout *, int);
+/* rpc_call: Call synchronously */
+int			rpc_call(struct rpc_sock *, struct rpc_ioreq *,
+					 struct rpc_timeout *);
+/* These implement asynch calls for nfsiod: Process calls rpc_reserve and
+ * rpc_transmits, then passes the request to nfsiod, which collects the
+ * results via rpc_doio
+ */
+int			rpc_reserve(struct rpc_sock *, struct rpc_ioreq *, int);
+void			rpc_release(struct rpc_sock *, struct rpc_ioreq *);
+int			rpc_transmit(struct rpc_sock *, struct rpc_ioreq *);
+int			rpc_doio(struct rpc_sock *, struct rpc_ioreq *,
+					 struct rpc_timeout *, int);
 struct rpc_sock	*	rpc_makesock(struct file *);
 int			rpc_closesock(struct rpc_sock *);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this