Subject: Re: FIONWRITE proposal
To: Daniel Carosone <dan@geek.com.au>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 10/14/2004 06:51:17
--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 14, 2004 at 07:03:59PM +1000, Daniel Carosone wrote:
> On Wed, Oct 13, 2004 at 04:11:12PM -0700, Bill Studenmund wrote:
> > I'd like to propose a new ioctl, to be called FIONWRITE.
>=20
> [..]
>=20
>=20
> > +		if (com =3D=3D FIONWRITE) {
> > +			/*
> > +			 * Files don't have the semantic of unsent bytes,
> > +			 * so say all written bytes are "sent".
> > +			 */
> > +			*(int *)data =3D 0;
> > +			return (0);
> > +		}
>=20
>=20
> I have no idea if it would be hard to get the information, but one
> reasonable and probably quite useful result to return would be the
> amount of data still sitting in file cache, dirty and uncomitted to
> disk.
>=20
> Essentially, "if I call fsync now, how much disk traffic will I
> cause?".

I don't know of an easy way to get this info. We'd have to ask the file=20
system. Because in addition to writing dirty pages, you may have to write=
=20
metadata out, which only the file system will be able to add up.

> Of course, if it is too hard to find the right answer, one could
> always havge the ioctl implicitly call fsync first, so the 0 is not
> any kind of lie. :)

But 0 isn't a lie. ;-) All of the bytes written to the file have made it=20
to the file. Perhaps not the disk image of the file, but the kernel image=
=20
of the file has them. :-) Anywhere in the file that you read, you will see=
=20
the bytes you wrote.

Take care,

Bill

--SLDf9lqlvOQaIe6s
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFBboRVWz+3JHUci9cRAhkMAJ9ob3rpfak9rYztWnlWOmiEuMiqdgCeMf6l
eiIUguvfAJ60vf7vs4hNAi8=
=t7Ac
-----END PGP SIGNATURE-----

--SLDf9lqlvOQaIe6s--