[lustre-devel] [PATCH 26/33] lustre: mdc: md_open_data should keep ref on close_req
James Simmons <[email protected]> Sun, 2 Feb 2025 15:46:26 -0500
| Newsgroups | org.lustre.lists.lustre-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Li Dongyang <[email protected]> md_open_data should keep a ref on mod_close_req, otherwise the mod_close_req could be freed before we try to access mod_close_req via md_open_data. WC-bug-id: https://jira.whamcloud.com/browse/LU-16745 Lustre-commit: ca716f763f89af192 ("LU-16745 mdc: md_open_data should keep ref on close_req") Signed-off-by: Li Dongyang <[email protected]> Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50656 Reviewed-by: Andreas Dilger <[email protected]> Reviewed-by: Lai Siyao <[email protected]> Reviewed-by: Oleg Drokin <[email protected]> Signed-off-by: James Simmons <[email protected]> --- fs/lustre/include/obd.h | 2 ++ fs/lustre/mdc/mdc_request.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/fs/lustre/include/obd.h b/fs/lustre/include/obd.h index c62d9171150a..604739ca92c2 100644 --- a/fs/lustre/include/obd.h +++ b/fs/lustre/include/obd.h @@ -1188,6 +1188,8 @@ static inline struct md_open_data *obd_mod_alloc(void) if (atomic_dec_and_test(&(mod)->mod_refcount)) { \ if ((mod)->mod_open_req) \ ptlrpc_req_finished((mod)->mod_open_req); \ + if ((mod)->mod_close_req) \ + ptlrpc_req_finished((mod)->mod_close_req); \ kfree(mod); \ } \ }) diff --git a/fs/lustre/mdc/mdc_request.c b/fs/lustre/mdc/mdc_request.c index 2b8386661a31..3b838bceba39 100644 --- a/fs/lustre/mdc/mdc_request.c +++ b/fs/lustre/mdc/mdc_request.c @@ -1033,12 +1033,16 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, if (mod) { if (rc != 0) mod->mod_close_req = NULL; + if (mod->mod_close_req) + ptlrpc_request_addref(mod->mod_close_req); + /* Since now, mod is accessed through open_req only, * thus close req does not keep a reference on mod anymore. */ obd_mod_put(mod); } *request = req; + return rc < 0 ? rc : saved_rc; } -- 2.39.3 _______________________________________________ lustre-devel mailing list [email protected] http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org