Whamcloud - gitweb
LU-3319 procfs: move mdd/ofd proc handling to seq_files
[fs/lustre-release.git] / lustre / lfsck / lfsck_namespace.c
index 4dccb70..fc9a0dc 100644 (file)
@@ -1099,65 +1099,56 @@ static int lfsck_namespace_post(const struct lu_env *env,
 
 static int
 lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
-                    char *buf, int len)
+                    struct seq_file *m)
 {
        struct lfsck_instance   *lfsck = com->lc_lfsck;
        struct lfsck_bookmark   *bk    = &lfsck->li_bookmark_ram;
        struct lfsck_namespace  *ns    = com->lc_file_ram;
-       int                      save  = len;
-       int                      ret   = -ENOSPC;
        int                      rc;
 
        down_read(&com->lc_sem);
-       rc = snprintf(buf, len,
-                     "name: lfsck_namespace\n"
-                     "magic: %#x\n"
-                     "version: %d\n"
-                     "status: %s\n",
-                     ns->ln_magic,
-                     bk->lb_version,
-                     lfsck_status2names(ns->ln_status));
-       if (rc <= 0)
-               goto out;
-
-       buf += rc;
-       len -= rc;
-       rc = lfsck_bits_dump(&buf, &len, ns->ln_flags, lfsck_flags_names,
-                            "flags");
+       seq_printf(m, "name: lfsck_namespace\n"
+                  "magic: %#x\n"
+                  "version: %d\n"
+                  "status: %s\n",
+                  ns->ln_magic,
+                  bk->lb_version,
+                  lfsck_status2names(ns->ln_status));
+
+       rc = lfsck_bits_dump(m, ns->ln_flags, lfsck_flags_names, "flags");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_bits_dump(&buf, &len, bk->lb_param, lfsck_param_names,
-                            "param");
+       rc = lfsck_bits_dump(m, bk->lb_param, lfsck_param_names, "param");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_time_dump(&buf, &len, ns->ln_time_last_complete,
+       rc = lfsck_time_dump(m, ns->ln_time_last_complete,
                             "time_since_last_completed");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_time_dump(&buf, &len, ns->ln_time_latest_start,
+       rc = lfsck_time_dump(m, ns->ln_time_latest_start,
                             "time_since_latest_start");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_time_dump(&buf, &len, ns->ln_time_last_checkpoint,
+       rc = lfsck_time_dump(m, ns->ln_time_last_checkpoint,
                             "time_since_last_checkpoint");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_pos_dump(&buf, &len, &ns->ln_pos_latest_start,
+       rc = lfsck_pos_dump(m, &ns->ln_pos_latest_start,
                            "latest_start_position");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_pos_dump(&buf, &len, &ns->ln_pos_last_checkpoint,
+       rc = lfsck_pos_dump(m, &ns->ln_pos_last_checkpoint,
                            "last_checkpoint_position");
        if (rc < 0)
                goto out;
 
-       rc = lfsck_pos_dump(&buf, &len, &ns->ln_pos_first_inconsistent,
+       rc = lfsck_pos_dump(m, &ns->ln_pos_first_inconsistent,
                            "first_failure_position");
        if (rc < 0)
                goto out;
@@ -1177,8 +1168,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                        do_div(new_checked, duration);
                if (rtime != 0)
                        do_div(speed, rtime);
-               rc = snprintf(buf, len,
-                             "checked_phase1: "LPU64"\n"
+               seq_printf(m, "checked_phase1: "LPU64"\n"
                              "checked_phase2: "LPU64"\n"
                              "updated_phase1: "LPU64"\n"
                              "updated_phase2: "LPU64"\n"
@@ -1214,11 +1204,6 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              ns->ln_run_time_phase2,
                              speed,
                              new_checked);
-               if (rc <= 0)
-                       goto out;
-
-               buf += rc;
-               len -= rc;
 
                LASSERT(lfsck->li_di_oit != NULL);
 
@@ -1247,9 +1232,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                        pos.lp_dir_cookie = 0;
                }
                spin_unlock(&lfsck->li_lock);
-               rc = lfsck_pos_dump(&buf, &len, &pos, "current_position");
-               if (rc <= 0)
-                       goto out;
+               lfsck_pos_dump(m, &pos, "current_position");
        } else if (ns->ln_status == LS_SCANNING_PHASE2) {
                cfs_duration_t duration = cfs_time_current() -
                                          lfsck->li_time_last_checkpoint;
@@ -1267,8 +1250,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                        do_div(speed1, ns->ln_run_time_phase1);
                if (rtime != 0)
                        do_div(speed2, rtime);
-               rc = snprintf(buf, len,
-                             "checked_phase1: "LPU64"\n"
+               seq_printf(m, "checked_phase1: "LPU64"\n"
                              "checked_phase2: "LPU64"\n"
                              "updated_phase1: "LPU64"\n"
                              "updated_phase2: "LPU64"\n"
@@ -1307,11 +1289,6 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              speed2,
                              new_checked,
                              PFID(&ns->ln_fid_latest_scanned_phase2));
-               if (rc <= 0)
-                       goto out;
-
-               buf += rc;
-               len -= rc;
        } else {
                __u64 speed1 = ns->ln_items_checked;
                __u64 speed2 = ns->ln_objs_checked_phase2;
@@ -1320,8 +1297,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                        do_div(speed1, ns->ln_run_time_phase1);
                if (ns->ln_run_time_phase2 != 0)
                        do_div(speed2, ns->ln_run_time_phase2);
-               rc = snprintf(buf, len,
-                             "checked_phase1: "LPU64"\n"
+               seq_printf(m, "checked_phase1: "LPU64"\n"
                              "checked_phase2: "LPU64"\n"
                              "updated_phase1: "LPU64"\n"
                              "updated_phase2: "LPU64"\n"
@@ -1358,17 +1334,10 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                              ns->ln_run_time_phase2,
                              speed1,
                              speed2);
-               if (rc <= 0)
-                       goto out;
-
-               buf += rc;
-               len -= rc;
        }
-       ret = save - len;
-
 out:
        up_read(&com->lc_sem);
-       return ret;
+       return 0;
 }
 
 static int lfsck_namespace_double_scan_main(void *args)