Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: nospam@zk3.dec.com (Eric Werme - replace nospam with werme)
Subject: Re: How to clear UBC (unified buffer cache)?
Date: 1999/08/02	[thread overview]
Message-ID: <7o4oti$khl$1@nntpd.lkg.dec.com> (raw)
In-Reply-To: 379cd2eb@rcfnews.cs.umass.edu

"Karl" <kbarkei@cs.umass.edu> writes:

>Is there a way to programmatically (or *any* way) clear the UBC (Unified
>Buffer Cache)?  Is there a way to clear the metadata buffer cache?
>Rebooting the system or re-mounting the filesystem are not practical
>options.

Try this snippet from the Connectathon testsuite (www.connectathon.org):

#define MMAP

#ifdef MMAP
#include <sys/mman.h>
#endif

#ifdef MMAP
	caddr_t maddr;
#endif


#ifdef MMAP
	maddr = mmap((caddr_t)0, (size_t)size, PROT_READ,
			MAP_PRIVATE, fd, (off_t)0);
	if (maddr == NULL) {
		error("can't mmap '%s'", bigfile);
		exit(1);
	}
	if (msync(maddr, (size_t)size, MS_INVALIDATE) < 0) {
		error("can't invalidate pages for '%s'", bigfile);
		exit(1);
	}
	if (munmap(maddr, (size_t)size) < 0) {
		error("can't munmap '%s'", bigfile);
		exit(1);
	}
#endif

No guarantees that it works on all past or future releases or all file
systems.  It does work on NFS. (But no guaranteess it will continue to do
so.)

It invalidates the cache for the file descriptor fd, not for the whole
FS.

	-Ric Werme
--
<>    Eric (Ric) Werme     <> The above is unlikely to contain   <>
<>    ROT-13 addresses:    <> official claims or policies of     <>
<>   <jrezr@mx3.qrp.pbz>   <> Compaq Computer Corp.              <>
<> <jrezr@plorecbegny.arg> <>  http://www.cyberportal.net/werme  <>



      reply	other threads:[~1999-08-02  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-26  4:00 How to clear UBC (unified buffer cache)? Karl
1999-08-02  4:00 ` Eric Werme - replace nospam with werme [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox