When file systems run out of space bad things happen. We like to investigate what those “bad things” are but to do so we have to create artificially small installation directories and run CPU-intensive programs to deplete the remaining space. There is a better way on modern Linux systems.
If you should find yourself performing Linux platform fault-injection testing you might care to add spurious space free failures. The fallocate() routine immediately allocates the specified amount of file system space to an open file. It might be interesting to inject random space depletion in such areas as Oracle Clusterware (Grid Infrastructure) installation directories or application logging directories. Could a node ejection occur if all file system space immediately disappeared? What would that look like on the survivors? What happens if large swaths of space disappear and reappear? Be creative with your destructive tendencies and find out!
#include#include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { long int sz; char *fname; int ret,fd; if (argc != 3) { fprintf(stderr, "usage: %s file new-size-in-gigabytes\n", argv[0]); return(-1); } fname = argv[1]; sz = atol(argv[2]); if ((ret = (fd = open(fname, O_RDWR | O_CREAT | O_EXCL, 0666))) == -1 ) { perror("open"); return(ret); } if ( (ret = fallocate( fd, 0, (loff_t)0, (loff_t)sz * 1024 * 1024 * 1024 )) != 0 ){ perror ("fallocate"); unlink( fname ); } close(fd); return ret; }
# # cc fast_alloc.c # # ./a.out usage: ./a.out file new-size-in-gigabytes # # df -h . Filesystem Size Used Avail Use% Mounted on /dev/sdc 2.7T 1.6T 1.2T 57% /data1 # # time ./a.out bigfile 512 real 0m1.875s user 0m0.000s sys 0m0.730s # du -h bigfile 513G bigfile # rm -f bigfile # # ./a.out bigfile 512 # ls -l bigfile -rw-r--r-- 1 root root 549755813888 Jul 1 09:48 bigfile
Filed under: oracle
![]()
Recent comments
17 weeks 4 days ago
27 weeks 2 days ago
29 weeks 19 hours ago
32 weeks 2 days ago
34 weeks 4 days ago
44 weeks 21 hours ago
45 weeks 4 days ago
46 weeks 4 days ago
46 weeks 5 days ago
49 weeks 3 days ago