pxar: fuse: optimize fuse readdir callback

The expensive call to Decoder::read_directory_entry() can be omitted as
Decoder::attributes() returns all the information the fuse response needs.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-10-17 17:04:26 +02:00 committed by Dietmar Maurer
parent ffe171c5db
commit 9c25c0330a

View File

@ -712,14 +712,9 @@ extern "C" fn readdir(req: Request, inode: u64, size: size_t, offset: c_int, _fi
if offset < n_entries {
for e in gb_table[offset..gb_table.len()].iter() {
let entry = ctx
.decoder
.read_directory_entry(e.1, e.2)
.map_err(|_| libc::EIO)?;
let name = CString::new(entry.filename.as_bytes()).map_err(|_| libc::EIO)?;
let (_, entry, _, payload_size) =
let (filename, entry, _, payload_size) =
ctx.decoder.attributes(e.1).map_err(|_| libc::EIO)?;
let name = CString::new(filename.as_bytes()).map_err(|_| libc::EIO)?;
let item_offset = find_offset(&entry, e.1, e.2);
let item_inode = calculate_inode(item_offset, ctx.decoder.root_end_offset());
let attr = stat(item_inode, &entry, payload_size).map_err(|_| libc::EIO)?;