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.
Change-Id: I621f7db389854326db298d99957a0bce43024b6e
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50656
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
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);\
OBD_FREE_PTR(mod); \
} \
})
}
out:
- if (mod) {
- if (rc != 0)
- mod->mod_close_req = NULL;
- /* 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;
+ 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);
}