This source file includes following definitions.
- nfs_rpc_call
- nfs_rpc_doio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <linux/sched.h>
22 #include <linux/nfs_fs.h>
23 #include <linux/errno.h>
24 #include <linux/socket.h>
25 #include <linux/fcntl.h>
26 #include <linux/in.h>
27 #include <linux/net.h>
28 #include <linux/mm.h>
29 #include <linux/rpcsock.h>
30
31 #include <asm/segment.h>
32
33 #define _S(nr) (1<<((nr)-1))
34
35
36
37
38
39
40
41 int
42 nfs_rpc_call(struct nfs_server *server, int *start, int *end, int size)
43 {
44 struct rpc_ioreq req;
45
46 size += 1024;
47
48 req.rq_addr = &server->toaddr;
49 req.rq_alen = sizeof(server->toaddr);
50 req.rq_slot = NULL;
51
52 req.rq_svec[0].iov_base = start;
53 req.rq_svec[0].iov_len = (end - start) << 2;
54 req.rq_slen = (end - start) << 2;
55 req.rq_snr = 1;
56 req.rq_rvec[0].iov_base = start;
57 req.rq_rvec[0].iov_len = size;
58 req.rq_rlen = size;
59 req.rq_rnr = 1;
60
61 return nfs_rpc_doio(server, &req, 0);
62 }
63
64 int
65 nfs_rpc_doio(struct nfs_server *server, struct rpc_ioreq *req, int async)
66 {
67 struct rpc_timeout timeout;
68 unsigned long maxtimeo;
69 unsigned long oldmask;
70 int major_timeout_seen, result;
71
72 timeout.to_initval = server->timeo;
73 timeout.to_maxval = NFS_MAX_RPC_TIMEOUT*HZ/10;
74 timeout.to_retries = server->retrans;
75 timeout.to_exponential = 1;
76
77 oldmask = current->blocked;
78 current->blocked |= ~(_S(SIGKILL)
79 | ((server->flags & NFS_MOUNT_INTR)
80 ? ((current->sig->action[SIGINT - 1].sa_handler == SIG_DFL
81 ? _S(SIGINT) : 0)
82 | (current->sig->action[SIGQUIT - 1].sa_handler == SIG_DFL
83 ? _S(SIGQUIT) : 0))
84 : 0));
85
86 major_timeout_seen = 0;
87 maxtimeo = timeout.to_maxval;
88
89 do {
90 result = rpc_doio(server->rsock, req, &timeout, async);
91 rpc_release(server->rsock, req);
92
93 if (current->signal & ~current->blocked)
94 result = -ERESTARTSYS;
95 if (result == -ETIMEDOUT) {
96 if (async)
97 break;
98 if (server->flags & NFS_MOUNT_SOFT) {
99 printk("NFS server %s not responding, "
100 "timed out.\n", server->hostname);
101 result = -EIO;
102 break;
103 }
104 if (!major_timeout_seen) {
105 printk("NFS server %s not responding, "
106 "still trying.\n", server->hostname);
107 major_timeout_seen = 1;
108 }
109 if ((timeout.to_initval <<= 1) >= maxtimeo) {
110 timeout.to_initval = maxtimeo;
111 }
112 } else if (result < 0 && result != -ERESTARTSYS) {
113 printk("NFS: notice message: result = %d.\n", result);
114 }
115 } while (result == -ETIMEDOUT && !(server->flags & NFS_MOUNT_SOFT));
116
117 if (result >= 0 && major_timeout_seen)
118 printk("NFS server %s OK.\n", server->hostname);
119
120 if (result >= 0 && result < 20) {
121 printk("NFS: too small read memory size (%d bytes)\n", result);
122 result = -EIO;
123 }
124
125 current->blocked = oldmask;
126 return result;
127 }