};
struct lfsck_layout_object {
- struct dt_object *llo_obj;
struct lu_attr llo_attr;
atomic_t llo_ref;
__u64 llo_cookie;
return ERR_PTR(rc);
}
- lu_object_get(&obj->do_lu);
- llo->llo_obj = obj;
llo->llo_cookie = cookie;
/* The gen can be used to check whether some others have changed the
* file layout after LFSCK pre-fetching but before real verification. */
static inline void lfsck_layout_object_put(const struct lu_env *env,
struct lfsck_layout_object *llo)
{
- if (atomic_dec_and_test(&llo->llo_ref)) {
- lfsck_object_put(env, llo->llo_obj);
+ if (atomic_dec_and_test(&llo->llo_ref))
OBD_FREE_PTR(llo);
- }
}
static struct lfsck_layout_req *
lfsck_layout_assistant_req_init(struct lfsck_layout_object *parent,
+ const struct lu_fid *pfid,
struct dt_object *child, __u32 ost_idx,
__u32 lov_idx)
{
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&llr->llr_lar.lar_list);
+ llr->llr_lar.lar_fid = *pfid;
+
atomic_inc(&parent->llo_ref);
llr->llr_parent = parent;
llr->llr_child = child;
* 2) Re-create the missing OST-object with the FID/owner information. */
static int lfsck_layout_repair_dangling(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *parent,
struct lfsck_layout_req *llr,
const struct lu_attr *pla)
{
struct filter_fid *pfid = &info->lti_new_pfid;
struct dt_allocation_hint *hint = &info->lti_hint;
struct lu_attr *cla = &info->lti_la2;
- struct dt_object *parent = llr->llr_parent->llo_obj;
struct dt_object *child = llr->llr_child;
struct dt_device *dev = lfsck_obj2dt_dev(child);
const struct lu_fid *tfid = lu_object_fid(&parent->do_lu);
* given MDT-object as its parent. So update the OST-object filter_fid. */
static int lfsck_layout_repair_unmatched_pair(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *parent,
struct lfsck_layout_req *llr,
const struct lu_attr *pla)
{
struct lfsck_thread_info *info = lfsck_env_info(env);
struct filter_fid *pfid = &info->lti_new_pfid;
struct lu_attr *tla = &info->lti_la3;
- struct dt_object *parent = llr->llr_parent->llo_obj;
struct dt_object *child = llr->llr_child;
struct dt_device *dev = lfsck_obj2dt_dev(child);
const struct lu_fid *tfid = lu_object_fid(&parent->do_lu);
* new OST-object(s) with new fid(s) for the non-recognized MDT-object(s). */
static int lfsck_layout_repair_multiple_references(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *parent,
struct lfsck_layout_req *llr,
struct lu_attr *la,
struct lu_buf *buf)
struct dt_object_format *dof = &info->lti_dof;
struct dt_device *pdev = com->lc_lfsck->li_next;
struct ost_id *oi = &info->lti_oi;
- struct dt_object *parent = llr->llr_parent->llo_obj;
struct dt_device *cdev = lfsck_obj2dt_dev(llr->llr_child);
struct dt_object *child = NULL;
struct lu_device *d = &cdev->dd_lu_dev;
* is partly done. */
static int lfsck_layout_repair_owner(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *parent,
struct lfsck_layout_req *llr,
struct lu_attr *pla)
{
struct lfsck_thread_info *info = lfsck_env_info(env);
struct lu_attr *tla = &info->lti_la3;
- struct dt_object *parent = llr->llr_parent->llo_obj;
struct dt_object *child = llr->llr_child;
struct dt_device *dev = lfsck_obj2dt_dev(child);
struct thandle *handle;
struct filter_fid_old *pea = &info->lti_old_pfid;
struct lu_fid *pfid = &info->lti_fid;
struct lu_buf buf = { NULL };
- struct dt_object *parent = llr->llr_parent->llo_obj;
+ struct dt_object *parent;
struct dt_object *child = llr->llr_child;
struct lu_attr *pla = &info->lti_la;
struct lu_attr *cla = &info->lti_la2;
int rc;
ENTRY;
+ parent = lfsck_object_find(env, lfsck, &lar->lar_fid);
+ if (IS_ERR(parent))
+ RETURN(PTR_ERR(parent));
+
if (unlikely(lfsck_is_dead_obj(parent)))
- RETURN(0);
+ GOTO(put_parent, rc = 0);
rc = dt_attr_get(env, parent, pla, BYPASS_CAPA);
if (rc != 0)
rc = dt_attr_get(env, child, cla, BYPASS_CAPA);
if (rc == -ENOENT) {
if (unlikely(lfsck_is_dead_obj(parent)))
- RETURN(0);
+ GOTO(put_parent, rc = 0);
type = LLIT_DANGLING;
goto repair;
switch (type) {
case LLIT_DANGLING:
- rc = lfsck_layout_repair_dangling(env, com, llr, pla);
+ rc = lfsck_layout_repair_dangling(env, com, parent, llr, pla);
break;
case LLIT_UNMATCHED_PAIR:
- rc = lfsck_layout_repair_unmatched_pair(env, com, llr, pla);
+ rc = lfsck_layout_repair_unmatched_pair(env, com, parent,
+ llr, pla);
break;
case LLIT_MULTIPLE_REFERENCED:
- rc = lfsck_layout_repair_multiple_references(env, com, llr,
- pla, &buf);
+ rc = lfsck_layout_repair_multiple_references(env, com, parent,
+ llr, pla, &buf);
break;
case LLIT_INCONSISTENT_OWNER:
- rc = lfsck_layout_repair_owner(env, com, llr, pla);
+ rc = lfsck_layout_repair_owner(env, com, parent, llr, pla);
break;
default:
rc = 0;
}
up_write(&com->lc_sem);
+put_parent:
+ lu_object_put(env, &parent->do_lu);
+
return rc;
}
}
}
- llr = lfsck_layout_assistant_req_init(llo, cobj, index, i);
+ llr = lfsck_layout_assistant_req_init(llo,
+ lfsck_dto2fid(parent),
+ cobj, index, i);
if (IS_ERR(llr)) {
rc = PTR_ERR(llr);
goto next;
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&lnr->lnr_lar.lar_list);
- lnr->lnr_obj = lfsck_object_get(lfsck->li_obj_dir);
+ lnr->lnr_lar.lar_fid = *lfsck_dto2fid(lfsck->li_obj_dir);
lnr->lnr_lmv = lfsck_lmv_get(lfsck->li_lmv);
lnr->lnr_fid = ent->lde_fid;
lnr->lnr_oit_cookie = lfsck->li_pos_current.lp_oit_cookie;
if (lnr->lnr_lmv != NULL)
lfsck_lmv_put(env, lnr->lnr_lmv);
- lu_object_put(env, &lnr->lnr_obj->do_lu);
OBD_FREE(lnr, lnr->lnr_size);
}
/* Generate a dummy request to indicate that all shards' name entry
* in this striped directory has been scanned for the first time. */
INIT_LIST_HEAD(&lnr->lnr_lar.lar_list);
- lnr->lnr_obj = lfsck_object_get(lfsck->li_obj_dir);
+ lnr->lnr_lar.lar_fid = *lfsck_dto2fid(lfsck->li_obj_dir);
lnr->lnr_lmv = lfsck_lmv_get(llmv);
lnr->lnr_fid = *lfsck_dto2fid(lfsck->li_obj_dir);
lnr->lnr_oit_cookie = lfsck->li_pos_current.lp_oit_cookie;
*
* \param[in] env pointer to the thread context
* \param[in] com pointer to the lfsck component
+ * \param[in] parent pointer to the dir object that contains the dangling
+ * name entry
* \param[in] child pointer to the object corresponding to the dangling
* name entry
* \param[in] lnr pointer to the namespace request that contains the
*/
int lfsck_namespace_repair_dangling(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *parent,
struct dt_object *child,
struct lfsck_namespace_req *lnr)
{
struct dt_object_format *dof = &info->lti_dof;
struct dt_insert_rec *rec = &info->lti_dt_rec;
struct lmv_mds_md_v1 *lmv2 = &info->lti_lmv2;
- struct dt_object *parent = lnr->lnr_obj;
const struct lu_name *cname;
struct linkea_data ldata = { NULL };
struct lustre_handle lh = { 0 };
struct thandle *handle = NULL;
struct lfsck_namespace_req *lnr =
container_of0(lar, struct lfsck_namespace_req, lnr_lar);
- struct dt_object *dir = lnr->lnr_obj;
+ struct dt_object *dir = NULL;
struct dt_object *obj = NULL;
- const struct lu_fid *pfid = lfsck_dto2fid(dir);
+ const struct lu_fid *pfid;
struct dt_device *dev = NULL;
struct lustre_handle lh = { 0 };
bool repaired = false;
enum lfsck_namespace_inconsistency_type type = LNIT_NONE;
ENTRY;
+ dir = lfsck_object_find_bottom(env, lfsck, &lar->lar_fid);
+ if (IS_ERR(dir))
+ RETURN(PTR_ERR(dir));
+
+ if (unlikely(lfsck_is_dead_obj(dir)))
+ GOTO(put_dir, rc = 0);
+
+ pfid = lfsck_dto2fid(dir);
la->la_nlink = 0;
if (lnr->lnr_attr & LUDA_UPGRADE) {
ns->ln_flags |= LF_UPGRADE;
}
if (unlikely(lnr->lnr_dir_cookie == MDS_DIR_END_OFF)) {
- rc = lfsck_namespace_striped_dir_rescan(env, com, lnr);
+ rc = lfsck_namespace_striped_dir_rescan(env, com, dir, lnr);
- RETURN(rc);
+ GOTO(put_dir, rc);
}
if (lnr->lnr_name[0] == '.' &&
GOTO(out, rc = 0);
if (lnr->lnr_lmv != NULL && lnr->lnr_lmv->ll_lmv_master) {
- rc = lfsck_namespace_handle_striped_master(env, com, lnr);
+ rc = lfsck_namespace_handle_striped_master(env, com, dir, lnr);
- RETURN(rc);
+ GOTO(put_dir, rc);
}
idx = lfsck_find_mdt_idx_by_fid(env, lfsck, &lnr->lnr_fid);
if (unlikely(strcmp(lnr->lnr_name, dotdot) == 0))
GOTO(out, rc = 0);
- dev = lfsck->li_next;
+ dev = lfsck->li_bottom;
} else {
struct lfsck_tgt_desc *ltd;
}
type = LNIT_DANGLING;
- rc = lfsck_namespace_repair_dangling(env, com,
+ rc = lfsck_namespace_repair_dangling(env, com, dir,
obj, lnr);
if (rc == 0)
repaired = true;
CDEBUG(D_LFSCK, "%s: namespace LFSCK assistant fail to handle "
"the entry: "DFID", parent "DFID", name %.*s: rc = %d\n",
lfsck_lfsck2name(lfsck), PFID(&lnr->lnr_fid),
- PFID(lfsck_dto2fid(lnr->lnr_obj)),
+ PFID(lfsck_dto2fid(dir)),
lnr->lnr_namelen, lnr->lnr_name, rc);
lfsck_namespace_record_failure(env, lfsck, ns);
"repaired the entry: "DFID", parent "DFID
", name %.*s\n", lfsck_lfsck2name(lfsck),
PFID(&lnr->lnr_fid),
- PFID(lfsck_dto2fid(lnr->lnr_obj)),
+ PFID(lfsck_dto2fid(dir)),
lnr->lnr_namelen, lnr->lnr_name);
if (repaired) {
if (obj != NULL && !IS_ERR(obj))
lfsck_object_put(env, obj);
+put_dir:
+ lu_object_put(env, &dir->do_lu);
+
return rc;
}
lnr_lar.lar_list);
pos->lp_oit_cookie = lnr->lnr_oit_cookie;
pos->lp_dir_cookie = lnr->lnr_dir_cookie - 1;
- pos->lp_dir_parent = *lfsck_dto2fid(lnr->lnr_obj);
+ pos->lp_dir_parent = lnr->lnr_lar.lar_fid;
}
static int lfsck_namespace_double_scan_result(const struct lu_env *env,
*
* \param[in] env pointer to the thread context
* \param[in] com pointer to the lfsck component
+ * \param[in] obj pointer to the striped directory to be handled
* \param[in] lnr pointer to the namespace request that contains the
* striped directory to be handled and other information
*
*/
static int lfsck_remove_lmv(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *obj,
struct lfsck_namespace_req *lnr)
{
- struct dt_object *obj = lnr->lnr_obj;
struct lustre_handle lh = { 0 };
int rc;
*
* \param[in] env pointer to the thread context
* \param[in] com pointer to the lfsck component
+ * \param[in] dir pointer to the striped directory to be handled
* \param[in] lslr pointer to lfsck_disable_master_lmv slot which content
* will be replaced by the given information
* \param[in] lnr contain the shard's FID to be used to fill the
*/
static int lfsck_replace_lmv(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *dir,
struct lfsck_slave_lmv_rec *lslr,
struct lfsck_namespace_req *lnr,
struct lmv_mds_md_v1 *lmv,
struct lfsck_lmv *llmv = lnr->lnr_lmv;
int rc;
- rc = lfsck_remove_dirent(env, com, lnr->lnr_obj,
+ rc = lfsck_remove_dirent(env, com, dir,
&lslr->lslr_fid, index);
if (rc < 0)
return rc;
*
* \param[in] env pointer to the thread context
* \param[in] com pointer to the lfsck component
+ * \param[in] dir pointer to the striped directory to be handled
* \param[in] lnr contain the shard's FID to fill the @lslr slot,
* it also records the known max filled index and
* the known max stripe count
*/
static int lfsck_record_lmv(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *dir,
struct lfsck_namespace_req *lnr,
struct lmv_mds_md_v1 *lmv, __u32 shard_idx,
__u32 flags, __u32 flags2, __u32 *depth)
{
struct lfsck_instance *lfsck = com->lc_lfsck;
struct lfsck_lmv *llmv = lnr->lnr_lmv;
- struct dt_object *dir = lnr->lnr_obj;
const struct lu_fid *fid = &lnr->lnr_fid;
struct lfsck_slave_lmv_rec *lslr;
struct lfsck_rec_lmv_save *lrls;
* mark the master MDT-object as read-only. The
* administrator can handle the conflict with
* more human knowledge. */
- rc = lfsck_remove_lmv(env, com, lnr);
+ rc = lfsck_remove_lmv(env, com, dir, lnr);
break;
case LSLF_BAD_INDEX2:
GOTO(out, rc = -EEXIST);
* as read-only. The administrator can
* handle the conflict with more human
* knowledge. */
- rc = lfsck_remove_lmv(env, com, lnr);
+ rc = lfsck_remove_lmv(env, com, dir, lnr);
} else {
/* Otherwise, remove the current name entry,
* and add its FID in the LFSCK tracing file
/* The name entry claims an index that is conflict
* with a valid existing name entry, then try the
* index in the lmv recursively. */
- rc = lfsck_record_lmv(env, com, lnr, lmv, index,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index,
LSLF_BAD_INDEX2, lslr->lslr_flags, depth);
lmv->lmv_master_mdt_index = index;
if (rc == -ERANGE || rc == -EEXIST)
* not know how to resolve the conflict.
* We will handle it as handle the case
* of 'LSLF_NONE' vs 'LSLF_NONE'. */
- rc = lfsck_remove_lmv(env, com, lnr);
+ rc = lfsck_remove_lmv(env, com, dir, lnr);
break;
default:
* as read-only. The administrator can
* handle the conflict with more human
* knowledge. */
- rc = lfsck_remove_lmv(env, com, lnr);
+ rc = lfsck_remove_lmv(env, com, dir, lnr);
} else {
lrls = &lfsck->li_rec_lmv_save[*depth - 1];
lrls->lrls_fid = lslr->lslr_fid;
com, &lrls->lrls_fid,
LNTF_CHECK_PARENT, true);
if (rc == 0)
- rc = lfsck_replace_lmv(env, com, lslr,
- lnr, lmv, index, flags);
+ rc = lfsck_replace_lmv(env, com, dir,
+ lslr, lnr, lmv, index, flags);
}
break;
/* The name entry claims an index that is conflict
* with a valid existing name entry, then try the
* index in the lmv recursively. */
- rc = lfsck_record_lmv(env, com, lnr, lmv, index,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index,
LSLF_BAD_INDEX2, lslr->lslr_flags, depth);
lmv->lmv_master_mdt_index = index;
if (rc == -ERANGE || rc == -EEXIST) {
case LSLF_NO_LMVEA:
/* Remove the existing dangling name entry.
* Refill the lslr slot with the given LMV. */
- rc = lfsck_replace_lmv(env, com, lslr, lnr,
+ rc = lfsck_replace_lmv(env, com, dir, lslr, lnr,
lmv, index, flags);
break;
case LSLF_DANGLING:
/* The name entry claims an index that is conflict
* with a valid existing name entry, then try the
* index in the lmv recursively. */
- rc = lfsck_record_lmv(env, com, lnr, lmv, index,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index,
LSLF_BAD_INDEX2, lslr->lslr_flags, depth);
lmv->lmv_master_mdt_index = index;
if (rc == -ERANGE || rc == -EEXIST)
* also conflict with other, then remove
* the existing dangling name entry.
* Refill the lslr slot with the given LMV. */
- rc = lfsck_replace_lmv(env, com, lslr, lnr,
+ rc = lfsck_replace_lmv(env, com, dir, lslr, lnr,
lmv, shard_idx, flags);
break;
/* The existing one has another possible slot,
* try it recursively. */
- rc = lfsck_record_lmv(env, com, lnr, lmv, index,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index,
LSLF_BAD_INDEX2, flags, depth);
*lmv = lrls->lrls_lmv;
lnr->lnr_fid = lrls->lrls_fid;
* mark the master MDT-object as read-only. The
* administrator can handle the conflict with
* more human knowledge. */
- rc = lfsck_remove_lmv(env, com, lnr);
+ rc = lfsck_remove_lmv(env, com, dir, lnr);
break;
case LSLF_BAD_INDEX2:
GOTO(out, rc = -EEXIST);
/* The name entry claims an index that is conflict
* with a valid existing name entry, then try the
* index in the lmv recursively. */
- rc = lfsck_record_lmv(env, com, lnr, lmv, index,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, index,
LSLF_BAD_INDEX2, lslr->lslr_flags, depth);
lmv->lmv_master_mdt_index = index;
if (rc == -ERANGE || rc == -EEXIST)
* not know how to resolve the conflict.
* We will handle it as handle the case
* of 'LSLF_NONE' vs 'LSLF_NONE'. */
- rc = lfsck_remove_lmv(env, com, lnr);
+ rc = lfsck_remove_lmv(env, com, dir, lnr);
break;
}
*
* \param[in] env pointer to the thread context
* \param[in] com pointer to the lfsck component
+ * \paran[in] dir pointer to the striped directory or its shard to be
+ * rescanned
* \param[in] lnr pointer to the namespace request that contains the
* striped directory or the shard
*
*/
int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *dir,
struct lfsck_namespace_req *lnr)
{
struct lfsck_thread_info *info = lfsck_env_info(env);
struct lfsck_lmv *llmv = lnr->lnr_lmv;
struct lmv_mds_md_v1 *lmv = &llmv->ll_lmv;
struct lmv_mds_md_v1 *lmv2 = &info->lti_lmv2;
- struct dt_object *dir = lnr->lnr_obj;
const struct lu_fid *pfid = lfsck_dto2fid(dir);
struct lu_seq_range *range = &info->lti_range;
struct seq_server_site *ss =
repair:
if (create) {
- rc1 = lfsck_namespace_repair_dangling(env, com,
+ rc1 = lfsck_namespace_repair_dangling(env, com, dir,
obj, lnr);
if (rc1 >= 0) {
create_repaired = true;
*
* \param[in] env pointer to the thread context
* \param[in] com pointer to the lfsck component
+ * \param[in] dir pointer to the master MDT-object of the
+ * striped directory
* \param[in] lnr pointer to the namespace request that contains the
* shard's name, parent object, parent's LMV, and ect.
*
*/
int lfsck_namespace_handle_striped_master(const struct lu_env *env,
struct lfsck_component *com,
+ struct dt_object *dir,
struct lfsck_namespace_req *lnr)
{
struct lfsck_thread_info *info = lfsck_env_info(env);
struct lfsck_instance *lfsck = com->lc_lfsck;
struct lfsck_namespace *ns = com->lc_file_ram;
struct lfsck_lmv *llmv = lnr->lnr_lmv;
- struct dt_object *dir = lnr->lnr_obj;
const struct lu_fid *pfid = lfsck_dto2fid(dir);
struct dt_object *obj = NULL;
struct dt_device *dev = NULL;
if (rc == 0) {
memset(lmv, 0, sizeof(*lmv));
lmv->lmv_magic = LMV_MAGIC;
- rc = lfsck_record_lmv(env, com, lnr, lmv, stripe,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, stripe,
LSLF_DANGLING, LSLF_NONE, &depth);
}
goto dangling;
if (rc == -ENODATA)
- rc = lfsck_record_lmv(env, com, lnr, lmv, stripe,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, stripe,
LSLF_NO_LMVEA, LSLF_NONE, &depth);
else if (rc == 0)
- rc = lfsck_record_lmv(env, com, lnr, lmv, stripe,
+ rc = lfsck_record_lmv(env, com, dir, lnr, lmv, stripe,
lmv->lmv_master_mdt_index != stripe ?
LSLF_BAD_INDEX1 : LSLF_NONE, LSLF_NONE,
&depth);
CDEBUG(D_LFSCK, "%s: namespace LFSCK assistant fail to handle "
"the shard: "DFID", parent "DFID", name %.*s: rc = %d\n",
lfsck_lfsck2name(lfsck), PFID(&lnr->lnr_fid),
- PFID(lfsck_dto2fid(lnr->lnr_obj)),
+ PFID(lfsck_dto2fid(dir)),
lnr->lnr_namelen, lnr->lnr_name, rc);
if ((rc == -ENOTCONN || rc == -ESHUTDOWN || rc == -EREMCHG ||