Skip to content

Commit 908960c

Browse files
idryomovChris Mason
authored andcommitted
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: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
1 parent 33ef30a commit 908960c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎fs/btrfs/extent_io.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,7 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
19801980
struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
19811981
int ret;
19821982

1983+
ASSERT(!(fs_info->sb->s_flags & MS_RDONLY));
19831984
BUG_ON(!mirror_num);
19841985

19851986
/* 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,
20362037
unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
20372038
int ret = 0;
20382039

2040+
if (root->fs_info->sb->s_flags & MS_RDONLY)
2041+
return -EROFS;
2042+
20392043
for (i = 0; i < num_pages; i++) {
20402044
struct page *p = extent_buffer_page(eb, i);
20412045
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)
20572061
u64 private;
20582062
u64 private_failure;
20592063
struct io_failure_record *failrec;
2060-
struct btrfs_fs_info *fs_info;
2064+
struct inode *inode = page->mapping->host;
2065+
struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
20612066
struct extent_state *state;
20622067
int num_copies;
20632068
int did_repair = 0;
20642069
int ret;
2065-
struct inode *inode = page->mapping->host;
20662070

20672071
private = 0;
20682072
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)
20852089
did_repair = 1;
20862090
goto out;
20872091
}
2092+
if (fs_info->sb->s_flags & MS_RDONLY)
2093+
goto out;
20882094

20892095
spin_lock(&BTRFS_I(inode)->io_tree.lock);
20902096
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)
20942100

20952101
if (state && state->start <= failrec->start &&
20962102
state->end >= failrec->start + failrec->len - 1) {
2097-
fs_info = BTRFS_I(inode)->root->fs_info;
20982103
num_copies = btrfs_num_copies(fs_info, failrec->logical,
20992104
failrec->len);
21002105
if (num_copies > 1) {

0 commit comments

Comments
 (0)