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) 2012, 2013, Intel Corporation.
26 * lustre/osd-ldiskfs/osd_scrub.h
28 * Shared definitions and declarations for OI scrub.
30 * Author: Fan Yong <yong.fan@whamcloud.com>
38 #define SCRUB_MAGIC_V1 0x4C5FD252
39 #define SCRUB_CHECKPOINT_INTERVAL 60
40 #define SCRUB_OI_BITMAP_SIZE (OSD_OI_FID_NR_MAX >> 3)
41 #define SCRUB_WINDOW_SIZE 1024
44 /* The scrub file is new created, for new MDT, upgrading from old disk,
45 * or re-creating the scrub file manually. */
48 /* The scrub is checking/repairing the OI files. */
51 /* The scrub checked/repaired the OI files successfully. */
54 /* The scrub failed to check/repair the OI files. */
57 /* The scrub is stopped manually, the OI files may be inconsistent. */
60 /* The scrub is paused automatically when umount. */
63 /* The scrub crashed during the scanning, should be restarted. */
68 /* OI files have been recreated, OI mappings should be re-inserted. */
69 SF_RECREATED = 0x0000000000000001ULL,
71 /* OI files are invalid, should be rebuild ASAP */
72 SF_INCONSISTENT = 0x0000000000000002ULL,
74 /* OI scrub is triggered automatically. */
75 SF_AUTO = 0x0000000000000004ULL,
77 /* The device is upgraded from 1.8 format. */
78 SF_UPGRADE = 0x0000000000000008ULL,
87 /* Set failout flag. */
88 SS_SET_FAILOUT = 0x00000001,
90 /* Clear failout flag. */
91 SS_CLEAR_FAILOUT = 0x00000002,
93 /* Reset scrub start position. */
94 SS_RESET = 0x00000004,
96 /* Trigger scrub automatically. */
100 /* The flags here are only used inside OSD, NOT be visible by dump(). */
101 enum scrub_internal_flags {
102 /* This is a new formatted device. */
103 SIF_NO_HANDLE_OLD_FID = 0x0001,
107 /* 128-bit uuid for volume. */
110 /* See 'enum scrub_flags'. */
113 /* The scrub magic. */
116 /* See 'enum scrub_status'. */
119 /* See 'enum scrub_param'. */
122 /* The time for the last OI scrub completed. */
123 __u64 sf_time_last_complete;
125 /* The time for the latest OI scrub ran. */
126 __u64 sf_time_latest_start;
128 /* The time for the last OI scrub checkpoint. */
129 __u64 sf_time_last_checkpoint;
131 /* The position for the latest OI scrub started from. */
132 __u64 sf_pos_latest_start;
134 /* The position for the last OI scrub checkpoint. */
135 __u64 sf_pos_last_checkpoint;
137 /* The position for the first should be updated object. */
138 __u64 sf_pos_first_inconsistent;
140 /* How many objects have been checked. */
141 __u64 sf_items_checked;
143 /* How many objects have been updated. */
144 __u64 sf_items_updated;
146 /* How many objects failed to be processed. */
147 __u64 sf_items_failed;
149 /* How many prior objects have been updated during scanning. */
150 __u64 sf_items_updated_prior;
152 /* How many objects marked as LDISKFS_STATE_LUSTRE_NOSCRUB. */
153 __u64 sf_items_noscrub;
155 /* How many IGIF objects. */
158 /* How long the OI scrub has run. */
161 /* How many completed OI scrub ran on the device. */
162 __u32 sf_success_count;
164 /* How many OI files. */
167 /* Keep the flags after scrub reset. See 'enum scrub_internal_flags' */
168 __u16 sf_internal_flags;
171 __u64 sf_reserved_2[16];
173 /* Bitmap for OI files recreated case. */
174 __u8 sf_oi_bitmap[SCRUB_OI_BITMAP_SIZE];
178 struct lvfs_run_ctxt os_ctxt;
179 struct ptlrpc_thread os_thread;
180 struct osd_idmap_cache os_oic;
181 cfs_list_t os_inconsistent_items;
183 /* write lock for scrub prep/update/post/checkpoint,
184 * read lock for scrub dump. */
185 struct rw_semaphore os_rwsem;
188 /* Scrub file in memory. */
189 struct scrub_file os_file;
191 /* Buffer for scrub file load/store. */
192 struct scrub_file os_file_disk;
194 /* Inode for the scrub file. */
195 struct inode *os_inode;
197 /* The time for last checkpoint, jiffies */
198 cfs_time_t os_time_last_checkpoint;
200 /* The time for next checkpoint, jiffies */
201 cfs_time_t os_time_next_checkpoint;
203 /* statistics for /lost+found are in ram only, it will be reset
204 * when each time the device remount. */
206 /* How many objects have been scanned during initial OI scrub. */
208 /* How many objects have been repaired during initial OI scrub. */
209 __u64 os_lf_repaired;
210 /* How many objects failed to be processed during initial OI scrub. */
213 /* How many objects have been checked since last checkpoint. */
214 __u32 os_new_checked;
215 __u32 os_pos_current;
216 __u32 os_start_flags;
217 unsigned int os_in_prior:1, /* process inconsistent item
218 * found by RPC prior */
219 os_waiting:1, /* Waiting for scan window. */
220 os_full_speed:1, /* run w/o speed limit */
221 os_paused:1, /* The scrub is paused. */
225 #endif /* _OSD_SCRUB_H */