Comments (5)
To ensure that it isn't depending on the value of the cookie, I've change the code so it encrypts/decrypts the cookies with des.
The client still sends the cookie corresponding to the offset of 256 entries with a nfs.verifier
eight replies prior the last one.
from go-nfs.
would you be okay with #52 to address this?
- without a caching backend specified, it will re-read / re-hash the full directory, rather than up-to-the-cookie, so it will do more work but the verifier will be stable
- with a caching backend as specified in the examples, the directory listing will be re-used - I probably need to test a bit more for corner cases around invalidation.
from go-nfs.
That looks certainly like a better approach than mine. Just two things that I would like to remark:
TLDR: I would
- not to fail on cache miss in
DataForVerifier
and go on and compute a new verifier, and return anNFSStatusBadCookie
on mismatch, otherwise we are good to go. - Cache the verifiers by id and verify the match by file-system path instead of the nfs handle, so that the same content doesn't cause a "false" collision on the random NFS handle for the same path
(Changes in #53)
DataForVerifier
A cache miss in DataForVerifier
results in an NFSStatusBadCookie
. But the cache can simply have evicted the value, or we have a collision in the ID. I would propose to simply handle it as a cache miss, and continue in getDirListingWithVerifier
until you return the contents and "re-computed" verifier, and then compare the "re-computed" verifier with the one passed in, and only raise the error on a mismatch.
Caching Keys
The cache is using the verifier-id as a key, and uses the NFS-handle as a verifier to detect conflicts.
The issue here is a bit, that the NFS-handle is implemented as a random uuid, so it is different even for the same directory, But "natural" verifier-ids are the same for the same directory (such as the sha256 sum, or a timestamp).
Some way I think that could be addressed (order by effort, I think)
- Ensuring that the verifier-ids do not collide for different NFS-handles. That means though that we have to cache the same directory content multiple times.
- Require that the implementation generates verifier-id specific for the NFS-handle (I.e. mix in the file-handle in the hash). No code change required from your side, but requires more effort from anyone implementing the interface.
- Key the LRU by verifier-id and NFS-handle.
- Create an LRU-cache per NFS-handle
- File-system path instead NFS-handle. Requires going through
FromHandle
, but then the cache is shared between different file-handles for the same path.
- Validate that the verifier is the correct one the by file-system path instead NFS-handle.
- Use a pair of verifier-id and file-path as the key in the LRU. Less chance of collision, but more work.
- Move the state into the file-handle: Try to provide a stable NFS-handle for the same file-object, but that requires detecting changes (i.e. path deleted, and new one created with same). That puts less pressure on the NFS-handle cache, but requires quite some logic.
from go-nfs.
Makes sense,
I think I'm happy with having the interface so that users can implement a more advanced cache key structure if they need one.
from go-nfs.
True, thanks for you work!
from go-nfs.
Related Issues (20)
- There are still places where FileID zero is returned, which confuses linux HOT 9
- Still getting stale file handle issues: see #100 HOT 3
- `onRename` errors out with "comparing uncomparable type" HOT 4
- if `fs.Remove` fails with `non-empty directory`, the server should forward that. HOT 1
- Incorrect handling of an open file's `Name()` HOT 1
- If `Read` is above a certain size, it will return nothing HOT 1
- onReadDirPlus with small cache yields no results, but no error HOT 2
- Some Write calls leads to data loss HOT 30
- A git clone will lead to the server displaying files with corrupted permissions HOT 9
- Unnecessary error messages for non-errors HOT 8
- make `onlookup` use stat rather than readdir HOT 1
- Removing directory leads to `Stale file handle` HOT 3
- Symbolic Links Cause Stale NFS File Handles HOT 1
- tagged releases
- fs.Stat is called when fs.Lstat should be called HOT 5
- support backing systems without exposed fileids
- Sockets don't work through mount HOT 11
- "Illegal instruction" when trying to run `su user` in chroot in mount HOT 29
- `flock` hangs HOT 3
- GETATTR does not set fhandle in returned struct HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-nfs.