Whamcloud - gitweb
LU-1866 osd: FID-in-LMA and OI files
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_handler.c
index b322eeb..8ce07f5 100644 (file)
@@ -370,13 +370,13 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj,
         * unexpected reason, we should be able to detect it later by calling
         * do_create->osd_oi_insert()
         */
         * unexpected reason, we should be able to detect it later by calling
         * do_create->osd_oi_insert()
         */
-       if (conf != NULL && (conf->loc_flags & LOC_F_NEW) != 0)
+       if (conf != NULL && conf->loc_flags & LOC_F_NEW)
                GOTO(out, result = 0);
 
        /* Search order: 3. OI files. */
        result = osd_oi_lookup(info, dev, fid, id, true);
        if (result == -ENOENT) {
                GOTO(out, result = 0);
 
        /* Search order: 3. OI files. */
        result = osd_oi_lookup(info, dev, fid, id, true);
        if (result == -ENOENT) {
-               if (!fid_is_norm(fid) ||
+               if (!fid_is_norm(fid) || fid_is_on_ost(info, dev, fid) ||
                    !ldiskfs_test_bit(osd_oi_fid2idx(dev,fid),
                                      sf->sf_oi_bitmap))
                        GOTO(out, result = 0);
                    !ldiskfs_test_bit(osd_oi_fid2idx(dev,fid),
                                      sf->sf_oi_bitmap))
                        GOTO(out, result = 0);
@@ -1628,6 +1628,31 @@ static int osd_attr_set(const struct lu_env *env,
 
        osd_trans_exec_op(env, handle, OSD_OT_ATTR_SET);
 
 
        osd_trans_exec_op(env, handle, OSD_OT_ATTR_SET);
 
+       if (OBD_FAIL_CHECK(OBD_FAIL_OSD_FID_MAPPING)) {
+               struct osd_thread_info  *oti  = osd_oti_get(env);
+               const struct lu_fid     *fid0 = lu_object_fid(&dt->do_lu);
+               struct lu_fid           *fid1 = &oti->oti_fid;
+               struct osd_inode_id     *id   = &oti->oti_id;
+               struct iam_path_descr   *ipd;
+               struct iam_container    *bag;
+               struct osd_thandle      *oh;
+               int                      rc;
+
+               fid_cpu_to_be(fid1, fid0);
+               memset(id, 1, sizeof(*id));
+               bag = &osd_fid2oi(osd_dev(dt->do_lu.lo_dev),
+                                 fid0)->oi_dir.od_container;
+               ipd = osd_idx_ipd_get(env, bag);
+               if (unlikely(ipd == NULL))
+                       RETURN(-ENOMEM);
+
+               oh = container_of0(handle, struct osd_thandle, ot_super);
+               rc = iam_update(oh->ot_handle, bag, (const struct iam_key *)fid1,
+                               (const struct iam_rec *)id, ipd);
+               osd_ipd_put(env, bag, ipd);
+               return(rc > 0 ? 0 : rc);
+       }
+
         inode = obj->oo_inode;
        ll_vfs_dq_init(inode);
 
         inode = obj->oo_inode;
        ll_vfs_dq_init(inode);
 
@@ -1999,16 +2024,13 @@ static int osd_declare_object_create(const struct lu_env *env,
 
        osd_trans_declare_op(env, oh, OSD_OT_CREATE,
                             osd_dto_credits_noquota[DTO_OBJECT_CREATE]);
 
        osd_trans_declare_op(env, oh, OSD_OT_CREATE,
                             osd_dto_credits_noquota[DTO_OBJECT_CREATE]);
-       /* XXX: So far, only normal fid needs be inserted into the oi,
-        *      things could be changed later. Revise following code then. */
-       if (fid_is_norm(lu_object_fid(&dt->do_lu)) &&
-           !fid_is_on_ost(osd_oti_get(env), osd_dt_dev(handle->th_dev),
-                          lu_object_fid(&dt->do_lu))) {
+       if (!fid_is_on_ost(osd_oti_get(env), osd_dt_dev(handle->th_dev),
+                          lu_object_fid(&dt->do_lu)))
                /* Reuse idle OI block may cause additional one OI block
                 * to be changed. */
                osd_trans_declare_op(env, oh, OSD_OT_INSERT,
                                osd_dto_credits_noquota[DTO_INDEX_INSERT] + 1);
                /* Reuse idle OI block may cause additional one OI block
                 * to be changed. */
                osd_trans_declare_op(env, oh, OSD_OT_INSERT,
                                osd_dto_credits_noquota[DTO_INDEX_INSERT] + 1);
-       }
+
        /* If this is directory, then we expect . and .. to be inserted as
         * well. The one directory block always needs to be created for the
         * directory, so we could use DTO_WRITE_BASE here (GDT, block bitmap,
        /* If this is directory, then we expect . and .. to be inserted as
         * well. The one directory block always needs to be created for the
         * directory, so we could use DTO_WRITE_BASE here (GDT, block bitmap,
@@ -2097,13 +2119,10 @@ static int osd_declare_object_destroy(const struct lu_env *env,
 
        osd_trans_declare_op(env, oh, OSD_OT_DELETE,
                             osd_dto_credits_noquota[DTO_OBJECT_DELETE]);
 
        osd_trans_declare_op(env, oh, OSD_OT_DELETE,
                             osd_dto_credits_noquota[DTO_OBJECT_DELETE]);
-       /* XXX: So far, only normal fid needs to be inserted into the OI,
-        *      so only normal fid needs to be removed from the OI also.
-        * Recycle idle OI leaf may cause additional three OI blocks
+       /* Recycle idle OI leaf may cause additional three OI blocks
         * to be changed. */
        osd_trans_declare_op(env, oh, OSD_OT_DESTROY,
         * to be changed. */
        osd_trans_declare_op(env, oh, OSD_OT_DESTROY,
-                            fid_is_norm(lu_object_fid(&dt->do_lu)) ?
-                            osd_dto_credits_noquota[DTO_INDEX_DELETE] + 3 : 0);
+                            osd_dto_credits_noquota[DTO_INDEX_DELETE] + 3);
 
        /* one less inode */
        rc = osd_declare_inode_qid(env, inode->i_uid, inode->i_gid, -1, oh,
 
        /* one less inode */
        rc = osd_declare_inode_qid(env, inode->i_uid, inode->i_gid, -1, oh,
@@ -2218,10 +2237,7 @@ int osd_ea_fid_set(struct osd_thread_info *info, struct inode *inode,
 void osd_get_ldiskfs_dirent_param(struct ldiskfs_dentry_param *param,
                                  const struct dt_rec *fid)
 {
 void osd_get_ldiskfs_dirent_param(struct ldiskfs_dentry_param *param,
                                  const struct dt_rec *fid)
 {
-       /* XXX: replace the check with "!fid_is_client_mdt_visible()"
-        *      when FID in OI file introduced for local object. */
-       if (!fid_is_norm((const struct lu_fid *)fid) &&
-           !fid_is_igif((const struct lu_fid *)fid)) {
+       if (!fid_is_client_mdt_visible((const struct lu_fid *)fid)) {
                param->edp_magic = 0;
                return;
        }
                param->edp_magic = 0;
                return;
        }
@@ -2232,8 +2248,7 @@ void osd_get_ldiskfs_dirent_param(struct ldiskfs_dentry_param *param,
 }
 
 /**
 }
 
 /**
- * Try to read the fid from inode ea into dt_rec, if return value
- * i.e. rc is +ve, then we got fid, otherwise we will have to form igif
+ * Try to read the fid from inode ea into dt_rec.
  *
  * \param fid object fid.
  *
  *
  * \param fid object fid.
  *
@@ -2386,10 +2401,9 @@ 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);
        osd_trans_declare_rb(env, th, OSD_OT_REF_ADD);
 
         result = __osd_object_create(info, obj, attr, hint, dof, th);
-        /* objects under osd root shld have igif fid, so dont add fid EA */
-       /* For ost object, the fid will be stored during first write */
-       if (result == 0 && fid_seq(fid) >= FID_SEQ_NORMAL &&
-           !fid_is_on_ost(info, osd_dt_dev(th->th_dev), fid))
+       if ((result == 0) &&
+           (fid_is_last_id(fid) ||
+            !fid_is_on_ost(info, osd_dt_dev(th->th_dev), fid)))
                result = osd_ea_fid_set(info, obj->oo_inode, fid);
 
         if (result == 0)
                result = osd_ea_fid_set(info, obj->oo_inode, fid);
 
         if (result == 0)
@@ -3647,7 +3661,8 @@ static int osd_ea_lookup_rec(const struct lu_env *env, struct osd_object *obj,
                oic->oic_lid = *id;
                oic->oic_fid = *fid;
                if ((scrub->os_pos_current <= ino) &&
                oic->oic_lid = *id;
                oic->oic_fid = *fid;
                if ((scrub->os_pos_current <= ino) &&
-                   (sf->sf_flags & SF_INCONSISTENT ||
+                   ((sf->sf_flags & SF_INCONSISTENT) ||
+                    (sf->sf_flags & SF_UPGRADE && fid_is_igif(fid)) ||
                     ldiskfs_test_bit(osd_oi_fid2idx(dev, fid),
                                      sf->sf_oi_bitmap)))
                        osd_consistency_check(oti, dev, oic);
                     ldiskfs_test_bit(osd_oi_fid2idx(dev, fid),
                                      sf->sf_oi_bitmap)))
                        osd_consistency_check(oti, dev, oic);
@@ -4478,7 +4493,8 @@ static inline int osd_it_ea_rec(const struct lu_env *env,
        oic->oic_lid = *id;
        oic->oic_fid = *fid;
        if ((scrub->os_pos_current <= ino) &&
        oic->oic_lid = *id;
        oic->oic_fid = *fid;
        if ((scrub->os_pos_current <= ino) &&
-           (sf->sf_flags & SF_INCONSISTENT ||
+           ((sf->sf_flags & SF_INCONSISTENT) ||
+            (sf->sf_flags & SF_UPGRADE && fid_is_igif(fid)) ||
             ldiskfs_test_bit(osd_oi_fid2idx(dev, fid), sf->sf_oi_bitmap)))
                osd_consistency_check(oti, dev, oic);
 
             ldiskfs_test_bit(osd_oi_fid2idx(dev, fid), sf->sf_oi_bitmap)))
                osd_consistency_check(oti, dev, oic);