home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume3 / rfs / patches3 / text0000.txt < prev   
Encoding:
Text File  |  1986-11-30  |  14.3 KB  |  505 lines

  1.  
  2. 4 bug fixes follow.  The most important is one I did out of sheer
  3. frustration:  when a server host goes down, the client kernel marks the
  4. connection as closing and refuses to start up another connection until
  5. all the processes which have used that host have exited.  I now think
  6. that this is ridiculous requirement.  And from the hassles I have
  7. received from users and those you have told me you get from your users,
  8. I surmise that I am not alone in ridiculing my own implementation.
  9.  
  10. The fix simply entailed not waiting for processes using the connection
  11. to exit.  The result is that any process that has open file descriptors
  12. or a working directory on the remote host, suddenly loses them... but
  13. then, they were lost anyway.  Most important, though, the connection will
  14. restart (if the other host is up).  Two files changed in the kernel,
  15. remote/rmt_io.c and remote/rmt_generic.c.  First, here are the changes
  16. to remote/rmt_io.c:
  17.  
  18. ***************
  19. *** 11,17
  20.    * may be copied, modified or used in any way, without fee, provided this
  21.    * notice remains an unaltered part of the software.
  22.    *
  23. !  * $Header: rmt_io.c,v 2.3 86/02/04 10:26:43 toddb Exp $
  24.    *
  25.    * $Log:    rmt_io.c,v $
  26.    * Revision 2.3  86/02/04  10:26:43  toddb
  27.  
  28. - --- 11,17 -----
  29.    * may be copied, modified or used in any way, without fee, provided this
  30.    * notice remains an unaltered part of the software.
  31.    *
  32. !  * $Header: rmt_io.c,v 2.4 86/02/17 17:43:21 toddb Exp $
  33.    *
  34.    * $Log:    rmt_io.c,v $
  35.    * Revision 2.4  86/02/17  17:43:21  toddb
  36. ***************
  37. *** 14,19
  38.    * $Header: rmt_io.c,v 2.3 86/02/04 10:26:43 toddb Exp $
  39.    *
  40.    * $Log:    rmt_io.c,v $
  41.    * Revision 2.3  86/02/04  10:26:43  toddb
  42.    * Added a missing rmt_unuse() call when it is too soon to call a host
  43.    * that has failed a connection.  Contributed by Dennis Rockwell @ csnet.
  44.  
  45. - --- 14,25 -----
  46.    * $Header: rmt_io.c,v 2.4 86/02/17 17:43:21 toddb Exp $
  47.    *
  48.    * $Log:    rmt_io.c,v $
  49. +  * Revision 2.4  86/02/17  17:43:21  toddb
  50. +  * If the host is closing, remote_getconnection() goes right ahead and
  51. +  * closes and then tries to reopen.  This provides a pretty good recover
  52. +  * mechanism, except for the fact that current working directories are
  53. +  * lost and open files are lost.
  54. +  * 
  55.    * Revision 2.3  86/02/04  10:26:43  toddb
  56.    * Added a missing rmt_unuse() call when it is too soon to call a host
  57.    * that has failed a connection.  Contributed by Dennis Rockwell @ csnet.
  58. ***************
  59. *** 88,93
  60.           return(rp->r_openerr);
  61.       }
  62.       /*
  63.        * We may already have a connection
  64.        */
  65.       else if (rp->r_sock)
  66.  
  67. - --- 94,104 -----
  68.           return(rp->r_openerr);
  69.       }
  70.       /*
  71. +      * If it is closing, do it here and get it over with.
  72. +      */
  73. +     else if (rp->r_close)
  74. +         rmt_closehost(rp);
  75. +     /*
  76.        * We may already have a connection
  77.        */
  78.       else if (rp->r_sock)
  79. ***************
  80. *** 103,108
  81.           rp->r_failed = FALSE;
  82.       }
  83.       rp->r_opening = TRUE;
  84.   
  85.       /*
  86.        * pseudo loop to avoid labels...
  87.  
  88. - --- 114,120 -----
  89.           rp->r_failed = FALSE;
  90.       }
  91.       rp->r_opening = TRUE;
  92. +     rp->r_close = FALSE;
  93.   
  94.       /*
  95.        * pseudo loop to avoid labels...
  96. ***************
  97. *** 205,211
  98.       /*
  99.        * get a connection.
  100.        */
  101. !     if ((so = rp->r_sock) == NULL)
  102.           if (error = remote_getconnection(system)) {
  103.               (void) m_freem(*m);
  104.               return(error);
  105.  
  106. - --- 217,223 -----
  107.       /*
  108.        * get a connection.
  109.        */
  110. !     if ((so = rp->r_sock) == NULL || rp->r_close)
  111.           if (error = remote_getconnection(system)) {
  112.               (void) m_freem(*m);
  113.               return(error);
  114.  
  115. Changes to remote/rmt_generic.c:
  116. ***************
  117. *** 11,17
  118.    * may be copied, modified or used in any way, without fee, provided this
  119.    * notice remains an unaltered part of the software.
  120.    *
  121. !  * $Header: rmt_generic.c,v 2.3 86/02/17 14:36:37 toddb Exp $
  122.    *
  123.    * $Log:    rmt_generic.c,v $
  124.    * Revision 2.3  86/02/17  14:36:37  toddb
  125.  
  126. - --- 11,17 -----
  127.    * may be copied, modified or used in any way, without fee, provided this
  128.    * notice remains an unaltered part of the software.
  129.    *
  130. !  * $Header: rmt_generic.c,v 2.4 86/02/17 17:46:07 toddb Exp $
  131.    *
  132.    * $Log:    rmt_generic.c,v $
  133.    * Revision 2.4  86/02/17  17:46:07  toddb
  134. ***************
  135. *** 14,19
  136.    * $Header: rmt_generic.c,v 2.3 86/02/17 14:36:37 toddb Exp $
  137.    *
  138.    * $Log:    rmt_generic.c,v $
  139.    * Revision 2.3  86/02/17  14:36:37  toddb
  140.    * Fix so that the kernel properly reacts to nonexistant hosts
  141.    * on the generic mount point: sockargs() was being called in the
  142.  
  143. - --- 14,23 -----
  144.    * $Header: rmt_generic.c,v 2.4 86/02/17 17:46:07 toddb Exp $
  145.    *
  146.    * $Log:    rmt_generic.c,v $
  147. +  * Revision 2.4  86/02/17  17:46:07  toddb
  148. +  * We no longer stop processing in isremote() if the connection is in
  149. +  * the middle of closing.
  150. +  * 
  151.    * Revision 2.3  86/02/17  14:36:37  toddb
  152.    * Fix so that the kernel properly reacts to nonexistant hosts
  153.    * on the generic mount point: sockargs() was being called in the
  154. ***************
  155. *** 441,448
  156.       }
  157.   
  158.       /*
  159. !      * We have a remote mount point.  However, it may be in the midst of
  160. !      * shutting down from some error.  This mount point may also be
  161.        * a "generic" mount point, in which case, we must figure out
  162.        * the host.
  163.        */
  164.  
  165. - --- 445,451 -----
  166.       }
  167.   
  168.       /*
  169. !      * We have a remote mount point.   This mount point may be
  170.        * a "generic" mount point, in which case, we must figure out
  171.        * the host.
  172.        */
  173. ***************
  174. *** 452,462
  175.               debug8("isremote: can't map path %s\n", path);
  176.               return(TRUE);
  177.           }
  178. - -     }
  179. - -     if (rp->r_close) {
  180. - -         debug8("isremote: host %s is closing\n", rp->r_mntpath);
  181. - -         u.u_error = ENOREMOTEFS;
  182. - -         return(TRUE);
  183.       }
  184.       u.u_error = EISREMOTE;
  185.       remote_sysindex = sysnum;
  186.  
  187. - --- 455,460 -----
  188.               debug8("isremote: can't map path %s\n", path);
  189.               return(TRUE);
  190.           }
  191.       }
  192.       u.u_error = EISREMOTE;
  193.       remote_sysindex = sysnum;
  194.  
  195. Dennis Rockwell @ csnet found one of the counting bugs in the RFS
  196. bookkeepping.  I had forgotten a call to rmt_unuse() if it is not time
  197. for a retry.  Here are the changes to the kernel file remote/rmt_io.c:
  198.  
  199. ***************
  200. *** 11,17
  201.    * may be copied, modified or used in any way, without fee, provided this
  202.    * notice remains an unaltered part of the software.
  203.    *
  204. !  * $Header: rmt_io.c,v 2.2 86/01/21 11:05:41 toddb Exp $
  205.    *
  206.    * $Log:    rmt_io.c,v $
  207.    * Revision 2.2  86/01/21  11:05:41  toddb
  208.  
  209. - --- 11,17 -----
  210.    * may be copied, modified or used in any way, without fee, provided this
  211.    * notice remains an unaltered part of the software.
  212.    *
  213. !  * $Header: rmt_io.c,v 2.3 86/02/04 10:26:43 toddb Exp $
  214.    *
  215.    * $Log:    rmt_io.c,v $
  216.    * Revision 2.3  86/02/04  10:26:43  toddb
  217. ***************
  218. *** 14,19
  219.    * $Header: rmt_io.c,v 2.2 86/01/21 11:05:41 toddb Exp $
  220.    *
  221.    * $Log:    rmt_io.c,v $
  222.    * Revision 2.2  86/01/21  11:05:41  toddb
  223.    * Missing argument to sleep() in rmt_getconnection().
  224.    * 
  225.  
  226. - --- 14,23 -----
  227.    * $Header: rmt_io.c,v 2.3 86/02/04 10:26:43 toddb Exp $
  228.    *
  229.    * $Log:    rmt_io.c,v $
  230. +  * Revision 2.3  86/02/04  10:26:43  toddb
  231. +  * Added a missing rmt_unuse() call when it is too soon to call a host
  232. +  * that has failed a connection.  Contributed by Dennis Rockwell @ csnet.
  233. +  * 
  234.    * Revision 2.2  86/01/21  11:05:41  toddb
  235.    * Missing argument to sleep() in rmt_getconnection().
  236.    * 
  237. ***************
  238. *** 92,98
  239.        * If we have failed previously, it may be time to try again.
  240.        */
  241.       else if (rp->r_failed) {
  242. !         if (rp->r_age > time.tv_sec)
  243.               return(rp->r_openerr);
  244.           rp->r_failed = FALSE;
  245.       }
  246.  
  247. - --- 96,103 -----
  248.        * If we have failed previously, it may be time to try again.
  249.        */
  250.       else if (rp->r_failed) {
  251. !         if (rp->r_age > time.tv_sec) {
  252. !             rmt_unuse(rp, system);
  253.               return(rp->r_openerr);
  254.           }
  255.           rp->r_failed = FALSE;
  256. ***************
  257. *** 94,99
  258.       else if (rp->r_failed) {
  259.           if (rp->r_age > time.tv_sec)
  260.               return(rp->r_openerr);
  261.           rp->r_failed = FALSE;
  262.       }
  263.       rp->r_opening = TRUE;
  264.  
  265. - --- 99,105 -----
  266.           if (rp->r_age > time.tv_sec) {
  267.               rmt_unuse(rp, system);
  268.               return(rp->r_openerr);
  269. +         }
  270.           rp->r_failed = FALSE;
  271.       }
  272.       rp->r_opening = TRUE;
  273.  
  274.  
  275. Bill Sommerfeld found a bug in the kernel half of the name server.  If
  276. some invalid host was implied by the pathname /net/host, the server properly
  277. returned a null internet address, but the kernel still called sockargs()
  278. to allocate space for it.  Here are the changes to the kernel
  279. file remote/rmt_generic.c (my appologies, but you will probably have to do
  280. these context diffs by hand, because they contain the code for #ifdef BSD4_3
  281. which my installation script removes).
  282.  
  283. ***************
  284. *** 11,17
  285.    * may be copied, modified or used in any way, without fee, provided this
  286.    * notice remains an unaltered part of the software.
  287.    *
  288. !  * $Header: rmt_generic.c,v 2.2 86/01/02 13:52:32 toddb Exp $
  289.    *
  290.    * $Log:    rmt_generic.c,v $
  291.    * Revision 2.2  86/01/02  13:52:32  toddb
  292.  
  293. - --- 11,17 -----
  294.    * may be copied, modified or used in any way, without fee, provided this
  295.    * notice remains an unaltered part of the software.
  296.    *
  297. !  * $Header: rmt_generic.c,v 2.3 86/02/17 14:36:37 toddb Exp $
  298.    *
  299.    * $Log:    rmt_generic.c,v $
  300.    * Revision 2.3  86/02/17  14:36:37  toddb
  301. ***************
  302. *** 14,19
  303.    * $Header: rmt_generic.c,v 2.2 86/01/02 13:52:32 toddb Exp $
  304.    *
  305.    * $Log:    rmt_generic.c,v $
  306.    * Revision 2.2  86/01/02  13:52:32  toddb
  307.    * Ifdef'ed calls to sockargs() for the differences in 4.2 vs. 4.3.
  308.    * 
  309.  
  310. - --- 14,25 -----
  311.    * $Header: rmt_generic.c,v 2.3 86/02/17 14:36:37 toddb Exp $
  312.    *
  313.    * $Log:    rmt_generic.c,v $
  314. +  * Revision 2.3  86/02/17  14:36:37  toddb
  315. +  * Fix so that the kernel properly reacts to nonexistant hosts
  316. +  * on the generic mount point: sockargs() was being called in the
  317. +  * remotename() system call (case NM_NAMEIS) even if uap->name was null.
  318. +  * Bill Sommerfeld (wesommer@athena.mit.edu).
  319. +  * 
  320.    * Revision 2.2  86/01/02  13:52:32  toddb
  321.    * Ifdef'ed calls to sockargs() for the differences in 4.2 vs. 4.3.
  322.    * 
  323. ***************
  324. *** 328,333
  325.               m_free(m); /* free extra mbuf */
  326.               m = remote_ns.rn_name = NULL;
  327.           }
  328.   #ifdef BSD4_3
  329.           error = sockargs(&m, uap->name, uap->namelen, MT_SONAME);
  330.   #else BSD4_3
  331.  
  332. - --- 334,340 -----
  333.               m_free(m); /* free extra mbuf */
  334.               m = remote_ns.rn_name = NULL;
  335.           }
  336. +         if (uap->name) {
  337.   #ifdef BSD4_3
  338.               error = sockargs(&m, uap->name, uap->namelen, MT_SONAME);
  339.   #else BSD4_3
  340. ***************
  341. *** 329,335
  342.               m = remote_ns.rn_name = NULL;
  343.           }
  344.   #ifdef BSD4_3
  345. !         error = sockargs(&m, uap->name, uap->namelen, MT_SONAME);
  346.   #else BSD4_3
  347.           error = sockargs(&m, uap->name, uap->namelen);
  348.   #endif BSD4_3
  349.  
  350. - --- 336,342 -----
  351.           }
  352.           if (uap->name) {
  353.   #ifdef BSD4_3
  354. !             error = sockargs(&m, uap->name, uap->namelen, MT_SONAME);
  355.   #else BSD4_3
  356.               error = sockargs(&m, uap->name, uap->namelen);
  357.   #endif BSD4_3
  358. ***************
  359. *** 331,337
  360.   #ifdef BSD4_3
  361.           error = sockargs(&m, uap->name, uap->namelen, MT_SONAME);
  362.   #else BSD4_3
  363. !         error = sockargs(&m, uap->name, uap->namelen);
  364.   #endif BSD4_3
  365.           if (error == 0) {
  366.               cp = mtod(m, char *) + m->m_len;
  367.  
  368. - --- 338,344 -----
  369.   #ifdef BSD4_3
  370.               error = sockargs(&m, uap->name, uap->namelen, MT_SONAME);
  371.   #else BSD4_3
  372. !             error = sockargs(&m, uap->name, uap->namelen);
  373.   #endif BSD4_3
  374.               if (error == 0) {
  375.               cp = mtod(m, char *) + m->m_len;
  376. ***************
  377. *** 333,339
  378.   #else BSD4_3
  379.           error = sockargs(&m, uap->name, uap->namelen);
  380.   #endif BSD4_3
  381. !         if (error == 0) {
  382.               cp = mtod(m, char *) + m->m_len;
  383.               if (error = copyin((caddr_t)uap->path, (caddr_t)cp,
  384.                   MIN(R_MNTPATHLEN, MLEN - m->m_len))) {
  385.  
  386. - --- 340,346 -----
  387.   #else BSD4_3
  388.               error = sockargs(&m, uap->name, uap->namelen);
  389.   #endif BSD4_3
  390. !             if (error == 0) {
  391.               cp = mtod(m, char *) + m->m_len;
  392.               if (error = copyin((caddr_t)uap->path, (caddr_t)cp,
  393.                   MIN(R_MNTPATHLEN, MLEN - m->m_len))) {
  394. ***************
  395. *** 341,346
  396.                   m = NULL;
  397.               }
  398.               debug13("nmsrv: %s@%x\n", cp, m);
  399.           }
  400.           remote_ns.rn_name = m;
  401.           wakeup(&remote_ns.rn_name);
  402.  
  403. - --- 348,354 -----
  404.                   m = NULL;
  405.               }
  406.               debug13("nmsrv: %s@%x\n", cp, m);
  407. +             }
  408.           }
  409.           remote_ns.rn_name = m;
  410.           wakeup(&remote_ns.rn_name);
  411.  
  412. Joe Othmer may have found the bug that caused a command like
  413.  
  414.     ls /host1/host2/file
  415.  
  416. to hang.  The sentry server (which does only nameserver functions for
  417. "/net/...", and listens for connections) had the proper call to the
  418. system call "remoteoff(NULL)" so that remote access is denied for the
  419. server.  This sets the SNOREMOTE bit in the proc structure p_flag.
  420. Unfortunately, the gateway server (forked by the sentry server) and
  421. any of the other servers (forked by the gateway server), get this
  422. bit cleared by a fork().  The effect was that the server was actually
  423. allowing the hops to happen.  Here are the changes so that any server is
  424. sure to have the SNOREMOTE bit set.  The changes go in the server
  425. file remote/fileserver.c:
  426.  
  427. ***************
  428. *** 12,17
  429.    * notice remains an unaltered part of the software.
  430.    *
  431.    * $Log:    fileserver.c,v $
  432.    * Revision 2.0  85/12/07  18:21:14  toddb
  433.    * First public release.
  434.    * 
  435.  
  436. - --- 12,22 -----
  437.    * notice remains an unaltered part of the software.
  438.    *
  439.    * $Log:    fileserver.c,v $
  440. +  * Revision 2.1  86/02/17  15:11:03  toddb
  441. +  * The SNOREMOTE bit is cleared in the children of the server, so a call
  442. +  * to remoteoff(NULL) was added to server() and to become_server().
  443. +  * Joe Othmer (vax135!jo).
  444. +  * 
  445.    * Revision 2.0  85/12/07  18:21:14  toddb
  446.    * First public release.
  447.    * 
  448. ***************
  449. *** 16,22
  450.    * First public release.
  451.    * 
  452.    */
  453. ! static char    *rcsid = "$Header: fileserver.c,v 2.0 85/12/07 18:21:14 toddb Rel $";
  454.   #include <errno.h>
  455.   #include <stdio.h>
  456.   #include <ctype.h>
  457.  
  458. - --- 21,27 -----
  459.    * First public release.
  460.    * 
  461.    */
  462. ! static char    *rcsid = "$Header: fileserver.c,v 2.1 86/02/17 15:11:03 toddb Exp $";
  463.   #include <errno.h>
  464.   #include <stdio.h>
  465.   #include <ctype.h>
  466. ***************
  467. *** 177,182
  468.       /*
  469.        * Ok, now be a server!
  470.        */
  471.       for(;;)
  472.       {
  473.           if (i_am_gateway && ! i_have_control)
  474.  
  475. - --- 182,188 -----
  476.       /*
  477.        * Ok, now be a server!
  478.        */
  479. +     remoteoff(NULL);
  480.       for(;;)
  481.       {
  482.           if (i_am_gateway && ! i_have_control)
  483. ***************
  484. *** 342,347
  485.        * our pid, etc.  Also, try to dup stderr so that flock will work.
  486.        * If we can't do it, we are in big trouble.
  487.        */
  488.       current_ppid = current_pid;
  489.       current_pid = getpid();
  490.       if (i_am_gateway)
  491.  
  492. - --- 348,354 -----
  493.        * our pid, etc.  Also, try to dup stderr so that flock will work.
  494.        * If we can't do it, we are in big trouble.
  495.        */
  496. +     remoteoff(NULL);
  497.       current_ppid = current_pid;
  498.       current_pid = getpid();
  499.       if (i_am_gateway)
  500.  
  501.  
  502. ------- End of Blind-Carbon-Copy
  503.  
  504.  
  505.