4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details. A copy is
14 * included in the COPYING file that accompanied this code.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Copyright (c) 2014, Intel Corporation.
26 * lustre/lfsck/lfsck_striped_dir.c
28 * Author: Fan, Yong <fan.yong@intel.com>
32 * About the verification for striped directory. Some rules and assumptions:
34 * 1) lmv_magic: The magic may be wrong. But it is almost impossible (1/2^32
35 * probability) that a master LMV EA claims as a slave LMV EA by wrong,
36 * so we can ignore such race case and the reverse case.
38 * 2) lmv_master_mdt_index: The master index can be self-verified by compared
39 * with the MDT index directly. The slave stripe index can be verified by
40 * compared with the file name. Although both the name entry and the LMV EA
41 * can be wrong, it is almost impossible that they hit the same bad data
42 * So if they match each other, then trust them. Similarly, for the shard,
43 * it stores index in both slave LMV EA and in linkEA, if the two copies
44 * match, then trust them.
46 * 3) lmv_hash_type: The valid hash type should be LMV_HASH_TYPE_ALL_CHARS or
47 * LMV_HASH_TYPE_FNV_1A_64. If the LFSCK instance on some slave finds that
48 * the name hash against the hash function does not match the MDT, then it
49 * will change the master LMV EA hash type as LMV_HASH_TYPE_UNKNOWN. With
50 * such hash type, the whole striped directory still can be accessed via
51 * lookup/readdir, and also support unlink, but cannot add new name entry.
53 * 3.1) If the master hash type is one of the valid values, then trust the
54 * master LMV EA. Because:
56 * 3.1.1) The master hash type is visible to the client and used by the client.
58 * 3.1.2) For a given name, different hash types may map the name entry to the
59 * same MDT. So simply checking one name entry or some name entries may
60 * cannot verify whether the hash type is correct or not.
62 * 3.1.3) Different shards can claim different hash types, it is not easy to
63 * distinguish which ones are correct. Even though the master is wrong,
64 * as the LFSCK processing, some LFSCK instance on other MDT may finds
65 * unmatched name hash, then it will change the master hash type to
66 * LMV_HASH_TYPE_UNKNOWN as described above. The worst case is euqal
67 * to the case without the LFSCK.
69 * 3.2) If the master hash type is invalid, nor LMV_HASH_TYPE_UNKNOWN, then
70 * trust the first shard with valid hash type (ALL_CHARS or FNV_1A_64).
71 * If the shard is also worng, means there are double failures, then as
72 * the LFSCK processing, other LFSCK instances on the other MDTs may
73 * find unmatched name hash, and then, the master hash type will be
74 * changed to LMV_HASH_TYPE_UNKNOWN as described in the 3).
76 * 3.3) If the master hash type is LMV_HASH_TYPE_UNKNOWN, then it is possible
77 * that some other LFSCK instance on other MDT found bad name hash, then
78 * changed the master hash type to LMV_HASH_TYPE_UNKNOWN as described in
79 * the 3). But it also maybe because of data corruption in master LMV EA.
80 * To make such two cases to be distinguishable, when the LFSCK changes
81 * the master hash type to LMV_HASH_TYPE_UNKNOWN, it will mark in the
82 * master LMV EA (new lmv flags LMV_HASH_FLAG_BAD_TYPE). Then subsequent
83 * LFSCK checking can distinguish them: for former case, turst the master
84 * LMV EA with nothing to be done; otherwise, trust the first shard with
85 * valid hash type (ALL_CHARS or FNV_1A_64) as the 3.2) does.
87 * 4) lmv_stripe_count: For a shard of a striped directory, if its index has
88 * been verified as the 2), then the stripe count must be larger than its
89 * index. For the master object, by scanning each shard's index, the LFSCK
90 * can know the highest index, and the stripe count must be larger than the
91 * known highest index. If the stipe count in the LMV EA matches above two
92 * rules, then it is may be trustable. If both the master claimed stripe
93 * count and the slave claimed stripe count match each own rule, but they
94 * are not the same, then trust the master. Because the stripe count in
95 * the master LMV EA is visible to client and used to distribute the name
96 * entry to some shard, but the slave LMV EA is only used for verification
97 * and invisible to client.
99 * 5) If the master LMV EA is lost, then there are two possible cases:
101 * 5.1) The slave claims slave LMV EA by wrong, means that the parent was not
102 * a striped directory, but its sub-directory has a wrong slave LMV EA.
103 * It is very very race case, similar as the 1), can be ignored.
105 * 5.2) The parent directory is a striped directory, but the master LMV EA
106 * is lost or crashed. Then the LFSCK needs to re-generate the master
107 * LMV EA: the lmv_master_mdt_index is from the MDT device index; the
108 * lmv_hash_type is from the first valid shard; the lmv_stripe_count
109 * will be calculated via scanning all the shards.
111 * 5.2.1) Before re-generating the master LMV EA, the LFSCK needs to check
112 * whether someone has created some file(s) under the master object
113 * after the master LMV EA disappear. If yes, the LFSCK will cannot
114 * re-generate the master LMV EA, otherwise, such new created files
115 * will be invisible to client. Under such case, the LFSCK will mark
116 * the master object as read only (without master LMV EA). Then all
117 * things under the master MDT-object, including those new created
118 * files and the shards themselves, will be visibile to client. And
119 * then the administrator can handle the bad striped directory with
120 * more human knowledge.
122 * 5.2.2) If someone created some special sub-directory under the master
123 * MDT-object with the same naming rule as shard name $FID:$index,
124 * as to the LFSCK cannot detect it before re-generating the master
125 * LMV EA, then such sub-directory itself will be invisible after
126 * the LFSCK re-generating the master LMV EA. The sub-items under
127 * such sub-directory are still visible to client. As the LFSCK
128 * processing, if such sub-directory cause some conflict with other
129 * normal shard, such as the index conflict, then the LFSCK will
130 * remove the master LMV EA and change the master MDT-object to
131 * read-only mode as the 5.2.1). But if there is no conflict, the
132 * LFSCK will regard such sub-directory as a striped shard that
133 * lost its slave LMV EA, and will re-generate slave LMV EA for it.
135 * 5.2.3) Anytime, if the LFSCK found some shards name/index conflict,
136 * and cannot make the distinguish which one is right, then it
137 * will remove the master LMV EA and change the MDT-object to
138 * read-only mode as the 5.2.2).
141 #define DEBUG_SUBSYSTEM S_LFSCK
143 #include <lustre/lustre_idl.h>
144 #include <lu_object.h>
145 #include <dt_object.h>
146 #include <md_object.h>
147 #include <lustre_fid.h>
148 #include <lustre_lib.h>
149 #include <lustre_net.h>
150 #include <lustre_lmv.h>
151 #include <lustre/lustre_user.h>
153 #include "lfsck_internal.h"
155 void lfsck_lmv_put(const struct lu_env *env, struct lfsck_lmv *llmv)
157 if (llmv != NULL && atomic_dec_and_test(&llmv->ll_ref)) {
158 if (llmv->ll_lslr != NULL)
159 OBD_FREE_LARGE(llmv->ll_lslr,
160 sizeof(struct lfsck_slave_lmv_rec) *
161 llmv->ll_stripes_allocated);
167 static inline bool lfsck_is_valid_slave_lmv(struct lmv_mds_md_v1 *lmv)
169 return lmv->lmv_stripe_count >= 1 &&
170 lmv->lmv_stripe_count <= LFSCK_LMV_MAX_STRIPES &&
171 lmv->lmv_stripe_count > lmv->lmv_master_mdt_index &&
172 lmv_is_known_hash_type(lmv->lmv_hash_type);
175 int lfsck_read_stripe_lmv(const struct lu_env *env, struct dt_object *obj,
176 struct lmv_mds_md_v1 *lmv)
178 struct dt_object *bottom;
181 /* Currently, we only store the LMV header on disk. It is the LOD's
182 * duty to iterate the master MDT-object's directory to compose the
183 * integrated LMV EA. But here, we only want to load the LMV header,
184 * so we need to bypass LOD to avoid unnecessary iteration in LOD. */
185 bottom = lu2dt(container_of0(obj->do_lu.lo_header->loh_layers.prev,
186 struct lu_object, lo_linkage));
187 if (unlikely(bottom == NULL))
190 dt_read_lock(env, bottom, 0);
191 rc = dt_xattr_get(env, bottom, lfsck_buf_get(env, lmv, sizeof(*lmv)),
192 XATTR_NAME_LMV, BYPASS_CAPA);
193 dt_read_unlock(env, bottom);
194 if (rc != sizeof(*lmv))
195 return rc > 0 ? -EINVAL : rc;
197 lfsck_lmv_header_le_to_cpu(lmv, lmv);
198 if ((lmv->lmv_magic == LMV_MAGIC &&
199 !(lmv->lmv_hash_type & LMV_HASH_FLAG_MIGRATION)) ||
200 (lmv->lmv_magic == LMV_MAGIC_STRIPE &&
201 !(lmv->lmv_hash_type & LMV_HASH_FLAG_DEAD)))
208 * Parse the shard's index from the given shard name.
210 * The valid shard name/type should be:
211 * 1) The type must be S_IFDIR
212 * 2) The name should be $FID:$index
213 * 3) the index should within valid range.
215 * \param[in] env pointer to the thread context
216 * \param[in] name the shard name
217 * \param[in] namelen the name length
218 * \param[in] type the entry's type
219 * \param[in] fid the entry's FID
221 * \retval zero or positive number for the index from the name
222 * \retval negative error number on failure
224 int lfsck_shard_name_to_index(const struct lu_env *env, const char *name,
225 int namelen, __u16 type, const struct lu_fid *fid)
227 char *name2 = lfsck_env_info(env)->lti_tmpbuf2;
234 LASSERT(name != name2);
236 len = snprintf(name2, sizeof(lfsck_env_info(env)->lti_tmpbuf2),
238 if (namelen < len + 1 || memcmp(name, name2, len) != 0)
242 if (!isdigit(name[len]))
245 idx = idx * 10 + name[len++] - '0';
246 } while (len < namelen);
248 if (idx >= LFSCK_LMV_MAX_STRIPES)
254 bool lfsck_is_valid_slave_name_entry(const struct lu_env *env,
255 struct lfsck_lmv *llmv,
256 const char *name, int namelen)
258 struct lmv_mds_md_v1 *lmv;
261 if (llmv == NULL || !llmv->ll_lmv_slave || !llmv->ll_lmv_verified)
265 idx = lmv_name_to_stripe_index(lmv->lmv_hash_type,
266 lmv->lmv_stripe_count,
268 if (unlikely(idx != lmv->lmv_master_mdt_index))
275 * Check whether the given name is a valid entry under the @parent.
277 * If the @parent is a striped directory then the @child should one
278 * shard of the striped directory, its name should be $FID:$index.
280 * If the @parent is a shard of a striped directory, then the name hash
281 * should match the MDT, otherwise it is invalid.
283 * \param[in] env pointer to the thread context
284 * \param[in] parent the parent directory
285 * \param[in] child the child object to be checked
286 * \param[in] cname the name for the @child in the parent directory
288 * \retval positive number for invalid name entry
289 * \retval 0 if the name is valid or uncertain
290 * \retval negative error number on failure
292 int lfsck_namespace_check_name(const struct lu_env *env,
293 struct dt_object *parent,
294 struct dt_object *child,
295 const struct lu_name *cname)
297 struct lmv_mds_md_v1 *lmv = &lfsck_env_info(env)->lti_lmv;
301 rc = lfsck_read_stripe_lmv(env, parent, lmv);
303 RETURN(rc == -ENODATA ? 0 : rc);
305 if (lmv->lmv_magic == LMV_MAGIC_STRIPE) {
306 if (!lfsck_is_valid_slave_lmv(lmv))
309 idx = lmv_name_to_stripe_index(lmv->lmv_hash_type,
310 lmv->lmv_stripe_count,
313 if (unlikely(idx != lmv->lmv_master_mdt_index))
315 } else if (lfsck_shard_name_to_index(env, cname->ln_name,
316 cname->ln_namelen, lfsck_object_type(child),
317 lfsck_dto2fid(child)) < 0) {
325 * Update the object's LMV EA with the given @lmv.
327 * \param[in] env pointer to the thread context
328 * \param[in] com pointer to the lfsck component
329 * \param[in] obj pointer to the object which LMV EA will be updated
330 * \param[in] lmv pointer to buffer holding the new LMV EA
331 * \param[in] locked whether the caller has held ldlm lock on the @obj or not
333 * \retval positive number for nothing to be done
334 * \retval zero if updated successfully
335 * \retval negative error number on failure
337 int lfsck_namespace_update_lmv(const struct lu_env *env,
338 struct lfsck_component *com,
339 struct dt_object *obj,
340 struct lmv_mds_md_v1 *lmv, bool locked)
342 struct lfsck_thread_info *info = lfsck_env_info(env);
343 struct lmv_mds_md_v1 *lmv4 = &info->lti_lmv4;
344 struct lu_buf *buf = &info->lti_buf;
345 struct lfsck_instance *lfsck = com->lc_lfsck;
346 struct dt_device *dev = lfsck_obj2dt_dev(obj);
347 struct thandle *th = NULL;
348 struct lustre_handle lh = { 0 };
353 LASSERT(lmv4 != lmv);
355 lfsck_lmv_header_cpu_to_le(lmv4, lmv);
356 lfsck_buf_init(buf, lmv4, sizeof(*lmv4));
359 rc = lfsck_ibits_lock(env, lfsck, obj, &lh,
360 MDS_INODELOCK_UPDATE |
361 MDS_INODELOCK_XATTR, LCK_EX);
366 th = dt_trans_create(env, dev);
368 GOTO(log, rc = PTR_ERR(th));
370 /* For remote updating LMV EA, there will be further LFSCK action on
371 * remote MDT after the updating, so update the LMV EA synchronously. */
372 if (dt_object_remote(obj))
375 rc = dt_declare_xattr_set(env, obj, buf, XATTR_NAME_LMV, 0, th);
379 rc = dt_trans_start_local(env, dev, th);
383 dt_write_lock(env, obj, 0);
384 if (unlikely(lfsck_is_dead_obj(obj)))
385 GOTO(unlock, rc = 1);
387 if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN)
388 GOTO(unlock, rc = 0);
390 rc = dt_xattr_set(env, obj, buf, XATTR_NAME_LMV, 0, th, BYPASS_CAPA);
395 dt_write_unlock(env, obj);
398 rc1 = dt_trans_stop(env, dev, th);
403 lfsck_ibits_unlock(&lh, LCK_EX);
404 CDEBUG(D_LFSCK, "%s: namespace LFSCK updated the %s LMV EA "
405 "for the object "DFID": rc = %d\n",
406 lfsck_lfsck2name(lfsck),
407 lmv->lmv_magic == LMV_MAGIC ? "master" : "slave",
408 PFID(lfsck_dto2fid(obj)), rc);
414 * Set master LMV EA for the specified striped directory.
416 * \param[in] env pointer to the thread context
417 * \param[in] com pointer to the lfsck component
418 * \param[in] dir pointer to the object on which the LMV EA will be set
419 * \param[in] lmv pointer to the buffer holding the new LMV EA
420 * \param[in] cfid the shard's FID used for verification
421 * \param[in] cidx the shard's index used for verification
422 * \param[in] flags to indicate which element(s) in the LMV EA will be set
424 * \retval positive number if nothing to be done
425 * \retval zero for succeed
426 * \retval negative error number on failure
428 static int lfsck_namespace_set_lmv_master(const struct lu_env *env,
429 struct lfsck_component *com,
430 struct dt_object *dir,
431 struct lmv_mds_md_v1 *lmv,
432 const struct lu_fid *cfid,
433 __u32 cidx, __u32 flags)
435 struct lfsck_thread_info *info = lfsck_env_info(env);
436 struct lmv_mds_md_v1 *lmv3 = &info->lti_lmv3;
437 struct lfsck_instance *lfsck = com->lc_lfsck;
438 struct dt_object *obj;
439 struct lustre_handle lh = { 0 };
444 /* Find the bottom object to bypass LOD when set LMV EA. */
445 obj = lu2dt(container_of0(dir->do_lu.lo_header->loh_layers.prev,
446 struct lu_object, lo_linkage));
447 if (unlikely(obj == NULL))
450 if (dt_object_remote(obj)) {
451 struct lu_seq_range *range = &info->lti_range;
452 struct seq_server_site *ss =
453 lu_site2seq(lfsck->li_bottom->dd_lu_dev.ld_site);
455 fld_range_set_mdt(range);
456 rc = fld_server_lookup(env, ss->ss_server_fld,
457 fid_seq(lfsck_dto2fid(obj)), range);
461 pidx = range->lsr_index;
463 pidx = lfsck_dev_idx(lfsck->li_bottom);
466 /* XXX: it will be improved with subsequent patches landed. */
468 rc = lfsck_ibits_lock(env, lfsck, obj, &lh,
469 MDS_INODELOCK_UPDATE | MDS_INODELOCK_XATTR,
474 rc = lfsck_read_stripe_lmv(env, obj, lmv3);
478 lmv3->lmv_hash_type = lmv->lmv_hash_type;
479 lmv3->lmv_magic = LMV_MAGIC;
480 lmv3->lmv_master_mdt_index = pidx;
482 rc = lfsck_namespace_update_lmv(env, com, obj, lmv3, true);
487 lfsck_ibits_unlock(&lh, LCK_EX);
488 CDEBUG(D_LFSCK, "%s: namespace LFSCK set master LMV EA for the object "
489 DFID" on the %s MDT %d, flags %x: rc = %d\n",
490 lfsck_lfsck2name(lfsck), PFID(lfsck_dto2fid(obj)),
491 dt_object_remote(obj) ? "remote" : "local", pidx, flags, rc);
494 struct lfsck_namespace *ns = com->lc_file_ram;
496 ns->ln_flags |= LF_INCONSISTENT;
503 * Repair the bad name hash.
505 * If the name hash of some name entry under the striped directory does not
506 * match the shard of the striped directory, then the LFSCK will repair the
507 * inconsistency. Ideally, the LFSCK should migrate the name entry from the
508 * current MDT to the right MDT (another one), but before the async commit
509 * finished, the LFSCK will change the striped directory's hash type as
510 * LMV_HASH_TYPE_UNKNOWN and mark the lmv flags as LMV_HASH_FLAG_BAD_TYPE.
512 * \param[in] env pointer to the thread context
513 * \param[in] com pointer to the lfsck component
514 * \param[in] shard pointer to the shard of the striped directory that
515 * contains the bad name entry
516 * \param[in] llmv pointer to lfsck LMV EA structure
517 * \param[in] name the name of the bad name hash
519 * \retval positive number if nothing to be done
520 * \retval zero for succeed
521 * \retval negative error number on failure
523 int lfsck_namespace_repair_bad_name_hash(const struct lu_env *env,
524 struct lfsck_component *com,
525 struct dt_object *shard,
526 struct lfsck_lmv *llmv,
529 struct lfsck_thread_info *info = lfsck_env_info(env);
530 struct lu_fid *pfid = &info->lti_fid3;
531 struct lmv_mds_md_v1 *lmv2 = &info->lti_lmv2;
532 struct lfsck_instance *lfsck = com->lc_lfsck;
533 struct dt_object *parent = NULL;
537 rc = dt_lookup(env, shard, (struct dt_rec *)pfid,
538 (const struct dt_key *)dotdot, BYPASS_CAPA);
539 if (rc != 0 || !fid_is_sane(pfid))
542 parent = lfsck_object_find_bottom(env, lfsck, pfid);
544 GOTO(log, rc = PTR_ERR(parent));
546 *lmv2 = llmv->ll_lmv;
547 lmv2->lmv_hash_type = LMV_HASH_TYPE_UNKNOWN | LMV_HASH_FLAG_BAD_TYPE;
548 rc = lfsck_namespace_set_lmv_master(env, com, parent, lmv2,
549 lfsck_dto2fid(shard),
550 llmv->ll_lmv.lmv_master_mdt_index,
556 CDEBUG(D_LFSCK, "%s: namespace LFSCK assistant found bad name hash "
557 "on the MDT %x, parent "DFID", name %s, shard_%x "DFID
559 lfsck_lfsck2name(lfsck), lfsck_dev_idx(lfsck->li_bottom),
560 PFID(pfid), name, llmv->ll_lmv.lmv_master_mdt_index,
561 PFID(lfsck_dto2fid(shard)), rc);
563 if (parent != NULL && !IS_ERR(parent))
564 lfsck_object_put(env, parent);
570 * Verify the slave object's (of striped directory) LMV EA.
572 * For the slave object of a striped directory, before traversing the shard
573 * the LFSCK will verify whether its slave LMV EA matches its parent's master
576 * \param[in] env pointer to the thread context
577 * \param[in] com pointer to the lfsck component
578 * \param[in] obj pointer to the object which LMV EA will be checked
579 * \param[in] llmv pointer to buffer holding the slave LMV EA
581 * \retval zero for succeed
582 * \retval negative error number on failure
584 int lfsck_namespace_verify_stripe_slave(const struct lu_env *env,
585 struct lfsck_component *com,
586 struct dt_object *obj,
587 struct lfsck_lmv *llmv)
589 struct lfsck_thread_info *info = lfsck_env_info(env);
590 char *name = info->lti_key;
592 struct lu_fid *pfid = &info->lti_fid3;
593 struct lu_fid *tfid = &info->lti_fid4;
594 const struct lu_fid *cfid = lfsck_dto2fid(obj);
595 struct lfsck_instance *lfsck = com->lc_lfsck;
596 struct lmv_mds_md_v1 *clmv = &llmv->ll_lmv;
597 struct lmv_mds_md_v1 *plmv = &info->lti_lmv;
598 struct dt_object *parent = NULL;
602 if (!lfsck_is_valid_slave_lmv(clmv)) {
603 rc = lfsck_namespace_trace_update(env, com, cfid,
604 LNTF_UNCERTAIN_LMV, true);
609 rc = dt_lookup(env, obj, (struct dt_rec *)pfid,
610 (const struct dt_key *)dotdot, BYPASS_CAPA);
611 if (rc != 0 || !fid_is_sane(pfid)) {
612 rc = lfsck_namespace_trace_update(env, com, cfid,
613 LNTF_UNCERTAIN_LMV, true);
618 parent = lfsck_object_find(env, lfsck, pfid);
619 if (IS_ERR(parent)) {
620 rc = lfsck_namespace_trace_update(env, com, cfid,
621 LNTF_UNCERTAIN_LMV, true);
626 rc = lfsck_read_stripe_lmv(env, parent, plmv);
630 /* If the parent has no LMV EA, then it maybe because:
631 * 1) The parent lost the LMV EA.
632 * 2) The child claims a wrong (slave) LMV EA. */
634 /* XXX: to be improved. */
637 rc1 = lfsck_namespace_trace_update(env, com, cfid,
638 LNTF_UNCERTAIN_LMV, true);
640 GOTO(out, rc = (rc < 0 ? rc : rc1));
643 /* Unmatched magic or stripe count. */
644 if (unlikely(plmv->lmv_magic != LMV_MAGIC ||
645 plmv->lmv_stripe_count != clmv->lmv_stripe_count)) {
646 rc = lfsck_namespace_trace_update(env, com, cfid,
647 LNTF_UNCERTAIN_LMV, true);
652 /* If the master hash type has been set as LMV_HASH_TYPE_UNKNOWN,
653 * then the slave hash type is not important. */
654 if ((plmv->lmv_hash_type & LMV_HASH_TYPE_MASK) ==
655 LMV_HASH_TYPE_UNKNOWN &&
656 plmv->lmv_hash_type & LMV_HASH_FLAG_BAD_TYPE)
659 /* Unmatched hash type. */
660 if (unlikely((plmv->lmv_hash_type & LMV_HASH_TYPE_MASK) !=
661 (clmv->lmv_hash_type & LMV_HASH_TYPE_MASK))) {
662 rc = lfsck_namespace_trace_update(env, com, cfid,
663 LNTF_UNCERTAIN_LMV, true);
668 snprintf(info->lti_tmpbuf2, sizeof(info->lti_tmpbuf2), DFID":%u",
669 PFID(cfid), clmv->lmv_master_mdt_index);
670 name2 = info->lti_tmpbuf2;
672 rc = lfsck_links_get_first(env, obj, name, tfid);
673 if (rc == 0 && strcmp(name, name2) == 0 && lu_fid_eq(pfid, tfid)) {
674 llmv->ll_lmv_verified = 1;
679 rc = dt_lookup(env, parent, (struct dt_rec *)tfid,
680 (const struct dt_key *)name2, BYPASS_CAPA);
681 if (rc != 0 || !lu_fid_eq(cfid, tfid))
682 rc = lfsck_namespace_trace_update(env, com, cfid,
683 LNTF_UNCERTAIN_LMV, true);
685 llmv->ll_lmv_verified = 1;
690 if (parent != NULL && !IS_ERR(parent))
691 lfsck_object_put(env, parent);
697 * Double scan the striped directory or the shard.
699 * \param[in] env pointer to the thread context
700 * \param[in] com pointer to the lfsck component
701 * \param[in] lnr pointer to the namespace request that contains the
702 * striped directory or the shard
704 * \retval zero for succeed
705 * \retval negative error number on failure
707 int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
708 struct lfsck_component *com,
709 struct lfsck_namespace_req *lnr)
711 struct lfsck_namespace *ns = com->lc_file_ram;
712 struct lfsck_lmv *llmv = lnr->lnr_lmv;
713 struct dt_object *dir = lnr->lnr_obj;
716 /* XXX: it will be improved with subsequent patches landed. */
718 if (llmv->ll_lmv_slave && llmv->ll_lmv_verified) {
719 ns->ln_striped_shards_scanned++;
720 lfsck_namespace_trace_update(env, com,
723 LNTF_RECHECK_NAME_HASH, false);