home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / aix / 11730 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.2 KB  |  68 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!walter!porthos!pyuxd!esg
  3. From: esg@pyuxd.uucp (25235-gokhman)
  4. Subject: Re: /tmp Corrupted
  5. Organization: Bellcore, Livingston, NJ
  6. Date: Thu, 19 Nov 92 17:15:25 GMT
  7. Message-ID: <1992Nov19.171525.16507@porthos.cc.bellcore.com>
  8. Summary: Programming example of an AIX 3.2 bug related to this problem
  9. References: <1992Nov5.225824.3656@netcom.com> <1992Nov18.161444.97310@slate.mines.colorado.edu>
  10. Sender: netnews@porthos.cc.bellcore.com (USENET System Software)
  11. Lines: 55
  12.  
  13. In addition to several examples illustrating the typical reason for
  14. this situation to occur: running processes unlinking but not closing
  15. the files, similar simptoms may occur due to the NFS-related  bug
  16. in AIX 3.2. This bug may explain some of the "war stories",
  17. when the misterious loss of space could not be tracked to _running_ processes.
  18. Unfortunately, /tmp is rarely remote, so there are more problems
  19. out there to be explained...
  20.  
  21. We found that the AIX 3.2 RS6000 implementation of the flock subroutine
  22. is faulty when applied to files mounted accross NFS and causes a remote
  23. filesystem to run out of space.
  24.  
  25. If a file A is locked and a file B is renamed into A,
  26. the inodes of the old A are not properly reclaimed
  27. if A and B are mounted over NFS. This problem causes
  28. the remote file system to run out of space, e.g. use df command,
  29. while the du and ls -l commands do not show any changes.
  30. The same scenario works fine for local files.
  31.  
  32. Following example will quickly run the remote filesystem out of
  33. space, while causing no damage if ran locally.
  34.  
  35.                 Ed Gokhman, (908) 699-4785
  36.                 esg@pyuxd.cc.bellcore.com
  37.  
  38.  
  39.  
  40. #    include        <stdio.h>
  41. #    include        <fcntl.h>
  42. #    include        <sys/file.h>
  43. #    include        <errno.h>
  44.  
  45. #    define        ONE_MEG        1000000
  46.  
  47. main ()
  48. {
  49.  for (;;)
  50.  {
  51.   int try1, try2;
  52.   char one_meg [ONE_MEG];
  53.  
  54.   if (
  55.       (try2 = open ("try2", O_RDWR | O_CREAT, 0664)) == -1 ||
  56.        flock (try2, LOCK_EX) == -1                         ||
  57.       (try1 = open ("try1", O_RDWR | O_CREAT, 0664)) == -1 ||
  58.        write (try1, one_meg, ONE_MEG) == -1            ||
  59.        close (try1) == -1                       ||
  60.        rename ("try1", "try2") == -1                       ||
  61.        close (try2) == -1 
  62.      )
  63.  
  64.   { fprintf (stderr, "Problems...%s\n", strerror(errno)); exit (1); }
  65.  }
  66. }
  67.  
  68.