mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-25 09:21:15 +00:00
vhost_user_fs: add a flag to disable extended attributes
Extended attributes (xattr) support has a huge impact on write performance. The reason for this is that, if enabled, FUSE sends a setxattr request after each write operation, and due to the inode locking inside the kernel during said request, the ability to execute the operations in parallel becomes heavily limited. Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
parent
710520e9a1
commit
07cc73bddc
@ -289,6 +289,11 @@ fn main() {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.min_values(1),
|
.min_values(1),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("disable-xattr")
|
||||||
|
.long("disable-xattr")
|
||||||
|
.help("Disable support for extended attributes"),
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
// Retrieve arguments
|
// Retrieve arguments
|
||||||
@ -302,12 +307,14 @@ fn main() {
|
|||||||
Some(size) => size.parse().expect("Invalid argument for thread-pool-size"),
|
Some(size) => size.parse().expect("Invalid argument for thread-pool-size"),
|
||||||
None => THREAD_POOL_SIZE,
|
None => THREAD_POOL_SIZE,
|
||||||
};
|
};
|
||||||
|
let xattr: bool = !cmd_arguments.is_present("disable-xattr");
|
||||||
|
|
||||||
// Convert into appropriate types
|
// Convert into appropriate types
|
||||||
let sock = String::from(sock);
|
let sock = String::from(sock);
|
||||||
|
|
||||||
let fs_cfg = passthrough::Config {
|
let fs_cfg = passthrough::Config {
|
||||||
root_dir: shared_dir.to_string(),
|
root_dir: shared_dir.to_string(),
|
||||||
|
xattr,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let fs = PassthroughFs::new(fs_cfg).unwrap();
|
let fs = PassthroughFs::new(fs_cfg).unwrap();
|
||||||
|
@ -231,6 +231,13 @@ pub struct Config {
|
|||||||
///
|
///
|
||||||
/// The default is `/`.
|
/// The default is `/`.
|
||||||
pub root_dir: String,
|
pub root_dir: String,
|
||||||
|
|
||||||
|
/// Whether the file system should support Extended Attributes (xattr). Enabling this feature may
|
||||||
|
/// have a significant impact on performance, especially on write parallelism. This is the result
|
||||||
|
/// of FUSE attempting to remove the special file privileges after each write request.
|
||||||
|
///
|
||||||
|
/// The default value for this options is `false`.
|
||||||
|
pub xattr: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@ -241,6 +248,7 @@ impl Default for Config {
|
|||||||
cache_policy: Default::default(),
|
cache_policy: Default::default(),
|
||||||
writeback: false,
|
writeback: false,
|
||||||
root_dir: String::from("/"),
|
root_dir: String::from("/"),
|
||||||
|
xattr: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1461,6 +1469,10 @@ impl FileSystem for PassthroughFs {
|
|||||||
value: &[u8],
|
value: &[u8],
|
||||||
flags: u32,
|
flags: u32,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
|
if !self.cfg.xattr {
|
||||||
|
return Err(io::Error::from_raw_os_error(libc::ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
||||||
// need to get a new fd.
|
// need to get a new fd.
|
||||||
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
||||||
@ -1489,6 +1501,10 @@ impl FileSystem for PassthroughFs {
|
|||||||
name: &CStr,
|
name: &CStr,
|
||||||
size: u32,
|
size: u32,
|
||||||
) -> io::Result<GetxattrReply> {
|
) -> io::Result<GetxattrReply> {
|
||||||
|
if !self.cfg.xattr {
|
||||||
|
return Err(io::Error::from_raw_os_error(libc::ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
||||||
// need to get a new fd.
|
// need to get a new fd.
|
||||||
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
||||||
@ -1517,6 +1533,10 @@ impl FileSystem for PassthroughFs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn listxattr(&self, _ctx: Context, inode: Inode, size: u32) -> io::Result<ListxattrReply> {
|
fn listxattr(&self, _ctx: Context, inode: Inode, size: u32) -> io::Result<ListxattrReply> {
|
||||||
|
if !self.cfg.xattr {
|
||||||
|
return Err(io::Error::from_raw_os_error(libc::ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
||||||
// need to get a new fd.
|
// need to get a new fd.
|
||||||
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
||||||
@ -1544,6 +1564,10 @@ impl FileSystem for PassthroughFs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn removexattr(&self, _ctx: Context, inode: Inode, name: &CStr) -> io::Result<()> {
|
fn removexattr(&self, _ctx: Context, inode: Inode, name: &CStr) -> io::Result<()> {
|
||||||
|
if !self.cfg.xattr {
|
||||||
|
return Err(io::Error::from_raw_os_error(libc::ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
// The f{set,get,remove,list}xattr functions don't work on an fd opened with `O_PATH` so we
|
||||||
// need to get a new fd.
|
// need to get a new fd.
|
||||||
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
let file = self.open_inode(inode, libc::O_RDONLY | libc::O_NONBLOCK)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user