Implement FSMID. Use one of the spare 64 bit fields in the stat structure
authorMatthew Dillon <dillon@dragonflybsd.org>
Thu, 25 Aug 2005 18:34:17 +0000 (18:34 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Thu, 25 Aug 2005 18:34:17 +0000 (18:34 +0000)
commit7d15906a7a159575b1983f7c1fadde4bd6266d29
tree7b076c0cdb65771808ec7c54ecfd67e2d2b3d08b
parent17648b5d06c797bcecf57585e89a6cffa1e4609f
Implement FSMID.  Use one of the spare 64 bit fields in the stat structure
for the FSMID.   The FSMID is a recursively updated field which allows one
to determine whether a subdirectory hierarchy has changed simply by checking
the base directory of the desired hierarchy.  The new field is st_fsmid.

The initial implementation stores the FSMID in the namecache, which means that
the FSMID will indicate a false change if a namecache entry is destroyed and
recreated.  A more deterministic test can be made by holding a file or
directory descriptor open.  However, it should be noted that DragonFly
implements a coherent and hierarchically consistent namecache so simply having
a subdirectory or file open will prevent the namecache records from that point
through to the root from being destroyed.

The FSMID can be used to greatly reduce the directories that must be searched
when synchronizing a filesystem.  The immediate intention is to use it to
provide a more efficient way to resynchronize a mirror (to generate journal
records 'diff'ing the current filesystem against a mirror), to improve
filesystem mirroring utilities, and to provide for an alternative backup
strategy that involves generating a diff set between two filesystems.
Normally such schemes would require the entire filesystem to be scanned, but
with FSMID the number of directories that must be searched can be greatly
reduced.

TODO: It is desireable for the FSMID information to be stored more permanently
in the inode to survive reboots and to not return false hits due to namecache
thrash.

Note that the FSMID facility does not work on an NFS client if the NFS server
or some other client modifies the filesystem.
sys/kern/vfs_cache.c
sys/kern/vfs_syscalls.c
sys/kern/vfs_vnops.c
sys/kern/vfs_vopops.c
sys/sys/namecache.h
sys/sys/stat.h