Whamcloud - gitweb
LU-13124 scrub: check for multiple linked file
[fs/lustre-release.git] / lustre / lfsck / lfsck_internal.h
index 428e28f..e6a8a48 100644 (file)
@@ -456,9 +456,6 @@ struct lfsck_operations {
                          struct lfsck_start_param *lsp);
 };
 
-#define TGT_PTRS               256     /* number of pointers at 1st level */
-#define TGT_PTRS_PER_BLOCK     256     /* number of pointers at 2nd level */
-
 struct lfsck_tgt_desc {
        struct list_head   ltd_orphan_list;
        struct dt_device  *ltd_tgt;
@@ -555,7 +552,7 @@ struct lfsck_component {
        struct lfsck_instance   *lc_lfsck;
        struct dt_object        *lc_obj;
        struct lfsck_sub_trace_obj lc_sub_trace_objs[LFSCK_STF_COUNT];
-       struct lfsck_operations *lc_ops;
+       const struct lfsck_operations *lc_ops;
        void                    *lc_file_ram;
        void                    *lc_file_disk;
        void                    *lc_data;
@@ -755,6 +752,11 @@ struct lfsck_instance {
        struct lfsck_rec_lmv_save li_rec_lmv_save[LFSCK_REC_LMV_MAX_DEPTH];
 };
 
+static inline bool lfsck_is_dryrun(struct lfsck_instance *lfsck)
+{
+       return lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN;
+}
+
 struct lfsck_async_interpret_args {
        struct lfsck_component          *laia_com;
        struct lfsck_tgt_descs          *laia_ltds;
@@ -847,7 +849,7 @@ struct lfsck_assistant_data {
        struct ptlrpc_thread                     lad_thread;
        struct task_struct                      *lad_task;
 
-       struct lfsck_assistant_operations       *lad_ops;
+       const struct lfsck_assistant_operations *lad_ops;
 
        struct cfs_bitmap                               *lad_bitmap;
 
@@ -946,7 +948,7 @@ void lfsck_component_cleanup(const struct lu_env *env,
                             struct lfsck_component *com);
 void lfsck_instance_cleanup(const struct lu_env *env,
                            struct lfsck_instance *lfsck);
-void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
+void lfsck_bits_dump(struct seq_file *m, int bits, const char *const names[],
                     const char *prefix);
 void lfsck_time_dump(struct seq_file *m, time64_t time, const char *name);
 void lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
@@ -958,7 +960,7 @@ void lfsck_control_speed(struct lfsck_instance *lfsck);
 void lfsck_control_speed_by_self(struct lfsck_component *com);
 void lfsck_thread_args_fini(struct lfsck_thread_args *lta);
 struct lfsck_assistant_data *
-lfsck_assistant_data_init(struct lfsck_assistant_operations *lao,
+lfsck_assistant_data_init(const struct lfsck_assistant_operations *lao,
                          const char *name);
 struct lfsck_assistant_object *
 lfsck_assistant_object_init(const struct lu_env *env, const struct lu_fid *fid,
@@ -1042,8 +1044,9 @@ int lfsck_namespace_repair_dirent(const struct lu_env *env,
                                  struct dt_object *child,
                                  const char *name, const char *name2,
                                  __u16 type, bool update, bool dec);
-int lfsck_verify_linkea(const struct lu_env *env, struct dt_object *obj,
-                       const struct lu_name *cname, const struct lu_fid *pfid);
+int lfsck_verify_linkea(const struct lu_env *env, struct lfsck_instance *lfsck,
+                       struct dt_object *obj, const struct lu_name *cname,
+                       const struct lu_fid *pfid);
 int lfsck_links_get_first(const struct lu_env *env, struct dt_object *obj,
                          char *name, struct lu_fid *pfid);
 int lfsck_update_name_entry(const struct lu_env *env,
@@ -1101,13 +1104,14 @@ int lfsck_layout_setup(const struct lu_env *env, struct lfsck_instance *lfsck);
 
 extern const char dot[];
 extern const char dotdot[];
-extern const char *lfsck_flags_names[];
-extern const char *lfsck_param_names[];
+extern const char *const lfsck_flags_names[];
+extern const char *const lfsck_param_names[];
 extern struct lu_context_key lfsck_thread_key;
 
 static inline struct dt_device *lfsck_obj2dev(struct dt_object *obj)
 {
-       return container_of0(obj->do_lu.lo_dev, struct dt_device, dd_lu_dev);
+       return container_of_safe(obj->do_lu.lo_dev, struct dt_device,
+                                dd_lu_dev);
 }
 
 static inline struct lfsck_thread_info *
@@ -1539,4 +1543,19 @@ lfsck_assistant_object_put(const struct lu_env *env,
        if (atomic_dec_and_test(&lso->lso_ref))
                OBD_FREE_PTR(lso);
 }
+
+static inline struct thandle*
+lfsck_trans_create(const struct lu_env *env, struct dt_device *dev,
+                  struct lfsck_instance *lfsck)
+{
+       if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN) {
+               CERROR("%s: transaction is being created in DRYRUN mode!\n",
+                      lfsck_lfsck2name(lfsck));
+
+               dump_stack();
+               return ERR_PTR(-EINVAL);
+       }
+
+       return dt_trans_create(env, dev);
+}
 #endif /* _LFSCK_INTERNAL_H */