]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioFsDxe/FuseForget.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / VirtioFsDxe / FuseForget.c
1 /** @file
2 FUSE_FORGET wrapper for the Virtio Filesystem device.
3
4 Copyright (C) 2020, Red Hat, Inc.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7 **/
8
9 #include "VirtioFsDxe.h"
10
11 /**
12 Make the Virtio Filesysem device drop one reference count from a NodeId that
13 the driver looked up by filename.
14
15 Send the FUSE_FORGET request to the Virtio Filesysem device for this. Unlike
16 most other FUSE requests, FUSE_FORGET doesn't elicit a response, not even the
17 common VIRTIO_FS_FUSE_RESPONSE header.
18
19 The function may only be called after VirtioFsFuseInitSession() returns
20 successfully and before VirtioFsUninit() is called.
21
22 @param[in,out] VirtioFs The Virtio Filesystem device to send the FUSE_FORGET
23 request to. On output, the FUSE request counter
24 "VirtioFs->RequestId" will have been incremented.
25
26 @param[in] NodeId The inode number that the client learned by way of
27 lookup, and that the server should now un-reference
28 exactly once.
29
30 @retval EFI_SUCCESS The FUSE_FORGET request has been submitted.
31
32 @return Error codes propagated from VirtioFsSgListsValidate(),
33 VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit().
34 **/
35 EFI_STATUS
36 VirtioFsFuseForget (
37 IN OUT VIRTIO_FS *VirtioFs,
38 IN UINT64 NodeId
39 )
40 {
41 VIRTIO_FS_FUSE_REQUEST CommonReq;
42 VIRTIO_FS_FUSE_FORGET_REQUEST ForgetReq;
43 VIRTIO_FS_IO_VECTOR ReqIoVec[2];
44 VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList;
45 EFI_STATUS Status;
46
47 //
48 // Set up the scatter-gather list (note: only request).
49 //
50 ReqIoVec[0].Buffer = &CommonReq;
51 ReqIoVec[0].Size = sizeof CommonReq;
52 ReqIoVec[1].Buffer = &ForgetReq;
53 ReqIoVec[1].Size = sizeof ForgetReq;
54 ReqSgList.IoVec = ReqIoVec;
55 ReqSgList.NumVec = ARRAY_SIZE (ReqIoVec);
56
57 //
58 // Validate the scatter-gather list (request only); calculate the total
59 // transfer size.
60 //
61 Status = VirtioFsSgListsValidate (VirtioFs, &ReqSgList, NULL);
62 if (EFI_ERROR (Status)) {
63 return Status;
64 }
65
66 //
67 // Populate the common request header.
68 //
69 Status = VirtioFsFuseNewRequest (
70 VirtioFs,
71 &CommonReq,
72 ReqSgList.TotalSize,
73 VirtioFsFuseOpForget,
74 NodeId
75 );
76 if (EFI_ERROR (Status)) {
77 return Status;
78 }
79
80 //
81 // Populate the FUSE_FORGET-specific fields.
82 //
83 ForgetReq.NumberOfLookups = 1;
84
85 //
86 // Submit the request. There's not going to be a response.
87 //
88 Status = VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, NULL);
89 return Status;
90 }