Whamcloud - gitweb
LU-6027 osd-zfs: Preserve lu_buf when listing EAs
[fs/lustre-release.git] / lustre / lfsck / lfsck_lib.c
index 3e6a1d5..60f1df6 100644 (file)
@@ -98,6 +98,7 @@ const char *lfsck_param_names[] = {
        "broadcast",
        "orphan",
        "create_ostobj",
+       "create_mdtobj",
        NULL
 };
 
@@ -391,10 +392,25 @@ int lfsck_ibits_lock(const struct lu_env *env, struct lfsck_instance *lfsck,
        memset(policy, 0, sizeof(*policy));
        policy->l_inodebits.bits = bits;
        fid_build_reg_res_name(lfsck_dto2fid(obj), resid);
-       rc = ldlm_cli_enqueue_local(lfsck->li_namespace, resid, LDLM_IBITS,
-                                   policy, mode, &flags, ldlm_blocking_ast,
-                                   ldlm_completion_ast, NULL, NULL, 0,
-                                   LVB_T_NONE, NULL, lh);
+       if (dt_object_remote(obj)) {
+               struct ldlm_enqueue_info *einfo = &info->lti_einfo;
+
+               memset(einfo, 0, sizeof(*einfo));
+               einfo->ei_type = LDLM_IBITS;
+               einfo->ei_mode = mode;
+               einfo->ei_cb_bl = ldlm_blocking_ast;
+               einfo->ei_cb_cp = ldlm_completion_ast;
+               einfo->ei_res_id = resid;
+
+               rc = dt_object_lock(env, obj, lh, einfo, policy);
+       } else {
+               rc = ldlm_cli_enqueue_local(lfsck->li_namespace, resid,
+                                           LDLM_IBITS, policy, mode,
+                                           &flags, ldlm_blocking_ast,
+                                           ldlm_completion_ast, NULL, NULL,
+                                           0, LVB_T_NONE, NULL, lh);
+       }
+
        if (rc == ELDLM_OK) {
                rc = 0;
        } else {
@@ -935,13 +951,8 @@ static int lfsck_scan_lpf_bad_entries(const struct lu_env *env,
                        break;
 
                ent->lde_namelen = le16_to_cpu(ent->lde_namelen);
-               if (ent->lde_name[0] == '.') {
-                       if (ent->lde_namelen == 1)
-                               goto next;
-
-                       if (ent->lde_namelen == 2 && ent->lde_name[1] == '.')
-                               goto next;
-               }
+               if (name_is_dot_or_dotdot(ent->lde_name, ent->lde_namelen))
+                       goto next;
 
                /* name length must be strlen("MDTxxxx") */
                if (ent->lde_namelen != 7)
@@ -1428,6 +1439,9 @@ void lfsck_instance_cleanup(const struct lu_env *env,
        struct ptlrpc_thread    *thread = &lfsck->li_thread;
        struct lfsck_component  *com;
        struct lfsck_component  *next;
+       struct lfsck_lmv_unit   *llu;
+       struct lfsck_lmv_unit   *llu_next;
+       struct lfsck_lmv        *llmv;
        ENTRY;
 
        LASSERT(list_empty(&lfsck->li_link));
@@ -1439,6 +1453,17 @@ void lfsck_instance_cleanup(const struct lu_env *env,
        }
 
        LASSERT(lfsck->li_obj_dir == NULL);
+       LASSERT(lfsck->li_lmv == NULL);
+
+       list_for_each_entry_safe(llu, llu_next, &lfsck->li_list_lmv, llu_link) {
+               llmv = &llu->llu_lmv;
+
+               LASSERTF(atomic_read(&llmv->ll_ref) == 1,
+                        "still in using: %u\n",
+                        atomic_read(&llmv->ll_ref));
+
+               lfsck_lmv_put(env, llmv);
+       }
 
        list_for_each_entry_safe(com, next, &lfsck->li_list_scan, lc_link) {
                lfsck_component_cleanup(env, com);
@@ -1620,12 +1645,14 @@ bool __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit)
        bool dirty = false;
 
        if (limit != LFSCK_SPEED_NO_LIMIT) {
-               if (limit > HZ) {
-                       lfsck->li_sleep_rate = limit / HZ;
+               if (limit > msecs_to_jiffies(MSEC_PER_SEC)) {
+                       lfsck->li_sleep_rate = limit /
+                                              msecs_to_jiffies(MSEC_PER_SEC);
                        lfsck->li_sleep_jif = 1;
                } else {
                        lfsck->li_sleep_rate = 1;
-                       lfsck->li_sleep_jif = HZ / limit;
+                       lfsck->li_sleep_jif = msecs_to_jiffies(MSEC_PER_SEC) /
+                                             limit;
                }
        } else {
                lfsck->li_sleep_jif = 0;
@@ -2514,7 +2541,8 @@ static int lfsck_start_all(const struct lu_env *env,
        lr->lr_param = start->ls_flags;
        lr->lr_async_windows = bk->lb_async_windows;
        lr->lr_valid = LSV_SPEED_LIMIT | LSV_ERROR_HANDLE | LSV_DRYRUN |
-                      LSV_ASYNC_WINDOWS;
+                      LSV_ASYNC_WINDOWS | LSV_CREATE_OSTOBJ |
+                      LSV_CREATE_MDTOBJ;
 
        laia->laia_com = NULL;
        laia->laia_ltds = ltds;
@@ -2875,7 +2903,7 @@ out:
 EXPORT_SYMBOL(lfsck_stop);
 
 int lfsck_in_notify(const struct lu_env *env, struct dt_device *key,
-                   struct lfsck_request *lr)
+                   struct lfsck_request *lr, struct thandle *th)
 {
        int rc = -EOPNOTSUPP;
        ENTRY;
@@ -2913,6 +2941,11 @@ int lfsck_in_notify(const struct lu_env *env, struct dt_device *key,
        case LE_FID_ACCESSED:
        case LE_PEER_EXIT:
        case LE_CONDITIONAL_DESTROY:
+       case LE_CREATE_ORPHAN:
+       case LE_SKIP_NLINK_DECLARE:
+       case LE_SKIP_NLINK:
+       case LE_SET_LMV_MASTER:
+       case LE_SET_LMV_SLAVE:
        case LE_PAIRS_VERIFY: {
                struct lfsck_instance  *lfsck;
                struct lfsck_component *com;
@@ -2923,7 +2956,7 @@ int lfsck_in_notify(const struct lu_env *env, struct dt_device *key,
 
                com = lfsck_component_find(lfsck, lr->lr_active);
                if (likely(com != NULL)) {
-                       rc = com->lc_ops->lfsck_in_notify(env, com, lr);
+                       rc = com->lc_ops->lfsck_in_notify(env, com, lr, th);
                        lfsck_component_put(env, com);
                }
 
@@ -3007,6 +3040,7 @@ int lfsck_register(const struct lu_env *env, struct dt_device *key,
        INIT_LIST_HEAD(&lfsck->li_list_dir);
        INIT_LIST_HEAD(&lfsck->li_list_double_scan);
        INIT_LIST_HEAD(&lfsck->li_list_idle);
+       INIT_LIST_HEAD(&lfsck->li_list_lmv);
        atomic_set(&lfsck->li_ref, 1);
        atomic_set(&lfsck->li_double_scan_count, 0);
        init_waitqueue_head(&lfsck->li_thread.t_ctl_waitq);