diff options
author | Christian Schoenebeck <qemu_oss@crudebyte.com> | 2025-03-07 10:23:02 +0100 |
---|---|---|
committer | Christian Schoenebeck <qemu_oss@crudebyte.com> | 2025-05-05 11:28:29 +0200 |
commit | 89f7b4da7662ecc6840ffb0846045f03f9714bc6 (patch) | |
tree | 7a2230938762e7797bdb10e6124a009234300508 /rust/qemu-api-macros | |
parent | 61da38db70affd925226ce1e8a61d761c20d045b (diff) | |
download | qemu-89f7b4da7662ecc6840ffb0846045f03f9714bc6.zip qemu-89f7b4da7662ecc6840ffb0846045f03f9714bc6.tar.gz qemu-89f7b4da7662ecc6840ffb0846045f03f9714bc6.tar.bz2 |
9pfs: fix FD leak and reduce latency of v9fs_reclaim_fd()
This patch fixes two different bugs in v9fs_reclaim_fd():
1. Reduce latency:
This function calls v9fs_co_close() and v9fs_co_closedir() in a loop. Each
one of the calls adds two thread hops (between main thread and a fs driver
background thread). Each thread hop adds latency, which sums up in
function's loop to a significant duration.
Reduce overall latency by open coding what v9fs_co_close() and
v9fs_co_closedir() do, executing those and the loop itself altogether in
only one background thread block, hence reducing the total amount of
thread hops to only two.
2. Fix file descriptor leak:
The existing code called v9fs_co_close() and v9fs_co_closedir() to close
file descriptors. Both functions check right at the beginning if the 9p
request was cancelled:
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
}
So if client sent a 'Tflush' message, v9fs_co_close() / v9fs_co_closedir()
returned without having closed the file descriptor and v9fs_reclaim_fd()
subsequently freed the FID without its file descriptor being closed, hence
leaking those file descriptors.
This 2nd bug is fixed by this patch as well by open coding v9fs_co_close()
and v9fs_co_closedir() inside of v9fs_reclaim_fd() and not performing the
v9fs_request_cancelled(pdu) check there.
Fixes: 7a46274529c ('hw/9pfs: Add file descriptor reclaim support')
Fixes: bccacf6c792 ('hw/9pfs: Implement TFLUSH operation')
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <5747469d3f039c53147e850b456943a1d4b5485c.1741339452.git.qemu_oss@crudebyte.com>
Diffstat (limited to 'rust/qemu-api-macros')
0 files changed, 0 insertions, 0 deletions