Whamcloud - gitweb
LU-14044 llog: check fid after convert 94/40294/6
authorYang Sheng <ys@whamcloud.com>
Sat, 17 Oct 2020 15:28:43 +0000 (23:28 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 08:21:24 +0000 (08:21 +0000)
We should convert from llog_id and then check fid. Also
change fid-lookup to error check instead LASSERT.

Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: I673d8f16ff9e57a0482d6a3ec3ee3db33699f57f
Reviewed-on: https://review.whamcloud.com/40294
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/llog_ioctl.c
lustre/osd-ldiskfs/osd_handler.c
lustre/utils/lctl.c

index 894e2ea..11478a5 100644 (file)
@@ -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)
index e384806..584c8c1 100644 (file)
@@ -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;
index b32b3d1..830d240 100644 (file)
@@ -540,21 +540,21 @@ command_t cmdlist[] = {
         "usage: llog_catlist"},
        {"llog_info", jt_llog_info, 0,
         "print log header information.\n"
-        "usage: llog_info <logname|FID>\n"},
+        "usage: llog_info <logname|LLOG_ID>\n"},
        {"llog_print", jt_llog_print, 0,
         "print log content information.\n"
-        "usage: llog_print <logname|FID> [--start <index>] [--end <index>j]\n"
+        "usage: llog_print <logname|LLOG_ID> [--start <index>] [--end <index>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 <logname|FID> --log_idx <idx>\n"},
+        "usage:llog_cancel <logname|LLOG_ID> --log_idx <idx>\n"},
        {"llog_check", jt_llog_check, 0,
         "verify that log content is valid.\n"
-        "usage: llog_check <logname|FID> [--start <index>] [--end <index>j]\n"
+        "usage: llog_check <logname|LLOG_ID> [--start <index>] [--end <index>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 <logname|FID> [--log_id <id>]"},
+        "usage: llog_remove <logname|LLOG_ID> [--log_id <id>]"},
        {"==== obsolete (DANGEROUS) ====", NULL, 0, "obsolete (DANGEROUS)"},
        /* some test scripts still use these */
        /* saving for sanity 44a */