summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioFsDxe/SimpleFsClose.c
Commit message (Collapse)AuthorAgeFilesLines
* OvmfPkg/VirtioFsDxe: add EFI_FILE_INFO cache fields to VIRTIO_FS_FILELaszlo Ersek2020-12-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | 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>
* OvmfPkg/VirtioFsDxe: manage path lifecycle in OpenVolume, Close, DeleteLaszlo Ersek2020-12-211-0/+1
| | | | | | | | | | | | | | | | | Add a canonical pathname field to VIRTIO_FS_FILE. Initialize the new field in EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume(). Release the new field in EFI_FILE_PROTOCOL.Close() and EFI_FILE_PROTOCOL.Delete(). 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-18-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
* OvmfPkg/VirtioFsDxe: flush, sync, release and forget in Close() / Delete()Laszlo Ersek2020-12-211-9/+25
| | | | | | | | | | | | | | | | | | | | | | | The two member functions that free the EFI_FILE_PROTOCOL object are Close() and Delete(). Before we create VIRTIO_FS_FILE objects with EFI_FILE_PROTOCOL.Open() later in this patch series, extend each of these "destructor" functions to get rid of the FuseHandle and NodeId resources properly -- in a way that matches each function's own purpose. For the time being, VirtioFsSimpleFileDelete() only gets a reminder about its core task (namely, removing the file), as the needed machinery will become only later. But we can already outline the "task list", and deal with the FuseHandle and NodeId resources. The "task list" of VirtioFsSimpleFileDelete() is different from that of VirtioFsSimpleFileClose(), thus both destructors diverge at this point. 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-16-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
* OvmfPkg/VirtioFsDxe: implement EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume()Laszlo Ersek2020-12-211-0/+48
With the help of the VirtioFsFuseOpenDir() and VirtioFsFuseReleaseFileOrDir() functions introduced previously, we can now open and close the root directory. So let's implement EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume(). OpenVolume() creates a new EFI_FILE_PROTOCOL object -- a reference to the root directory of the filesystem. Thus, we have to start tracking references to EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, lest we unbind the virtio-fs device while files are open. There are two methods that release an EFI_FILE_PROTOCOL object: the Close() and the Delete() member functions. In particular, they are not allowed to fail with regard to resource management -- they must release resources unconditionally. Thus, for rolling back the resource accounting that we do in EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume(), we have to implement the first versions of EFI_FILE_PROTOCOL.Close() and EFI_FILE_PROTOCOL.Delete() in this patch as well. With this patch applied, the UEFI shell can enter the root directory of the Virtio Filesystem (such as with the "FS3:" shell command), and the "DIR" shell command exercises FUSE_OPENDIR and FUSE_RELEASEDIR, according to the virtiofsd log. The "DIR" command reports the root directory as if it were empty; probably because at this time, we only allow the shell to open and to close the root directory, but not to read it. 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-12-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>