Whamcloud - gitweb
LU-6050 target: control OST-index in IDIF via ROCOMPAT flag
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_handler.c
index 588d233..086a812 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -86,6 +86,9 @@ CFS_MODULE_PARM(ldiskfs_track_declares_assert, "i", int, 0644,
 /* Slab to allocate dynlocks */
 struct kmem_cache *dynlock_cachep;
 
+/* Slab to allocate osd_it_ea */
+struct kmem_cache *osd_itea_cachep;
+
 static struct lu_kmem_descr ldiskfs_caches[] = {
        {
                .ckd_cache = &dynlock_cachep,
@@ -93,6 +96,11 @@ static struct lu_kmem_descr ldiskfs_caches[] = {
                .ckd_size  = sizeof(struct dynlock_handle)
        },
        {
+               .ckd_cache = &osd_itea_cachep,
+               .ckd_name  = "osd_itea_cache",
+               .ckd_size  = sizeof(struct osd_it_ea)
+       },
+       {
                .ckd_cache = NULL
        }
 };
@@ -349,6 +357,8 @@ static struct inode *osd_iget_check(struct osd_thread_info *info,
 
 check_oi:
        if (rc != 0) {
+               struct osd_inode_id saved_id = *id;
+
                LASSERTF(rc == -ESTALE || rc == -ENOENT, "rc = %d\n", rc);
 
                rc = osd_oi_lookup(info, dev, fid, id, OI_CHECK_FLD);
@@ -370,10 +380,22 @@ check_oi:
                 *      to distinguish the 1st case from the 2nd case. */
                if (rc == 0) {
                        if (!IS_ERR(inode) && inode->i_generation != 0 &&
-                           inode->i_generation == id->oii_gen)
+                           inode->i_generation == id->oii_gen) {
                                rc = -ENOENT;
-                       else
+                       } else {
+                               __u32 level = D_LFSCK;
+
                                rc = -EREMCHG;
+                               if (!thread_is_running(&dev->od_scrub.os_thread))
+                                       level |= D_CONSOLE;
+
+                               CDEBUG(level, "%s: the OI mapping for the FID "
+                                      DFID" become inconsistent, the given ID "
+                                      "%u/%u, the ID in OI mapping %u/%u\n",
+                                      osd_name(dev), PFID(fid),
+                                      saved_id.oii_ino, saved_id.oii_gen,
+                                      id->oii_ino, id->oii_ino);
+                       }
                }
        } else {
                if (id->oii_gen == OSD_OII_NOGEN)
@@ -473,15 +495,14 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj)
        if (rc == -ENODATA && !fid_is_igif(rfid) && osd->od_check_ff) {
                fid = &lma->lma_self_fid;
                rc = osd_get_idif(info, inode, dentry, fid);
-               if ((rc > 0) || (rc == -ENODATA && osd->od_lma_self_repair)) {
+               if ((rc > 0) || (rc == -ENODATA && osd->od_index_in_idif)) {
                        /* For the given OST-object, if it has neither LMA nor
                         * FID in XATTR_NAME_FID, then the given FID (which is
                         * contained in the @obj, from client RPC for locating
                         * the OST-object) is trusted. We use it to generate
                         * the LMA. */
                        osd_lma_self_repair(info, osd, inode, rfid,
-                               fid_is_on_ost(info, osd, fid, OI_CHECK_FLD) ?
-                               LMAC_FID_ON_OST : 0);
+                                           LMAC_FID_ON_OST);
                        RETURN(0);
                }
        }
@@ -508,6 +529,8 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj)
        }
 
        if (fid != NULL && unlikely(!lu_fid_eq(rfid, fid))) {
+               __u32 level = D_LFSCK;
+
                if (fid_is_idif(rfid) && fid_is_idif(fid)) {
                        struct ost_id   *oi   = &info->oti_ostid;
                        struct lu_fid   *fid1 = &info->oti_fid3;
@@ -522,7 +545,7 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj)
                                fid_to_ostid(fid, oi);
                                ostid_to_fid(fid1, oi, idx);
                                if (lu_fid_eq(fid1, rfid)) {
-                                       if (osd->od_lma_self_repair)
+                                       if (osd->od_index_in_idif)
                                                osd_lma_self_repair(info, osd,
                                                        inode, rfid,
                                                        LMAC_FID_ON_OST);
@@ -531,9 +554,13 @@ static int osd_check_lma(const struct lu_env *env, struct osd_object *obj)
                        }
                }
 
