diff options
author | Arne Jansen <sensille@gmx.net> | 2011-03-08 08:14:00 -0500 |
---|---|---|
committer | Arne Jansen <sensille@gmx.net> | 2011-05-12 08:45:20 -0400 |
commit | a2de733c78fa7af51ba9670482fa7d392aa67c57 (patch) | |
tree | d88817bc7aba94e7efea530efac5ef190c1b799c /fs/btrfs/disk-io.c | |
parent | 7cf96da3ec7ca225acf4f284b0e904a1f5f98821 (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/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index fe5aec9b3924..e48e8095c61f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1773,6 +1773,17 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1773 | INIT_LIST_HEAD(&fs_info->ordered_extents); | 1773 | INIT_LIST_HEAD(&fs_info->ordered_extents); |
1774 | spin_lock_init(&fs_info->ordered_extent_lock); | 1774 | spin_lock_init(&fs_info->ordered_extent_lock); |
1775 | 1775 | ||
1776 | mutex_init(&fs_info->scrub_lock); | ||
1777 | atomic_set(&fs_info->scrubs_running, 0); | ||
1778 | atomic_set(&fs_info->scrub_pause_req, 0); | ||
1779 | atomic_set(&fs_info->scrubs_paused, 0); | ||
1780 | atomic_set(&fs_info->scrub_cancel_req, 0); | ||
1781 | init_waitqueue_head(&fs_info->scrub_pause_wait); | ||
1782 | init_rwsem(&fs_info->scrub_super_lock); | ||
1783 | fs_info->scrub_workers_refcnt = 0; | ||
1784 | btrfs_init_workers(&fs_info->scrub_workers, "scrub", | ||
1785 | fs_info->thread_pool_size, &fs_info->generic_worker); | ||
1786 | |||
1776 | sb->s_blocksize = 4096; | 1787 | sb->s_blocksize = 4096; |
1777 | sb->s_blocksize_bits = blksize_bits(4096); | 1788 | sb->s_blocksize_bits = blksize_bits(4096); |
1778 | sb->s_bdi = &fs_info->bdi; | 1789 | sb->s_bdi = &fs_info->bdi; |
@@ -2599,6 +2610,7 @@ int close_ctree(struct btrfs_root *root) | |||
2599 | fs_info->closing = 1; | 2610 | fs_info->closing = 1; |
2600 | smp_mb(); | 2611 | smp_mb(); |
2601 | 2612 | ||
2613 | btrfs_scrub_cancel(root); | ||
2602 | btrfs_put_block_group_cache(fs_info); | 2614 | btrfs_put_block_group_cache(fs_info); |
2603 | 2615 | ||
2604 | /* | 2616 | /* |