[PATCH 02/18] xstat: Add a pair of system calls to make extended file stats available [ver #6]

David Howells dhowells at redhat.com
Fri Jul 16 04:24:02 MDT 2010


Mark Harris <mhlk at osj.us> wrote:

> > struct xstat_time {
> > 	unsigned long long	tv_sec, tv_nsec;
> > };
> 
> unsigned?  Existing filesystems support on-disk timestamps
> representing times prior to the epoch.

I suppose it doesn't hurt to make is signed.  It's large enough...

Looking at it again, having a 64-bit field for tv_nsec is overkill.  It can't
(or shouldn't) exceed 999,999,999 - well within the capability of a 32-bit
unsigned integer.

So how about using up the dead space for what Steve French wanted:

	| One hole that this reminded me about is how to return the superblock
	| time granularity (for NFSv4 this is attribute 51 "time_delta" which
	| is called on a superblock not on a file).  We run into time rounding
	| issues with Samba too.

By doing something like:

	struct xstat_time {
		signed long long	tv_sec;
		unsigned int		tv_nsec;
		unsigned short		tv_granularity;
		unsigned short		tv_gran_units;
	};

Where tv_granularity is the minimum granularity for tv_sec and tv_nsec given
as a quantity of tv_gran_units.  tv_gran_units could then be a constant, such
as:

	XSTAT_NANOSECONDS_GRANULARITY
	XSTAT_MICROSECONDS_GRANULARITY
	XSTAT_MILLISECONDS_GRANULARITY
	XSTAT_SECONDS_GRANULARITY
	XSTAT_MINUTES_GRANULARITY
	XSTAT_HOURS_GRANULARITY
	XSTAT_DAYS_GRANULARITY

So, for example, FAT times are a 2s granularity, so FAT would set
tv_granularity to 2 and tv_gran_units to XSTAT_SECONDS_GRANULARITY.

We could even support picosecond granularity if we made tv_nsec a 5-byte
field (tv_psec):

	struct xstat_time {
		signed long long	tv_sec;
		unsigned long long	tv_gran_units : 8;
		unsigned long long	tv_granularity : 16;
		unsigned long long	tv_psec	: 48;
	};

but that's probably excessive.  Does any filesystem we currently support need
that?

David


More information about the samba-technical mailing list