Andrew Gabriel <and...@cucumber.demon.co.uk> wrote:
?
?However, solaris comes with no command to do this. :-(
?You will have to pick up and compile the fastfs command for yourself.
?Unfortunately, I don't remember a pointer to it on the net, but I'm
?sure someone will oblige with one (Casper?)...
Here's it as Casper posted it back in March 95.
Davin.
--
Davin Milun Internet: mi...@cs.Buffalo.EDU mi...@acm.org
Fax: (716) 645-3464
WWW: http://www.cs.buffalo.edu/~milun/
---------------------------------------------------------------------------
>From: cas...@fwi.uva.nl (Casper H.S. Dik)
>Newsgroups: comp.unix.solaris
>Subject: Re: Disk I/O on Sparc 20/514 just bites
>Date: 14 Mar 1995 10:23:37 +0100
>Organization: FWI, University of Amsterdam
...
You'd do it with the programm I append here.
The consequence are that durig a panic a disk may be in a lot
funier state than fsck can make. (Also, Solaris 2.3 won't reboot properly
if / is a "fast" filesystem).
Casper
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: fastfs.c
# Wrapped by casper@mail on Tue Mar 14 10:22:21 1995
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'fastfs.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'fastfs.c'\"
else
echo shar: Extracting \"'fastfs.c'\" \(4592 characters\)
sed "s/^X//" >'fastfs.c' <<'END_OF_FILE'
X/*
X * $Id: fastfs.c,v 1.3 1995/02/02 15:32:19 casper Exp casper $
X *
X * This programs turns on/off delayed I/O on a filesystem.
X *
X * Usage: fastfs filesystem fast|slow|status
X *
X * Note that it is intended for use with restore(8)
X * to speed up full filesystem restores. Remember
X * that if a filesystem is running with delayed I/O
X * enabled when the system crashes it can result in
X * fsck being unable to "fix" the filesystem on reboot
X * without manual intervention.
X *
X * Typical use is
X *
X * fastfs /home fast
X * cd /home; restore rf /dev/rst5
X * fastfs /home slow
X *
X * The above gives about a 500% increase in the speed of
X * the restore (your milage may vary).
X *
X * Its also good for /tmp giving most of the benifits of tmpfs
X * without the problems.
X *
X * In rc.local
X *
X * fastfs /tmp fast
X *
X * but you may need to add fsck -y /tmp into /etc/rc.boot
X * before the real fsck to ensure the machine always boots
X *
X * Adapted from the original fastfs.c code by
X * Peter Gray, University of Wollongong.
X *
X * Casper Dik
X*/
X
X#include <stdio.h>
X#include <string.h>
X#include <sys/ioctl.h>
X#include <sys/filio.h>
X#include <fcntl.h>
X#include <errno.h>
X#ifndef FIODIO
X#define SOLARIS
X#define FIODIO _FIOSDIO
X#define FIODIOS _FIOGDIO
X#include <sys/mnttab.h>
X#define MTAB "/etc/mnttab"
X#else
X#include <mntent.h>
X#define MTAB "/etc/mtab"
X#endif
X
X#ifndef SOLARIS
Xextern char *sys_errlist[];
Xextern int sys_nerr;
X#define strerror(x) ((x > sys_nerr || x < 0) ? "Uknown error" : sys_errlist[x])
X#endif
X
Xint errors;
X
Xchar *cmds[] = { "slow", "fast", "status" };
X
X#define CMD_SLOW 0
X#define CMD_FAST 1
X#define CMD_STATUS 2
X#define CMD_ERROR -1
X#define CMD_AMBIGUOUS -2
X
Xint
Xstr2cmd(str)
Xchar *str;
X{
X int i,len = strlen(str), hits = 0, res = CMD_ERROR;
X for (i = 0; i < sizeof(cmds)/sizeof(char*); i++) {
X if (strncmp(str, cmds[i], len) == 0) {
X res = i;
X hits++;
X }
X }
X if (hits <= 1)
X return res;
X else
X return CMD_AMBIGUOUS;
X}
X
Xvoid
Xfastfs(path, cmd)
Xchar *path;
Xint cmd;
X{
X int fd = open(path, O_RDONLY);
X int flag, newflag, oldflag, nochange = 0;
X char *how;
X
X if (fd < 0) {
X perror(path);
X errors ++;
X return;
X }
X if (ioctl(fd, FIODIOS, &oldflag) == -1) {
X perror("status ioctl");
X errors ++;
X return;
X }
X switch (cmd) {
X case CMD_SLOW:
X flag = 0;
X if (oldflag == flag)
X nochange = 1;
X else
X if (ioctl(fd, FIODIO, &flag) == -1) {
X perror("slow ioctl");
X errors ++;
X return;
X }
X break;
X case CMD_FAST:
X flag = 1;
X if (oldflag == flag)
X nochange = 1;
X else
X if (ioctl(fd, FIODIO, &flag) == -1) {
X perror("fast ioctl");
X errors ++;
X return;
X }
X break;
X case CMD_STATUS:
X how = "";
X break;
X default:
X fprintf(stderr,"Internal error: unexpected command\n");
X exit(1);
X /*NOTREACHED*/
X }
X if (ioctl(fd, FIODIOS, &newflag) == -1) {
X perror("status ioctl");
X errors ++;
X } else {
X if (cmd != CMD_STATUS && flag != newflag)
X printf("FAILED: ");
X if (cmd != CMD_STATUS)
X how = nochange ? "already " : "now ";
X printf("%s\tis %s%s\n", path, how, cmds[newflag]);
X }
X close(fd);
X}
X
Xvoid usage()
X{
X fprintf(stderr,"Usage: fastfs -a [slow|status|fast]\n");
X fprintf(stderr,"Usage: fastfs path1 .. pathN [slow|status|fast]\n");
X exit(1);
X}
X
Xint
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X int opstat = 0;
X int i;
X char *cmd;
X int icmd;
X
X /*
X * New usage:
X * fastfs -a [ report status on all ufs filesystems ]
X * fastfs -a status|slow|fast
X * fastfs path1 ... pathN status|slow|fast
X */
X
X if (argc < 2) usage();
X
X if (argc > 2) {
X if (str2cmd(argv[argc-1]) == CMD_ERROR)
X opstat = 1;
X } else
X opstat = 1;
X
X if (opstat)
X cmd = "status";
X else
X cmd = argv[argc-1];
X
X if ((icmd = str2cmd(cmd)) < 0)
X usage();
X
X if (strcmp(argv[1],"-a") == 0) {
X FILE *fp = fopen(MTAB,"r");
X#ifdef SOLARIS
X struct mnttab mp, mtemplate;
X#else
X struct mntent *mnt;
X#endif
X
X if (fp == NULL) {
X fprintf(stderr,"Can't open %s\n", MTAB);
X exit(1);
X }
X if (argc + opstat != 3)
X usage();
X#ifdef SOLARIS
X mtemplate.mnt_fstype = "ufs";
X mtemplate.mnt_special = 0;
X mtemplate.mnt_mntopts = 0;
X mtemplate.mnt_mountp = 0;
X mtemplate.mnt_time = 0;
X while (getmntany(fp, &mp, &mtemplate) == 0)
X fastfs(mp.mnt_mountp, icmd);
X#else
X while (mnt = getmntent(fp)) {
X if (strcmp(mnt->mnt_type,"4.2") != 0)
X continue;
X fastfs(mnt->mnt_dir, icmd);
X }
X#endif
X fclose(fp);
X } else {
X for (i = 1; i < argc + opstat - 1; i++)
X fastfs(argv[i], icmd);
X }
X
X exit(errors ? 1 : 0);
X}
END_OF_FILE
if test 4592 -ne `wc -c <'fastfs.c'`; then
echo shar: \"'fastfs.c'\" unpacked with wrong size!
fi
# end of 'fastfs.c'
fi
echo shar: End of shell archive.
exit 0