vhost_user_fs: Add support for FOPEN_CACHE_DIR

Add support for FOPEN_CACHE_DIR, a flag that allows us to tell the
guest that it's safe to cache a directory, introduced in FUSE 7.28.

Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
Sergio Lopez 2020-03-20 17:26:27 +01:00 committed by Rob Bradford
parent 97e2d5d266
commit 5eb903a509
2 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,9 @@ const FOPEN_KEEP_CACHE: u32 = 2;
/// The file is not seekable.
const FOPEN_NONSEEKABLE: u32 = 4;
/// Allow caching this directory.
const FOPEN_CACHE_DIR: u32 = 8;
bitflags! {
/// Options controlling the behavior of files opened by the server in response
/// to an open or create request.
@ -62,6 +65,7 @@ bitflags! {
const DIRECT_IO = FOPEN_DIRECT_IO;
const KEEP_CACHE = FOPEN_KEEP_CACHE;
const NONSEEKABLE = FOPEN_NONSEEKABLE;
const CACHE_DIR = FOPEN_CACHE_DIR;
}
}

View File

@ -558,7 +558,13 @@ impl PassthroughFs {
OpenOptions::DIRECT_IO,
flags & (libc::O_DIRECTORY as u32) == 0,
),
CachePolicy::Always => opts |= OpenOptions::KEEP_CACHE,
CachePolicy::Always => {
if flags & (libc::O_DIRECTORY as u32) == 0 {
opts |= OpenOptions::KEEP_CACHE;
} else {
opts |= OpenOptions::CACHE_DIR;
}
}
_ => {}
};