Whamcloud - gitweb
LU-2430 mdd: add lfs mv to migrate inode.
[fs/lustre-release.git] / lustre / lfsck / lfsck_layout.c
index 01e3151..d2f7ae7 100644 (file)
@@ -780,7 +780,8 @@ static int lfsck_layout_store(const struct lu_env *env,
                RETURN(rc);
        }
 
-       rc = dt_declare_record_write(env, obj, size, pos, handle);
+       rc = dt_declare_record_write(env, obj, lfsck_buf_get(env, lo, size),
+                                    pos, handle);
        if (rc != 0) {
                CERROR("%s: fail to declare trans for storing lfsck_layout(1): "
                       "rc = %d\n", lfsck_lfsck2name(lfsck), rc);
@@ -922,7 +923,10 @@ lfsck_layout_lastid_create(const struct lu_env *env,
        if (rc != 0)
                GOTO(stop, rc);
 
-       rc = dt_declare_record_write(env, obj, sizeof(lastid), pos, th);
+       rc = dt_declare_record_write(env, obj,
+                                    lfsck_buf_get(env, &lastid,
+                                                  sizeof(lastid)),
+                                    pos, th);
        if (rc != 0)
                GOTO(stop, rc);
 
@@ -1042,8 +1046,10 @@ lfsck_layout_lastid_store(const struct lu_env *env,
                        continue;
                }
 
+               lastid = cpu_to_le64(lls->lls_lastid);
                rc = dt_declare_record_write(env, lls->lls_lastid_obj,
-                                            sizeof(lastid), pos, th);
+                                            lfsck_buf_get(env, &lastid,
+                                            sizeof(lastid)), pos, th);
                if (rc != 0)
                        goto stop;
 
@@ -1051,7 +1057,6 @@ lfsck_layout_lastid_store(const struct lu_env *env,
                if (rc != 0)
                        goto stop;
 
-               lastid = cpu_to_le64(lls->lls_lastid);
                dt_write_lock(env, lls->lls_lastid_obj, 0);
                rc = dt_record_write(env, lls->lls_lastid_obj,
                                     lfsck_buf_get(env, &lastid,
@@ -3380,11 +3385,15 @@ static int lfsck_layout_assistant(void *args)
                        rc = lfsck_layout_assistant_handle_one(env, com, llr);
                        spin_lock(&llmd->llmd_lock);
                        list_del_init(&llr->llr_list);
-                       if (bk->lb_async_windows != 0 &&
-                           llmd->llmd_prefetched >= bk->lb_async_windows)
-                               wakeup = true;
-
                        llmd->llmd_prefetched--;
+                       /* Wake up the main engine thread only when the list
+                        * is empty or half of the prefetched items have been
+                        * handled to avoid too frequent thread schedule. */
+                       if (llmd->llmd_prefetched == 0 ||
+                           (bk->lb_async_windows != 0 &&
+                            (bk->lb_async_windows >> 1) ==
+                            llmd->llmd_prefetched))
+                               wakeup = true;
                        spin_unlock(&llmd->llmd_lock);
                        if (wakeup)
                                wake_up_all(&mthread->t_ctl_waitq);
@@ -3394,9 +3403,6 @@ static int lfsck_layout_assistant(void *args)
                                GOTO(cleanup1, rc);
                }
 
-               /* Wakeup the master engine if it is waiting in checkpoint. */
-               wake_up_all(&mthread->t_ctl_waitq);
-
                l_wait_event(athread->t_ctl_waitq,
                             !lfsck_layout_req_empty(llmd) ||
                             llmd->llmd_exit ||