Whamcloud - gitweb
LU-8508 nodemap: improve object handling in cache saving
[fs/lustre-release.git] / lustre / mdd / mdd_device.c
index 242f3e6..4a7b872 100644 (file)
@@ -51,6 +51,7 @@
 #include <lu_object.h>
 #include <lustre_param.h>
 #include <lustre_fid.h>
+#include <lustre_nodemap.h>
 
 #include "mdd_internal.h"
 
@@ -124,6 +125,10 @@ static int mdd_init0(const struct lu_env *env, struct mdd_device *mdd,
        const char *dev;
        ENTRY;
 
+       /* LU-8040 Set defaults here, before values configs */
+       mdd->mdd_cl.mc_flags = 0; /* off by default */
+       mdd->mdd_cl.mc_mask = CHANGELOG_DEFMASK;
+
        dev = lustre_cfg_string(lcfg, 0);
        if (dev == NULL)
                RETURN(rc);
@@ -340,7 +345,7 @@ static int mdd_changelog_llog_init(const struct lu_env *env,
        if (rc)
                GOTO(out_cleanup, rc);
 
-       rc = llog_cat_init_and_process(env, ctxt->loc_handle);
+       rc = llog_init_handle(env, ctxt->loc_handle, LLOG_F_IS_CAT, NULL);
        if (rc)
                GOTO(out_close, rc);
 
@@ -376,7 +381,7 @@ static int mdd_changelog_llog_init(const struct lu_env *env,
        uctxt->loc_handle->lgh_logops->lop_add = llog_cat_add_rec;
        uctxt->loc_handle->lgh_logops->lop_declare_add = llog_cat_declare_add_rec;
 
-       rc = llog_cat_init_and_process(env, uctxt->loc_handle);
+       rc = llog_init_handle(env, uctxt->loc_handle, LLOG_F_IS_CAT, NULL);
        if (rc)
                GOTO(out_uclose, rc);
 
@@ -416,8 +421,6 @@ static int mdd_changelog_init(const struct lu_env *env, struct mdd_device *mdd)
        mdd->mdd_cl.mc_index = 0;
        spin_lock_init(&mdd->mdd_cl.mc_lock);
        mdd->mdd_cl.mc_starttime = cfs_time_current_64();
-       mdd->mdd_cl.mc_flags = 0; /* off by default */
-       mdd->mdd_cl.mc_mask = CHANGELOG_DEFMASK;
        spin_lock_init(&mdd->mdd_cl.mc_user_lock);
        mdd->mdd_cl.mc_lastuser = 0;
 
@@ -836,7 +839,7 @@ static int mdd_hsm_actions_llog_init(const struct lu_env *env,
                GOTO(out_cleanup, rc);
        }
 
-       rc = llog_cat_init_and_process(env, ctxt->loc_handle);
+       rc = llog_init_handle(env, ctxt->loc_handle, LLOG_F_IS_CAT, NULL);
        if (rc)
                GOTO(out_close, rc);
 
@@ -881,6 +884,7 @@ static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
        mdd_changelog_fini(env, m);
        orph_index_fini(env, m);
        mdd_dot_lustre_cleanup(env, m);
+       nm_config_file_deregister_tgt(env, mdd2obd_dev(m)->u.obt.obt_nodemap_config_file);
        if (m->mdd_los != NULL) {
                local_oid_storage_fini(env, m->mdd_los);
                m->mdd_los = NULL;
@@ -991,10 +995,11 @@ static int mdd_prepare(const struct lu_env *env,
                        struct lu_device *pdev,
                        struct lu_device *cdev)
 {
-       struct mdd_device       *mdd = lu2mdd_dev(cdev);
-       struct lu_device        *next = &mdd->mdd_child->dd_lu_dev;
-       struct lu_fid            fid;
-       int                      rc;
+       struct mdd_device *mdd = lu2mdd_dev(cdev);
+       struct lu_device *next = &mdd->mdd_child->dd_lu_dev;
+       struct nm_config_file *nodemap_config;
+       struct lu_fid fid;
+       int rc;
 
        ENTRY;
 
@@ -1054,15 +1059,27 @@ static int mdd_prepare(const struct lu_env *env,
        if (rc != 0)
                GOTO(out_changelog, rc);
 
+       nodemap_config = nm_config_file_register_tgt(env, mdd->mdd_bottom,
+                                                    mdd->mdd_los);
+       if (IS_ERR(nodemap_config))
+               GOTO(out_hsm, rc = PTR_ERR(nodemap_config));
+
+       mdd2obd_dev(mdd)->u.obt.obt_nodemap_config_file = nodemap_config;
+
        rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child,
                            mdd2obd_dev(mdd), mdd_lfsck_out_notify,
                            mdd, true);
        if (rc != 0) {
                CERROR("%s: failed to initialize lfsck: rc = %d\n",
                       mdd2obd_dev(mdd)->obd_name, rc);
-               GOTO(out_hsm, rc);
+               GOTO(out_nodemap, rc);
        }
+
        RETURN(0);
+
+out_nodemap:
+       nm_config_file_deregister_tgt(env, mdd2obd_dev(mdd)->u.obt.obt_nodemap_config_file);
+       mdd2obd_dev(mdd)->u.obt.obt_nodemap_config_file = NULL;
 out_hsm:
        mdd_hsm_actions_llog_fini(env, mdd);
 out_changelog:
@@ -1487,7 +1504,12 @@ static int mdd_iocontrol(const struct lu_env *env, struct md_device *m,
                                (struct lfsck_stop *)karg);
                RETURN(rc);
        }
-        }
+       case OBD_IOC_QUERY_LFSCK: {
+               rc = lfsck_query(env, mdd->mdd_bottom, NULL, NULL,
+                                (struct lfsck_query *)karg);
+               RETURN(rc);
+       }
+       }
 
         /* Below ioctls use obd_ioctl_data */
         if (len != sizeof(*data)) {