avoiding stat() races

Kenichi Okuyama okuyamak at dd.iij4u.or.jp
Sat Nov 11 20:26:01 GMT 2000


>>>>> "JEM" == John E Malmberg <wb8tyw at qsl.net> writes:
JEM> The missing word contains a serial number that contains a count of the times
JEM> that the rest of the "inode" number has been used.  This was implemented in
JEM> OpenVMS to possibly eliminate the race conditions that Okuyamak refers to.

So, there already exists system. Very interesting.


JEM> To do the compare correctly would require a macro similar to a memcmp() that
JEM> can be defined in config.h for the platform.

Since I don't know about OpenVMS, I might be mistaking, but
according to what I remember, gcc have memcmp() as built-in function
too. And if given length of memcmp() is fixed value, and is very
small, gcc will inline the comparison.

So, if you're having smart enough compiler, calling memcmp() will
not require any big overhead. Just by making field bigger, and
compare them using memcmp(), will give more trustable status cache
against file system.
( If I understand your explain right, this timestamp will
  tell 'validness'. It will truly give you that cache is valid,  
  while unix's time stamp will only tell about 'invalidness'.
  'it was not proven to be invalid' only means "we don't know" )

# or, how about making SMB_INO_T as 64bit, and convert the time
# value from 48bits to 64bits. I think this also well work good, for
# we will not control timestamp of file anyway... by the way, is
# that 48bit file timestamp unsigned? or signed??  I'm interested in
# design of the system.
## If it was signed, first make 32bit signed value from first 2 words.
## Then, expand it to 64bit signed valud, then shift 16bit to left,
## and let last 1 word fit to the lsb 16bits.
## If it was unsigned, story is even more simpler.


By the way, I think "smbw_inode()" should return SMB_INO_T, not
"ino_t".


best regards,
---- 
Kenichi Okuyama at Tokyo Research Lab, IBM-Japan, Co.




More information about the samba-technical mailing list