OvmfPkg/VirtioFsDxe: add EFI_FILE_INFO cache fields to VIRTIO_FS_FILE

For reading through a directory stream with tolerable performance, we'll
have to call FUSE_READDIRPLUS each time with such a buffer that can
deliver a good number of variable size records
(VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE elements). Every time we'll do that,
we'll turn the whole bunch into an array of EFI_FILE_INFOs immediately.
EFI_FILE_PROTOCOL.Read() invocations (on directories) will be served from
this EFI_FILE_INFO cache.

Add the fields for the EFI_FILE_INFO cache to VIRTIO_FS_FILE:
- initialize them in Open() and OpenVolume(),
- release the cache in Close() and Delete(),
- also release the cache when the directory is rewound, in SetPosition().

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20201216211125.19496-36-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
This commit is contained in:
Laszlo Ersek
2020-12-16 22:11:12 +01:00
committed by mergify[bot]
parent 7a7752095c
commit b845de89d0
6 changed files with 42 additions and 0 deletions

View File

@@ -47,6 +47,11 @@
//
#define VIRTIO_FS_MAX_PATHNAME_LENGTH ((UINTN)65535)
//
// Maximum value for VIRTIO_FS_FILE.NumFileInfo.
//
#define VIRTIO_FS_FILE_MAX_FILE_INFO 256
//
// Filesystem label encoded in UCS-2, transformed from the UTF-8 representation
// in "VIRTIO_FS_CONFIG.Tag", and NUL-terminated. Only the printable ASCII code
@@ -154,6 +159,20 @@ typedef struct {
//
UINT64 NodeId;
UINT64 FuseHandle;
//
// EFI_FILE_INFO objects cached for an in-flight directory read.
//
// For reading through a directory stream with tolerable performance, we have
// to call FUSE_READDIRPLUS each time with such a buffer that can deliver a
// good number of variable size records (VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE
// elements). Every time we do that, we turn the whole bunch into an array of
// EFI_FILE_INFOs immediately. EFI_FILE_PROTOCOL.Read() invocations (on
// directories) will be served from this EFI_FILE_INFO cache.
//
UINT8 *FileInfoArray;
UINTN SingleFileInfoSize;
UINTN NumFileInfo;
UINTN NextFileInfo;
} VIRTIO_FS_FILE;
#define VIRTIO_FS_FILE_FROM_SIMPLE_FILE(SimpleFileReference) \