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

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