Whamcloud - gitweb
LU-14734 osd-ldiskfs: enable large_dir automatically
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_handler.c
index 97fceb3..3b46322 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/osd/osd_handler.c
  *
@@ -933,7 +932,6 @@ struct osd_check_lmv_buf {
        struct dir_context ctx;
        struct osd_thread_info *oclb_info;
        struct osd_device *oclb_dev;
-       struct osd_idmap_cache *oclb_oic;
        int oclb_items;
        bool oclb_found;
 };
@@ -959,7 +957,6 @@ static int osd_stripe_dir_filldir(void *buf,
        struct lu_fid *fid = &oti->oti_fid3;
        struct osd_inode_id *id = &oti->oti_id3;
        struct osd_device *dev = oclb->oclb_dev;
-       struct osd_idmap_cache *oic = oclb->oclb_oic;
        struct inode *inode;
 
        oclb->oclb_items++;
@@ -982,10 +979,7 @@ static int osd_stripe_dir_filldir(void *buf,
 
        iput(inode);
        osd_add_oi_cache(oti, dev, id, fid);
-       oic->oic_fid = *fid;
-       oic->oic_lid = *id;
-       oic->oic_dev = dev;
-       osd_oii_insert(dev, oic, true);
+       osd_oii_insert(dev, fid, id, true);
        oclb->oclb_found = true;
 
        return 1;
@@ -1028,7 +1022,7 @@ static int osd_stripe_dir_filldir(void *buf,
  *    the correct OI mapping for the slave MDT-object.
  */
 static int osd_check_lmv(struct osd_thread_info *oti, struct osd_device *dev,
-                        struct inode *inode, struct osd_idmap_cache *oic)
+                        struct inode *inode)
 {
        struct lu_buf *buf = &oti->oti_big_buf;
        struct dentry *dentry = &oti->oti_obj_dentry;
@@ -1038,7 +1032,6 @@ static int osd_check_lmv(struct osd_thread_info *oti, struct osd_device *dev,
                .ctx.actor = osd_stripe_dir_filldir,
                .oclb_info = oti,
                .oclb_dev = dev,
-               .oclb_oic = oic,
                .oclb_found = false,
        };
        int rc = 0;
@@ -1092,9 +1085,9 @@ again:
 out:
        if (rc < 0)
                CDEBUG(D_LFSCK,
-                      "%s: cannot check LMV, ino = %lu/%u "DFID": rc = %d\n",
+                      "%s: cannot check LMV, ino = %lu/%u: rc = %d\n",
                       osd_ino2name(inode), inode->i_ino, inode->i_generation,
-                      PFID(&oic->oic_fid), rc);
+                      rc);
        else
                rc = 0;
 
@@ -1252,16 +1245,15 @@ trigger:
                if (scrub->os_partial_scan && !scrub->os_in_join)
                        goto join;
 
-               osd_add_oi_cache(info, dev, id, fid);
                if (IS_ERR_OR_NULL(inode) || result) {
-                       osd_oii_insert(dev, oic, result == -ENOENT);
+                       osd_oii_insert(dev, fid, id, result == -ENOENT);
                        GOTO(out, result = -EINPROGRESS);
                }
 
                LASSERT(remote);
                LASSERT(obj->oo_inode == inode);
 
-               osd_oii_insert(dev, oic, true);
+               osd_oii_insert(dev, fid, id, true);
                goto found;
        }
 
@@ -1278,21 +1270,21 @@ trigger:
 
 join:
        rc1 = osd_scrub_start(env, dev, flags);
-       LCONSOLE_WARN("%s: trigger OI scrub by RPC for the " DFID" with flags "
-                     "0x%x, rc = %d\n", osd_name(dev), PFID(fid), flags, rc1);
+       CDEBUG_LIMIT(D_LFSCK | D_CONSOLE | D_WARNING,
+                    "%s: trigger OI scrub by RPC for "DFID"/%u with flags %#x: rc = %d\n",
+                    osd_name(dev), PFID(fid), id->oii_ino, flags, rc1);
        if (rc1 && rc1 != -EALREADY)
                GOTO(out, result = -EREMCHG);
 
-       osd_add_oi_cache(info, dev, id, fid);
        if (IS_ERR_OR_NULL(inode) || result) {
-               osd_oii_insert(dev, oic, result == -ENOENT);
+               osd_oii_insert(dev, fid, id, result == -ENOENT);
                GOTO(out, result = -EINPROGRESS);
        }
 
        LASSERT(remote);
        LASSERT(obj->oo_inode == inode);
 
-       osd_oii_insert(dev, oic, true);
+       osd_oii_insert(dev, fid, id, true);
        goto found;
 
 check_lma:
@@ -1389,6 +1381,8 @@ check_lma:
 
        if (saved_ino == id->oii_ino && saved_gen == id->oii_gen) {
                result = -EREMCHG;
+               osd_scrub_refresh_mapping(info, dev, fid, id, DTO_INDEX_DELETE,
+                                         true, 0, NULL);
                goto trigger;
        }
 
@@ -1423,7 +1417,7 @@ found:
 
        if (S_ISDIR(inode->i_mode) &&
            (flags & SS_AUTO_PARTIAL || sf->sf_status == SS_SCANNING))
-               osd_check_lmv(info, dev, inode, oic);
+               osd_check_lmv(info, dev, inode);
 
        result = osd_attach_jinode(inode);
        if (result)
@@ -2092,7 +2086,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
                if (!rc)
                        rc = rc2;
 
-               osd_process_truncates(&truncates);
+               osd_process_truncates(env, &truncates);
        } else {
                osd_trans_stop_cb(oh, th->th_result);
                OBD_FREE_PTR(oh);
@@ -2429,13 +2423,12 @@ static void osd_conf_get(const struct lu_env *env,
                                        OBD_CKSUM_T10IP512 :
                                        OBD_CKSUM_T10IP4K;
                        } else {
-                               CERROR("%s: unsupported checksum type of "
-                                      "T10PI type '%s'",
+                               CERROR("%s: unsupported checksum type of T10PI type '%s'\n",
                                       d->od_svname, name);
                        }
 
                } else {
-                       CERROR("%s: unsupported T10PI type '%s'",
+                       CERROR("%s: unsupported T10PI type '%s'\n",
                               d->od_svname, name);
                }
        }
@@ -3442,7 +3435,6 @@ static osd_obj_type_f osd_create_type_f(enum dt_format_type type)
        return result;
 }
 
