You are here

El Topo, vfs locking

I spent a long time Friday afternoon with my coworker David trying to work out how to solve a complicated problem with NFSv4 delegations.

A server can give a delegation on a file to a client, which is basically a promise to a client that

  1. Nobody else is changing a the file
  2. Before somebody else is allowed to change the file, the client will be consulted first and given a reasonable amount of time to acknowledge that it has lost the delegation.

This improves performance by allowing the client to rely on its own cached information about the file instead of having to constantly poll the server to ask if something's changed.

The challenge with the kernel NFS server is that it isn't in control of the data it serves to clients--it just exports preexisting filesystems, which other applications on the server may also be using. So any time we implement something like delegations, we have to make sure it works in cooperation with the filesystems we export.

In this case that means that when a local application opens a delegated file to modify it, for example, we have to block that open until we've recalled any delegations.

We've actually got that part working, more or less. The complicated piece is that the delegation is supposed to cover the metadata of a file as well as its data--so the client also needs to be consulted before we allow the file to be renamed or unlinked. We've been ignoring that problem.

It sounds like a small thing, but it's tricky to avoid race conditions (what if we're giving a client a new delegation at the exact moment that someone is renaming the file? How do we make sure the right thing happens?), and performance regressions.

In the end I think we came up with two solutions--one very complicated, whose correctness I'm less sure of, and one correct, but that requires adding a new field to the inode. The inode is the in-memory structure that stores basic data about a file, and it's advantageous to be able to cache as many inodes as possible in memory, so making it even a little bit larger is something we don't want to do unless we're sure it's the only option.

I worked pretty late, then met Paul and Sara at nine for a sushi dinner in preparation for the midnight showing of "El Topo" at the State theater. We killed the two hours between dinner and the movie by spending some time in Sara's office trying (mostly unsuccesfully) to troubleshoot some of her computer problems. Sara went home, and Paul and I joined a young, rowdy crowd outside the State waiting to get in to the movie.

I was curious about El Topo mainly because the director, writer, star, and composer, Alejandro Jodorowsky, has written a few french comic books that I'd read, and it's a consistent source of fascination to me that someone so odd would somehow manage to make his living turning out such odd work. There's a possibly apocryphal story about his being briefly put in charge of a big budget production of Frank Herbert's "Dune", to star Salvador Dali among others. The idea that so much money could be invested in such an obviously nutty project--even if it was really only considered for a little while--gives a person the encouraging feeling that maybe the world is quite a bit more absurd than people would sometimes have us think.

So in a way it was a little disappointing that the movie turned out to be pretty coherent. Good, even. Who knew? Not that I've actually made up my mind to say that I actually *liked* it yet....

Paul gave me a ride home and I fell asleep around 3 or 4. I woke up in the morning to find Sara had made a lovely sushi-based breakfast complete with a japanese sweet omelet thing. Yowza.