* cache revalidation & locking
@ 2008-02-27 17:12 Brian Smith
0 siblings, 0 replies; only message in thread
From: Brian Smith @ 2008-02-27 17:12 UTC (permalink / raw)
To: linux-nfs
According to http://www.unixcoding.org/NFSCoding#attrcache, the Linux NFS client flushes the attribute cache when a fnctl lock is obtained ("fcntl() locking flushes attribute cache with Linux and Solaris, but not with FreeBSD.")
1. What is the first version of the client that does this (in terms of Linux kernel version)?
2. Is this a side-effect of the implementation, or is this a guarentee that the Linux client makes?
What I really want to know is "How can I get consistent read access, and perform safe appends, when multiple systems are appending to a file?"
My current locking strategy is:
Opening the file:
* fd = open(path, O_RDWR | O_APPEND | O_SYNC)
* verify file integrity via checksums embedded in it
Reading:
* lock the while file (l_type=F_RDLCK, l_len=0, l_off=0)
* fstat(fd, &st);
* unlock everything after EOF (l_len=0, l_off=st.st_size)
* read up to (st.st_size)
* unlock everything before EOF (l_len=st.st_size, l_off=0)
Appending:
* lock the whole file (l_type=F_WRLCK, l_len=0, l_off=0)
* fstat(fd, &st);
* read up to (st.st_size)
* replace write lock with read lock before EOF
(l_len=st.st_size, l_off=0)
* append the new data.
* unlock the whole file (l_len = 0, l_off = 0)
Protection against partial write failures:
* checksums are written within the file in every write()
Is this a sound strategy when using the Linux NFS client? Is there a better one (one that reduces lock contention?)
- Brian
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-02-27 17:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-27 17:12 cache revalidation & locking Brian Smith
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.