Skip to content

Commit

Permalink
DAOS-16686 dfuse: fix the memory leak
Browse files Browse the repository at this point in the history
fix the memory leak

Run-GHA: true
Allow-unstable-test: true
Required-githooks: true
Signed-off-by: Di Wang <ddiwang@google.com>
  • Loading branch information
wangdi1 committed Dec 28, 2024
1 parent 26f3696 commit 9d681a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/client/dfuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/client/dfuse/ops/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9d681a4

Please sign in to comment.