Whamcloud - gitweb
LU-8508 nodemap: improve object handling in cache saving
[fs/lustre-release.git] / lustre / ofd / ofd_dev.c
index be51836..9e810a2 100644 (file)
@@ -2138,14 +2138,14 @@ static int ofd_ladvise_prefetch(const struct lu_env *env,
                GOTO(out_unlock, rc);
 
        /* We need page aligned offset and length */
-       start_index = start >> PAGE_CACHE_SHIFT;
-       end_index = (end - 1) >> PAGE_CACHE_SHIFT;
+       start_index = start >> PAGE_SHIFT;
+       end_index = (end - 1) >> PAGE_SHIFT;
        pages = end_index - start_index + 1;
        while (pages > 0) {
                nr_local = pages <= PTLRPC_MAX_BRW_PAGES ? pages :
                        PTLRPC_MAX_BRW_PAGES;
-               rnb.rnb_offset = start_index << PAGE_CACHE_SHIFT;
-               rnb.rnb_len = nr_local << PAGE_CACHE_SHIFT;
+               rnb.rnb_offset = start_index << PAGE_SHIFT;
+               rnb.rnb_len = nr_local << PAGE_SHIFT;
                rc = dt_bufs_get(env, ofd_object_child(fo), &rnb, lnb, 0);
                if (unlikely(rc < 0))
                        break;
@@ -2191,6 +2191,7 @@ static int ofd_ladvise_hdl(struct tgt_session_info *tsi)
        struct lustre_handle     lockh = { 0 };
        __u64                    flags = 0;
        int                      i;
+       struct dt_object        *dob;
        ENTRY;
 
        CFS_FAIL_TIMEOUT(OBD_FAIL_OST_LADVISE_PAUSE, cfs_fail_val);
@@ -2237,6 +2238,7 @@ static int ofd_ladvise_hdl(struct tgt_session_info *tsi)
                RETURN(rc);
        }
        LASSERT(fo != NULL);
+       dob = ofd_object_child(fo);
 
        for (i = 0; i < num_advise; i++, ladvise++) {
                if (ladvise->lla_end <= ladvise->lla_start) {
@@ -2266,6 +2268,10 @@ static int ofd_ladvise_hdl(struct tgt_session_info *tsi)
                                ladvise->lla_end);
                        tgt_extent_unlock(&lockh, LCK_PR);
                        break;
+               case LU_LADVISE_DONTNEED:
+                       rc = dt_ladvise(env, dob, ladvise->lla_start,
+                                       ladvise->lla_end, LU_LADVISE_DONTNEED);
+                       break;
                }
                if (rc != 0)
                        break;
@@ -2878,12 +2884,13 @@ struct lu_context_key ofd_thread_key = {
 static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
                     struct lu_device_type *ldt, struct lustre_cfg *cfg)
 {
-       const char              *dev = lustre_cfg_string(cfg, 0);
-       struct ofd_thread_info  *info = NULL;
-       struct obd_device       *obd;
-       struct obd_statfs       *osfs;
-       struct lu_fid            fid;
-       int                      rc;
+       const char *dev = lustre_cfg_string(cfg, 0);
+       struct ofd_thread_info *info = NULL;
+       struct obd_device *obd;
+       struct obd_statfs *osfs;
+       struct lu_fid fid;
+       struct nm_config_file *nodemap_config;
+       int rc;
 
        ENTRY;
 
@@ -3026,9 +3033,12 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (rc != 0)
                GOTO(err_fini_fs, rc);
 
-       rc = nodemap_fs_init(env, m->ofd_osd, obd, m->ofd_los);
-       if (rc != 0)
-               GOTO(err_fini_los, rc);
+       nodemap_config = nm_config_file_register_tgt(env, m->ofd_osd,
+                                                    m->ofd_los);
+       if (IS_ERR(nodemap_config))
+               GOTO(err_fini_los, rc = PTR_ERR(nodemap_config));
+
+       obd->u.obt.obt_nodemap_config_file = nodemap_config;
 
        rc = ofd_start_inconsistency_verification_thread(m);
        if (rc != 0)
@@ -3039,7 +3049,8 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        RETURN(0);
 
 err_fini_nm:
-       nodemap_fs_fini(env, obd);
+       nm_config_file_deregister_tgt(env, obd->u.obt.obt_nodemap_config_file);
+       obd->u.obt.obt_nodemap_config_file = NULL;
 err_fini_los:
        local_oid_storage_fini(env, m->ofd_los);
        m->ofd_los = NULL;
@@ -3087,7 +3098,8 @@ static void ofd_fini(const struct lu_env *env, struct ofd_device *m)
        ofd_stop_inconsistency_verification_thread(m);
        lfsck_degister(env, m->ofd_osd);
        ofd_fs_cleanup(env, m);
-       nodemap_fs_fini(env, obd);
+       nm_config_file_deregister_tgt(env, obd->u.obt.obt_nodemap_config_file);
+       obd->u.obt.obt_nodemap_config_file = NULL;
 
        if (m->ofd_los != NULL) {
                local_oid_storage_fini(env, m->ofd_los);