root/fs/nfs/sock.c

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

DEFINITIONS

This source file includes following definitions.
  1. nfs_rpc_call

   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 /* JEJB/JSP 2/7/94
  34  * this must match the value of NFS_SLACK_SPACE in linux/fs/nfs/proc.c 
  35  * ***FIXME*** should probably put this in nfs_fs.h */
  36 #define NFS_SLACK_SPACE 1024
  37 
  38 #define _S(nr) (1<<((nr)-1))
  39 
  40 /*
  41  * We violate some modularity principles here by poking around
  42  * in some socket internals.  Besides having to call socket
  43  * functions from kernel-space instead of user space, the socket
  44  * interface does not lend itself well to being cleanly called
  45  * without a file descriptor.  Since the nfs calls can run on
  46  * behalf of any process, the superblock maintains a file pointer
  47  * to the server socket.
  48  */
  49 
  50 int
  51 nfs_rpc_call(struct nfs_server *server, int *start, int *end, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
  52 {
  53         struct rpc_timeout      timeout;
  54         unsigned long           maxtimeo;
  55         unsigned long           oldmask;
  56         int                     major_timeout_seen, result;
  57 
  58         timeout.init_timeout = server->timeo;
  59         timeout.max_timeout = maxtimeo = NFS_MAX_RPC_TIMEOUT*HZ/10;
  60         timeout.retries = server->retrans;
  61         timeout.exponential = 1;
  62 
  63         oldmask = current->blocked;
  64         current->blocked |= ~(_S(SIGKILL)
  65                 | ((server->flags & NFS_MOUNT_INTR)
  66                 ? ((current->sig->action[SIGINT - 1].sa_handler == SIG_DFL
  67                         ? _S(SIGINT) : 0)
  68                 | (current->sig->action[SIGQUIT - 1].sa_handler == SIG_DFL
  69                         ? _S(SIGQUIT) : 0))
  70                 : 0));
  71         major_timeout_seen = 0;
  72 
  73         do {
  74                 result = rpc_call(server->rsock, 
  75                                 &server->toaddr, sizeof(server->toaddr),
  76                                 start, ((char *) end) - ((char *) start),
  77                                 start, size + 1024,
  78                                 &timeout, 1);
  79                 if (current->signal & ~current->blocked)
  80                         result = -ERESTARTSYS;
  81                 if (result == -ETIMEDOUT) {
  82                         if (server->flags & NFS_MOUNT_SOFT) {
  83                                 printk("NFS server %s not responding, "
  84                                         "timed out.\n", server->hostname);
  85                                 result = -EIO;
  86                                 break;
  87                         }
  88                         if (!major_timeout_seen) {
  89                                 printk("NFS server %s not responding, "
  90                                         "still trying.\n", server->hostname);
  91                                 major_timeout_seen = 1;
  92                         }
  93                         if ((timeout.init_timeout <<= 1) >= maxtimeo)
  94                                 timeout.init_timeout = maxtimeo;
  95                 } else if (result < 0 && result != ERESTARTSYS) {
  96                         printk("NFS: notice message: result = %d.\n", result);
  97                 }
  98         } while (result == -ETIMEDOUT && !(server->flags & NFS_MOUNT_SOFT));
  99 
 100         if (result >= 0 && major_timeout_seen)
 101                 printk("NFS server %s OK.\n", server->hostname);
 102         /* 20 is the minimum RPC reply header size */
 103         if (result >= 0 && result < 20) {
 104                 printk("NFS: too small read memory size (%d bytes)\n", result);
 105                 result = -EIO;
 106         }
 107 
 108         current->blocked = oldmask;
 109         return result;
 110 }

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