[comp.unix.questions] Flushing Dirty Pages to Disk

barry@wolman.prime.com (06/30/90)

For the SPEC version of my IOBENCH benchmark, I need to be able to
determine how long it takes to flush an unknown number of pages from the
buffer cache to their respective files. 

Berkeley variants of UNIX contain a fsync(fd) system call that causes
all "dirty" pages for the specified open file in the buffer cache to be
written to disk, and doesn't return until this is done.  Thus, if I have
a set of open files, I can flush just their pages to disk and determine
how long it took by the simple sequence

	time(&start);
	for(i=0;i<nfiles;i++)
		if (fsync(fid[i]) < 0) { ... error processing }

	time(&finish);

I'd like to know how I can do this with standard vanilla ATT versions of
UNIX, e.g.  5.3.x.  sync() flushes ALL dirty pages and returns
immediately. 

I've thought about putting the benchmark files on separate partitions
that are mounted at the start of a run and unmounted at the end ...  but
that greatly complicates running IOBENCH. 

I'll post a summary of the responses. 

Thanks, Barry
------------------------------------------------------------------------
Barry Wolman                      | barry@s66.prime.com
Principal Technical Consultant    | 500 Old Connecticut Path
Prime Computer                    | Framingham, MA 01701
                                  | 508/879-2960, ext. 1100
------------------------------------------------------------------------