Btrfs: do not inc uncorrectable_errors counter on ro scrubs
PATCH 1/3 Btrfs: do not inc uncorrectable_errors counter on ro scrubs
Currently if we discover an error when scrubbing in ro mode we a) blindly increment the uncorrectable_errors counter, and b) spam the dmesg with the 'unable to fixup (regular) error at ...' message, even though a) we haven't tried to determine if the error is correctable or not, and b) we haven't tried to fixup anything. Fix this.
--- fs/btrfs/scrub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/scrub.c +4 -2
@@ -938,8 +938,10 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check) BTRFS_DEV_STAT_CORRUPTION_ERRS); } -if (sctx->readonly && !sctx->is_dev_replace) - goto did_not_correct_error; +if (sctx->readonly) { +ASSERT (!sctx->is_dev_replace); + goto out; + }if (!is_metadata && !have_csum) {struct scrub_fixup_nodatasum *fixup_nodatasum;
Signature · 1 line
1.7.10.4
PATCH 2/3 Btrfs: disable online raid-repair on ro mounts
This disables the "if needed, write the good copy back before the read is completed" part of the read sequence for read-only mounts.
--- fs/btrfs/extent_io.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/btrfs/extent_io.c +8 -3
@@ -1979,6 +1979,7 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;int ret; +ASSERT (!(fs_info->sb->s_flags &MS_RDONLY ));BUG_ON (!mirror_num);/* we can't repair anything in raid56 yet */
@@ -2035,6 +2036,9 @@ int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb,unsigned long i, num_pages =num_extent_pages (eb->start, eb->len);int ret =0 ; +if (root->fs_info->sb->s_flags &MS_RDONLY ) +return -EROFS ; +for (i =0 ; i < num_pages; i++) {struct page *p =extent_buffer_page (eb, i); ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE,
@@ -2056,12 +2060,12 @@ static int clean_io_failure(u64 start, struct page *page)u64 private;u64 private_failure;struct io_failure_record *failrec; -struct btrfs_fs_info *fs_info; +struct inode *inode = page->mapping->host; +struct btrfs_fs_info *fs_info =BTRFS_I (inode)->root->fs_info;struct extent_state *state;int num_copies;int did_repair =0 ;int ret; -struct inode *inode = page->mapping->host; private =0 ; ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private,
@@ -2084,6 +2088,8 @@ static int clean_io_failure(u64 start, struct page *page) did_repair =1 ; goto out; } +if (fs_info->sb->s_flags &MS_RDONLY ) + goto out;spin_lock (&BTRFS_I (inode)->io_tree.lock); state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree,
@@ -2093,7 +2099,6 @@ static int clean_io_failure(u64 start, struct page *page)if (state && state->start <= failrec->start && state->end >= failrec->start + failrec->len -1 ) { - fs_info =BTRFS_I (inode)->root->fs_info; num_copies =btrfs_num_copies (fs_info, failrec->logical, failrec->len);if (num_copies >1 ) {
Signature · 1 line
1.7.10.4
PATCH 3/3 Btrfs: fix __btrfs_start_workers retval
In reply to Ilya Dryomov__btrfs_start_workers returns 0 in case it raced with btrfs_stop_workers and lost the race. This is wrong because worker in this case is not allowed to start and is in fact destroyed. Return -EINVAL instead.
--- fs/btrfs/async-thread.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/async-thread.c +1 -0
@@ -495,6 +495,7 @@ static int __btrfs_start_workers(struct btrfs_workers *workers)spin_lock_irq (&workers->lock);if (workers->stopping) {spin_unlock_irq (&workers->lock); + ret = -EINVAL ; goto fail_kthread; }list_add_tail (&worker->worker_list, &workers->idle_list);
Signature · 1 line
1.7.10.4