-               CDEBUG(D_INODE, "%s: FID "DFID" != self_fid "DFID"\n",
-                      osd_name(osd), PFID(rfid), PFID(fid));
+
                rc = -EREMCHG;
+               if (!thread_is_running(&osd->od_scrub.os_thread))
+                       level |= D_CONSOLE;
+
+               CDEBUG(level, "%s: FID "DFID" != self_fid "DFID"\n",
+                      osd_name(osd), PFID(rfid), PFID(fid));
        }
 
        RETURN(rc);
@@ -638,9 +665,9 @@ trigger:
                                 * whole device. */
                                result = osd_scrub_start(dev, SS_AUTO_FULL |
                                        SS_CLEAR_DRYRUN | SS_CLEAR_FAILOUT);
-                               LCONSOLE_WARN("%.16s: trigger OI scrub by RPC "
-                                             "for "DFID", rc = %d [1]\n",
-                                             osd_name(dev), PFID(fid),result);
+                               CDEBUG(D_LFSCK | D_CONSOLE, "%.16s: trigger OI "
+                                      "scrub by RPC for "DFID", rc = %d [1]\n",
+                                      osd_name(dev), PFID(fid),result);
                                if (result == 0 || result == -EALREADY)
                                        result = -EINPROGRESS;
                                else