-
 static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah,
                        struct dt_object *parent, struct dt_object *child,
                        umode_t child_mode)
@@ -3621,6 +3613,8 @@ static int osd_declare_create(const struct lu_env *env, struct dt_object *dt,
                              struct thandle *handle)
 {
        struct osd_thandle *oh;
+       struct super_block *sb = osd_sb(osd_dev(dt->do_lu.lo_dev));
+       int credits;
        int rc;
 
        ENTRY;
@@ -3635,10 +3629,23 @@ static int osd_declare_create(const struct lu_env *env, struct dt_object *dt,
         * vs. osd_mkreg: osd_mk_index will create 2 blocks for root_node and
         * leaf_node, could involves the block, block bitmap, groups, GDT
         * change for each block, so add 4 * 2 credits in that case.
+        *
+        * The default ACL initialization may consume an additional 16 blocks
+        */
+       credits = osd_dto_credits_noquota[DTO_OBJECT_CREATE] +
+                 ((dof->dof_type == DFT_INDEX) ? 4 * 2 : 0);
+
+       /**
+        * While ldiskfs_new_inode() calls ldiskfs_init_acl() we have to add
+        * credits for possible default ACL creation in new inode
         */
-       osd_trans_declare_op(env, oh, OSD_OT_CREATE,
-                            osd_dto_credits_noquota[DTO_OBJECT_CREATE] +
-                            (dof->dof_type == DFT_INDEX) ? 4 * 2 : 0);
+       if (hint && hint->dah_acl_len)
+               credits += osd_calc_bkmap_credits(sb, NULL, 0, -1,
+                               (hint->dah_acl_len + sb->s_blocksize - 1) >>
+                               sb->s_blocksize_bits);
+
+       osd_trans_declare_op(env, oh, OSD_OT_CREATE, credits);
+
        /*
         * Reuse idle OI block may cause additional one OI block
         * to be changed.
@@ -4624,8 +4631,8 @@ static int osd_xattr_set_pfid(const struct lu_env *env, struct osd_object *obj,
                dquot_initialize(inode);
                rc = ll_vfs_removexattr(dentry, inode, XATTR_NAME_FID);
                if (rc == -ENODATA) {
-                       if ((fl & LU_XATTR_REPLACE) && !(fl & LU_XATTR_CREATE))
-                               RETURN(rc);
+                       /* XATTR_NAME_FID is already absent */
+                       rc = 0;
                } else if (rc) {
                        RETURN(rc);
                }
@@ -5771,11 +5778,9 @@ static int osd_ea_add_rec(const struct lu_env *env, struct osd_object *pobj,
 
 static int
 osd_consistency_check(struct osd_thread_info *oti, struct osd_device *dev,
-                     struct osd_idmap_cache *oic)
+                     const struct lu_fid *fid, struct osd_inode_id *id)
 {
        struct lustre_scrub *scrub = &dev->od_scrub.os_scrub;
-       struct lu_fid *fid = &oic->oic_fid;
-       struct osd_inode_id *id = &oic->oic_lid;
        struct inode *inode = NULL;
        int once = 0;
        bool insert;
@@ -5838,7 +5843,7 @@ trigger:
                        }
                }
 
-               rc = osd_oii_insert(dev, oic, insert);
+               rc = osd_oii_insert(dev, fid, id, insert);
                /*
                 * There is race condition between osd_oi_lookup and OI scrub.
                 * The OI scrub finished just after osd_oi_lookup() failure.
@@ -5851,7 +5856,7 @@ trigger:
                if (!S_ISDIR(inode->i_mode))
                        rc = 0;
                else
-                       rc = osd_check_lmv(oti, dev, inode, oic);
+                       rc = osd_check_lmv(oti, dev, inode);
 
                GOTO(out, rc);
        }
@@ -5859,9 +5864,9 @@ trigger:
        if (dev->od_auto_scrub_interval != AS_NEVER && ++once == 1) {
                rc = osd_scrub_start(oti->oti_env, dev, SS_AUTO_PARTIAL |
                                     SS_CLEAR_DRYRUN | SS_CLEAR_FAILOUT);
-               CDEBUG(D_LFSCK | D_CONSOLE | D_WARNING,
-                      "%s: trigger partial OI scrub for RPC inconsistency checking FID "DFID": rc = %d\n",
-                      osd_dev2name(dev), PFID(fid), rc);
+               CDEBUG_LIMIT(D_LFSCK | D_CONSOLE | D_WARNING,
+                            "%s: trigger partial OI scrub for RPC inconsistency, checking FID "DFID"/%u: rc = %d\n",
+                            osd_dev2name(dev), PFID(fid), id->oii_ino, rc);
                if (rc == 0 || rc == -EALREADY)
                        goto again;
        }
@@ -5869,18 +5874,17 @@ trigger:
        GOTO(out, rc);
 
 out:
-       if (inode)
-               iput(inode);
+       iput(inode);
 
        RETURN(rc);
 }
 
 static int osd_fail_fid_lookup(struct osd_thread_info *oti,
                               struct osd_device *dev,
-                              struct osd_idmap_cache *oic,
                               struct lu_fid *fid, __u32 ino)
 {
        struct lustre_ost_attrs *loa = &oti->oti_ost_attrs;
+       struct osd_idmap_cache *oic = &oti->oti_cache;
        struct inode *inode;
        int rc;
 
@@ -6071,13 +6075,12 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
        if (!IS_ERR(bh)) {
                struct osd_thread_info *oti = osd_oti_get(env);
                struct osd_inode_id *id = &oti->oti_id;
-               struct osd_idmap_cache *oic = &oti->oti_cache;
                struct osd_device *dev = osd_obj2dev(obj);
 
                ino = le32_to_cpu(de->inode);
                if (OBD_FAIL_CHECK(OBD_FAIL_FID_LOOKUP)) {
                        brelse(bh);
-                       rc = osd_fail_fid_lookup(oti, dev, oic, fid, ino);
+                       rc = osd_fail_fid_lookup(oti, dev, fid, ino);
                        GOTO(out, rc);
                }
 
@@ -6105,19 +6108,24 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
                        osd_id_gen(id, ino, OSD_OII_NOGEN);
                }
 
-               if (rc != 0 || osd_remote_fid(env, dev, fid)) {
-                       fid_zero(&oic->oic_fid);
-
+               if (rc != 0 || osd_remote_fid(env, dev, fid))
                        GOTO(out, rc);
-               }
 
-               osd_add_oi_cache(osd_oti_get(env), osd_obj2dev(obj), id, fid);
-               rc = osd_consistency_check(oti, dev, oic);
-               if (rc == -ENOENT)
-                       fid_zero(&oic->oic_fid);
-               else
+               rc = osd_consistency_check(oti, dev, fid, id);
+               if (rc != -ENOENT) {
                        /* Other error should not affect lookup result. */
                        rc = 0;
