Commit 908960c6 authored by Ilya Dryomov's avatar Ilya Dryomov Committed by Chris Mason

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.

Cc: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 33ef30ad
...@@ -1980,6 +1980,7 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start, ...@@ -1980,6 +1980,7 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
int ret; int ret;
ASSERT(!(fs_info->sb->s_flags & MS_RDONLY));
BUG_ON(!mirror_num); BUG_ON(!mirror_num);
/* we can't repair anything in raid56 yet */ /* we can't repair anything in raid56 yet */
...@@ -2036,6 +2037,9 @@ int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, ...@@ -2036,6 +2037,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); unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
int ret = 0; int ret = 0;
if (root->fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
struct page *p = extent_buffer_page(eb, i); struct page *p = extent_buffer_page(eb, i);
ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE, ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE,
...@@ -2057,12 +2061,12 @@ static int clean_io_failure(u64 start, struct page *page) ...@@ -2057,12 +2061,12 @@ static int clean_io_failure(u64 start, struct page *page)
u64 private; u64 private;
u64 private_failure; u64 private_failure;
struct io_failure_record *failrec; 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; struct extent_state *state;
int num_copies; int num_copies;
int did_repair = 0; int did_repair = 0;
int ret; int ret;
struct inode *inode = page->mapping->host;
private = 0; private = 0;
ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private, ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private,
...@@ -2085,6 +2089,8 @@ static int clean_io_failure(u64 start, struct page *page) ...@@ -2085,6 +2089,8 @@ static int clean_io_failure(u64 start, struct page *page)
did_repair = 1; did_repair = 1;
goto out; goto out;
} }
if (fs_info->sb->s_flags & MS_RDONLY)
goto out;
spin_lock(&BTRFS_I(inode)->io_tree.lock); spin_lock(&BTRFS_I(inode)->io_tree.lock);
state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree, state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree,
...@@ -2094,7 +2100,6 @@ static int clean_io_failure(u64 start, struct page *page) ...@@ -2094,7 +2100,6 @@ static int clean_io_failure(u64 start, struct page *page)
if (state && state->start <= failrec->start && if (state && state->start <= failrec->start &&
state->end >= failrec->start + failrec->len - 1) { state->end >= failrec->start + failrec->len - 1) {
fs_info = BTRFS_I(inode)->root->fs_info;
num_copies = btrfs_num_copies(fs_info, failrec->logical, num_copies = btrfs_num_copies(fs_info, failrec->logical,
failrec->len); failrec->len);
if (num_copies > 1) { if (num_copies > 1) {
......
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