file cache: support alternate open modes

Previously, the file cache only supported opening existing files; any new
file creation happened out-of-band and then the file reopened via the cache.
If we're going to use the file cache for log index chunks, however, we need
to support CREATE_OR_OPEN style usage, and doing it in the log index itself
is somewhat hairy.

This patch modifies the file cache to support most of the modes defined in
Env::OpenMode. I tried to ensure that cache operations look and feel like a
standard POSIX filesystem, but it's tough to get this right, and I'm sure I
missed some corner cases. I feel pretty good about our use cases (block
managers, log segments, and log index chunks) though.

Change-Id: Ie167302ef85b8e1a40fbb89a7742e2cbb43bcec3
Reviewed-on: http://gerrit.cloudera.org:8080/15081
Tested-by: Kudu Jenkins
Reviewed-by: Andrew Wong <awong@cloudera.com>
6 files changed