Commit 0e735872 authored by Chris Mason's avatar Chris Mason

Merge branch 'for-chris' of...

Merge branch 'for-chris' of git://git.kernel.org/pub/scm/linux/kernel/git/arne/btrfs-unstable-arne into for-linus
parents 5be76758 6eef3125
...@@ -1668,8 +1668,6 @@ struct btrfs_root *open_ctree(struct super_block *sb, ...@@ -1668,8 +1668,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
init_waitqueue_head(&fs_info->scrub_pause_wait); init_waitqueue_head(&fs_info->scrub_pause_wait);
init_rwsem(&fs_info->scrub_super_lock); init_rwsem(&fs_info->scrub_super_lock);
fs_info->scrub_workers_refcnt = 0; fs_info->scrub_workers_refcnt = 0;
btrfs_init_workers(&fs_info->scrub_workers, "scrub",
fs_info->thread_pool_size, &fs_info->generic_worker);
sb->s_blocksize = 4096; sb->s_blocksize = 4096;
sb->s_blocksize_bits = blksize_bits(4096); sb->s_blocksize_bits = blksize_bits(4096);
......
...@@ -16,13 +16,7 @@ ...@@ -16,13 +16,7 @@
* Boston, MA 021110-1307, USA. * Boston, MA 021110-1307, USA.
*/ */
#include <linux/sched.h>
#include <linux/pagemap.h>
#include <linux/writeback.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/rbtree.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include "ctree.h" #include "ctree.h"
#include "volumes.h" #include "volumes.h"
#include "disk-io.h" #include "disk-io.h"
...@@ -804,18 +798,12 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev, ...@@ -804,18 +798,12 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev,
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
goto out; goto out_noplug;
l = path->nodes[0];
slot = path->slots[0];
btrfs_item_key_to_cpu(l, &key, slot);
if (key.objectid != logical) {
ret = btrfs_previous_item(root, path, 0,
BTRFS_EXTENT_ITEM_KEY);
if (ret < 0)
goto out;
}
/*
* we might miss half an extent here, but that doesn't matter,
* as it's only the prefetch
*/
while (1) { while (1) {
l = path->nodes[0]; l = path->nodes[0];
slot = path->slots[0]; slot = path->slots[0];
...@@ -824,7 +812,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev, ...@@ -824,7 +812,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev,
if (ret == 0) if (ret == 0)
continue; continue;
if (ret < 0) if (ret < 0)
goto out; goto out_noplug;
break; break;
} }
...@@ -906,15 +894,20 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev, ...@@ -906,15 +894,20 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev,
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
goto out; goto out;
if (ret > 0) {
l = path->nodes[0];
slot = path->slots[0];
btrfs_item_key_to_cpu(l, &key, slot);
if (key.objectid != logical) {
ret = btrfs_previous_item(root, path, 0, ret = btrfs_previous_item(root, path, 0,
BTRFS_EXTENT_ITEM_KEY); BTRFS_EXTENT_ITEM_KEY);
if (ret < 0) if (ret < 0)
goto out; goto out;
if (ret > 0) {
/* there's no smaller item, so stick with the
* larger one */
btrfs_release_path(path);
ret = btrfs_search_slot(NULL, root, &key,
path, 0, 0);
if (ret < 0)
goto out;
}
} }
while (1) { while (1) {
...@@ -989,6 +982,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev, ...@@ -989,6 +982,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev,
out: out:
blk_finish_plug(&plug); blk_finish_plug(&plug);
out_noplug:
btrfs_free_path(path); btrfs_free_path(path);
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
...@@ -1064,8 +1058,15 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end) ...@@ -1064,8 +1058,15 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end)
while (1) { while (1) {
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
goto out; break;
ret = 0; if (ret > 0) {
if (path->slots[0] >=
btrfs_header_nritems(path->nodes[0])) {
ret = btrfs_next_leaf(root, path);
if (ret)
break;
}
}
l = path->nodes[0]; l = path->nodes[0];
slot = path->slots[0]; slot = path->slots[0];
...@@ -1075,7 +1076,7 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end) ...@@ -1075,7 +1076,7 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end)
if (found_key.objectid != sdev->dev->devid) if (found_key.objectid != sdev->dev->devid)
break; break;
if (btrfs_key_type(&key) != BTRFS_DEV_EXTENT_KEY) if (btrfs_key_type(&found_key) != BTRFS_DEV_EXTENT_KEY)
break; break;
if (found_key.offset >= end) if (found_key.offset >= end)
...@@ -1104,7 +1105,7 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end) ...@@ -1104,7 +1105,7 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end)
cache = btrfs_lookup_block_group(fs_info, chunk_offset); cache = btrfs_lookup_block_group(fs_info, chunk_offset);
if (!cache) { if (!cache) {
ret = -ENOENT; ret = -ENOENT;
goto out; break;
} }
ret = scrub_chunk(sdev, chunk_tree, chunk_objectid, ret = scrub_chunk(sdev, chunk_tree, chunk_objectid,
chunk_offset, length); chunk_offset, length);
...@@ -1116,9 +1117,13 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end) ...@@ -1116,9 +1117,13 @@ int scrub_enumerate_chunks(struct scrub_dev *sdev, u64 start, u64 end)
btrfs_release_path(path); btrfs_release_path(path);
} }
out:
btrfs_free_path(path); btrfs_free_path(path);
return ret;
/*
* ret can still be 1 from search_slot or next_leaf,
* that's not an error
*/
return ret < 0 ? ret : 0;
} }
static noinline_for_stack int scrub_supers(struct scrub_dev *sdev) static noinline_for_stack int scrub_supers(struct scrub_dev *sdev)
...@@ -1155,8 +1160,12 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_root *root) ...@@ -1155,8 +1160,12 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_root *root)
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
mutex_lock(&fs_info->scrub_lock); mutex_lock(&fs_info->scrub_lock);
if (fs_info->scrub_workers_refcnt == 0) if (fs_info->scrub_workers_refcnt == 0) {
btrfs_init_workers(&fs_info->scrub_workers, "scrub",
fs_info->thread_pool_size, &fs_info->generic_worker);
fs_info->scrub_workers.idle_thresh = 4;
btrfs_start_workers(&fs_info->scrub_workers, 1); btrfs_start_workers(&fs_info->scrub_workers, 1);
}
++fs_info->scrub_workers_refcnt; ++fs_info->scrub_workers_refcnt;
mutex_unlock(&fs_info->scrub_lock); mutex_unlock(&fs_info->scrub_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment