diff options
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 6a50801ecfa..a31f2a9bd2e 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -42,7 +42,6 @@ | |||
42 | * - In case of a read error on files with nodatasum, map the file and read | 42 | * - In case of a read error on files with nodatasum, map the file and read |
43 | * the extent to trigger a writeback of the good copy | 43 | * the extent to trigger a writeback of the good copy |
44 | * - track and record media errors, throw out bad devices | 44 | * - track and record media errors, throw out bad devices |
45 | * - add a readonly mode | ||
46 | * - add a mode to also read unallocated space | 45 | * - add a mode to also read unallocated space |
47 | * - make the prefetch cancellable | 46 | * - make the prefetch cancellable |
48 | */ | 47 | */ |
@@ -99,6 +98,7 @@ struct scrub_dev { | |||
99 | u16 csum_size; | 98 | u16 csum_size; |
100 | struct list_head csum_list; | 99 | struct list_head csum_list; |
101 | atomic_t cancel_req; | 100 | atomic_t cancel_req; |
101 | int readonly; | ||
102 | /* | 102 | /* |
103 | * statistics | 103 | * statistics |
104 | */ | 104 | */ |
@@ -329,14 +329,16 @@ static void scrub_fixup(struct scrub_bio *sbio, int ix) | |||
329 | if (i == multi->num_stripes) | 329 | if (i == multi->num_stripes) |
330 | goto uncorrectable; | 330 | goto uncorrectable; |
331 | 331 | ||
332 | /* | 332 | if (!sdev->readonly) { |
333 | * bi_io_vec[ix].bv_page now contains good data, write it back | 333 | /* |
334 | */ | 334 | * bi_io_vec[ix].bv_page now contains good data, write it back |
335 | if (scrub_fixup_io(WRITE, sdev->dev->bdev, | 335 | */ |
336 | (sbio->physical + ix * PAGE_SIZE) >> 9, | 336 | if (scrub_fixup_io(WRITE, sdev->dev->bdev, |
337 | sbio->bio->bi_io_vec[ix].bv_page)) { | 337 | (sbio->physical + ix * PAGE_SIZE) >> 9, |
338 | /* I/O-error, writeback failed, give up */ | 338 | sbio->bio->bi_io_vec[ix].bv_page)) { |
339 | goto uncorrectable; | 339 | /* I/O-error, writeback failed, give up */ |
340 | goto uncorrectable; | ||
341 | } | ||
340 | } | 342 | } |
341 | 343 | ||
342 | kfree(multi); | 344 | kfree(multi); |
@@ -1156,7 +1158,7 @@ static noinline_for_stack void scrub_workers_put(struct btrfs_root *root) | |||
1156 | 1158 | ||
1157 | 1159 | ||
1158 | int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end, | 1160 | int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end, |
1159 | struct btrfs_scrub_progress *progress) | 1161 | struct btrfs_scrub_progress *progress, int readonly) |
1160 | { | 1162 | { |
1161 | struct scrub_dev *sdev; | 1163 | struct scrub_dev *sdev; |
1162 | struct btrfs_fs_info *fs_info = root->fs_info; | 1164 | struct btrfs_fs_info *fs_info = root->fs_info; |
@@ -1209,6 +1211,7 @@ int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end, | |||
1209 | scrub_workers_put(root); | 1211 | scrub_workers_put(root); |
1210 | return PTR_ERR(sdev); | 1212 | return PTR_ERR(sdev); |
1211 | } | 1213 | } |
1214 | sdev->readonly = readonly; | ||
1212 | dev->scrub_device = sdev; | 1215 | dev->scrub_device = sdev; |
1213 | 1216 | ||
1214 | atomic_inc(&fs_info->scrubs_running); | 1217 | atomic_inc(&fs_info->scrubs_running); |