@@ -1730,7 +1757,9 @@ static int osd_attr_get(const struct lu_env *env,
 {
        struct osd_object *obj = osd_dt_obj(dt);
 
-       LASSERT(dt_object_exists(dt));
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LASSERT(!dt_object_remote(dt));
        LINVRNT(osd_invariant(obj));
 
@@ -1973,8 +2002,10 @@ static int osd_attr_set(const struct lu_env *env,
        struct inode      *inode;
        int rc;
 
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LASSERT(handle != NULL);
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(osd_invariant(obj));
 
@@ -2416,8 +2447,10 @@ static int osd_object_create(const struct lu_env *env, struct dt_object *dt,
        int result;
        ENTRY;
 
+       if (dt_object_exists(dt))
+               return -EEXIST;
+
        LINVRNT(osd_invariant(obj));
-       LASSERT(!dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(osd_write_locked(env, obj));
        LASSERT(th != NULL);
@@ -2745,8 +2778,10 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt,
 
        ENTRY;
 
+       if (dt_object_exists(dt))
+               RETURN(-EEXIST);
+
        LASSERT(osd_invariant(obj));
-       LASSERT(!dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(osd_write_locked(env, obj));
        LASSERT(th != NULL);
@@ -2760,11 +2795,23 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt,
        osd_trans_declare_rb(env, th, OSD_OT_REF_ADD);
 
        result = __osd_object_create(info, obj, attr, hint, dof, th);
-       if (result == 0)
-               result = osd_ea_fid_set(info, obj->oo_inode, fid,
+       if (result == 0) {
+               if (fid_is_idif(fid) &&
+                   !osd_dev(dt->do_lu.lo_dev)->od_index_in_idif) {
+                       struct lu_fid *tfid = &info->oti_fid;
+                       struct ost_id *oi   = &info->oti_ostid;
+
+                       fid_to_ostid(fid, oi);
+                       ostid_to_fid(tfid, oi, 0);
+                       result = osd_ea_fid_set(info, obj->oo_inode, tfid,
+                                               LMAC_FID_ON_OST, 0);
+               } else {
+                       result = osd_ea_fid_set(info, obj->oo_inode, fid,
                                fid_is_on_ost(info, osd_obj2dev(obj),
                                              fid, OI_CHECK_FLD) ?
                                LMAC_FID_ON_OST : 0, 0);
+               }
+       }
 
        if (result == 0)
                result = __osd_oi_insert(env, obj, fid, th);
@@ -2804,8 +2851,10 @@ static int osd_object_ref_add(const struct lu_env *env,
        struct osd_thandle *oh;
        int                 rc = 0;
 
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LINVRNT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(osd_write_locked(env, obj));
        LASSERT(th != NULL);
@@ -2851,7 +2900,6 @@ static int osd_declare_object_ref_del(const struct lu_env *env,
 {
        struct osd_thandle *oh;
 
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(handle != NULL);
 
@@ -2875,8 +2923,10 @@ static int osd_object_ref_del(const struct lu_env *env, struct dt_object *dt,
        struct osd_device       *osd = osd_dev(dt->do_lu.lo_dev);
        struct osd_thandle      *oh;
 
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LINVRNT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(osd_write_locked(env, obj));
        LASSERT(th != NULL);
@@ -2952,7 +3002,9 @@ static int osd_xattr_get(const struct lu_env *env, struct dt_object *dt,
                return sizeof(dt_obj_version_t);
         }
 
-       LASSERT(dt_object_exists(dt));
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LASSERT(!dt_object_remote(dt));
        LASSERT(inode->i_op != NULL);
        LASSERT(inode->i_op->getxattr != NULL);
@@ -3094,7 +3146,9 @@ static int osd_xattr_list(const struct lu_env *env, struct dt_object *dt,
        struct osd_thread_info *info   = osd_oti_get(env);
        struct dentry          *dentry = &info->oti_obj_dentry;
 
-       LASSERT(dt_object_exists(dt));
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LASSERT(!dt_object_remote(dt));
        LASSERT(inode->i_op != NULL);
        LASSERT(inode->i_op->listxattr != NULL);
@@ -3114,7 +3168,6 @@ static int osd_declare_xattr_del(const struct lu_env *env,
        struct osd_thandle *oh;
        struct super_block *sb = osd_sb(osd_dev(dt->do_lu.lo_dev));
 
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(handle != NULL);
 
@@ -3145,7 +3198,9 @@ static int osd_xattr_del(const struct lu_env *env, struct dt_object *dt,
        struct dentry          *dentry = &info->oti_obj_dentry;
        int                     rc;
 
-       LASSERT(dt_object_exists(dt));
+       if (!dt_object_exists(dt))
+               return -ENOENT;
+
        LASSERT(!dt_object_remote(dt));
        LASSERT(inode->i_op != NULL);
        LASSERT(inode->i_op->removexattr != NULL);
@@ -3181,7 +3236,9 @@ static struct obd_capa *osd_capa_get(const struct lu_env *env,
        if (!osd->od_fl_capa)
                RETURN(ERR_PTR(-ENOENT));
 
-       LASSERT(dt_object_exists(dt));
+       if (!dt_object_exists(dt))
+               RETURN(ERR_PTR(-ENOENT));
+
        LASSERT(!dt_object_remote(dt));
        LINVRNT(osd_invariant(obj));
 
@@ -3535,8 +3592,10 @@ static int osd_index_iam_delete(const struct lu_env *env, struct dt_object *dt,
        int                     rc;
        ENTRY;
 
+       if (!dt_object_exists(dt))
+               RETURN(-ENOENT);
+
        LINVRNT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(bag->ic_object == obj->oo_inode);
        LASSERT(handle != NULL);
@@ -3576,7 +3635,6 @@ static int osd_index_declare_ea_delete(const struct lu_env *env,
        int                 rc;
        ENTRY;
 
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(handle != NULL);
 
@@ -3656,8 +3714,10 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
        int                        rc;
        ENTRY;
 
+       if (!dt_object_exists(dt))
+               RETURN(-ENOENT);
+
        LINVRNT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(handle != NULL);
 
@@ -3810,8 +3870,10 @@ static int osd_index_iam_lookup(const struct lu_env *env, struct dt_object *dt,
        int                     rc;
        ENTRY;
 
+       if (!dt_object_exists(dt))
+               RETURN(-ENOENT);
+
        LASSERT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(bag->ic_object == obj->oo_inode);
 
@@ -3894,15 +3956,19 @@ static int osd_index_iam_insert(const struct lu_env *env, struct dt_object *dt,
        struct osd_object     *obj = osd_dt_obj(dt);
        struct iam_path_descr *ipd;
        struct osd_thandle    *oh;
-       struct iam_container  *bag = &obj->oo_dir->od_container;
+       struct iam_container  *bag;
        struct osd_thread_info *oti = osd_oti_get(env);
        struct iam_rec         *iam_rec;
        int                     rc;
        ENTRY;
 
+       if (!dt_object_exists(dt))
+               RETURN(-ENOENT);
+
        LINVRNT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
+
+       bag = &obj->oo_dir->od_container;
        LASSERT(bag->ic_object == obj->oo_inode);
        LASSERT(th != NULL);
 
@@ -3989,8 +4055,8 @@ static int __osd_ea_add_rec(struct osd_thread_info *info,
                                else
                                        de->file_type = LDISKFS_DIRENT_LUFID |
                                                        LDISKFS_FT_DIR;
-                               ldiskfs_journal_dirty_metadata(oth->ot_handle,
-                                                              bh);
+                               ldiskfs_handle_dirty_metadata(oth->ot_handle,
+                                                             NULL, bh);
                                brelse(bh);
                        }
                }
@@ -4158,10 +4224,10 @@ again:
        if (!dev->od_noscrub && ++once == 1) {
                rc = osd_scrub_start(dev, SS_AUTO_PARTIAL | SS_CLEAR_DRYRUN |
                                     SS_CLEAR_FAILOUT);
-               LCONSOLE_WARN("%.16s: trigger OI scrub by RPC for "DFID
-                             ", rc = %d [2]\n",
-                             LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name,
-                             PFID(fid), rc);
+               CDEBUG(D_LFSCK | D_CONSOLE, "%.16s: trigger OI scrub by RPC "
+                      "for "DFID", rc = %d [2]\n",
+                      LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name,
+                      PFID(fid), rc);
                if (rc == 0 || rc == -EALREADY)
                        goto again;
        }
@@ -4234,7 +4300,7 @@ static int osd_get_pfid_from_linkea(const struct lu_env *env,
        struct lu_buf           *buf    = &oti->oti_big_buf;
        struct dentry           *dentry = &oti->oti_obj_dentry;
        struct inode            *inode  = obj->oo_inode;
-       struct linkea_data       ldata  = { 0 };
+       struct linkea_data       ldata  = { NULL };
        int                      rc;
        ENTRY;
 
@@ -4519,8 +4585,10 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
        int                     rc;
        ENTRY;
 
+       if (!dt_object_exists(dt))
+               RETURN(-ENOENT);
+
        LASSERT(osd_invariant(obj));
-       LASSERT(dt_object_exists(dt));
        LASSERT(!dt_object_remote(dt));
        LASSERT(th != NULL);
 
@@ -4598,26 +4666,21 @@ static struct dt_it *osd_it_iam_init(const struct lu_env *env,
                                      __u32 unused,
                                      struct lustre_capa *capa)
 {
-        struct osd_it_iam      *it;
-        struct osd_thread_info *oti = osd_oti_get(env);
-        struct osd_object      *obj = osd_dt_obj(dt);
-        struct lu_object       *lo  = &dt->do_lu;
-        struct iam_path_descr  *ipd;
-        struct iam_container   *bag = &obj->oo_dir->od_container;
+       struct osd_it_iam      *it;
+       struct osd_object      *obj = osd_dt_obj(dt);
+       struct lu_object       *lo  = &dt->do_lu;
+       struct iam_path_descr  *ipd;
+       struct iam_container   *bag = &obj->oo_dir->od_container;
 
-        LASSERT(lu_object_exists(lo));
+       if (!dt_object_exists(dt))
+               return ERR_PTR(-ENOENT);
 
-        if (osd_object_auth(env, dt, capa, CAPA_OPC_BODY_READ))
-                return ERR_PTR(-EACCES);
+       if (osd_object_auth(env, dt, capa, CAPA_OPC_BODY_READ))
+               return ERR_PTR(-EACCES);
 
-       if (oti->oti_it_inline) {
-               OBD_ALLOC_PTR(it);
-               if (it == NULL)
-                       return ERR_PTR(-ENOMEM);
-       } else {
-               it = &oti->oti_it;
-               oti->oti_it_inline = 1;
-       }
+       OBD_ALLOC_PTR(it);
+       if (it == NULL)
+               return ERR_PTR(-ENOMEM);
 
        ipd = osd_it_ipd_get(env, bag);
        if (likely(ipd != NULL)) {
@@ -4627,11 +4690,7 @@ static struct dt_it *osd_it_iam_init(const struct lu_env *env,
                iam_it_init(&it->oi_it, bag, IAM_IT_MOVE, ipd);
                return (struct dt_it *)it;
        } else {
-               if (it != &oti->oti_it)
-                       OBD_FREE_PTR(it);
-               else
-                       oti->oti_it_inline = 0;
-
+               OBD_FREE_PTR(it);
                return ERR_PTR(-ENOMEM);
        }
 }
@@ -4642,17 +4701,13 @@ static struct dt_it *osd_it_iam_init(const struct lu_env *env,
 
 static void osd_it_iam_fini(const struct lu_env *env, struct dt_it *di)
 {
-       struct osd_thread_info  *oti = osd_oti_get(env);
        struct osd_it_iam       *it  = (struct osd_it_iam *)di;
        struct osd_object       *obj = it->oi_obj;
 
        iam_it_fini(&it->oi_it);
        osd_ipd_put(env, &obj->oo_dir->od_container, it->oi_ipd);
        lu_object_put(env, &obj->oo_dt.do_lu);
-       if (it != &oti->oti_it)
-               OBD_FREE_PTR(it);
-       else
-               oti->oti_it_inline = 0;
+       OBD_FREE_PTR(it);
 }
 
 /**
@@ -4896,37 +4951,39 @@ static struct dt_it *osd_it_ea_init(const struct lu_env *env,
 {
        struct osd_object       *obj  = osd_dt_obj(dt);
        struct osd_thread_info  *info = osd_oti_get(env);
-       struct osd_it_ea        *it;
+       struct osd_it_ea        *oie;
        struct file             *file;
        struct lu_object        *lo   = &dt->do_lu;
-       struct dentry           *obj_dentry = &info->oti_it_dentry;
+       struct dentry           *obj_dentry;
        ENTRY;
 
-       LASSERT(lu_object_exists(lo));
+       if (!dt_object_exists(dt))
+               RETURN(ERR_PTR(-ENOENT));
 
-       if (info->oti_it_inline) {
-               OBD_ALLOC_PTR(it);
-               if (it == NULL)
-                       RETURN(ERR_PTR(-ENOMEM));
-       } else {
-               it = &info->oti_it_ea;
-               info->oti_it_inline = 1;
-       }
+       OBD_SLAB_ALLOC_PTR_GFP(oie, osd_itea_cachep, GFP_NOFS);
+       if (oie == NULL)
+               RETURN(ERR_PTR(-ENOMEM));
+       obj_dentry = &oie->oie_dentry;
 
        obj_dentry->d_inode = obj->oo_inode;
        obj_dentry->d_sb = osd_sb(osd_obj2dev(obj));
        obj_dentry->d_name.hash = 0;
 
-       it->oie_rd_dirent       = 0;
-       it->oie_it_dirent       = 0;
-       it->oie_dirent          = NULL;
-       it->oie_buf             = info->oti_it_ea_buf;
-       it->oie_obj             = obj;
+       oie->oie_rd_dirent       = 0;
+       oie->oie_it_dirent       = 0;
+       oie->oie_dirent          = NULL;
+       if (unlikely(!info->oti_it_ea_buf_used)) {
+               oie->oie_buf = info->oti_it_ea_buf;
+               info->oti_it_ea_buf_used = 1;
+       } else {
+               OBD_ALLOC(oie->oie_buf, OSD_IT_EA_BUFSIZE);
+               if (oie->oie_buf == NULL)
+                       RETURN(ERR_PTR(-ENOMEM));
+       }
+       oie->oie_obj             = obj;
+
+       file = &oie->oie_file;
 
-       file = &it->oie_file;
-       /* Reset the "file" totally to avoid to reuse any old value from
-        * former readdir handling, the "file->f_pos" should be zero. */
-       memset(file, 0, sizeof(*file));
        /* Only FMODE_64BITHASH or FMODE_32BITHASH should be set, NOT both. */
        if (attr & LUDA_64BITHASH)
                file->f_mode    = FMODE_64BITHASH;
@@ -4938,7 +4995,7 @@ static struct dt_it *osd_it_ea_init(const struct lu_env *env,
        set_file_inode(file, obj->oo_inode);
 
        lu_object_get(lo);
-       RETURN((struct dt_it *) it);
+       RETURN((struct dt_it *) oie);
 }
 
 /**
@@ -4948,18 +5005,19 @@ static struct dt_it *osd_it_ea_init(const struct lu_env *env,
  */
 static void osd_it_ea_fini(const struct lu_env *env, struct dt_it *di)
 {
-        struct osd_thread_info  *info  = osd_oti_get(env);
-        struct osd_it_ea       *it     = (struct osd_it_ea *)di;
-        struct osd_object      *obj    = it->oie_obj;
-        struct inode           *inode  = obj->oo_inode;
+       struct osd_thread_info  *info = osd_oti_get(env);
+       struct osd_it_ea        *oie    = (struct osd_it_ea *)di;
+       struct osd_object       *obj    = oie->oie_obj;
+       struct inode            *inode  = obj->oo_inode;
 
-        ENTRY;
-        it->oie_file.f_op->release(inode, &it->oie_file);
-        lu_object_put(env, &obj->oo_dt.do_lu);
-       if (it != &info->oti_it_ea)
-               OBD_FREE_PTR(it);
+       ENTRY;
+       oie->oie_file.f_op->release(inode, &oie->oie_file);
+       lu_object_put(env, &obj->oo_dt.do_lu);
+       if (unlikely(oie->oie_buf != info->oti_it_ea_buf))
+               OBD_FREE(oie->oie_buf, OSD_IT_EA_BUFSIZE);
        else
-               info->oti_it_inline = 0;
+               info->oti_it_ea_buf_used = 0;
+       OBD_SLAB_FREE_PTR(oie, osd_itea_cachep);
        EXIT;
 }
 
@@ -5210,7 +5268,7 @@ osd_dirent_update(handle_t *jh, struct super_block *sb,
 
        rec = (struct osd_fid_pack *)(de->name + de->name_len + 1);
        fid_cpu_to_be((struct lu_fid *)rec->fp_area, fid);
-       rc = ldiskfs_journal_dirty_metadata(jh, bh);
+       rc = ldiskfs_handle_dirty_metadata(jh, NULL, bh);
 
        RETURN(rc);
 }
@@ -5268,7 +5326,7 @@ osd_dirent_reinsert(const struct lu_env *env, handle_t *jh,
                fid_cpu_to_be((struct lu_fid *)rec->fp_area, fid);
                de->file_type |= LDISKFS_DIRENT_LUFID;
 
-               rc = ldiskfs_journal_dirty_metadata(jh, bh);
+               rc = ldiskfs_handle_dirty_metadata(jh, NULL, bh);
 
                RETURN(rc);
        }
@@ -5348,7 +5406,7 @@ osd_dirent_check_repair(const struct lu_env *env, struct osd_object *obj,
                  osd_dto_credits_noquota[DTO_INDEX_INSERT] + 1 + 1 + 2;
 
 again:
-       if (dev->od_dirent_journal) {
+       if (dev->od_dirent_journal != 0) {
                jh = osd_journal_start_sb(sb, LDISKFS_HT_MISC, credits);
                if (IS_ERR(jh)) {
                        rc = PTR_ERR(jh);
@@ -5424,7 +5482,7 @@ again:
                                GOTO(out_inode, rc = 0);
                        }
 
-                       if (!dev->od_dirent_journal) {
+                       if (dev->od_dirent_journal == 0) {
                                iput(inode);
                                brelse(bh);
                                if (hlock != NULL)
@@ -5456,7 +5514,7 @@ again:
                                GOTO(out_inode, rc = 0);
                        }
 
-                       if (!dev->od_dirent_journal) {
+                       if (dev->od_dirent_journal == 0) {
                                iput(inode);
                                brelse(bh);
                                if (hlock != NULL)
@@ -5495,7 +5553,7 @@ again:
                        GOTO(out_inode, rc = 0);
                }
 
-               if (!dev->od_dirent_journal) {
+               if (dev->od_dirent_journal == 0) {
                        iput(inode);
                        brelse(bh);
                        if (hlock != NULL)
@@ -5548,7 +5606,7 @@ out_journal:
        if (hlock != NULL) {
                ldiskfs_htree_unlock(hlock);
        } else {
-               if (dev->od_dirent_journal)
+               if (dev->od_dirent_journal != 0)
                        up_write(&obj->oo_ext_idx_sem);
                else
                        up_read(&obj->oo_ext_idx_sem);
@@ -6064,7 +6122,7 @@ static int osd_device_init0(const struct lu_env *env,
                o->od_is_ost = 1;
 
        o->od_full_scrub_ratio = OFSR_DEFAULT;
-       o->od_full_scrub_speed = FULL_SCRUB_SPEED_DEFULT;
+       o->od_full_scrub_threshold_rate = FULL_SCRUB_THRESHOLD_RATE_DEFAULT;
        rc = osd_mount(env, o, cfg);
        if (rc != 0)
                GOTO(out_capa, rc);
@@ -6082,9 +6140,6 @@ static int osd_device_init0(const struct lu_env *env,
        if (rc != 0)
                GOTO(out_site, rc);
 
-       /* self-repair LMA by default */
-       o->od_lma_self_repair = 1;
-
        INIT_LIST_HEAD(&o->od_ios_list);
        /* setup scrub, including OI files initialization */
        rc = osd_scrub_setup(env, o);
@@ -6275,10 +6330,12 @@ static int osd_obd_disconnect(struct obd_export *exp)
 }
 
 static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
-                       struct lu_device *dev)
+                      struct lu_device *dev)
 {
-       struct osd_device *osd = osd_dev(dev);
-       int                result = 0;
+       struct osd_device       *osd    = osd_dev(dev);
+       struct lr_server_data   *lsd    =
+                       &osd->od_dt_dev.dd_lu_dev.ld_site->ls_tgt->lut_lsd;
+       int                      result = 0;
        ENTRY;
 
        if (osd->od_quota_slave != NULL) {
@@ -6288,6 +6345,21 @@ static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
                        RETURN(result);
        }
 
+       if (lsd->lsd_feature_incompat & OBD_COMPAT_OST) {
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 52, 0)
+               if (lsd->lsd_feature_rocompat & OBD_ROCOMPAT_IDX_IN_IDIF) {
+                       osd->od_index_in_idif = 1;
+               } else {
+                       osd->od_index_in_idif = 0;
+                       result = osd_register_proc_index_in_idif(osd);
+                       if (result != 0)
+                               RETURN(result);
+               }
+#else
+               osd->od_index_in_idif = 1;
+#endif
+       }
+
        result = osd_fid_init(env, osd);
 
        RETURN(result);