From nobody Mon Feb 9 16:50:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69049+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69049+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608157522; cv=none; d=zohomail.com; s=zohoarc; b=Bct1NGhpGzGWy/5B9ajik2nimFp37HDramhFI78Qf4on5WDqubnPnQV3bTpTL3K5tGCbVAzXljEx5IfEyqOJX5lWvgpUFz9ZTEGJZXroQl0VbU3+eaDxkCHlhhrnerMFKNUtgxHibvW8rkEAVdUoiofSrOLmTuAPk9nft5I3i6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608157522; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NZ8ckHFh6VcTKUOA6ufQwF++LVrh3HGeqkBUtI5eV4c=; b=QcEG8tbM2fBapt2JPDXEemgLAU9OLjXYsvRe5VhLqeuyfKgZ7amiRA0ZeqCiw5ujsExbwGUu2EqGHsqKVDruknDp5uWF0Ubki1DBQERy0KcGGuL40TFCo7vRrAZy4zXb45JUW+Hquvars/aEsiy56VuwGe9bBZ6fXYZ/AjejjwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69049+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1608157522861295.23488843111033; Wed, 16 Dec 2020 14:25:22 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0y4AYY1788612xEsWF0z7yXk; Wed, 16 Dec 2020 14:25:22 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web11.4630.1608157521461124037 for ; Wed, 16 Dec 2020 14:25:21 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-fz5Pf_FWP8izqGsOFadn1A-1; Wed, 16 Dec 2020 17:25:16 -0500 X-MC-Unique: fz5Pf_FWP8izqGsOFadn1A-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BAFD459; Wed, 16 Dec 2020 22:25:15 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-152.ams2.redhat.com [10.36.114.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id F17D360CD2; Wed, 16 Dec 2020 22:25:10 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io, virtio-fs@redhat.com, lersek@redhat.com Cc: Ard Biesheuvel , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [edk2 PATCH 35/48] OvmfPkg/VirtioFsDxe: add EFI_FILE_INFO cache fields to VIRTIO_FS_FILE Date: Wed, 16 Dec 2020 22:11:12 +0100 Message-Id: <20201216211125.19496-36-lersek@redhat.com> In-Reply-To: <20201216211125.19496-1-lersek@redhat.com> References: <20201216211125.19496-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: a0O9ZURHiiTXRu0E2KlQE1rwx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608157522; bh=NZ8ckHFh6VcTKUOA6ufQwF++LVrh3HGeqkBUtI5eV4c=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=gEjNuxU1UW15R/fLy9KO8LyRyTzA9L6x86YEXHNhx65GS7Say2TNchTZKudDOlz8+dv 2Oo2Bubqij/Sa5wYQ4Tqdj9nTRqIfSwip89F4XpWXWslhKeRAHXUb0HmRrf0zOdQytDoV mPIP77zqhS0iKb/HQKOyJffOREROHgD1h5o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 Cc: Jordan Justen Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3097 Signed-off-by: Laszlo Ersek --- OvmfPkg/VirtioFsDxe/VirtioFsDxe.h | 19 +++++++++++++++++++ OvmfPkg/VirtioFsDxe/SimpleFsClose.c | 3 +++ OvmfPkg/VirtioFsDxe/SimpleFsDelete.c | 3 +++ OvmfPkg/VirtioFsDxe/SimpleFsOpen.c | 4 ++++ OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c | 4 ++++ OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c | 9 +++++++++ 6 files changed, 42 insertions(+) diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/Virtio= FsDxe.h index 2b419048c232..a704acdd520e 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h @@ -42,16 +42,21 @@ // // The limit is not expected to be a practical limitation; it's only suppo= sed // to prevent attempts at overflowing size calculations. For both kinds of // pathnames, separate limits could be used; a common limit is used purely= for // simplicity. // #define VIRTIO_FS_MAX_PATHNAME_LENGTH ((UINTN)65535) =20 +// +// 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 represent= ation // in "VIRTIO_FS_CONFIG.Tag", and NUL-terminated. Only the printable ASCII= code // points (U+0020 through U+007E) are supported. // typedef CHAR16 VIRTIO_FS_LABEL[VIRTIO_FS_TAG_BYTES + 1]; =20 // @@ -149,16 +154,30 @@ typedef struct { // VIRTIO_FS_FILE object is created, primarily defined by its NodeId fie= ld, // we also *open* the referenced file at once, and save the returned file // handle in the FuseHandle field. This way, when an EFI_FILE_PROTOCOL m= ember // function must send a FUSE request that needs the file handle *in addi= tion* // to the inode number, FuseHandle will be at our disposal at once. // 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 delive= r a + // good number of variable size records (VIRTIO_FS_FUSE_DIRENTPLUS_RESPO= NSE + // elements). Every time we do that, we turn the whole bunch into an arr= ay 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; =20 #define VIRTIO_FS_FILE_FROM_SIMPLE_FILE(SimpleFileReference) \ CR (SimpleFileReference, VIRTIO_FS_FILE, SimpleFile, VIRTIO_FS_FILE_SIG); =20 #define VIRTIO_FS_FILE_FROM_OPEN_FILES_ENTRY(OpenFilesEntryReference) \ CR (OpenFilesEntryReference, VIRTIO_FS_FILE, OpenFilesEntry, \ VIRTIO_FS_FILE_SIG); diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c b/OvmfPkg/VirtioFsDxe/Simp= leFsClose.c index 04b4f2c382d7..4c1cf52112ce 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c @@ -55,11 +55,14 @@ VirtioFsSimpleFileClose ( } =20 // // One fewer file left open for the owner filesystem. // RemoveEntryList (&VirtioFsFile->OpenFilesEntry); =20 FreePool (VirtioFsFile->CanonicalPathname); + if (VirtioFsFile->FileInfoArray !=3D NULL) { + FreePool (VirtioFsFile->FileInfoArray); + } FreePool (VirtioFsFile); return EFI_SUCCESS; } diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c b/OvmfPkg/VirtioFsDxe/Sim= pleFsDelete.c index 76cfee5bceb1..76a868b3c24d 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c @@ -97,11 +97,14 @@ VirtioFsSimpleFileDelete ( } =20 // // One fewer file left open for the owner filesystem. // RemoveEntryList (&VirtioFsFile->OpenFilesEntry); =20 FreePool (VirtioFsFile->CanonicalPathname); + if (VirtioFsFile->FileInfoArray !=3D NULL) { + FreePool (VirtioFsFile->FileInfoArray); + } FreePool (VirtioFsFile); return Status; } diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c b/OvmfPkg/VirtioFsDxe/Simpl= eFsOpen.c index 7c50ce9c0e76..d73d23fe8665 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c @@ -477,16 +477,20 @@ VirtioFsSimpleFileOpen ( NewVirtioFsFile->SimpleFile.Flush =3D VirtioFsSimpleFileFlush; NewVirtioFsFile->IsDirectory =3D NewNodeIsDirectory; NewVirtioFsFile->IsOpenForWriting =3D OpenForWriting; NewVirtioFsFile->OwnerFs =3D VirtioFs; NewVirtioFsFile->CanonicalPathname =3D NewCanonicalPath; NewVirtioFsFile->FilePosition =3D 0; NewVirtioFsFile->NodeId =3D NewNodeId; NewVirtioFsFile->FuseHandle =3D NewFuseHandle; + NewVirtioFsFile->FileInfoArray =3D NULL; + NewVirtioFsFile->SingleFileInfoSize =3D 0; + NewVirtioFsFile->NumFileInfo =3D 0; + NewVirtioFsFile->NextFileInfo =3D 0; =20 // // One more file is now open for the filesystem. // InsertTailList (&VirtioFs->OpenFiles, &NewVirtioFsFile->OpenFilesEntry); =20 *NewHandle =3D &NewVirtioFsFile->SimpleFile; return EFI_SUCCESS; diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c b/OvmfPkg/VirtioFsDxe= /SimpleFsOpenVolume.c index 1181191d271b..058e7a41ab03 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c @@ -70,16 +70,20 @@ VirtioFsOpenVolume ( VirtioFsFile->SimpleFile.Flush =3D VirtioFsSimpleFileFlush; VirtioFsFile->IsDirectory =3D TRUE; VirtioFsFile->IsOpenForWriting =3D FALSE; VirtioFsFile->OwnerFs =3D VirtioFs; VirtioFsFile->CanonicalPathname =3D CanonicalPathname; VirtioFsFile->FilePosition =3D 0; VirtioFsFile->NodeId =3D VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID; VirtioFsFile->FuseHandle =3D RootDirHandle; + VirtioFsFile->FileInfoArray =3D NULL; + VirtioFsFile->SingleFileInfoSize =3D 0; + VirtioFsFile->NumFileInfo =3D 0; + VirtioFsFile->NextFileInfo =3D 0; =20 // // One more file open for the filesystem. // InsertTailList (&VirtioFs->OpenFiles, &VirtioFsFile->OpenFilesEntry); =20 *Root =3D &VirtioFsFile->SimpleFile; return EFI_SUCCESS; diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c b/OvmfPkg/VirtioFsDx= e/SimpleFsSetPosition.c index ac6285302652..a548012d9c09 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c @@ -2,16 +2,18 @@ EFI_FILE_PROTOCOL.SetPosition() member function for the Virtio Filesystem driver. =20 Copyright (C) 2020, Red Hat, Inc. =20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 +#include // FreePool() + #include "VirtioFsDxe.h" =20 EFI_STATUS EFIAPI VirtioFsSimpleFileSetPosition ( IN EFI_FILE_PROTOCOL *This, IN UINT64 Position ) @@ -26,16 +28,23 @@ VirtioFsSimpleFileSetPosition ( // // Directories can only be rewound, per spec. // if (VirtioFsFile->IsDirectory) { if (Position !=3D 0) { return EFI_UNSUPPORTED; } VirtioFsFile->FilePosition =3D 0; + if (VirtioFsFile->FileInfoArray !=3D NULL) { + FreePool (VirtioFsFile->FileInfoArray); + VirtioFsFile->FileInfoArray =3D NULL; + } + VirtioFsFile->SingleFileInfoSize =3D 0; + VirtioFsFile->NumFileInfo =3D 0; + VirtioFsFile->NextFileInfo =3D 0; return EFI_SUCCESS; } =20 // // Regular file. // if (Position < MAX_UINT64) { // --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#69049): https://edk2.groups.io/g/devel/message/69049 Mute This Topic: https://groups.io/mt/79024111/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-