root/fs/nfs/sock.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. nfs_rpc_call
  2. nfs_rpc_doio

   1 /*
   2  *  linux/fs/nfs/sock.c
   3  *
   4  *  Copyright (C) 1992, 1993  Rick Sladkey
   5  *
   6  *  low-level nfs remote procedure call interface
   7  *
   8  * FIXES
   9  *
  10  * 2/7/94 James Bottomley and Jon Peatfield DAMTP, Cambridge University
  11  *
  12  * An xid mismatch no longer causes the request to be trashed.
  13  *
  14  * Peter Eriksson - incorrect XID used to confuse Linux
  15  * Florian La Roche - use the correct max size, if reading a packet and
  16  *                    also verify, if the whole packet has been read...
  17  *                    more checks should be done in proc.c...
  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  * Place a synchronous call to the NFS server, meaning that the process
  37  * sleeps in rpc_call until it either receives a reply or a major timeout
  38  * occurs.
  39  * This is now merely a front-end to nfs_rpc_doio.
  40  */
  41 int
  42 nfs_rpc_call(struct nfs_server *server, int *start, int *end, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
  43 {
  44         struct rpc_ioreq        req;
  45 
  46         size += 1024;           /* account for NFS slack space. ugly */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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);        /* Release slot */
  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         /* 20 is the minimum RPC reply header size */
 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 }

/* [previous][next][first][last][top][bottom][index][help] */