Patch for LU-9153 ("llog: consolidate common error checking") has
introduced a regression in llog_cat_id2handle() error handling
path by adding llog_cat_process_common() common routine additional
call in sequence and allowing it to return zero even when catalog
entry was invalid and it had cleared it instead to populate
llog_handle, thus causing an exception when handle was later
dereferenced in llog_process_thread().
Signed-off-by: Bruno Faccini <bruno.faccini@intel.com>
Change-Id: I50153b931e3c1567bfe9c15564ba29fabe3a2d4c
Reviewed-on: https://review.whamcloud.com/29370
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
* deletion are not atomic. So we end up with an index but no
* actual record. Destroy the index and move on. */
if (rc == -ENOENT || rc == -ESTALE)
* deletion are not atomic. So we end up with an index but no
* actual record. Destroy the index and move on. */
if (rc == -ENOENT || rc == -ESTALE)
- rc = llog_cat_cleanup(env, cat_llh, NULL,
- rec->lrh_index);
- if (rc)
+ rc = LLOG_DEL_RECORD;
+ else if (rc)
CWARN("%s: can't find llog handle "DFID":%x: rc = %d\n",
cat_llh->lgh_ctxt->loc_obd->obd_name,
PFID(&lir->lid_id.lgl_oi.oi_fid),
CWARN("%s: can't find llog handle "DFID":%x: rc = %d\n",
cat_llh->lgh_ctxt->loc_obd->obd_name,
PFID(&lir->lid_id.lgl_oi.oi_fid),
out:
/* The empty plain log was destroyed while processing */
out:
/* The empty plain log was destroyed while processing */
- if (rc == LLOG_DEL_PLAIN)
+ if (rc == LLOG_DEL_PLAIN) {
rc = llog_cat_cleanup(env, cat_llh, llh,
llh->u.phd.phd_cookie.lgc_index);
rc = llog_cat_cleanup(env, cat_llh, llh,
llh->u.phd.phd_cookie.lgc_index);
+ } else if (rc == LLOG_DEL_RECORD) {
+ /* clear wrong catalog entry */
+ rc = llog_cat_cleanup(env, cat_llh, NULL, rec->lrh_index);
+ }
+
if (llh)
llog_handle_put(llh);
if (llh)
llog_handle_put(llh);
ENTRY;
rc = llog_cat_process_common(env, cat_llh, rec, &llh);
ENTRY;
rc = llog_cat_process_common(env, cat_llh, rec, &llh);
- if (llh == NULL)
- RETURN(0);
if (rc == LLOG_DEL_PLAIN) {
/* empty log was deleted, don't count it */
rc = llog_cat_cleanup(env, cat_llh, llh,
llh->u.phd.phd_cookie.lgc_index);
if (rc == LLOG_DEL_PLAIN) {
/* empty log was deleted, don't count it */
rc = llog_cat_cleanup(env, cat_llh, llh,
llh->u.phd.phd_cookie.lgc_index);
+ } else if (rc == LLOG_DEL_RECORD) {
+ /* clear wrong catalog entry */
+ rc = llog_cat_cleanup(env, cat_llh, NULL, rec->lrh_index);
} else {
size = llog_size(env, llh);
*cum_size += size;
} else {
size = llog_size(env, llh);
*cum_size += size;
PFID(&llh->lgh_id.lgl_oi.oi_fid), size, *cum_size);
}
PFID(&llh->lgh_id.lgl_oi.oi_fid), size, *cum_size);
}
+ if (llh != NULL)
+ llog_handle_put(llh);
ENTRY;
rc = llog_cat_process_common(env, cat_llh, rec, &llh);
ENTRY;
rc = llog_cat_process_common(env, cat_llh, rec, &llh);
+
+ /* The empty plain log was destroyed while processing */
+ if (rc == LLOG_DEL_PLAIN) {
+ rc = llog_cat_cleanup(env, cat_llh, llh,
+ llh->u.phd.phd_cookie.lgc_index);
+ } else if (rc == LLOG_DEL_RECORD) {
+ /* clear wrong catalog entry */
+ rc = llog_cat_cleanup(env, cat_llh, NULL, rec->lrh_index);
+ }