aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file-item.c
diff options
context:
space:
mode:
authorArne Jansen <sensille@gmx.net>2011-03-08 08:14:00 -0500
committerArne Jansen <sensille@gmx.net>2011-05-12 08:45:20 -0400
commita2de733c78fa7af51ba9670482fa7d392aa67c57 (patch)
treed88817bc7aba94e7efea530efac5ef190c1b799c /fs/btrfs/file-item.c
parent7cf96da3ec7ca225acf4f284b0e904a1f5f98821 (diff)
btrfs: scrub
This adds an initial implementation for scrub. It works quite straightforward. The usermode issues an ioctl for each device in the fs. For each device, it enumerates the allocated device chunks. For each chunk, the contained extents are enumerated and the data checksums fetched. The extents are read sequentially and the checksums verified. If an error occurs (checksum or EIO), a good copy is searched for. If one is found, the bad copy will be rewritten. All enumerations happen from the commit roots. During a transaction commit, the scrubs get paused and afterwards continue from the new roots. This commit is based on the series originally posted to linux-btrfs with some improvements that resulted from comments from David Sterba, Ilya Dryomov and Jan Schmidt. Signed-off-by: Arne Jansen <sensille@gmx.net>
Diffstat (limited to 'fs/btrfs/file-item.c')
-rw-r--r--fs/btrfs/file-item.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index a6a9d4e8b491..39ca7c1250e7 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -266,7 +266,7 @@ int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
266} 266}
267 267
268int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, 268int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
269 struct list_head *list) 269 struct list_head *list, int search_commit)
270{ 270{
271 struct btrfs_key key; 271 struct btrfs_key key;
272 struct btrfs_path *path; 272 struct btrfs_path *path;
@@ -283,6 +283,12 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
283 path = btrfs_alloc_path(); 283 path = btrfs_alloc_path();
284 BUG_ON(!path); 284 BUG_ON(!path);
285 285
286 if (search_commit) {
287 path->skip_locking = 1;
288 path->reada = 2;
289 path->search_commit_root = 1;
290 }
291
286 key.objectid = BTRFS_EXTENT_CSUM_OBJECTID; 292 key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
287 key.offset = start; 293 key.offset = start;
288 key.type = BTRFS_EXTENT_CSUM_KEY; 294 key.type = BTRFS_EXTENT_CSUM_KEY;