From: Mikhail Pershin Date: Sat, 11 Dec 2021 12:49:47 +0000 (+0300) Subject: LU-15357 mdd: fix changelog context leak X-Git-Tag: 2.12.9-RC1~14 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F32%2F45832%2F3;p=fs%2Flustre-release.git LU-15357 mdd: fix changelog context leak The mdd_changelog_clear() shouldn't skip llog_ctxt_put() in case of error. Lustre-change: https://review.whamcloud.com/45831 Lustre-commit: TBD (from c330a73e4cffb1fb642fadfa38001275251d1f14) Fixes: 6b183927e1 (LU-14553 changelog: eliminate mdd_changelog_clear warning) Signed-off-by: Mikhail Pershin Change-Id: I9c9aa3ce0d11e8f67470b450d007f2a1081644c6 Reviewed-on: https://review.whamcloud.com/45832 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Olaf Faaland-LLNL Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index ea065e0..8eb5fd2 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -1866,8 +1866,10 @@ static int mdd_changelog_clear(const struct lu_env *env, ctxt = llog_get_context(mdd2obd_dev(mdd), LLOG_CHANGELOG_USER_ORIG_CTXT); - if (ctxt == NULL || - (ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) == 0) + if (!ctxt) + RETURN(-ENXIO); + + if (!(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) GOTO(out, rc = -ENXIO); rc = llog_cat_process(env, ctxt->loc_handle, @@ -1875,33 +1877,36 @@ static int mdd_changelog_clear(const struct lu_env *env, 0, 0); if (rc == -EINVAL) { - CDEBUG(D_IOCTL, "%s: No changelog recnum <= %llu to clear\n", + CDEBUG(D_IOCTL, "%s: no changelog recnum <= %llu to clear\n", mdd2obd_dev(mdd)->obd_name, (unsigned long long) endrec); - RETURN(-EINVAL); - } else if (rc < 0) { - CWARN("%s: Failure to clear the changelog for user %d: %d\n", + GOTO(out, rc); + } + + if (rc < 0) { + CWARN("%s: failure to clear the changelog for user %d: %d\n", mdd2obd_dev(mdd)->obd_name, id, rc); - } else if (mcuc.mcuc_flush) { - /* Cancelling record 0 destroys the entire changelog, make sure - we don't do that unless we mean it. */ - if (mcuc.mcuc_minrec != 0) { - CDEBUG(D_IOCTL, "%s: Purging changelog entries up "\ - "to %llu\n", mdd2obd_dev(mdd)->obd_name, - mcuc.mcuc_minrec); + GOTO(out, rc); + } - rc = mdd_changelog_llog_cancel(env, mdd, - mcuc.mcuc_minrec); - } - } else { - CDEBUG(D_IOCTL, "%s: No entry for user %d\n", - mdd2obd_dev(mdd)->obd_name, id); - rc = -ENOENT; + if (!mcuc.mcuc_flush) { + CDEBUG(D_IOCTL, "%s: no entry for user %d\n", + mdd2obd_dev(mdd)->obd_name, id); + GOTO(out, rc = -ENOENT); + } + + /* Cancelling record 0 destroys the entire changelog, make sure + we don't do that unless we mean it. */ + if (mcuc.mcuc_minrec != 0) { + CDEBUG(D_IOCTL, "%s: purge changelog entries up to %llu\n", + mdd2obd_dev(mdd)->obd_name, mcuc.mcuc_minrec); + rc = mdd_changelog_llog_cancel(env, mdd, mcuc.mcuc_minrec); + if (rc) + GOTO(out, rc); } EXIT; out: - if (ctxt != NULL) - llog_ctxt_put(ctxt); + llog_ctxt_put(ctxt); return rc; }