Whamcloud - gitweb
LU-6179 llite: remove LOCKAHEAD_OLD compatibility
[fs/lustre-release.git] / lustre / ofd / ofd_dev.c
index 3161d9a..bb60e94 100644 (file)
@@ -161,7 +161,8 @@ out:
  * \retval             negative value on error
  */
 static int ofd_stack_init(const struct lu_env *env,
-                         struct ofd_device *m, struct lustre_cfg *cfg)
+                         struct ofd_device *m, struct lustre_cfg *cfg,
+                         u32 *lmd_flags)
 {
        const char              *dev = lustre_cfg_string(cfg, 0);
        struct lu_device        *d;
@@ -180,8 +181,13 @@ static int ofd_stack_init(const struct lu_env *env,
        }
 
        lmd = s2lsi(lmi->lmi_sb)->lsi_lmd;
-       if (lmd != NULL && lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
-               m->ofd_skip_lfsck = 1;
+       if (lmd) {
+               if (lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
+                       m->ofd_skip_lfsck = 1;
+               if (lmd->lmd_flags & LMD_FLG_NO_PRECREATE)
+                       m->ofd_no_precreate = 1;
+               *lmd_flags = lmd->lmd_flags;
+       }
 
        /* find bottom osd */
        OBD_ALLOC(osdname, MTI_NAME_MAXLEN);
@@ -449,6 +455,14 @@ static int ofd_object_init(const struct lu_env *env, struct lu_object *o,
        RETURN(rc);
 }
 
+static void ofd_object_free_rcu(struct rcu_head *head)
+{
+       struct ofd_object *of = container_of(head, struct ofd_object,
+                                            ofo_header.loh_rcu);
+
+       kmem_cache_free(ofd_object_kmem, of);
+}
+
 /**
  * Implementation of lu_object_operations::loo_object_free.
  *
@@ -470,7 +484,8 @@ static void ofd_object_free(const struct lu_env *env, struct lu_object *o)
 
        lu_object_fini(o);
        lu_object_header_fini(h);
-       OBD_SLAB_FREE_PTR(of, ofd_object_kmem);
+       OBD_FREE_PRE(of, sizeof(*of), "slab-freed");
+       call_rcu(&of->ofo_header.loh_rcu, ofd_object_free_rcu);
        EXIT;
 }
 
@@ -1488,6 +1503,9 @@ static int ofd_create_hdl(struct tgt_session_info *tsi)
        if (OBD_FAIL_CHECK(OBD_FAIL_OST_EROFS))
                RETURN(-EROFS);
 
+       if (ofd->ofd_no_precreate)
+               return -EPERM;
+
        repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_OST_BODY);
        if (repbody == NULL)
                RETURN(-ENOMEM);
@@ -1722,18 +1740,8 @@ static int ofd_create_hdl(struct tgt_session_info *tsi)
 out:
        mutex_unlock(&oseq->os_create_lock);
 out_nolock:
-       if (rc == 0) {
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 8, 53, 0)
-               struct ofd_thread_info  *info = ofd_info(tsi->tsi_env);
-               struct lu_fid           *fid = &info->fti_fid;
-
-               /* For compatible purpose, it needs to convert back to
-                * OST ID before put it on wire. */
-               *fid = rep_oa->o_oi.oi_fid;
-               fid_to_ostid(fid, &rep_oa->o_oi);
-#endif
+       if (rc == 0)
                rep_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
-       }
        ofd_seq_put(tsi->tsi_env, oseq);
 
 out_sem:
@@ -1955,7 +1963,7 @@ static int ofd_punch_hdl(struct tgt_session_info *tsi)
        OBD_FAIL_TIMEOUT(OBD_FAIL_OST_PAUSE_PUNCH, cfs_fail_val);
 
        /* check that we do support OBD_CONNECT_TRUNCLOCK. */
-       CLASSERT(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK);
+       BUILD_BUG_ON(!(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK));
 
        if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
            (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
@@ -2075,7 +2083,8 @@ static int ofd_ladvise_prefetch(const struct lu_env *env,
                        PTLRPC_MAX_BRW_PAGES;
                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, dbt);
+               rc = dt_bufs_get(env, ofd_object_child(fo), &rnb, lnb,
+                                PTLRPC_MAX_BRW_PAGES, dbt);
                if (unlikely(rc < 0))
                        break;
                nr_local = rc;
@@ -2834,6 +2843,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        struct lu_fid fid;
        struct nm_config_file *nodemap_config;
        struct obd_device_target *obt;
+       u32 lmd_flags = 0;
        int rc;
 
        ENTRY;
@@ -2889,7 +2899,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (info == NULL)
                RETURN(-EFAULT);
 
-       rc = ofd_stack_init(env, m, cfg);
+       rc = ofd_stack_init(env, m, cfg, &lmd_flags);
        if (rc) {
                CERROR("%s: can't init device stack, rc %d\n",
                       obd->obd_name, rc);
@@ -2923,6 +2933,11 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (rc)
                GOTO(err_free_ns, rc);
 
+       if (lmd_flags & LMD_FLG_SKIP_LFSCK)
+               m->ofd_skip_lfsck = 1;
+       if (lmd_flags & LMD_FLG_LOCAL_RECOV)
+               m->ofd_lut.lut_local_recovery = 1;
+
        rc = ofd_tunables_init(m);
        if (rc)
                GOTO(err_fini_lut, rc);