Whamcloud - gitweb
LU-8066 obdclass: Remove lprocfs_obd_short_io_bytes_* declarations
[fs/lustre-release.git] / lustre / obdclass / llog_ioctl.c
index 191880a..2a0ee90 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #define DEBUG_SUBSYSTEM S_LOG
@@ -48,13 +47,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)
@@ -167,7 +168,7 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
                        RETURN(rc);
                }
                rc = llog_process(env, loghandle, llog_check_cb, NULL, NULL);
-               llog_handle_put(loghandle);
+               llog_handle_put(env, loghandle);
        } else {
                bool ok;
 
@@ -292,7 +293,7 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat,
        }
        llog_cat_cleanup(env, cat, log, log->u.phd.phd_cookie.lgc_index);
 out:
-       llog_handle_put(log);
+       llog_handle_put(env, log);
        RETURN(rc);
 
 }
@@ -318,12 +319,13 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
        struct llog_logid logid;
        int rc = 0;
        struct llog_handle *handle = NULL;
-       char *logname;
+       char *logname, start;
 
        ENTRY;
 
        logname = data->ioc_inlbuf1;
-       if (logname[0] == '#' || logname[0] == '[') {
+       start = logname[0];
+       if (start == '#' || start == '[') {
                rc = str2logid(&logid, logname, data->ioc_inllen1);
                if (rc)
                        RETURN(rc);
@@ -331,8 +333,8 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
                               LLOG_OPEN_EXISTS);
                if (rc)
                        RETURN(rc);
-       } else if (logname[0] == '$' || isalpha(logname[0])) {
-               if (logname[0] == '$')
+       } else if (start == '$' || isalpha(start) || isdigit(start)) {
+               if (start == '$')
                        logname++;
 
                rc = llog_open(env, ctxt, &handle, NULL, logname,
@@ -340,7 +342,10 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
                if (rc)
                        RETURN(rc);
        } else {
-               RETURN(-EINVAL);
+               rc = -EINVAL;
+               CDEBUG(D_INFO, "%s: invalid log name '%s': rc = %d\n",
+                     ctxt->loc_obd->obd_name, logname, rc);
+               RETURN(rc);
        }
 
        rc = llog_init_handle(env, handle, 0, NULL);
@@ -430,7 +435,7 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
                        GOTO(out_close, rc = -EINVAL);
                }
 
-               if (data->ioc_inlbuf2 > 0) {
+               if (data->ioc_inlbuf2) {
                        /* remove indicate log from the catalog */
                        rc = str2logid(&plain, data->ioc_inlbuf2,
                                       data->ioc_inllen2);
@@ -493,15 +498,28 @@ int llog_catalog_list(const struct lu_env *env, struct dt_device *d,
 
        out = data->ioc_bulk;
        remains = data->ioc_inllen1;
-       for (i = 0; i < count; i++) {
+       /* OBD_FAIL: fetch the catalog records from the specified one */
+       if (OBD_FAIL_CHECK(OBD_FAIL_CATLIST))
+               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);
+                             PFID(&id->lgl_oi.oi_fid), id->lgl_ogen);
                out += l;
                remains -= l;
-               if (remains <= 0)
-                       break;
+               if (remains <= 0) {
+                       if (remains < 0) {
+                               /* the print is not complete */
+                               remains += l;
+                               data->ioc_bulk[out - data->ioc_bulk - l] = '\0';
+                               data->ioc_count = i;
+                       } else {
+                               data->ioc_count = i++;
+                       }
+                       goto out;
+               }
        }
+       data->ioc_count = 0;
 out:
        OBD_FREE_LARGE(idarray, size);
        RETURN(rc);