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) 2013, 2016, Intel Corporation.
26 * lustre/lfsck/lfsck_internal.h
28 * Shared definitions and declarations for the LFSCK.
30 * Author: Fan, Yong <fan.yong@intel.com>
33 #ifndef _LFSCK_INTERNAL_H
34 # define _LFSCK_INTERNAL_H
36 #include <lustre/lustre_lfsck_user.h>
37 #include <lustre/lustre_user.h>
38 #include <lustre/lustre_idl.h>
39 #include <lustre_lfsck.h>
41 #include <lu_object.h>
42 #include <dt_object.h>
43 #include <md_object.h>
44 #include <lustre_net.h>
45 #include <lustre_dlm.h>
46 #include <lustre_fid.h>
47 #include <md_object.h>
48 #include <lustre_linkea.h>
50 #define HALF_SEC msecs_to_jiffies(MSEC_PER_SEC >> 1)
51 #define LFSCK_CHECKPOINT_INTERVAL 60
54 /* Finish the first cycle scanning. */
55 LF_SCANNED_ONCE = 0x00000001ULL,
57 /* There is some namespace inconsistency. */
58 LF_INCONSISTENT = 0x00000002ULL,
60 /* The device is upgraded from 1.8 format. */
61 LF_UPGRADE = 0x00000004ULL,
63 /* The server ever restarted during the LFSCK, and may miss to process
64 * some objects check/repair. */
65 LF_INCOMPLETE = 0x00000008ULL,
67 /* The LAST_ID (file) crashed. */
68 LF_CRASHED_LASTID = 0x00000010ULL,
71 struct lfsck_position {
72 /* low layer object table-based iteration position. */
75 /* parent FID for directory traversal. */
76 struct lu_fid lp_dir_parent;
78 /* namespace-based directory traversal position. */
82 struct lfsck_bookmark {
83 /* Magic number to detect that this struct contains valid data. */
86 /* For compatible with old versions. */
89 /* See 'enum lfsck_param_flags' */
92 /* How many items can be scanned at most per second. */
95 /* The windows size for async requests pipeline. */
96 __u16 lb_async_windows;
98 /* For 64-bits aligned. */
101 /* The FID for .lustre/lost+found/MDTxxxx */
102 struct lu_fid lb_lpf_fid;
104 /* The FID for the last MDT-object created by the LFSCK repairing. */
105 struct lu_fid lb_last_fid;
107 /* For future using. */
108 __u64 lb_reserved[2];
111 enum lfsck_namespace_trace_flags {
112 LNTF_CHECK_LINKEA = 0x01,
113 LNTF_CHECK_PARENT = 0x02,
114 LNTF_CHECK_ORPHAN = 0x08,
115 LNTF_UNCERTAIN_LMV = 0x10,
116 LNTF_RECHECK_NAME_HASH = 0x20,
120 enum lfsck_namespace_inconsistency_type {
123 LNIT_UNMATCHED_PAIRS = 2,
130 struct lfsck_namespace {
131 /* Magic number to detect that this struct contains valid data. */
134 /* See 'enum lfsck_status'. */
137 /* See 'enum lfsck_flags'. */
140 /* How many completed LFSCK runs on the device. */
141 __u32 ln_success_count;
143 /* How long the LFSCK phase1 has run in seconds. */
144 __u32 ln_run_time_phase1;
146 /* How long the LFSCK phase2 has run in seconds. */
147 __u32 ln_run_time_phase2;
149 /* Time for the last LFSCK completed in seconds since epoch. */
150 __u64 ln_time_last_complete;
152 /* Time for the latest LFSCK ran in seconds since epoch. */
153 __u64 ln_time_latest_start;
155 /* Time for the last LFSCK checkpoint in seconds since epoch. */
156 __u64 ln_time_last_checkpoint;
158 /* Position for the latest LFSCK started from. */
159 struct lfsck_position ln_pos_latest_start;
161 /* Position for the last LFSCK checkpoint. */
162 struct lfsck_position ln_pos_last_checkpoint;
164 /* Position for the first should be updated object. */
165 struct lfsck_position ln_pos_first_inconsistent;
167 /* How many items (including dir) have been checked. */
168 __u64 ln_items_checked;
170 /* How many items have been repaired. */
171 __u64 ln_items_repaired;
173 /* How many items failed to be processed. */
174 __u64 ln_items_failed;
176 /* How many directories have been traversed. */
177 __u64 ln_dirs_checked;
179 /* How many objects have been double scanned. */
180 __u64 ln_objs_checked_phase2;
182 /* How many objects have been reparied during double scan. */
183 __u64 ln_objs_repaired_phase2;
185 /* How many objects failed to be processed during double scan. */
186 __u64 ln_objs_failed_phase2;
188 /* How many objects with nlink fixed. */
189 __u64 ln_objs_nlink_repaired;
191 /* The latest object has been processed (failed) during double scan. */
192 struct lu_fid ln_fid_latest_scanned_phase2;
194 /* How many FID-in-dirent entries have been repaired. */
195 __u64 ln_dirent_repaired;
197 /* How many linkEA entries have been repaired. */
198 __u64 ln_linkea_repaired;
200 /* How many multiple-linked objects have been checked. */
201 __u64 ln_mul_linked_checked;
203 /* How many multiple-linked objects have been repaired. */
204 __u64 ln_mul_linked_repaired;
206 /* How many undefined inconsistency found in phase2. */
207 __u64 ln_unknown_inconsistency;
209 /* How many unmatched pairs have been repaired. */
210 __u64 ln_unmatched_pairs_repaired;
212 /* How many dangling name entries have been found/repaired. */
213 __u64 ln_dangling_repaired;
215 /* How many multiple referenced name entries have been
217 __u64 ln_mul_ref_repaired;
219 /* How many name entries with bad file type have been repaired. */
220 __u64 ln_bad_type_repaired;
222 /* How many lost name entries have been re-inserted. */
223 __u64 ln_lost_dirent_repaired;
225 /* How many objects under /lost+found have been scanned. */
226 __u64 ln_local_lpf_scanned;
228 /* How many objects under /lost+found have been moved to
229 * namespace visible directory. */
230 __u64 ln_local_lpf_moved;
232 /* How many objects under /lost+found have been skipped. */
233 __u64 ln_local_lpf_skipped;
235 /* How many objects under /lost+found failed to be processed. */
236 __u64 ln_local_lpf_failed;
238 /* How many striped directories (master) have been scanned. */
239 __u64 ln_striped_dirs_scanned;
241 /* How many striped directories (master) have been repaired. */
242 __u64 ln_striped_dirs_repaired;
244 /* How many striped directories (master) failed verification. */
245 __u64 ln_striped_dirs_failed;
247 /* How many striped directories (master) has been disabled. */
248 __u64 ln_striped_dirs_disabled;
250 /* How many striped directory's (master) have been skipped
251 * (for shards verification) because of lost master LMV EA. */
252 __u64 ln_striped_dirs_skipped;
254 /* How many striped directory's shards (slave) have been scanned. */
255 __u64 ln_striped_shards_scanned;
257 /* How many striped directory's shards (slave) have been repaired. */
258 __u64 ln_striped_shards_repaired;
260 /* How many striped directory's shards (slave) failed verification. */
261 __u64 ln_striped_shards_failed;
263 /* How many striped directory's shards (slave) have been skipped
264 * (for name hash verification) because do not know whether the slave
265 * LMV EA is valid or not. */
266 __u64 ln_striped_shards_skipped;
268 /* How many name entries under striped directory with bad name
269 * hash have been repaired. */
270 __u64 ln_name_hash_repaired;
272 /* The size of MDT targets bitmap with nbits. Such bitmap records
273 * the MDTs that contain non-verified MDT-objects. */
274 __u32 ln_bitmap_size;
276 /* Time for the latest LFSCK scan in seconds from the beginning. */
277 __u32 ln_time_latest_reset;
279 /* How many linkEA overflow timestamp have been cleared. */
280 __u64 ln_linkea_overflow_cleared;
282 /* For further using. 256-bytes aligned now. */
283 __u64 ln_reserved[14];
286 enum lfsck_layout_inconsistency_type {
289 LLIT_UNMATCHED_PAIR = 2,
290 LLIT_MULTIPLE_REFERENCED = 3,
292 LLIT_INCONSISTENT_OWNER = 5,
294 LLIT_MAX = LLIT_OTHERS
297 struct lfsck_layout {
298 /* Magic number to detect that this struct contains valid data. */
301 /* See 'enum lfsck_status'. */
304 /* See 'enum lfsck_flags'. */
307 /* How many completed LFSCK runs on the device. */
308 __u32 ll_success_count;
310 /* How long the LFSCK phase1 has run in seconds. */
311 __u32 ll_run_time_phase1;
313 /* How long the LFSCK phase2 has run in seconds. */
314 __u32 ll_run_time_phase2;
316 /* Time for the last LFSCK completed in seconds since epoch. */
317 __u64 ll_time_last_complete;
319 /* Time for the latest LFSCK ran in seconds since epoch. */
320 __u64 ll_time_latest_start;
322 /* Time for the last LFSCK checkpoint in seconds since epoch. */
323 __u64 ll_time_last_checkpoint;
325 /* Position for the latest LFSCK started from. */
326 __u64 ll_pos_latest_start;
328 /* Position for the last LFSCK checkpoint. */
329 __u64 ll_pos_last_checkpoint;
331 /* Position for the first object to be fixed or
332 * failed to be checked in the phase1. */
333 __u64 ll_pos_first_inconsistent;
335 /* How many objects have been checked. */
336 __u64 ll_objs_checked_phase1;
338 /* How many objects failed to be processed. */
339 __u64 ll_objs_failed_phase1;
341 /* How many objects have been double scanned. */
342 __u64 ll_objs_checked_phase2;
344 /* How many objects failed to be processed during double scan. */
345 __u64 ll_objs_failed_phase2;
347 /* kinds of inconsistency have been or to be repaired.
348 * ll_objs_repaired[type - 1] is the count for the given @type. */
349 __u64 ll_objs_repaired[LLIT_MAX];
351 /* How many objects have been skipped because of related
352 * MDT(s)/OST(s) do not participate in the LFSCK */
353 __u64 ll_objs_skipped;
355 /* The size of ll_ost_bitmap with nbits. */
356 __u32 ll_bitmap_size;
358 /* For further using. 256-bytes aligned now. */
361 /* The latest object has been processed (failed) during double scan. */
362 struct lu_fid ll_fid_latest_scanned_phase2;
364 __u64 ll_reserved_2[9];
366 /* The OST targets bitmap to record the OSTs that contain
367 * non-verified OST-objects. */
368 __u8 ll_ost_bitmap[0];
371 struct lfsck_assistant_object {
372 struct lu_fid lso_fid;
373 __u64 lso_oit_cookie;
374 struct lu_attr lso_attr;
376 unsigned int lso_dead:1,
380 struct lfsck_component;
381 struct lfsck_tgt_descs;
382 struct lfsck_tgt_desc;
384 struct lfsck_operations {
385 int (*lfsck_reset)(const struct lu_env *env,
386 struct lfsck_component *com,
389 void (*lfsck_fail)(const struct lu_env *env,
390 struct lfsck_component *com,
393 void (*lfsck_close_dir)(const struct lu_env *env,
394 struct lfsck_component *com);
396 int (*lfsck_open_dir)(const struct lu_env *env,
397 struct lfsck_component *com);
399 int (*lfsck_checkpoint)(const struct lu_env *env,
400 struct lfsck_component *com,
403 int (*lfsck_prep)(const struct lu_env *env,
404 struct lfsck_component *com,
405 struct lfsck_start_param *lsp);
407 int (*lfsck_exec_oit)(const struct lu_env *env,
408 struct lfsck_component *com,
409 struct dt_object *obj);
411 int (*lfsck_exec_dir)(const struct lu_env *env,
412 struct lfsck_component *com,
413 struct lfsck_assistant_object *lso,
414 struct lu_dirent *ent,
417 int (*lfsck_post)(const struct lu_env *env,
418 struct lfsck_component *com,
422 void (*lfsck_dump)(const struct lu_env *env,
423 struct lfsck_component *com,
426 int (*lfsck_double_scan)(const struct lu_env *env,
427 struct lfsck_component *com);
429 void (*lfsck_data_release)(const struct lu_env *env,
430 struct lfsck_component *com);
432 void (*lfsck_quit)(const struct lu_env *env,
433 struct lfsck_component *com);
435 int (*lfsck_in_notify)(const struct lu_env *env,
436 struct lfsck_component *com,
437 struct lfsck_request *lr,
440 int (*lfsck_query)(const struct lu_env *env,
441 struct lfsck_component *com,
442 struct lfsck_request *req,
443 struct lfsck_reply *rep,
444 struct lfsck_query *que, int idx);
446 int (*lfsck_join)(const struct lu_env *env,
447 struct lfsck_component *com,
448 struct lfsck_start_param *lsp);
451 #define TGT_PTRS 256 /* number of pointers at 1st level */
452 #define TGT_PTRS_PER_BLOCK 256 /* number of pointers at 2nd level */
454 struct lfsck_tgt_desc {
455 struct list_head ltd_orphan_list;
456 struct dt_device *ltd_tgt;
457 struct dt_device *ltd_key;
458 struct obd_export *ltd_exp;
459 struct list_head ltd_layout_list;
460 struct list_head ltd_layout_phase_list;
461 struct list_head ltd_namespace_list;
462 struct list_head ltd_namespace_phase_list;
463 __u32 ltd_layout_status;
464 __u32 ltd_namespace_status;
465 __u64 ltd_layout_repaired;
466 __u64 ltd_namespace_repaired;
469 __u32 ltd_layout_gen;
470 __u32 ltd_namespace_gen;
471 unsigned int ltd_dead:1,
473 ltd_namespace_done:1,
474 ltd_synced_failures:1;
477 struct lfsck_tgt_desc_idx {
478 struct lfsck_tgt_desc *ldi_tgts[TGT_PTRS_PER_BLOCK];
481 struct lfsck_tgt_descs {
482 /* list of known TGTs */
483 struct lfsck_tgt_desc_idx *ltd_tgts_idx[TGT_PTRS];
485 /* bitmap of TGTs available */
486 struct cfs_bitmap *ltd_tgts_bitmap;
488 /* for lfsck_tgt_desc::ltd_xxx_list */
491 /* for tgts table accessing and changes */
492 struct rw_semaphore ltd_rw_sem;
494 /* Temporary list for orphan targets. */
495 struct list_head ltd_orphan;
497 /* number of registered TGTs */
501 static inline struct lfsck_tgt_desc *
502 lfsck_ltd2tgt(struct lfsck_tgt_descs *ltd, __u32 index)
504 __u32 idx1 = index / TGT_PTRS_PER_BLOCK;
505 __u32 idx2 = index % TGT_PTRS_PER_BLOCK;
506 struct lfsck_tgt_desc *__tgt = NULL;
508 if (unlikely(idx1 >= TGT_PTRS))
509 CDEBUG(D_LFSCK, "The target idx %u is invalid.\n", index);
510 else if (likely(ltd->ltd_tgts_idx[idx1] != NULL))
511 __tgt = ltd->ltd_tgts_idx[idx1]->ldi_tgts[idx2];
516 static inline void lfsck_assign_tgt(struct lfsck_tgt_descs *ltd,
517 struct lfsck_tgt_desc *tgt, __u32 index)
519 __u32 idx1 = index / TGT_PTRS_PER_BLOCK;
520 __u32 idx2 = index % TGT_PTRS_PER_BLOCK;
522 if (likely(idx1 < TGT_PTRS && ltd->ltd_tgts_idx[idx1] != NULL))
523 ltd->ltd_tgts_idx[idx1]->ldi_tgts[idx2] = tgt;
526 #define LFSCK_STF_BITS 4
527 /* If want to adjust the LFSCK_STF_COUNT, please change LFSCK_STF_BITS. */
528 #define LFSCK_STF_COUNT (1 << LFSCK_STF_BITS)
530 struct lfsck_sub_trace_obj {
531 struct dt_object *lsto_obj;
532 struct mutex lsto_mutex;
535 struct lfsck_component {
536 /* into lfsck_instance::li_list_(scan,double_scan,idle} */
537 struct list_head lc_link;
539 /* into lfsck_instance::li_list_dir */
540 struct list_head lc_link_dir;
542 struct rw_semaphore lc_sem;
545 struct lfsck_position lc_pos_start;
546 struct lfsck_instance *lc_lfsck;
547 struct dt_object *lc_obj;
548 struct lfsck_sub_trace_obj lc_sub_trace_objs[LFSCK_STF_COUNT];
549 struct lfsck_operations *lc_ops;
553 struct lu_fid lc_fid_latest_scanned_phase2;
555 /* The time for last checkpoint, jiffies */
556 cfs_time_t lc_time_last_checkpoint;
558 /* The time for next checkpoint, jiffies */
559 cfs_time_t lc_time_next_checkpoint;
563 /* How many objects have been checked since last checkpoint. */
564 __u32 lc_new_checked;
566 /* How many objects have been scanned since last sleep. */
567 __u32 lc_new_scanned;
572 #define LFSCK_LMV_MAX_STRIPES LMV_MAX_STRIPE_COUNT
573 #define LFSCK_LMV_DEF_STRIPES 4
575 /* Warning: NOT change the lfsck_slave_lmv_flags members order,
576 * otherwise the lfsck_record_lmv() may be wrong. */
577 enum lfsck_slave_lmv_flags {
585 /* When the namespace LFSCK scans a striped directory, it will record all
586 * the known shards' information in the structure "lfsck_slave_lmv_rec",
587 * including the shard's FID, index, slave LMV EA, and so on. Each shard
588 * will take one lfsck_slave_lmv_rec slot. After the 1st cycle scanning
589 * the striped directory, the LFSCK will get all the information about
590 * whether there are some inconsistency, and then it can repair them in
591 * the 2nd cycle scanning. */
592 struct lfsck_slave_lmv_rec {
593 struct lu_fid lslr_fid;
594 __u32 lslr_stripe_count;
595 __u32 lslr_index; /* the index in name or in slave lmv */
596 __u32 lslr_hash_type;
601 struct lmv_mds_md_v1 ll_lmv;
603 int ll_stripes_allocated;
604 int ll_stripes_filled;
606 __u32 ll_max_stripe_count;
607 __u32 ll_max_filled_off;
609 unsigned int ll_lmv_master:1,
616 struct lfsck_slave_lmv_rec *ll_lslr; /* may be vmalloc'd */
619 /* If the namespace LFSCK finds that the master MDT-object of a striped
620 * directory lost its master LMV EA, it will re-generate the master LMV
621 * EA and notify the LFSCK instance on the MDT on which the striped dir
622 * master MDT-object resides to rescan the striped directory. To do that,
623 * the notify handler will insert a "lfsck_lmv_unit" structure into the
624 * lfsck::li_list_lmv. The LFSCK instance will scan such list from time
625 * to time to check whether needs to rescan some stirped directories. */
626 struct lfsck_lmv_unit {
627 struct list_head llu_link;
628 struct lfsck_lmv llu_lmv;
629 struct dt_object *llu_obj;
630 struct lfsck_instance *llu_lfsck;
633 struct lfsck_rec_lmv_save {
634 struct lu_fid lrls_fid;
635 struct lmv_mds_md_v1 lrls_lmv;
638 /* Allow lfsck_record_lmv() to be called recursively at most three times. */
639 #define LFSCK_REC_LMV_MAX_DEPTH 3
641 struct lfsck_instance {
642 struct mutex li_mutex;
645 /* Link into the lfsck_instance_list. */
646 struct list_head li_link;
648 /* For the components in (first) scanning via otable-based iteration. */
649 struct list_head li_list_scan;
651 /* For the components in scanning via directory traversal. Because
652 * directory traversal cannot guarantee all the object be scanned,
653 * so the component in the li_list_dir must be in li_list_scan. */
654 struct list_head li_list_dir;
656 /* For the components in double scanning. */
657 struct list_head li_list_double_scan;
659 /* For the components those are not scanning now. */
660 struct list_head li_list_idle;
662 /* For the lfsck_lmv_unit to be handled. */
663 struct list_head li_list_lmv;
666 atomic_t li_double_scan_count;
667 struct ptlrpc_thread li_thread;
669 /* The time for last checkpoint, jiffies */
670 cfs_time_t li_time_last_checkpoint;
672 /* The time for next checkpoint, jiffies */
673 cfs_time_t li_time_next_checkpoint;
675 lfsck_out_notify li_out_notify;
676 void *li_out_notify_data;
677 struct dt_device *li_next;
678 struct dt_device *li_bottom;
679 struct obd_device *li_obd;
680 struct ldlm_namespace *li_namespace;
681 struct local_oid_storage *li_los;
682 struct lu_fid li_local_root_fid; /* backend root "/" */
683 struct lu_fid li_global_root_fid; /* /ROOT */
684 struct dt_object *li_lfsck_dir;
685 struct dt_object *li_bookmark_obj;
686 struct dt_object *li_lpf_obj;
687 struct dt_object *li_lpf_root_obj;
688 struct lu_client_seq *li_seq;
689 struct lfsck_bookmark li_bookmark_ram;
690 struct lfsck_bookmark li_bookmark_disk;
691 struct lfsck_position li_pos_current;
692 struct lfsck_position li_pos_checkpoint;
694 struct lfsck_lmv *li_lmv;
696 /* Obj for otable-based iteration */
697 struct dt_object *li_obj_oit;
699 /* Obj for directory traversal */
700 struct dt_object *li_obj_dir;
702 /* It for otable-based iteration */
703 struct dt_it *li_di_oit;
705 /* It for directory traversal */
706 struct dt_it *li_di_dir;
708 /* Description of OST */
709 struct lfsck_tgt_descs li_ost_descs;
711 /* Description of MDT */
712 struct lfsck_tgt_descs li_mdt_descs;
714 /* namespace-based directory traversal position. */
717 /* Arguments for low layer otable-based iteration. */
720 /* Arugments for namespace-based directory traversal. */
723 /* Schedule for every N objects. */
726 /* Sleep N jiffies for each schedule. */
729 /* How many objects have been scanned since last sleep. */
730 __u32 li_new_scanned;
732 /* The status when the LFSCK stopped or paused. */
735 /* The flags when the lFSCK stopped or paused. */
738 unsigned int li_oit_over:1, /* oit is finished. */
739 li_drop_dryrun:1, /* Ever dryrun, not now. */
740 li_master:1, /* Master instance or not. */
741 li_current_oit_processed:1,
743 struct lfsck_rec_lmv_save li_rec_lmv_save[LFSCK_REC_LMV_MAX_DEPTH];
746 struct lfsck_async_interpret_args {
747 struct lfsck_component *laia_com;
748 struct lfsck_tgt_descs *laia_ltds;
749 struct lfsck_tgt_desc *laia_ltd;
750 struct lfsck_request *laia_lr;
751 atomic_t *laia_count;
753 unsigned int laia_shared:1;
756 struct lfsck_thread_args {
757 struct lu_env lta_env;
758 struct lfsck_instance *lta_lfsck;
759 struct lfsck_component *lta_com;
760 struct lfsck_start_param *lta_lsp;
763 struct lfsck_assistant_req {
764 struct list_head lar_list;
765 struct lfsck_assistant_object *lar_parent;
768 struct lfsck_namespace_req {
769 struct lfsck_assistant_req lnr_lar;
770 struct lfsck_lmv *lnr_lmv;
771 struct lu_fid lnr_fid;
772 __u64 lnr_dir_cookie;
780 struct lfsck_layout_req {
781 struct lfsck_assistant_req llr_lar;
782 struct dt_object *llr_child;
784 __u32 llr_lov_idx; /* offset in LOV EA */
787 struct lfsck_assistant_operations {
788 int (*la_handler_p1)(const struct lu_env *env,
789 struct lfsck_component *com,
790 struct lfsck_assistant_req *lar);
792 int (*la_handler_p2)(const struct lu_env *env,
793 struct lfsck_component *com);
795 void (*la_fill_pos)(const struct lu_env *env,
796 struct lfsck_component *com,
797 struct lfsck_position *pos);
799 int (*la_double_scan_result)(const struct lu_env *env,
800 struct lfsck_component *com,
803 void (*la_req_fini)(const struct lu_env *env,
804 struct lfsck_assistant_req *lar);
806 void (*la_sync_failures)(const struct lu_env *env,
807 struct lfsck_component *com,
808 struct lfsck_request *lr);
811 struct lfsck_assistant_data {
813 struct list_head lad_req_list;
815 /* list for the ost targets involve LFSCK. */
816 struct list_head lad_ost_list;
818 /* list for the ost targets in phase1 scanning. */
819 struct list_head lad_ost_phase1_list;
821 /* list for the ost targets in phase2 scanning. */
822 struct list_head lad_ost_phase2_list;
824 /* list for the mdt targets involve LFSCK. */
825 struct list_head lad_mdt_list;
827 /* list for the mdt targets in phase1 scanning. */
828 struct list_head lad_mdt_phase1_list;
830 /* list for the mdt targets in phase2 scanning. */
831 struct list_head lad_mdt_phase2_list;
833 const char *lad_name;
834 struct ptlrpc_thread lad_thread;
835 struct task_struct *lad_task;
837 struct lfsck_assistant_operations *lad_ops;
839 struct cfs_bitmap *lad_bitmap;
843 int lad_assistant_status;
845 unsigned int lad_to_post:1,
846 lad_to_double_scan:1,
847 lad_in_double_scan:1,
850 bool lad_advance_lock;
853 #define LFSCK_TMPBUF_LEN 64
855 struct lfsck_lock_handle {
856 struct lustre_handle llh_pdo_lh;
857 struct lustre_handle llh_reg_lh;
858 enum ldlm_mode llh_pdo_mode;
859 enum ldlm_mode llh_reg_mode;
862 struct lfsck_thread_info {
863 struct lu_name lti_name_const;
864 struct lu_name lti_name;
865 struct lu_name lti_name2;
866 struct lu_buf lti_buf;
867 struct lu_buf lti_linkea_buf;
868 struct lu_buf lti_linkea_buf2;
869 struct lu_buf lti_big_buf;
870 struct lu_fid lti_fid;
871 struct lu_fid lti_fid2;
872 struct lu_fid lti_fid3;
873 struct lu_fid lti_fid4;
874 struct lu_attr lti_la;
875 struct lu_attr lti_la2;
876 struct ost_id lti_oi;
878 struct lustre_mdt_attrs lti_lma;
879 /* old LMA for compatibility */
880 char lti_lma_old[LMA_OLD_SIZE];
882 struct dt_object_format lti_dof;
883 /* There will be '\0' at the end of the name. */
884 char lti_key[sizeof(struct lu_dirent) + NAME_MAX + 1];
885 char lti_tmpbuf[LFSCK_TMPBUF_LEN];
886 char lti_tmpbuf2[LFSCK_TMPBUF_LEN];
887 struct lfsck_request lti_lr;
888 struct lfsck_async_interpret_args lti_laia;
889 struct lfsck_async_interpret_args lti_laia2;
890 struct lfsck_start lti_start;
891 struct lfsck_stop lti_stop;
892 union ldlm_policy_data lti_policy;
893 struct ldlm_enqueue_info lti_einfo;
894 struct ldlm_res_id lti_resid;
896 struct filter_fid_old lti_old_pfid;
897 struct filter_fid lti_new_pfid;
899 struct dt_allocation_hint lti_hint;
900 struct lu_orphan_rec lti_rec;
901 struct lov_user_md lti_lum;
902 struct dt_insert_rec lti_dt_rec;
903 struct lu_object_conf lti_conf;
904 struct lu_seq_range lti_range;
905 struct lmv_mds_md_v1 lti_lmv;
906 struct lmv_mds_md_v1 lti_lmv2;
907 struct lmv_mds_md_v1 lti_lmv3;
908 struct lmv_mds_md_v1 lti_lmv4;
909 struct lfsck_lock_handle lti_llh;
913 int lfsck_fid_alloc(const struct lu_env *env, struct lfsck_instance *lfsck,
914 struct lu_fid *fid, bool locked);
915 int lfsck_ibits_lock(const struct lu_env *env, struct lfsck_instance *lfsck,
916 struct dt_object *obj, struct lustre_handle *lh,
917 __u64 bits, enum ldlm_mode mode);
918 void lfsck_ibits_unlock(struct lustre_handle *lh, enum ldlm_mode mode);
919 int lfsck_lock(const struct lu_env *env, struct lfsck_instance *lfsck,
920 struct dt_object *obj, const char *name,
921 struct lfsck_lock_handle *llh, __u64 bits, enum ldlm_mode mode);
922 void lfsck_unlock(struct lfsck_lock_handle *llh);
923 int lfsck_find_mdt_idx_by_fid(const struct lu_env *env,
924 struct lfsck_instance *lfsck,
925 const struct lu_fid *fid);
926 int lfsck_verify_lpf(const struct lu_env *env, struct lfsck_instance *lfsck);
927 struct lfsck_instance *lfsck_instance_find(struct dt_device *key, bool ref,
929 struct lfsck_component *lfsck_component_find(struct lfsck_instance *lfsck,
931 void lfsck_component_cleanup(const struct lu_env *env,
932 struct lfsck_component *com);
933 void lfsck_instance_cleanup(const struct lu_env *env,
934 struct lfsck_instance *lfsck);
935 void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
937 void lfsck_time_dump(struct seq_file *m, __u64 time, const char *name);
938 void lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
940 void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
941 struct lfsck_position *pos, bool init);
942 bool __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit);
943 void lfsck_control_speed(struct lfsck_instance *lfsck);
944 void lfsck_control_speed_by_self(struct lfsck_component *com);
945 void lfsck_thread_args_fini(struct lfsck_thread_args *lta);
946 struct lfsck_assistant_data *
947 lfsck_assistant_data_init(struct lfsck_assistant_operations *lao,
949 struct lfsck_assistant_object *
950 lfsck_assistant_object_init(const struct lu_env *env, const struct lu_fid *fid,
951 const struct lu_attr *attr, __u64 cookie,
954 lfsck_assistant_object_load(const struct lu_env *env,
955 struct lfsck_instance *lfsck,
956 struct lfsck_assistant_object *lso);
957 int lfsck_async_interpret_common(const struct lu_env *env,
958 struct ptlrpc_request *req,
960 int lfsck_async_request(const struct lu_env *env, struct obd_export *exp,
961 struct lfsck_request *lr,
962 struct ptlrpc_request_set *set,
963 ptlrpc_interpterer_t interpterer,
964 void *args, int request);
965 int lfsck_query_all(const struct lu_env *env, struct lfsck_component *com);
966 int lfsck_start_assistant(const struct lu_env *env, struct lfsck_component *com,
967 struct lfsck_start_param *lsp);
968 int lfsck_checkpoint_generic(const struct lu_env *env,
969 struct lfsck_component *com);
970 void lfsck_post_generic(const struct lu_env *env,
971 struct lfsck_component *com, int *result);
972 int lfsck_double_scan_generic(const struct lu_env *env,
973 struct lfsck_component *com, int status);
974 void lfsck_quit_generic(const struct lu_env *env,
975 struct lfsck_component *com);
976 int lfsck_load_one_trace_file(const struct lu_env *env,
977 struct lfsck_component *com,
978 struct dt_object *parent,
979 struct dt_object **child,
980 const struct dt_index_features *ft,
981 const char *name, bool reset);
982 int lfsck_load_sub_trace_files(const struct lu_env *env,
983 struct lfsck_component *com,
984 const struct dt_index_features *ft,
985 const char *prefix, bool reset);
988 int lfsck_unpack_ent(struct lu_dirent *ent, __u64 *cookie, __u16 *type);
989 void lfsck_close_dir(const struct lu_env *env,
990 struct lfsck_instance *lfsck, int result);
991 int lfsck_open_dir(const struct lu_env *env,
992 struct lfsck_instance *lfsck, __u64 cookie);
993 int lfsck_master_engine(void *args);
994 int lfsck_assistant_engine(void *args);
996 /* lfsck_bookmark.c */
997 void lfsck_bookmark_cpu_to_le(struct lfsck_bookmark *des,
998 struct lfsck_bookmark *src);
999 int lfsck_bookmark_store(const struct lu_env *env,
1000 struct lfsck_instance *lfsck);
1001 int lfsck_bookmark_setup(const struct lu_env *env,
1002 struct lfsck_instance *lfsck);
1003 int lfsck_set_param(const struct lu_env *env, struct lfsck_instance *lfsck,
1004 struct lfsck_start *start, bool reset);
1006 /* lfsck_namespace.c */
1007 int lfsck_namespace_trace_update(const struct lu_env *env,
1008 struct lfsck_component *com,
1009 const struct lu_fid *fid,
1010 const __u8 flags, bool add);
1011 int lfsck_namespace_check_exist(const struct lu_env *env,
1012 struct dt_object *dir,
1013 struct dt_object *obj, const char *name);
1014 int __lfsck_links_read(const struct lu_env *env, struct dt_object *obj,
1015 struct linkea_data *ldata, bool with_rec);
1016 int lfsck_namespace_rebuild_linkea(const struct lu_env *env,
1017 struct lfsck_component *com,
1018 struct dt_object *obj,
1019 struct linkea_data *ldata);
1020 int lfsck_namespace_repair_dangling(const struct lu_env *env,
1021 struct lfsck_component *com,
1022 struct dt_object *parent,
1023 struct dt_object *child,
1024 struct lfsck_namespace_req *lnr);
1025 int lfsck_namespace_repair_dirent(const struct lu_env *env,
1026 struct lfsck_component *com,
1027 struct dt_object *parent,
1028 struct dt_object *child,
1029 const char *name, const char *name2,
1030 __u16 type, bool update, bool dec);
1031 int lfsck_verify_linkea(const struct lu_env *env, struct dt_object *obj,
1032 const struct lu_name *cname, const struct lu_fid *pfid);
1033 int lfsck_links_get_first(const struct lu_env *env, struct dt_object *obj,
1034 char *name, struct lu_fid *pfid);
1035 int lfsck_update_name_entry(const struct lu_env *env,
1036 struct lfsck_instance *lfsck,
1037 struct dt_object *dir, const char *name,
1038 const struct lu_fid *fid, __u32 type);
1039 int lfsck_namespace_setup(const struct lu_env *env,
1040 struct lfsck_instance *lfsck);
1042 /* lfsck_striped_dir.c */
1043 void lfsck_lmv_put(const struct lu_env *env, struct lfsck_lmv *llmv);
1044 int lfsck_read_stripe_lmv(const struct lu_env *env, struct dt_object *obj,
1045 struct lmv_mds_md_v1 *lmv);
1046 int lfsck_shard_name_to_index(const struct lu_env *env, const char *name,
1047 int namelen, __u16 type,
1048 const struct lu_fid *fid);
1049 bool lfsck_is_valid_slave_name_entry(const struct lu_env *env,
1050 struct lfsck_lmv *llmv,
1051 const char *name, int namelen);
1052 int lfsck_namespace_check_name(const struct lu_env *env,
1053 struct dt_object *parent,
1054 struct dt_object *child,
1055 const struct lu_name *cname);
1056 int lfsck_namespace_update_lmv(const struct lu_env *env,
1057 struct lfsck_component *com,
1058 struct dt_object *obj,
1059 struct lmv_mds_md_v1 *lmv, bool locked);
1060 int lfsck_namespace_verify_stripe_slave(const struct lu_env *env,
1061 struct lfsck_component *com,
1062 struct dt_object *obj,
1063 struct lfsck_lmv *llmv);
1064 int lfsck_namespace_scan_shard(const struct lu_env *env,
1065 struct lfsck_component *com,
1066 struct dt_object *child);
1067 int lfsck_namespace_notify_lmv_master_local(const struct lu_env *env,
1068 struct lfsck_component *com,
1069 struct dt_object *obj);
1070 int lfsck_namespace_repair_bad_name_hash(const struct lu_env *env,
1071 struct lfsck_component *com,
1072 struct dt_object *shard,
1073 struct lfsck_lmv *llmv,
1075 int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
1076 struct lfsck_component *com,
1077 struct lfsck_namespace_req *lnr);
1078 int lfsck_namespace_handle_striped_master(const struct lu_env *env,
1079 struct lfsck_component *com,
1080 struct lfsck_namespace_req *lnr);
1082 /* lfsck_layout.c */
1083 int lfsck_layout_setup(const struct lu_env *env, struct lfsck_instance *lfsck);
1085 extern const char dot[];
1086 extern const char dotdot[];
1087 extern const char *lfsck_flags_names[];
1088 extern const char *lfsck_param_names[];
1089 extern struct lu_context_key lfsck_thread_key;
1091 static inline bool name_is_dot_or_dotdot(const char *name, int namelen)
1093 return name[0] == '.' &&
1094 (namelen == 1 || (namelen == 2 && name[1] == '.'));
1097 static inline struct dt_device *lfsck_obj2dev(struct dt_object *obj)
1099 return container_of0(obj->do_lu.lo_dev, struct dt_device, dd_lu_dev);
1102 static inline struct lfsck_thread_info *
1103 lfsck_env_info(const struct lu_env *env)
1105 struct lfsck_thread_info *info;
1107 info = lu_context_key_get(&env->le_ctx, &lfsck_thread_key);
1108 LASSERT(info != NULL);
1112 static inline const struct lu_name *
1113 lfsck_name_get_const(const struct lu_env *env, const void *area, ssize_t len)
1115 struct lu_name *lname;
1117 lname = &lfsck_env_info(env)->lti_name_const;
1118 lname->ln_name = area;
1119 lname->ln_namelen = len;
1124 lfsck_buf_init(struct lu_buf *buf, void *area, ssize_t len)
1130 static inline struct lu_buf *
1131 lfsck_buf_get(const struct lu_env *env, void *area, ssize_t len)
1135 buf = &lfsck_env_info(env)->lti_buf;
1141 static inline const struct lu_buf *
1142 lfsck_buf_get_const(const struct lu_env *env, const void *area, ssize_t len)
1146 buf = &lfsck_env_info(env)->lti_buf;
1147 buf->lb_buf = (void *)area;
1152 static inline char *lfsck_lfsck2name(struct lfsck_instance *lfsck)
1154 return lfsck->li_bottom->dd_lu_dev.ld_obd->obd_name;
1157 static inline const struct lu_fid *lfsck_dto2fid(const struct dt_object *obj)
1159 return lu_object_fid(&obj->do_lu);
1162 static inline void lfsck_pos_set_zero(struct lfsck_position *pos)
1164 memset(pos, 0, sizeof(*pos));
1167 static inline int lfsck_pos_is_zero(const struct lfsck_position *pos)
1169 return pos->lp_oit_cookie == 0 && fid_is_zero(&pos->lp_dir_parent);
1172 static inline int lfsck_pos_is_eq(const struct lfsck_position *pos1,
1173 const struct lfsck_position *pos2)
1175 if (pos1->lp_oit_cookie < pos2->lp_oit_cookie)
1178 if (pos1->lp_oit_cookie > pos2->lp_oit_cookie)
1181 if (fid_is_zero(&pos1->lp_dir_parent) &&
1182 !fid_is_zero(&pos2->lp_dir_parent))
1185 if (!fid_is_zero(&pos1->lp_dir_parent) &&
1186 fid_is_zero(&pos2->lp_dir_parent))
1189 if (fid_is_zero(&pos1->lp_dir_parent) &&
1190 fid_is_zero(&pos2->lp_dir_parent))
1193 LASSERT(lu_fid_eq(&pos1->lp_dir_parent, &pos2->lp_dir_parent));
1195 if (pos1->lp_dir_cookie < pos2->lp_dir_cookie)
1198 if (pos1->lp_dir_cookie > pos2->lp_dir_cookie)
1204 static void inline lfsck_position_le_to_cpu(struct lfsck_position *des,
1205 struct lfsck_position *src)
1207 des->lp_oit_cookie = le64_to_cpu(src->lp_oit_cookie);
1208 fid_le_to_cpu(&des->lp_dir_parent, &src->lp_dir_parent);
1209 des->lp_dir_cookie = le64_to_cpu(src->lp_dir_cookie);
1212 static void inline lfsck_position_cpu_to_le(struct lfsck_position *des,
1213 struct lfsck_position *src)
1215 des->lp_oit_cookie = cpu_to_le64(src->lp_oit_cookie);
1216 fid_cpu_to_le(&des->lp_dir_parent, &src->lp_dir_parent);
1217 des->lp_dir_cookie = cpu_to_le64(src->lp_dir_cookie);
1220 static inline umode_t lfsck_object_type(const struct dt_object *obj)
1222 return lu_object_attr(&obj->do_lu);
1225 static inline int lfsck_is_dead_obj(const struct dt_object *obj)
1227 struct lu_object_header *loh = obj->do_lu.lo_header;
1229 return !!test_bit(LU_OBJECT_HEARD_BANSHEE, &loh->loh_flags);
1232 static inline struct dt_object *lfsck_object_get(struct dt_object *obj)
1234 lu_object_get(&obj->do_lu);
1238 static inline void lfsck_object_put(const struct lu_env *env,
1239 struct dt_object *obj)
1241 lu_object_put(env, &obj->do_lu);
1244 static inline struct seq_server_site
1245 *lfsck_dev_site(struct lfsck_instance *lfsck)
1247 return lu_site2seq(lfsck->li_bottom->dd_lu_dev.ld_site);
1250 static inline u32 lfsck_dev_idx(struct lfsck_instance *lfsck)
1252 return lfsck_dev_site(lfsck)->ss_node_id;
1255 static inline struct dt_object *
1256 lfsck_object_find_by_dev_new(const struct lu_env *env, struct dt_device *dev,
1257 const struct lu_fid *fid)
1259 struct lu_object_conf *conf = &lfsck_env_info(env)->lti_conf;
1261 conf->loc_flags = LOC_F_NEW;
1262 return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, conf));
1265 static inline struct dt_object *
1266 lfsck_object_find_by_dev_nowait(const struct lu_env *env, struct dt_device *dev,
1267 const struct lu_fid *fid)
1269 struct lu_object_conf *conf = &lfsck_env_info(env)->lti_conf;
1271 conf->loc_flags = LOC_F_NOWAIT;
1272 return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, conf));
1275 static inline struct dt_object *
1276 lfsck_object_find_by_dev(const struct lu_env *env, struct dt_device *dev,
1277 const struct lu_fid *fid)
1279 return lu2dt(lu_object_find_slice(env, dt2lu_dev(dev), fid, NULL));
1282 static inline struct dt_device *
1283 lfsck_find_dev_by_fid(const struct lu_env *env, struct lfsck_instance *lfsck,
1284 const struct lu_fid *fid)
1286 struct dt_device *dev;
1289 if (!lfsck->li_master)
1290 return lfsck->li_bottom;
1292 idx = lfsck_find_mdt_idx_by_fid(env, lfsck, fid);
1294 return ERR_PTR(idx);
1296 if (idx == lfsck_dev_idx(lfsck)) {
1297 dev = lfsck->li_bottom;
1299 struct lfsck_tgt_desc *ltd;
1301 ltd = lfsck_ltd2tgt(&lfsck->li_mdt_descs, idx);
1302 if (unlikely(ltd == NULL))
1303 return ERR_PTR(-ENODEV);
1311 static inline struct dt_object *
1312 lfsck_object_find_bottom(const struct lu_env *env, struct lfsck_instance *lfsck,
1313 const struct lu_fid *fid)
1315 struct dt_device *dev;
1317 dev = lfsck_find_dev_by_fid(env, lfsck, fid);
1319 return (struct dt_object *)dev;
1321 return lfsck_object_find_by_dev(env, dev, fid);
1324 static inline struct dt_object *
1325 lfsck_object_find_bottom_nowait(const struct lu_env *env,
1326 struct lfsck_instance *lfsck,
1327 const struct lu_fid *fid)
1329 struct dt_device *dev;
1331 dev = lfsck_find_dev_by_fid(env, lfsck, fid);
1333 return (struct dt_object *)dev;
1335 return lfsck_object_find_by_dev_nowait(env, dev, fid);
1338 static inline struct dt_object *
1339 lfsck_object_find_bottom_new(const struct lu_env *env,
1340 struct lfsck_instance *lfsck,
1341 const struct lu_fid *fid)
1343 struct dt_device *dev;
1345 dev = lfsck_find_dev_by_fid(env, lfsck, fid);
1347 return (struct dt_object *)dev;
1349 return lfsck_object_find_by_dev_new(env, dev, fid);
1352 static inline struct dt_object *
1353 lfsck_object_locate(struct dt_device *dev, struct dt_object *obj)
1355 if (lfsck_obj2dev(obj) == dev) {
1358 struct lu_object *lo;
1360 lo = lu_object_locate(obj->do_lu.lo_header,
1361 dev->dd_lu_dev.ld_type);
1362 if (unlikely(lo == NULL))
1363 return ERR_PTR(-ENOENT);
1369 static inline struct lfsck_tgt_desc *lfsck_tgt_get(struct lfsck_tgt_descs *ltds,
1372 struct lfsck_tgt_desc *ltd;
1374 ltd = lfsck_ltd2tgt(ltds, index);
1376 atomic_inc(<d->ltd_ref);
1381 static inline void lfsck_tgt_put(struct lfsck_tgt_desc *ltd)
1383 if (atomic_dec_and_test(<d->ltd_ref))
1387 static inline struct lfsck_component *
1388 lfsck_component_get(struct lfsck_component *com)
1390 atomic_inc(&com->lc_ref);
1395 static inline void lfsck_component_put(const struct lu_env *env,
1396 struct lfsck_component *com)
1398 if (atomic_dec_and_test(&com->lc_ref)) {
1399 struct lfsck_sub_trace_obj *lsto;
1402 for (i = 0, lsto = &com->lc_sub_trace_objs[0];
1403 i < LFSCK_STF_COUNT; i++, lsto++) {
1404 if (lsto->lsto_obj != NULL)
1405 lfsck_object_put(env, lsto->lsto_obj);
1408 if (com->lc_obj != NULL)
1409 lfsck_object_put(env, com->lc_obj);
1410 if (com->lc_file_ram != NULL)
1411 OBD_FREE(com->lc_file_ram, com->lc_file_size);
1412 if (com->lc_file_disk != NULL)
1413 OBD_FREE(com->lc_file_disk, com->lc_file_size);
1414 if (com->lc_data != NULL) {
1415 LASSERT(com->lc_ops->lfsck_data_release != NULL);
1417 com->lc_ops->lfsck_data_release(env, com);
1424 static inline struct lfsck_instance *
1425 lfsck_instance_get(struct lfsck_instance *lfsck)
1427 atomic_inc(&lfsck->li_ref);
1432 static inline void lfsck_instance_put(const struct lu_env *env,
1433 struct lfsck_instance *lfsck)
1435 if (atomic_dec_and_test(&lfsck->li_ref))
1436 lfsck_instance_cleanup(env, lfsck);
1439 static inline bool lfsck_phase2_next_ready(struct lfsck_assistant_data *lad)
1441 return list_empty(&lad->lad_mdt_phase1_list) &&
1442 (!list_empty(&lad->lad_ost_phase2_list) ||
1443 list_empty(&lad->lad_ost_phase1_list));
1446 static inline void lfsck_lad_set_bitmap(const struct lu_env *env,
1447 struct lfsck_component *com,
1450 struct lfsck_assistant_data *lad = com->lc_data;
1451 struct cfs_bitmap *bitmap = lad->lad_bitmap;
1453 LASSERT(com->lc_lfsck->li_master);
1454 LASSERT(bitmap != NULL);
1456 if (likely(bitmap->size > index)) {
1457 cfs_bitmap_set(bitmap, index);
1458 lad->lad_incomplete = 1;
1459 } else if (com->lc_type == LFSCK_TYPE_NAMESPACE) {
1460 struct lfsck_namespace *ns = com->lc_file_ram;
1462 ns->ln_flags |= LF_INCOMPLETE;
1466 static inline int lfsck_links_read(const struct lu_env *env,
1467 struct dt_object *obj,
1468 struct linkea_data *ldata)
1471 lu_buf_check_and_alloc(&lfsck_env_info(env)->lti_linkea_buf,
1474 return __lfsck_links_read(env, obj, ldata, false);
1477 /* Read linkEA for the given object, the linkEA should contain
1478 * at least one entry, otherwise, -ENODATA will be returned. */
1479 static inline int lfsck_links_read_with_rec(const struct lu_env *env,
1480 struct dt_object *obj,
1481 struct linkea_data *ldata)
1484 lu_buf_check_and_alloc(&lfsck_env_info(env)->lti_linkea_buf,
1487 return __lfsck_links_read(env, obj, ldata, true);
1490 static inline int lfsck_links_read2_with_rec(const struct lu_env *env,
1491 struct dt_object *obj,
1492 struct linkea_data *ldata)
1495 lu_buf_check_and_alloc(&lfsck_env_info(env)->lti_linkea_buf2,
1498 return __lfsck_links_read(env, obj, ldata, true);
1501 static inline struct lfsck_lmv *lfsck_lmv_get(struct lfsck_lmv *llmv)
1504 atomic_inc(&llmv->ll_ref);
1509 static inline int lfsck_sub_trace_file_fid2idx(const struct lu_fid *fid)
1511 return fid->f_oid & (LFSCK_STF_COUNT - 1);
1514 static inline void lfsck_lmv_header_le_to_cpu(struct lmv_mds_md_v1 *dst,
1515 const struct lmv_mds_md_v1 *src)
1517 dst->lmv_magic = le32_to_cpu(src->lmv_magic);
1518 dst->lmv_stripe_count = le32_to_cpu(src->lmv_stripe_count);
1519 dst->lmv_master_mdt_index = le32_to_cpu(src->lmv_master_mdt_index);
1520 dst->lmv_hash_type = le32_to_cpu(src->lmv_hash_type);
1521 dst->lmv_layout_version = le32_to_cpu(src->lmv_layout_version);
1524 static inline void lfsck_lmv_header_cpu_to_le(struct lmv_mds_md_v1 *dst,
1525 const struct lmv_mds_md_v1 *src)
1527 dst->lmv_magic = cpu_to_le32(src->lmv_magic);
1528 dst->lmv_stripe_count = cpu_to_le32(src->lmv_stripe_count);
1529 dst->lmv_master_mdt_index = cpu_to_le32(src->lmv_master_mdt_index);
1530 dst->lmv_hash_type = cpu_to_le32(src->lmv_hash_type);
1531 dst->lmv_layout_version = cpu_to_le32(src->lmv_layout_version);
1534 static inline struct lfsck_assistant_object *
1535 lfsck_assistant_object_get(struct lfsck_assistant_object *lso)
1537 atomic_inc(&lso->lso_ref);
1543 lfsck_assistant_object_put(const struct lu_env *env,
1544 struct lfsck_assistant_object *lso)
1546 if (atomic_dec_and_test(&lso->lso_ref))
1549 #endif /* _LFSCK_INTERNAL_H */