aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2013-11-03 12:06:39 -0500
committerChris Mason <chris.mason@fusionio.com>2013-11-20 20:42:05 -0500
commit908960c6c0fb3b3ce3971dc0ca47b581d256b968 (patch)
tree442d6f6c9dd6e5f10225a09a5b6bfadf07ec4729 /fs/btrfs/extent_io.c
parent33ef30add16905f99bbe799ee5ccea15ba497803 (diff)
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>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 856bc2b2192c..8e457fca0a0b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1980,6 +1980,7 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start,
1980 struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; 1980 struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
1981 int ret; 1981 int ret;
1982 1982
1983 ASSERT(!(fs_info->sb->s_flags & MS_RDONLY));
1983 BUG_ON(!mirror_num); 1984 BUG_ON(!mirror_num);
1984 1985
1985 /* we can't repair anything in raid56 yet */ 1986 /* 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 unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); 2037 unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
2037 int ret = 0; 2038 int ret = 0;
2038 2039
2040 if (root->fs_info->sb->s_flags & MS_RDONLY)
2041 return -EROFS;
2042
2039 for (i = 0; i < num_pages; i++) { 2043 for (i = 0; i < num_pages; i++) {
2040 struct page *p = extent_buffer_page(eb, i); 2044 struct page *p = extent_buffer_page(eb, i);
2041 ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE, 2045 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 u64 private; 2061 u64 private;
2058 u64 private_failure; 2062 u64 private_failure;
2059 struct io_failure_record *failrec; 2063 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;
2061 struct extent_state *state; 2066 struct extent_state *state;
2062 int num_copies; 2067 int num_copies;
2063 int did_repair = 0; 2068 int did_repair = 0;
2064 int ret; 2069 int ret;
2065 struct inode *inode = page->mapping->host;
2066 2070
2067 private = 0; 2071 private = 0;
2068 ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private, 2072 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 did_repair = 1; 2089 did_repair = 1;
2086 goto out; 2090 goto out;
2087 } 2091 }
2092 if (fs_info->sb->s_flags & MS_RDONLY)
2093 goto out;
2088 2094
2089 spin_lock(&BTRFS_I(inode)->io_tree.lock); 2095 spin_lock(&BTRFS_I(inode)->io_tree.lock);
2090 state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree, 2096 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 2100
2095 if (state && state->start <= failrec->start && 2101 if (state && state->start <= failrec->start &&
2096 state->end >= failrec->start + failrec->len - 1) { 2102 state->end >= failrec->start + failrec->len - 1) {
2097 fs_info = BTRFS_I(inode)->root->fs_info;
2098 num_copies = btrfs_num_copies(fs_info, failrec->logical, 2103 num_copies = btrfs_num_copies(fs_info, failrec->logical,
2099 failrec->len); 2104 failrec->len);
2100 if (num_copies > 1) { 2105 if (num_copies > 1) {