From 6df76d3357fc5896b6902399ed7ce6d7c7835f58 Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Sat, 17 Oct 2020 23:28:43 +0800 Subject: [PATCH] LU-14044 llog: check fid after convert We should convert from llog_id and then check fid. Also change fid-lookup to error check instead LASSERT. Signed-off-by: Yang Sheng Change-Id: I673d8f16ff9e57a0482d6a3ec3ee3db33699f57f Reviewed-on: https://review.whamcloud.com/40294 Tested-by: jenkins Reviewed-by: Emoly Liu Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/obdclass/llog_ioctl.c | 4 +++- lustre/osd-ldiskfs/osd_handler.c | 8 +++++++- lustre/utils/lctl.c | 10 +++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index 894e2ea..11478a5 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -48,13 +48,15 @@ static int str2logid(struct llog_logid *logid, char *str, int len) start = str; if (start[0] == '[') { struct lu_fid *fid = &logid->lgl_oi.oi_fid; + struct lu_fid sfid; 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); - RETURN(num == 3 && fid_is_sane(fid) ? 0 : -EINVAL); + logid_to_fid(logid, &sfid); + RETURN(num == 3 && fid_is_sane(&sfid) ? 0 : -EINVAL); } #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 1, 53, 0) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index e384806..584c8c1 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1127,7 +1127,13 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, LINVRNT(osd_invariant(obj)); LASSERT(obj->oo_inode == NULL); - LASSERTF(fid_is_sane(fid) || fid_is_idif(fid), DFID"\n", PFID(fid)); + + if (fid_is_sane(fid) == 0) { + CERROR("%s: invalid FID "DFID"\n", ldev->ld_obd->obd_name, + PFID(fid)); + dump_stack(); + RETURN(-EINVAL); + } dev = osd_dev(ldev); scrub = &dev->od_scrub.os_scrub; diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index b32b3d1..830d240 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -540,21 +540,21 @@ command_t cmdlist[] = { "usage: llog_catlist"}, {"llog_info", jt_llog_info, 0, "print log header information.\n" - "usage: llog_info \n"}, + "usage: llog_info \n"}, {"llog_print", jt_llog_print, 0, "print log content information.\n" - "usage: llog_print [--start ] [--end j]\n" + "usage: llog_print [--start ] [--end j]\n" " print all records by default, or within given index range."}, {"llog_cancel", jt_llog_cancel, 0, "cancel one record in specified log.\n" - "usage:llog_cancel --log_idx \n"}, + "usage:llog_cancel --log_idx \n"}, {"llog_check", jt_llog_check, 0, "verify that log content is valid.\n" - "usage: llog_check [--start ] [--end j]\n" + "usage: llog_check [--start ] [--end j]\n" " check all records from index 1 by default."}, {"llog_remove", jt_llog_remove, 0, "remove one log from catalog or plain log, erase it from disk.\n" - "usage: llog_remove [--log_id ]"}, + "usage: llog_remove [--log_id ]"}, {"==== obsolete (DANGEROUS) ====", NULL, 0, "obsolete (DANGEROUS)"}, /* some test scripts still use these */ /* saving for sanity 44a */ -- 1.8.3.1