home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sun.admin
- Path: sparky!uunet!munnari.oz.au!metro!cs.uow.edu.au!pdg
- From: pdg@cs.uow.edu.au (Peter Gray)
- Subject: fast restores
- Message-ID: <1992Nov23.043712.2792@cs.uow.edu.au>
- Summary: turning on delayed I/O
- Keywords: restore, speedup
- Organization: Dept of Computer Science, Wollongong University, Australia
- Date: Mon, 23 Nov 1992 04:37:12 GMT
- Lines: 117
-
-
- Below is a program I wrote to turn on delayed
- I/O while doing restores. It improves the speed
- of restores by about 500% on my machines.
-
- I also use it for /tmp rather than running tmpfs.
-
- Let me know if you find any bugs.
- I have only tried this on SUN's running 4.1.2.
- It will work under Solaris 2 I think but
- the name of the ioctl has changed slightly.
-
- Does anybody know of any reason why you should
- not do this???
-
-
- pdg
-
- Peter Gray Internet: pdg@cs.uow.EDU.AU
- Professional Officer UUCP: ...!munnari!cs.uow.EDU.AU!pdg
- Dept of Computer Science MHSnet: pdg@cs.uow.oz.au
- University of Wollongong Phone: +61 42 213770
- N.S.W. 2500 Australia Fax : +61 42 213262
-
-
-
- /*
- * This programs turns on/off delayed I/O on a filesystem.
- *
- * Usage: fastfs filesystem fast|slow|status
- *
- * Note that it is intended for use with restore(8)
- * to speed up full filesystem restores. Remember
- * that if a filesystem is running with delayed I/O
- * enabled when the system crashes it can result in
- * fsck being unable to "fix" the filesystem on reboot
- * without manual intervention.
- *
- * Typical use is
- *
- * fastfs /home fast
- * cd /home; restore rf /dev/rst5
- * fastfs /home slow
- *
- * The above gives about a 500% increase in the speed of
- * the restore (your milage may vary).
- *
- * Its also good for /tmp giving most of the benifits of tmpfs
- * without the problems.
- *
- * In rc.local
- *
- * fastfs /tmp fast
- *
- * but you may need to add fsck -y /tmp into /etc/rc.boot
- * before the real fsck to ensure the machine always boots
- * (I have not done this yet).
- */
-
- #include <stdio.h>
- #include <sys/ioctl.h>
- #include <fcntl.h>
- #include <errno.h>
-
- extern char *sys_errlist[];
-
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- int fd;
- int flag;
-
- if (geteuid() != 0)
- {
- fprintf(stderr,"%s: Must run as root.\n", argv[0]);
- exit(1);
- }
-
- if (argc != 3)
- {
- fprintf(stderr,"Usage: %s path {fast|slow|status}\n",argv[0]);
- exit(2);
- }
-
- if ((fd = open(argv[1], O_RDONLY)) < 0)
- {
- fprintf(stderr,"%s: Unable to open \"%s\"\n%s\n", argv[0], argv[1], sys_errlist[errno]);
- exit(3);
- }
-
- if (!strcasecmp(argv[2], "status"))
- {
- if (ioctl(fd, FIODIOS, &flag) != 0)
- {
- fprintf(stderr,"%s: ioctl failed%s\n", argv[0], sys_errlist[errno]);
- exit(4);
- }
- if (flag == 0) printf("%s is slow.\n", argv[1]);
- else printf("%s is fast\n", argv[1]);
- exit(0);
- }
-
- flag = (strcasecmp(argv[2], "fast") == 0) ? 1 : 0;
-
- if (ioctl(fd, FIODIO, &flag) != 0)
- {
- fprintf(stderr,"%s: ioctl failed\n%s\n", argv[0], sys_errlist[errno]);
- exit(5);
- }
-
- printf("%s is now %s\n",argv[1], flag ? "fast" : "slow");
- exit(0);
-
- }
-