From e28f3ee185b2ef7bad8046f46444772fac214a40 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Sat, 3 Sep 2022 10:31:38 +0300 Subject: [PATCH] LU-15646 llog: correct llog FID and path output - fix wrong LLOG_ID-to-FID convertion to output llog FID by introducing PLOGID macro to expand llog ID for DFID format - stop printing lgl_ogen along with llog FID as it always zero since 2.3.51 and is not used anymore - output correct path for update llog in llog_reader - always print header info in llog_reader if available - print llog flags in header info Fixes: 5a8e47d0a1a7 ("LU-9153 llog: update llog print format to use FIDs") Signed-off-by: Mikhail Pershin Change-Id: I7ba49e8101a67d2d80c204a5fc629bfd0bce89ad Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48430 Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/include/uapi/linux/lustre/lustre_user.h | 1 + lustre/lod/lod_dev.c | 4 +- lustre/lod/lod_sub_object.c | 5 +- lustre/mdd/mdd_device.c | 18 +++--- lustre/obdclass/llog.c | 26 ++++---- lustre/obdclass/llog_cat.c | 86 ++++++++++---------------- lustre/obdclass/llog_ioctl.c | 40 +++++------- lustre/obdclass/llog_osd.c | 33 ++++------ lustre/obdclass/llog_swab.c | 2 +- lustre/osp/osp_sync.c | 14 ++--- lustre/target/update_trans.c | 9 ++- lustre/utils/llog_reader.c | 20 ++++-- 12 files changed, 110 insertions(+), 148 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 83936dd..c4e00bf 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -1283,6 +1283,7 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) * usage: sscanf(fidstr, SFID, RFID(&fid)); */ #define SFID "0x%llx:0x%x:0x%x" #define RFID(fid) (unsigned long long *)&((fid)->f_seq), &((fid)->f_oid), &((fid)->f_ver) +#define PLOGID(logid) (unsigned long long)(logid)->lgl_oi.oi.oi_seq, (__u32)(logid)->lgl_oi.oi.oi_id, 0 /********* Quotas **********/ diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index e4d27cf..7a69520 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -323,7 +323,7 @@ static int lod_process_recovery_updates(const struct lu_env *env, llog_update_record_size((struct llog_update_record *)rec)) { CERROR("%s: broken update record! index %u "DFID".%u: rc = %d\n", lod2obd(lrd->lrd_lod)->obd_name, index, - PFID(&llh->lgh_id.lgl_oi.oi_fid), rec->lrh_index, -EIO); + PLOGID(&llh->lgh_id), rec->lrh_index, -EIO); return -EINVAL; } @@ -333,7 +333,7 @@ static int lod_process_recovery_updates(const struct lu_env *env, CDEBUG(D_HA, "%s: process recovery updates "DFID".%u\n", lod2obd(lrd->lrd_lod)->obd_name, - PFID(&llh->lgh_id.lgl_oi.oi_fid), rec->lrh_index); + PLOGID(&llh->lgh_id), rec->lrh_index); lut = lod2lu_dev(lrd->lrd_lod)->ld_site->ls_tgt; if (lod_recovery_abort(lut->lut_obd)) diff --git a/lustre/lod/lod_sub_object.c b/lustre/lod/lod_sub_object.c index 3e8d822..c7f3cc7 100644 --- a/lustre/lod/lod_sub_object.c +++ b/lustre/lod/lod_sub_object.c @@ -977,9 +977,8 @@ int lod_sub_prep_llog(const struct lu_env *env, struct lod_device *lod, ctxt->loc_handle = lgh; - CDEBUG(D_INFO, "%s: init llog for index %d - catid "DFID":%x\n", - obd->obd_name, index, PFID(&cid->lci_logid.lgl_oi.oi_fid), - cid->lci_logid.lgl_ogen); + CDEBUG(D_INFO, "%s: init llog for index %d - catid "DFID"\n", + obd->obd_name, index, PLOGID(&cid->lci_logid)); out_close: if (rc != 0) llog_cat_close(env, lgh); diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 99967a0..7082b41 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -202,7 +202,7 @@ static int changelog_init_cb(const struct lu_env *env, struct llog_handle *llh, "seeing record at index %d/%d/%llu t=%x %.*s in log" DFID"\n", hdr->lrh_index, rec->cr_hdr.lrh_index, rec->cr.cr_index, rec->cr.cr_type, rec->cr.cr_namelen, - changelog_rec_name(&rec->cr), PFID(&llh->lgh_id.lgl_oi.oi_fid)); + changelog_rec_name(&rec->cr), PLOGID(&llh->lgh_id)); spin_lock(&mdd->mdd_cl.mc_lock); mdd->mdd_cl.mc_index = rec->cr.cr_index; spin_unlock(&mdd->mdd_cl.mc_lock); @@ -242,7 +242,7 @@ static int changelog_user_init_cb(const struct lu_env *env, rec->cur_hdr.lrh_type != CHANGELOG_USER_REC2) { CWARN("%s: unknown user type %x at index %u in log "DFID"\n", mdd2obd_dev(mdd)->obd_name, hdr->lrh_index, - rec->cur_hdr.lrh_type, PFID(&llh->lgh_id.lgl_oi.oi_fid)); + rec->cur_hdr.lrh_type, PLOGID(&llh->lgh_id)); return 0; } @@ -251,7 +251,7 @@ static int changelog_user_init_cb(const struct lu_env *env, mdd2obd_dev(mdd)->obd_name, mdd_chlg_username(rec, user_name, sizeof(user_name)), hdr->lrh_index, rec->cur_hdr.lrh_index, rec->cur_endrec, - PFID(&llh->lgh_id.lgl_oi.oi_fid)); + PLOGID(&llh->lgh_id)); spin_lock(&mdd->mdd_cl.mc_user_lock); mdd->mdd_cl.mc_lastuser = rec->cur_id; @@ -291,7 +291,7 @@ static int changelog_detect_orphan_cb(const struct lu_env *env, if (rec->cr_hdr.lrh_type != CHANGELOG_REC) { CWARN("%s: invalid record at index %d in log "DFID"\n", mdd2obd_dev(mdd)->obd_name, hdr->lrh_index, - PFID(&llh->lgh_id.lgl_oi.oi_fid)); + PLOGID(&llh->lgh_id)); /* try to find some next valid record and thus allow to recover * from a corrupted LLOG, instead to assert and force a crash */ @@ -303,7 +303,7 @@ static int changelog_detect_orphan_cb(const struct lu_env *env, mdd2obd_dev(mdd)->obd_name, hdr->lrh_index, rec->cr_hdr.lrh_index, rec->cr.cr_index, rec->cr.cr_type, rec->cr.cr_namelen, changelog_rec_name(&rec->cr), - PFID(&llh->lgh_id.lgl_oi.oi_fid)); + PLOGID(&llh->lgh_id)); clod->clod_index = rec->cr.cr_index; @@ -327,7 +327,7 @@ static int changelog_user_detect_orphan_cb(const struct lu_env *env, rec->cur_hdr.lrh_type != CHANGELOG_USER_REC2) { CWARN("%s: unknown user type %u at index %u in log "DFID"\n", mdd2obd_dev(mdd)->obd_name, hdr->lrh_index, - rec->cur_hdr.lrh_type, PFID(&llh->lgh_id.lgl_oi.oi_fid)); + rec->cur_hdr.lrh_type, PLOGID(&llh->lgh_id)); /* try to find some next valid record and thus allow to recover * from a corrupted LLOG, instead to assert and force a crash */ @@ -338,7 +338,7 @@ static int changelog_user_detect_orphan_cb(const struct lu_env *env, mdd2obd_dev(mdd)->obd_name, mdd_chlg_username(rec, user_name, sizeof(user_name)), hdr->lrh_index, rec->cur_hdr.lrh_index, - rec->cur_endrec, PFID(&llh->lgh_id.lgl_oi.oi_fid)); + rec->cur_endrec, PLOGID(&llh->lgh_id)); clod->clod_index = min_t(__u64, clod->clod_index, rec->cur_endrec); @@ -410,7 +410,7 @@ static int llog_changelog_cancel_cb(const struct lu_env *env, rc = llog_destroy(env, llh); if (!rc) { CDEBUG(D_HA, "Changelog destroyed plain "DFID"\n", - PFID(&llh->lgh_id.lgl_oi.oi_fid)); + PLOGID(&llh->lgh_id)); RETURN(LLOG_DEL_PLAIN); } } @@ -442,7 +442,7 @@ static int llog_changelog_cancel(const struct lu_env *env, else CERROR("%s: cancel idx %u of catalog "DFID": rc = %d\n", ctxt->loc_obd->obd_name, cathandle->lgh_last_idx, - PFID(&cathandle->lgh_id.lgl_oi.oi_fid), rc); + PLOGID(&cathandle->lgh_id), rc); RETURN(rc); } diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index b23645d..dc59322 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -232,7 +232,7 @@ int llog_cancel_arr_rec(const struct lu_env *env, struct llog_handle *loghandle, llh = loghandle->lgh_hdr; CDEBUG(D_RPCTRACE, "Canceling %d records, first %d in log "DFID"\n", - num, index[0], PFID(&loghandle->lgh_id.lgl_oi.oi_fid)); + num, index[0], PLOGID(&loghandle->lgh_id)); dt = lu2dt_dev(loghandle->lgh_obj->do_lu.lo_dev); @@ -306,7 +306,7 @@ int llog_cancel_arr_rec(const struct lu_env *env, struct llog_handle *loghandle, * the orphan will be handled by LFSCK. */ CERROR("%s: can't destroy empty llog "DFID": rc = %d\n", loghandle2name(loghandle), - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), rc); + PLOGID(&loghandle->lgh_id), rc); GOTO(out_unlock, rc = 0); } rc = LLOG_DEL_PLAIN; @@ -664,7 +664,7 @@ repeat: CERROR("%s: invalid record in llog "DFID " record for index %d/%d: rc = %d\n", loghandle2name(loghandle), - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), + PLOGID(&loghandle->lgh_id), rec->lrh_index, index, rc); /* * the block seem to be corrupted, let's try @@ -688,7 +688,7 @@ repeat: * keep going */ CERROR("%s: "DFID" index %u, expected %u\n", loghandle2name(loghandle), - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), + PLOGID(&loghandle->lgh_id), rec->lrh_index, index); index = rec->lrh_index; } @@ -767,10 +767,9 @@ repeat: } out: - CDEBUG(D_HA, "stop processing %s "DOSTID":%x index %d count %d\n", + CDEBUG(D_HA, "stop processing %s "DFID" index %d count %d\n", ((llh->llh_flags & LLOG_F_IS_CAT) ? "catalog" : "plain"), - POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, - index, llh->llh_count); + PLOGID(&loghandle->lgh_id), index, llh->llh_count); if (cd != NULL) cd->lpcd_last_idx = last_called_index; @@ -790,13 +789,11 @@ out: * llog file, probably I/O error or the log got * corrupted to be able to finally release the log we * discard any remaining bits in the header */ - CERROR("%s: Local llog found corrupted #"DOSTID":%x" - " %s index %d count %d\n", + CERROR("%s: local llog is corrupted "DFID" %s index %d count %d\n", loghandle2name(loghandle), - POSTID(&loghandle->lgh_id.lgl_oi), - loghandle->lgh_id.lgl_ogen, + PLOGID(&loghandle->lgh_id), ((llh->llh_flags & LLOG_F_IS_CAT) ? "catalog" : - "plain"), index, llh->llh_count); + "plain"), index, llh->llh_count); while (index <= last_index) { if (test_bit_le(index, @@ -875,7 +872,7 @@ int llog_process_or_fork(const struct lu_env *env, lpi->lpi_catdata = catdata; CDEBUG(D_OTHER, "Processing "DFID" flags 0x%03x startcat %d startidx %d first_idx %d last_idx %d read_mode %d\n", - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), flags, + PLOGID(&loghandle->lgh_id), flags, (flags & LLOG_F_IS_CAT) && d ? d->lpd_startcat : -1, (flags & LLOG_F_IS_CAT) && d ? d->lpd_startidx : -1, cd ? cd->lpcd_first_idx : -1, cd ? cd->lpcd_last_idx : -1, @@ -1530,8 +1527,7 @@ __u64 llog_size(const struct lu_env *env, struct llog_handle *llh) rc = llh->lgh_obj->do_ops->do_attr_get(env, llh->lgh_obj, &la); if (rc) { CERROR("%s: attr_get failed for "DFID": rc = %d\n", - loghandle2name(llh), PFID(&llh->lgh_id.lgl_oi.oi_fid), - rc); + loghandle2name(llh), PLOGID(&llh->lgh_id), rc); return 0; } diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index 4f5b0b1..c20fcdd 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -94,15 +94,12 @@ static int llog_cat_new_log(const struct lu_env *env, if ((index == llh->llh_cat_idx + 1 && llh->llh_count > 1) || (index == 0 && llh->llh_cat_idx == 0)) { if (cathandle->lgh_name == NULL) { - CWARN("%s: there are no more free slots in catalog " - DFID":%x\n", + CWARN("%s: there are no more free slots in catalog "DFID"\n", loghandle2name(loghandle), - PFID(&cathandle->lgh_id.lgl_oi.oi_fid), - cathandle->lgh_id.lgl_ogen); + PLOGID(&cathandle->lgh_id)); } else { - CWARN("%s: there are no more free slots in " - "catalog %s\n", loghandle2name(loghandle), - cathandle->lgh_name); + CWARN("%s: there are no more free slots in catalog %s\n", + loghandle2name(loghandle), cathandle->lgh_name); } RETURN(-ENOSPC); } @@ -183,8 +180,8 @@ static int llog_cat_new_log(const struct lu_env *env, GOTO(out_destroy, rc); CDEBUG(D_OTHER, "new plain log "DFID".%u of catalog "DFID"\n", - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), rec->lid_hdr.lrh_index, - PFID(&cathandle->lgh_id.lgl_oi.oi_fid)); + PLOGID(&loghandle->lgh_id), rec->lid_hdr.lrh_index, + PLOGID(&cathandle->lgh_id)); loghandle->lgh_hdr->llh_cat_idx = rec->lid_hdr.lrh_index; @@ -389,18 +386,11 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, if (ostid_id(&cgl->lgl_oi) == ostid_id(&logid->lgl_oi) && ostid_seq(&cgl->lgl_oi) == ostid_seq(&logid->lgl_oi)) { - if (cgl->lgl_ogen != logid->lgl_ogen) { - CWARN("%s: log "DFID" generation %x != %x\n", - loghandle2name(loghandle), - PFID(&logid->lgl_oi.oi_fid), - cgl->lgl_ogen, logid->lgl_ogen); - continue; - } *res = llog_handle_get(loghandle); if (!*res) { CERROR("%s: log "DFID" refcount is zero!\n", loghandle2name(loghandle), - PFID(&logid->lgl_oi.oi_fid)); + PLOGID(logid)); continue; } loghandle->u.phd.phd_cat_handle = cathandle; @@ -413,9 +403,8 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, rc = llog_open(env, cathandle->lgh_ctxt, &loghandle, logid, NULL, LLOG_OPEN_EXISTS); if (rc < 0) { - CERROR("%s: error opening log id "DFID":%x: rc = %d\n", - loghandle2name(cathandle), PFID(&logid->lgl_oi.oi_fid), - logid->lgl_ogen, rc); + CERROR("%s: error opening log id "DFID": rc = %d\n", + loghandle2name(cathandle), PLOGID(logid), rc); RETURN(rc); } @@ -712,9 +701,8 @@ int llog_cat_cancel_arr_rec(const struct lu_env *env, ENTRY; rc = llog_cat_id2handle(env, cathandle, &loghandle, lgl); if (rc) { - CDEBUG(D_HA, "%s: cannot find llog for handle "DFID":%x" - ": rc = %d\n", loghandle2name(cathandle), - PFID(&lgl->lgl_oi.oi_fid), lgl->lgl_ogen, rc); + CDEBUG(D_HA, "%s: can't find llog handle for "DFID": rc = %d\n", + loghandle2name(cathandle), PLOGID(lgl), rc); RETURN(rc); } @@ -726,10 +714,8 @@ int llog_cat_cancel_arr_rec(const struct lu_env *env, * for these non-exist llogs. */ rc = -ENOENT; - CDEBUG(D_HA, "%s: llog "DFID":%x does not exist" - ": rc = %d\n", loghandle2name(cathandle), - PFID(&lgl->lgl_oi.oi_fid), lgl->lgl_ogen, rc); - + CDEBUG(D_HA, "%s: llog "DFID" does not exist: rc = %d\n", + loghandle2name(cathandle), PLOGID(lgl), rc); llog_handle_put(env, loghandle); RETURN(rc); } @@ -803,16 +789,13 @@ static int llog_cat_process_common(const struct lu_env *env, ENTRY; if (rec->lrh_type != le32_to_cpu(LLOG_LOGID_MAGIC)) { rc = -EINVAL; - CWARN("%s: invalid record in catalog "DFID":%x: rc = %d\n", - loghandle2name(cat_llh), - PFID(&cat_llh->lgh_id.lgl_oi.oi_fid), - cat_llh->lgh_id.lgl_ogen, rc); + CWARN("%s: invalid record in catalog "DFID": rc = %d\n", + loghandle2name(cat_llh), PLOGID(&cat_llh->lgh_id), rc); RETURN(rc); } - CDEBUG(D_HA, "processing log "DFID":%x at index %u of catalog "DFID"\n", - PFID(&lir->lid_id.lgl_oi.oi_fid), lir->lid_id.lgl_ogen, - le32_to_cpu(rec->lrh_index), - PFID(&cat_llh->lgh_id.lgl_oi.oi_fid)); + CDEBUG(D_HA, "processing log "DFID" at index %u of catalog "DFID"\n", + PLOGID(&lir->lid_id), le32_to_cpu(rec->lrh_index), + PLOGID(&cat_llh->lgh_id)); rc = llog_cat_id2handle(env, cat_llh, llhp, &lir->lid_id); if (rc) { @@ -823,10 +806,9 @@ static int llog_cat_process_common(const struct lu_env *env, if (rc == -ENOENT || rc == -ESTALE) rc = LLOG_DEL_RECORD; else if (rc) - CWARN("%s: can't find llog handle "DFID":%x: rc = %d\n", - loghandle2name(cat_llh), - PFID(&lir->lid_id.lgl_oi.oi_fid), - lir->lid_id.lgl_ogen, rc); + CWARN("%s: can't find llog handle "DFID": rc = %d\n", + loghandle2name(cat_llh), PLOGID(&lir->lid_id), + rc); RETURN(rc); } @@ -841,8 +823,8 @@ static int llog_cat_process_common(const struct lu_env *env, rc = llog_destroy(env, *llhp); if (rc) CWARN("%s: can't destroy empty log "DFID": rc = %d\n", - loghandle2name((*llhp)), - PFID(&lir->lid_id.lgl_oi.oi_fid), rc); + loghandle2name((*llhp)), PLOGID(&lir->lid_id), + rc); rc = LLOG_DEL_PLAIN; } @@ -885,8 +867,7 @@ static int llog_cat_process_cb(const struct lu_env *env, * it if the caller is fine with that. */ CERROR("%s: remove corrupted/missing llog "DFID"\n", - loghandle2name(cat_llh), - PFID(&llh->lgh_id.lgl_oi.oi_fid)); + loghandle2name(cat_llh), PLOGID(&llh->lgh_id)); rc = LLOG_DEL_PLAIN; } @@ -929,8 +910,7 @@ int llog_cat_process_or_fork(const struct lu_env *env, }; CWARN("%s: catlog "DFID" crosses index zero\n", - loghandle2name(cat_llh), - PFID(&cat_llh->lgh_id.lgl_oi.oi_fid)); + loghandle2name(cat_llh), PLOGID(&cat_llh->lgh_id)); /*startcat = 0 is default value for general processing */ if ((startcat != LLOG_CAT_FIRST && startcat >= llh->llh_cat_idx) || !startcat) { @@ -1003,7 +983,7 @@ static int llog_cat_size_cb(const struct lu_env *env, *cum_size += size; CDEBUG(D_INFO, "Add llog entry "DFID" size=%llu, tot=%llu\n", - PFID(&llh->lgh_id.lgl_oi.oi_fid), size, *cum_size); + PLOGID(&llh->lgh_id), size, *cum_size); } if (llh != NULL) @@ -1100,7 +1080,7 @@ int llog_cat_reverse_process(const struct lu_env *env, llh->llh_count > 1) { CWARN("%s: catalog "DFID" crosses index zero\n", loghandle2name(cat_llh), - PFID(&cat_llh->lgh_id.lgl_oi.oi_fid)); + PLOGID(&cat_llh->lgh_id)); cd.lpcd_first_idx = 0; cd.lpcd_last_idx = cat_llh->lgh_last_idx; @@ -1158,8 +1138,8 @@ static int llog_cat_set_first_idx(struct llog_handle *cathandle, int idx) } CDEBUG(D_HA, "catlog "DFID" first idx %u, last_idx %u\n", - PFID(&cathandle->lgh_id.lgl_oi.oi_fid), - llh->llh_cat_idx, cathandle->lgh_last_idx); + PLOGID(&cathandle->lgh_id), llh->llh_cat_idx, + cathandle->lgh_last_idx); } RETURN(0); @@ -1170,13 +1150,11 @@ int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle, struct llog_handle *loghandle, int index) { int rc; - struct lu_fid fid = {.f_seq = 0, .f_oid = 0, .f_ver = 0}; LASSERT(index); if (loghandle != NULL) { /* remove destroyed llog from catalog list and * chd_current_log variable */ - fid = loghandle->lgh_id.lgl_oi.oi_fid; down_write(&cathandle->lgh_lock); if (cathandle->u.chd.chd_current_log == loghandle) cathandle->u.chd.chd_current_log = NULL; @@ -1195,10 +1173,10 @@ int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle, /* remove plain llog entry from catalog by index */ llog_cat_set_first_idx(cathandle, index); rc = llog_cancel_rec(env, cathandle, index); - if (rc == 0) + if (!rc && loghandle) CDEBUG(D_HA, "cancel plain log "DFID" at index %u of catalog "DFID"\n", - PFID(&fid), index, - PFID(&cathandle->lgh_id.lgl_oi.oi_fid)); + PLOGID(&loghandle->lgh_id), index, + PLOGID(&cathandle->lgh_id)); return rc; } diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index 62a5b88..6a3a41e 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -46,16 +46,14 @@ static int str2logid(struct llog_logid *logid, char *str, int len) ENTRY; start = str; if (start[0] == '[') { - struct lu_fid *fid = &logid->lgl_oi.oi_fid; - struct lu_fid sfid; + struct lu_fid fid; int num; - fid_zero(fid); - logid->lgl_ogen = 0; - num = sscanf(start + 1, SFID, RFID(fid)); - CDEBUG(D_INFO, DFID":%x\n", PFID(fid), logid->lgl_ogen); - logid_to_fid(logid, &sfid); - RETURN(num == 3 && fid_is_sane(&sfid) ? 0 : -EINVAL); + fid_zero(&fid); + num = sscanf(start + 1, SFID, RFID(&fid)); + CDEBUG(D_INFO, "get FID "DFID"\n", PFID(&fid)); + fid_to_logid(&fid, logid); + RETURN(num == 3 && fid_is_sane(&fid) ? 0 : -EINVAL); } #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 1, 53, 0) @@ -162,9 +160,8 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, RETURN(-EOPNOTSUPP); rc = llog_cat_id2handle(env, handle, &loghandle, &lir->lid_id); if (rc) { - CDEBUG(D_IOCTL, "cannot find log "DFID":%x\n", - PFID(&lir->lid_id.lgl_oi.oi_fid), - lir->lid_id.lgl_ogen); + CDEBUG(D_IOCTL, "cannot find log "DFID"\n", + PLOGID(&lir->lid_id)); RETURN(rc); } rc = llog_process(env, loghandle, llog_check_cb, NULL, NULL); @@ -261,10 +258,8 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, RETURN(-EINVAL); } - l = snprintf(out, remains, - "[index]: %05d [logid]: "DFID":%x\n", - cur_index, PFID(&lir->lid_id.lgl_oi.oi_fid), - lir->lid_id.lgl_ogen); + l = snprintf(out, remains, "[index]: %05d [logid]: "DFID"\n", + cur_index, PLOGID(&lir->lid_id)); } else if (rec->lrh_type == OBD_CFG_REC) { int rc; @@ -298,15 +293,13 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, rc = llog_cat_id2handle(env, cat, &log, logid); if (rc) { - CDEBUG(D_IOCTL, "cannot find log "DFID":%x\n", - PFID(&logid->lgl_oi.oi_fid), logid->lgl_ogen); + CDEBUG(D_IOCTL, "cannot find log "DFID"\n", PLOGID(logid)); RETURN(-ENOENT); } rc = llog_destroy(env, log); if (rc) { - CDEBUG(D_IOCTL, "cannot destroy log "DFID":%x\n", - PFID(&logid->lgl_oi.oi_fid), logid->lgl_ogen); + CDEBUG(D_IOCTL, "cannot destroy log "DFID"\n", PLOGID(logid)); GOTO(out, rc); } llog_cat_cleanup(env, cat, log, log->u.phd.phd_cookie.lgc_index); @@ -378,12 +371,11 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, char *out = data->ioc_bulk; l = snprintf(out, remains, - "logid: "DFID":%x\n" + "logid: "DFID"\n" "flags: %x (%s)\n" "records_count: %d\n" "last_index: %d\n", - PFID(&handle->lgh_id.lgl_oi.oi_fid), - handle->lgh_id.lgl_ogen, + PLOGID(&handle->lgh_id), handle->lgh_hdr->llh_flags, handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT ? "cat" : "plain", @@ -527,8 +519,8 @@ int llog_catalog_list(const struct lu_env *env, struct dt_device *d, data->ioc_count = cfs_fail_val - 1; for (i = data->ioc_count; i < count; i++) { id = &idarray[i].lci_logid; - l = snprintf(out, remains, "catalog_log: "DFID":%x\n", - PFID(&id->lgl_oi.oi_fid), id->lgl_ogen); + l = snprintf(out, remains, "catalog_log: "DFID"\n", + PLOGID(id)); out += l; remains -= l; if (remains <= 0) { diff --git a/lustre/obdclass/llog_osd.c b/lustre/obdclass/llog_osd.c index 67fa54f..4838e2a 100644 --- a/lustre/obdclass/llog_osd.c +++ b/lustre/obdclass/llog_osd.c @@ -517,7 +517,7 @@ static int llog_osd_write_rec(const struct lu_env *env, lgi->lgi_off = reccookie->lgc_offset; CDEBUG(D_OTHER, "modify record "DFID": idx:%u, " "len:%u offset %llu\n", - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), idx, + PLOGID(&loghandle->lgh_id), idx, rec->lrh_len, (long long)lgi->lgi_off); } else { /* This can be result of lgh_cur_idx is not set during @@ -570,7 +570,7 @@ static int llog_osd_write_rec(const struct lu_env *env, CDEBUG(D_OTHER, "llog is getting too large (%u > %u) at %u " DFID"\n", (unsigned)lgi->lgi_off, loghandle->lgh_max_size, (int)loghandle->lgh_last_idx, - PFID(&loghandle->lgh_id.lgl_oi.oi_fid)); + PLOGID(&loghandle->lgh_id)); /* this is to signal that this llog is full */ loghandle->lgh_last_idx = LLOG_HDR_BITMAP_SIZE(llh) - 1; RETURN(-ENOSPC); @@ -996,11 +996,9 @@ static int llog_osd_next_block(const struct lu_env *env, if (!force_mini_rec) goto retry; - CERROR("%s: invalid llog block at log id "DFID":%x " - "offset %llu\n", + CERROR("%s: invalid llog block at log id "DFID" offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), - loghandle->lgh_id.lgl_ogen, *cur_offset); + PLOGID(&loghandle->lgh_id), *cur_offset); GOTO(out, rc = -EINVAL); } @@ -1034,10 +1032,9 @@ static int llog_osd_next_block(const struct lu_env *env, lustre_swab_llog_rec(last_rec); if (last_rec->lrh_index != tail->lrt_index) { - CERROR("%s: invalid llog tail at log id "DFID":%x offset %llu last_rec idx %u tail idx %u lrt len %u read_size %d\n", + CERROR("%s: invalid llog tail at log id "DFID" offset %llu last_rec idx %u tail idx %u lrt len %u read_size %d\n", o->do_lu.lo_dev->ld_obd->obd_name, - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), - loghandle->lgh_id.lgl_ogen, *cur_offset, + PLOGID(&loghandle->lgh_id), *cur_offset, last_rec->lrh_index, tail->lrt_index, tail->lrt_len, rc); GOTO(out, rc = -EINVAL); @@ -1047,11 +1044,9 @@ static int llog_osd_next_block(const struct lu_env *env, /* this shouldn't happen */ if (tail->lrt_index == 0) { - CERROR("%s: invalid llog tail at log id "DFID":%x " - "offset %llu bytes %d\n", + CERROR("%s: invalid llog tail at log id "DFID"offset %llu bytes %d\n", o->do_lu.lo_dev->ld_obd->obd_name, - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), - loghandle->lgh_id.lgl_ogen, *cur_offset, rc); + PLOGID(&loghandle->lgh_id), *cur_offset, rc); GOTO(out, rc = -EINVAL); } if (tail->lrt_index < next_idx) { @@ -1173,11 +1168,9 @@ static int llog_osd_prev_block(const struct lu_env *env, GOTO(out, rc); if (rc < sizeof(*tail)) { - CERROR("%s: invalid llog block at log id "DFID":%x " - "offset %llu\n", + CERROR("%s: invalid llog block at log id "DFID" offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), - loghandle->lgh_id.lgl_ogen, cur_offset); + PLOGID(&loghandle->lgh_id), cur_offset); GOTO(out, rc = -EINVAL); } @@ -1197,11 +1190,9 @@ static int llog_osd_prev_block(const struct lu_env *env, /* this shouldn't happen */ if (tail->lrt_index == 0) { - CERROR("%s: invalid llog tail at log id "DFID":%x " - "offset %llu\n", + CERROR("%s: invalid llog tail at log id "DFID" offset %llu\n", o->do_lu.lo_dev->ld_obd->obd_name, - PFID(&loghandle->lgh_id.lgl_oi.oi_fid), - loghandle->lgh_id.lgl_ogen, cur_offset); + PLOGID(&loghandle->lgh_id), cur_offset); GOTO(out, rc = -EINVAL); } if (tail->lrt_index < prev_idx) diff --git a/lustre/obdclass/llog_swab.c b/lustre/obdclass/llog_swab.c index 79aa160..1c9d0be 100644 --- a/lustre/obdclass/llog_swab.c +++ b/lustre/obdclass/llog_swab.c @@ -45,7 +45,7 @@ static void print_llogd_body(struct llogd_body *d) { CDEBUG(D_OTHER, "llogd body: %p\n", d); CDEBUG(D_OTHER, "\tlgd_logid.lgl_oi.oi_fid: "DFID"\n", - PFID(&d->lgd_logid.lgl_oi.oi_fid)); + PLOGID(&d->lgd_logid)); CDEBUG(D_OTHER, "\tlgd_logid.lgl_ogen: %#x\n", d->lgd_logid.lgl_ogen); CDEBUG(D_OTHER, "\tlgd_ctxt_idx: %#x\n", d->lgd_ctxt_idx); CDEBUG(D_OTHER, "\tlgd_llh_flags: %#x\n", d->lgd_llh_flags); diff --git a/lustre/osp/osp_sync.c b/lustre/osp/osp_sync.c index 8d3ea09..5eee526 100644 --- a/lustre/osp/osp_sync.c +++ b/lustre/osp/osp_sync.c @@ -443,10 +443,9 @@ static int osp_sync_add_rec(const struct lu_env *env, struct osp_device *d, llog_ctxt_put(ctxt); if (likely(rc >= 0)) { - CDEBUG(D_OTHER, "%s: new record "DFID":%x.%u: rc = %d\n", + CDEBUG(D_OTHER, "%s: new record "DFID".%u: rc = %d\n", d->opd_obd->obd_name, - PFID(&osi->osi_cookie.lgc_lgl.lgl_oi.oi_fid), - osi->osi_cookie.lgc_lgl.lgl_ogen, + PLOGID(&osi->osi_cookie.lgc_lgl), osi->osi_cookie.lgc_index, rc); atomic_inc(&d->opd_sync_changes); } @@ -1096,8 +1095,7 @@ static void osp_sync_process_committed(const struct lu_env *env, obd->obd_name, i, rc); else CDEBUG(D_OTHER, "%s: massive records cancel id "DFID" num %d\n", - obd->obd_name, PFID(&lgid.lgl_oi.oi_fid), - i); + obd->obd_name, PLOGID(&lgid), i); i = 0; } @@ -1394,10 +1392,8 @@ static int osp_sync_llog_init(const struct lu_env *env, struct osp_device *d) rc = 0; } - CDEBUG(D_INFO, "%s: Init llog for %d - catid "DFID":%x\n", - obd->obd_name, d->opd_index, - PFID(&osi->osi_cid.lci_logid.lgl_oi.oi_fid), - osi->osi_cid.lci_logid.lgl_ogen); + CDEBUG(D_INFO, "%s: init llog for %d - catid "DFID"\n", + obd->obd_name, d->opd_index, PLOGID(&osi->osi_cid.lci_logid)); rc = llog_setup(env, obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, d->opd_storage->dd_lu_dev.ld_obd, diff --git a/lustre/target/update_trans.c b/lustre/target/update_trans.c index aa13f94..16acc80 100644 --- a/lustre/target/update_trans.c +++ b/lustre/target/update_trans.c @@ -90,7 +90,7 @@ static void top_multiple_thandle_dump(struct top_multiple_thandle *tmt, list_for_each_entry(stc, &st->st_cookie_list, stc_list) { CDEBUG(mask, " cookie "DFID".%u\n", - PFID(&stc->stc_cookie.lgc_lgl.lgl_oi.oi_fid), + PLOGID(&stc->stc_cookie.lgc_lgl), stc->stc_cookie.lgc_index); } } @@ -224,7 +224,7 @@ static int sub_updates_write(const struct lu_env *env, CDEBUG(D_INFO, "%s: Add update log "DFID".%u: rc = %d\n", dt->dd_lu_dev.ld_obd->obd_name, - PFID(&stc->stc_cookie.lgc_lgl.lgl_oi.oi_fid), + PLOGID(&stc->stc_cookie.lgc_lgl), stc->stc_cookie.lgc_index, rc); if (rc > 0) { @@ -297,7 +297,7 @@ static int sub_updates_write(const struct lu_env *env, CDEBUG(D_INFO, "%s: Add update log "DFID".%u: rc = %d\n", dt->dd_lu_dev.ld_obd->obd_name, - PFID(&stc->stc_cookie.lgc_lgl.lgl_oi.oi_fid), + PLOGID(&stc->stc_cookie.lgc_lgl), stc->stc_cookie.lgc_index, rc); if (rc > 0) { @@ -1308,8 +1308,7 @@ static int distribute_txn_cancel_records(const struct lu_env *env, cookie); CDEBUG(D_HA, "%s: batchid %llu cancel update log " DFID".%u: rc = %d\n", obd->obd_name, - tmt->tmt_batchid, - PFID(&cookie->lgc_lgl.lgl_oi.oi_fid), + tmt->tmt_batchid, PLOGID(&cookie->lgc_lgl), cookie->lgc_index, rc); } diff --git a/lustre/utils/llog_reader.c b/lustre/utils/llog_reader.c index f0fb503..78020f4 100644 --- a/lustre/utils/llog_reader.c +++ b/lustre/utils/llog_reader.c @@ -142,7 +142,18 @@ static void print_log_path(struct llog_logid_rec *lid, int is_ext) logid_to_fid(&lid->lid_id, &fid_from_logid); - if (is_ext) + /** + * Llogs with regular llog SEQ such as FID_SEQ_LLOG and + * FID_SEQ_LLOG_NAME are stored under O/ directory but + * update llogs are using normal FIDs and stored under + * 'update_log_dir' directory with FID format name + * Distinguish them by FID sequence + */ + if (fid_from_logid.f_seq != FID_SEQ_LLOG && + fid_from_logid.f_seq != FID_SEQ_LLOG_NAME) + snprintf(object_path, sizeof(object_path), + "update_log_dir/"DFID, PFID(&fid_from_logid)); + else if (is_ext) snprintf(object_path, sizeof(object_path), "O/%ju/d%u/%u", (uintmax_t)fid_from_logid.f_seq, fid_from_logid.f_oid % 32, @@ -154,8 +165,7 @@ static void print_log_path(struct llog_logid_rec *lid, int is_ext) (OSD_OI_FID_NR - 1)), PFID(&fid_from_logid)); - printf("id="DFID":%x path=%s\n", - PFID(&lid->lid_id.lgl_oi.oi_fid), lid->lid_id.lgl_ogen, + printf("fid="DFID" path=%s\n", PFID(&fid_from_logid), object_path); } @@ -279,7 +289,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog, /* the llog header not countable here.*/ recs_num = count - 1; if (recs_num == 0) - goto clear_file_buf; + return 0; recs_buf = calloc(recs_num, sizeof(**recs_pr)); if (!recs_buf) { @@ -411,7 +421,7 @@ void print_llog_header(struct llog_log_hdr *llog_buf) __le32_to_cpu(llog_buf->llh_count)-1, __le32_to_cpu(llog_buf->llh_cat_idx), __le32_to_cpu(tail->lrt_index)); - + printf("Flags: %#x\n", __le32_to_cpu(llog_buf->llh_flags)); printf("Target uuid : %s\n", (char *)(&llog_buf->llh_tgtuuid)); -- 1.8.3.1