From 9d681a462df295e61cf268ad671ad8c02fa19ece Mon Sep 17 00:00:00 2001 From: Di Wang Date: Sat, 28 Dec 2024 05:40:11 +0000 Subject: [PATCH] DAOS-16686 dfuse: fix the memory leak fix the memory leak Run-GHA: true Allow-unstable-test: true Required-githooks: true Signed-off-by: Di Wang --- src/client/dfuse/file.c | 7 ++++++- src/client/dfuse/ops/read.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/dfuse/file.c b/src/client/dfuse/file.c index 8f95a658d68..09fb43fbff0 100644 --- a/src/client/dfuse/file.c +++ b/src/client/dfuse/file.c @@ -92,8 +92,13 @@ active_oh_decref(struct dfuse_info *dfuse_info, struct dfuse_obj_hdl *oh) oh->doh_linear_read = true; /* Invalid readahead cache */ - if (oh->doh_ie->ie_active->readahead) + if (oh->doh_ie->ie_active->readahead && oh->doh_ie->ie_active->readahead->dra_ev) { + struct dfuse_event *ev = oh->doh_ie->ie_active->readahead->dra_ev; + + daos_event_fini(&ev->de_ev); + d_slab_release(ev->de_eqt->de_pre_read_slab, ev); oh->doh_ie->ie_active->readahead->dra_ev = NULL; + } /* Do not set linear read in the case where there's no reads or writes, this could be * simple open/close calls but it could also be cache use so leave the setting unchanged diff --git a/src/client/dfuse/ops/read.c b/src/client/dfuse/ops/read.c index edf1b8ad506..f01391af127 100644 --- a/src/client/dfuse/ops/read.c +++ b/src/client/dfuse/ops/read.c @@ -715,8 +715,10 @@ dfuse_pre_read_init(struct dfuse_info *dfuse_info, struct dfuse_inode_entry *ie, int rc; rc = active_ie_readahead_init(ie); - if (rc != 0) + if (rc != 0) { + d_slab_release(ev->de_eqt->de_pre_read_slab, ev); return rc; + } } active->readahead->dra_ev = ev;