+
+                       /* Normal file mapping should be added into OI cache
+                        * after FID in LMA check, but for local files like
+                        * hsm_actions, their FIDs are not stored in OI files,
+                        * see osd_initial_OI_scrub(), and here is the only
+                        * place to load mapping into OI cache.
+                        */
+                       if (!fid_is_namespace_visible(fid))
+                               osd_add_oi_cache(osd_oti_get(env),
+                                                osd_obj2dev(obj), id, fid);
+               }
        } else {
                rc = PTR_ERR(bh);
        }
@@ -6594,36 +6602,23 @@ static const struct dt_index_operations osd_index_iam_ops = {
        }
 };
 
-
-/**
- * Creates or initializes iterator context.
- *
- * \retval struct osd_it_ea, iterator structure on success
- *
- */
-static struct dt_it *osd_it_ea_init(const struct lu_env *env,
-                                   struct dt_object *dt,
-                                   __u32 attr)
+struct osd_it_ea *osd_it_dir_init(const struct lu_env *env,
+                                 struct inode *inode, __u32 attr)
 {
-       struct osd_object *obj = osd_dt_obj(dt);
        struct osd_thread_info *info = osd_oti_get(env);
        struct osd_it_ea *oie;
        struct file *file;
-       struct lu_object *lo = &dt->do_lu;
        struct dentry *obj_dentry;
 
        ENTRY;
 
-       if (!dt_object_exists(dt) || obj->oo_destroyed)
-               RETURN(ERR_PTR(-ENOENT));
-
        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_inode = inode;
+       obj_dentry->d_sb = inode->i_sb;
        obj_dentry->d_name.hash = 0;
 
        oie->oie_rd_dirent       = 0;
@@ -6637,7 +6632,7 @@ static struct dt_it *osd_it_ea_init(const struct lu_env *env,
                if (oie->oie_buf == NULL)
                        RETURN(ERR_PTR(-ENOMEM));
        }
-       oie->oie_obj = obj;
+       oie->oie_obj = NULL;
 
        file = &oie->oie_file;
 
@@ -6647,14 +6642,56 @@ static struct dt_it *osd_it_ea_init(const struct lu_env *env,
        else
                file->f_mode    = FMODE_32BITHASH;
        file->f_path.dentry     = obj_dentry;
-       file->f_mapping         = obj->oo_inode->i_mapping;
-       file->f_op              = obj->oo_inode->i_fop;
-       file->f_inode = obj->oo_inode;
+       file->f_mapping         = inode->i_mapping;
+       file->f_op              = inode->i_fop;
+       file->f_inode = inode;
+
+       RETURN(oie);
+}
+
+/**
+ * Creates or initializes iterator context.
+ *
+ * \retval struct osd_it_ea, iterator structure on success
+ *
+ */
+static struct dt_it *osd_it_ea_init(const struct lu_env *env,
+                                   struct dt_object *dt,
+                                   __u32 attr)
+{
+       struct osd_object *obj = osd_dt_obj(dt);
+       struct lu_object *lo = &dt->do_lu;
+       struct osd_it_ea *oie;
+
+       ENTRY;
+
+       if (!dt_object_exists(dt) || obj->oo_destroyed)
+               RETURN(ERR_PTR(-ENOENT));
 
+       oie = osd_it_dir_init(env, obj->oo_inode, attr);
+       if (IS_ERR(oie))
+               RETURN((struct dt_it *)oie);
+
+       oie->oie_obj = obj;
        lu_object_get(lo);
        RETURN((struct dt_it *)oie);
 }
 
+void osd_it_dir_fini(const struct lu_env *env, struct osd_it_ea *oie,
+                    struct inode *inode)
+{
+       struct osd_thread_info *info = osd_oti_get(env);
+
+       ENTRY;
+       oie->oie_file.f_op->release(inode, &oie->oie_file);
+       if (unlikely(oie->oie_buf != info->oti_it_ea_buf))
+               OBD_FREE(oie->oie_buf, OSD_IT_EA_BUFSIZE);
+       else
+               info->oti_it_ea_buf_used = 0;
+       OBD_SLAB_FREE_PTR(oie, osd_itea_cachep);
+       EXIT;
+}
+
 /**
  * Destroy or finishes iterator context.
  *
@@ -6662,19 +6699,13 @@ 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 *oie = (struct osd_it_ea *)di;
        struct osd_object *obj = oie->oie_obj;
        struct inode *inode = obj->oo_inode;
 
        ENTRY;
-       oie->oie_file.f_op->release(inode, &oie->oie_file);
+       osd_it_dir_fini(env, (struct osd_it_ea *)di, inode);
        osd_object_put(env, obj);
-       if (unlikely(oie->oie_buf != info->oti_it_ea_buf))
-               OBD_FREE(oie->oie_buf, OSD_IT_EA_BUFSIZE);
-       else
-               info->oti_it_ea_buf_used = 0;
-       OBD_SLAB_FREE_PTR(oie, osd_itea_cachep);
        EXIT;
 }
 
@@ -6753,7 +6784,8 @@ static int osd_ldiskfs_filldir(void *buf,
 
        /* "." is just the object itself. */
        if (namelen == 1 && name[0] == '.') {
-               *fid = obj->oo_dt.do_lu.lo_header->loh_fid;
+               if (obj != NULL)
+                       *fid = obj->oo_dt.do_lu.lo_header->loh_fid;
        } else if (d_type & LDISKFS_DIRENT_LUFID) {
                rec = (struct osd_fid_pack *)(name + namelen + 1);
                if (osd_fid_unpack(fid, rec) != 0)
@@ -6764,7 +6796,8 @@ static int osd_ldiskfs_filldir(void *buf,
        d_type &= ~LDISKFS_DIRENT_LUFID;
 
        /* NOT export local root. */
-       if (unlikely(osd_sb(osd_obj2dev(obj))->s_root->d_inode->i_ino == ino)) {
+       if (obj != NULL &&
+           unlikely(osd_sb(osd_obj2dev(obj))->s_root->d_inode->i_ino == ino)) {
                ino = obj->oo_inode->i_ino;
                *fid = obj->oo_dt.do_lu.lo_header->loh_fid;
        }
@@ -6791,12 +6824,10 @@ static int osd_ldiskfs_filldir(void *buf,
  * \retval -ve on error
  * \retval +1 reach the end of entry
  */
-static int osd_ldiskfs_it_fill(const struct lu_env *env,
-                              const struct dt_it *di)
+int osd_ldiskfs_it_fill(const struct lu_env *env, const struct dt_it *di)
 {
        struct osd_it_ea *it = (struct osd_it_ea *)di;
        struct osd_object *obj = it->oie_obj;
-       struct inode *inode = obj->oo_inode;
        struct htree_lock *hlock = NULL;
        struct file *filp = &it->oie_file;
        int rc = 0;
@@ -6809,12 +6840,15 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env,
        it->oie_dirent = it->oie_buf;
        it->oie_rd_dirent = 0;
 
-       if (obj->oo_hl_head != NULL) {
-               hlock = osd_oti_get(env)->oti_hlock;
-               ldiskfs_htree_lock(hlock, obj->oo_hl_head,
-                                  inode, LDISKFS_HLOCK_READDIR);
-       } else {
-               down_read(&obj->oo_ext_idx_sem);
+       if (obj) {
+               if (obj->oo_hl_head != NULL) {
+                       hlock = osd_oti_get(env)->oti_hlock;
+                       ldiskfs_htree_lock(hlock, obj->oo_hl_head,
+                                          obj->oo_inode,
+                                          LDISKFS_HLOCK_READDIR);
+               } else {
+                       down_read(&obj->oo_ext_idx_sem);
+               }
        }
 
        filp->f_cred = current_cred();
@@ -6841,10 +6875,12 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env,
                it->oie_it_dirent = 1;
        }
 unlock:
-       if (hlock != NULL)
-               ldiskfs_htree_unlock(hlock);
-       else
-               up_read(&obj->oo_ext_idx_sem);
+       if (obj) {
+               if (hlock != NULL)
+                       ldiskfs_htree_unlock(hlock);
+               else
+                       up_read(&obj->oo_ext_idx_sem);
+       }
 
        RETURN(rc);
 }
@@ -7720,6 +7756,20 @@ static void osd_umount(const struct lu_env *env, struct osd_device *o)
        EXIT;
 }
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 53, 0)
+# ifndef LDISKFS_HAS_INCOMPAT_FEATURE
+/* Newer kernels provide the ldiskfs_set_feature_largedir() wrapper already,
+ * which calls ldiskfs_update_dynamic_rev() to update ancient filesystems.
+ * All ldiskfs filesystems are already v2, so it is a no-op and unnecessary.
+ * This avoids maintaining patches to export this otherwise-useless function.
+ */
+void ldiskfs_update_dynamic_rev(struct super_block *sb)
+{
+       /* do nothing */
+}
+# endif
+#endif
+
 static int osd_mount(const struct lu_env *env,
                     struct osd_device *o, struct lustre_cfg *cfg)
 {
@@ -7797,6 +7847,7 @@ static int osd_mount(const struct lu_env *env,
                        "force_over_256tb",
                        "force_over_512tb",
                        "force_over_1024tb",
+                       "resetoi",
                        NULL
                };
                strncat(options, opts, PAGE_SIZE);
@@ -7852,7 +7903,7 @@ static int osd_mount(const struct lu_env *env,
        }
 
        if (lmd_flags & LMD_FLG_DEV_RDONLY) {
-               LCONSOLE_WARN("%s: not support dev_rdonly on this device",
+               LCONSOLE_WARN("%s: not support dev_rdonly on this device\n",
                              name);
 
                GOTO(out_mnt, rc = -EOPNOTSUPP);
@@ -7863,6 +7914,7 @@ static int osd_mount(const struct lu_env *env,
                GOTO(out_mnt, rc = -EINVAL);
        }
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 53, 0)
 #ifdef LDISKFS_MOUNT_DIRDATA
        if (ldiskfs_has_feature_dirdata(o->od_mnt->mnt_sb))
                LDISKFS_SB(osd_sb(o))->s_mount_opt |= LDISKFS_MOUNT_DIRDATA;
@@ -7872,6 +7924,15 @@ static int osd_mount(const struct lu_env *env,
                      "downgrade to Lustre-1.x again, you can enable it via "
                      "'tune2fs -O dirdata device'\n", name, dev);
 #endif
+       /* enable large_dir on MDTs to avoid REMOTE_PARENT_DIR overflow,
+        * and on very large OSTs to avoid object directory overflow */
+       if (unlikely(!ldiskfs_has_feature_largedir(o->od_mnt->mnt_sb) &&
+                    !strstr(name, "MGS"))) {
+               ldiskfs_set_feature_largedir(o->od_mnt->mnt_sb);
+               LCONSOLE_INFO("%s: enable 'large_dir' feature on device '%s'\n",
+                             name, dev);
+       }
+#endif
        inode = osd_sb(o)->s_root->d_inode;
        lu_local_obj_fid(fid, OSD_FS_ROOT_OID);
        rc = osd_ea_fid_set(info, inode, fid, LMAC_NOT_IN_OI, 0);
@@ -7928,8 +7989,10 @@ static int osd_device_init0(const struct lu_env *env,
 {
        struct lu_device *l = osd2lu_dev(o);
        struct osd_thread_info *info;
-       int rc;
        int cplen = 0;
+       char *opts = NULL;
+       bool restored = false;
+       int rc;
 
        /* if the module was re-loaded, env can loose its keys */
        rc = lu_env_refill((struct lu_env *)env);
@@ -7996,10 +8059,14 @@ static int osd_device_init0(const struct lu_env *env,
        if (rc != 0)
                GOTO(out_site, rc);
 
+       opts = lustre_cfg_string(cfg, 3);
+       if (opts && strstr(opts, "resetoi"))
+               restored = true;
+
        INIT_LIST_HEAD(&o->od_ios_list);
        /* setup scrub, including OI files initialization */
        o->od_in_init = 1;
-       rc = osd_scrub_setup(env, o);
+       rc = osd_scrub_setup(env, o, restored);
        o->od_in_init = 0;
        if (rc < 0)
                GOTO(out_site, rc);
@@ -8391,7 +8458,7 @@ static int __init osd_init(void)
 
 #ifdef CONFIG_KALLSYMS
        priv_security_file_alloc =
-               (void *)kallsyms_lookup_name("security_file_alloc");
+               (void *)cfs_kallsyms_lookup_name("security_file_alloc");
 #endif
 
        rc = class_register_type(&osd_obd_device_ops, NULL, true,