#endif
struct osd_thread_info *oclb_info;
struct osd_device *oclb_dev;
- struct osd_idmap_cache *oclb_oic;
int oclb_items;
bool oclb_found;
};
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++;
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;
* 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;
#endif
.oclb_info = oti,
.oclb_dev = dev,
- .oclb_oic = oic,
.oclb_found = false,
};
int rc = 0;
out:
if (rc < 0)
- CDEBUG(D_LFSCK, "%s: fail to check LMV EA, inode = %lu/%u,"
- DFID": rc = %d\n", osd_ino2name(inode),
- inode->i_ino, inode->i_generation,
- PFID(&oic->oic_fid), rc);
+ CDEBUG(D_LFSCK,
+ "%s: cannot check LMV, ino = %lu/%u: rc = %d\n",
+ osd_ino2name(inode), inode->i_ino, inode->i_generation,
+ rc);
else
rc = 0;
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;
}
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:
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;
}
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)
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;
}
}
- 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.
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);
}
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;
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);
}
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);
}
* \retval 0, changed successfully
* \retval -ve, on error
*/
-static int osd_scrub_refresh_mapping(struct osd_thread_info *info,
- struct osd_device *dev,
- const struct lu_fid *fid,
- const struct osd_inode_id *id,
- int ops, bool force,
- enum oi_check_flags flags, bool *exist)
+int osd_scrub_refresh_mapping(struct osd_thread_info *info,
+ struct osd_device *dev,
+ const struct lu_fid *fid,
+ const struct osd_inode_id *id,
+ int ops, bool force,
+ enum oi_check_flags flags, bool *exist)
{
handle_t *th;
int rc;
#define SCRUB_BAD_OIMAP_DECAY_INTERVAL 60
-int osd_oii_insert(struct osd_device *dev, struct osd_idmap_cache *oic,
- int insert)
+int osd_oii_insert(struct osd_device *dev, const struct lu_fid *fid,
+ struct osd_inode_id *id, int insert)
{
struct osd_inconsistent_item *oii;
struct osd_scrub *oscrub = &dev->od_scrub;
RETURN(-ENOMEM);
INIT_LIST_HEAD(&oii->oii_list);
- oii->oii_cache = *oic;
+ oii->oii_cache.oic_fid = *fid;
+ oii->oii_cache.oic_lid = *id;
+ oii->oii_cache.oic_dev = dev;
oii->oii_insert = insert;
if (lscrub->os_partial_scan) {