|
23 | 23 | #include <linux/mm.h> |
24 | 24 | #include <linux/highmem.h> |
25 | 25 | #include <linux/fs.h> |
| 26 | +#include <linux/rwsem.h> |
26 | 27 | #include <linux/completion.h> |
27 | 28 | #include <linux/backing-dev.h> |
28 | 29 | #include <linux/wait.h> |
|
33 | 34 | #include "extent_io.h" |
34 | 35 | #include "extent_map.h" |
35 | 36 | #include "async-thread.h" |
| 37 | +#include "ioctl.h" |
36 | 38 |
|
37 | 39 | struct btrfs_trans_handle; |
38 | 40 | struct btrfs_transaction; |
@@ -510,6 +512,12 @@ struct btrfs_extent_item_v0 { |
510 | 512 | /* use full backrefs for extent pointers in the block */ |
511 | 513 | #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8) |
512 | 514 |
|
| 515 | +/* |
| 516 | + * this flag is only used internally by scrub and may be changed at any time |
| 517 | + * it is only declared here to avoid collisions |
| 518 | + */ |
| 519 | +#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48) |
| 520 | + |
513 | 521 | struct btrfs_tree_block_info { |
514 | 522 | struct btrfs_disk_key key; |
515 | 523 | u8 level; |
@@ -1077,6 +1085,17 @@ struct btrfs_fs_info { |
1077 | 1085 |
|
1078 | 1086 | void *bdev_holder; |
1079 | 1087 |
|
| 1088 | + /* private scrub information */ |
| 1089 | + struct mutex scrub_lock; |
| 1090 | + atomic_t scrubs_running; |
| 1091 | + atomic_t scrub_pause_req; |
| 1092 | + atomic_t scrubs_paused; |
| 1093 | + atomic_t scrub_cancel_req; |
| 1094 | + wait_queue_head_t scrub_pause_wait; |
| 1095 | + struct rw_semaphore scrub_super_lock; |
| 1096 | + int scrub_workers_refcnt; |
| 1097 | + struct btrfs_workers scrub_workers; |
| 1098 | + |
1080 | 1099 | /* filesystem state */ |
1081 | 1100 | u64 fs_state; |
1082 | 1101 | }; |
@@ -2472,8 +2491,8 @@ struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans, |
2472 | 2491 | int btrfs_csum_truncate(struct btrfs_trans_handle *trans, |
2473 | 2492 | struct btrfs_root *root, struct btrfs_path *path, |
2474 | 2493 | u64 isize); |
2475 | | -int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, |
2476 | | - u64 end, struct list_head *list); |
| 2494 | +int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, |
| 2495 | + struct list_head *list, int search_commit); |
2477 | 2496 | /* inode.c */ |
2478 | 2497 |
|
2479 | 2498 | /* RHEL and EL kernels have a patch that renames PG_checked to FsMisc */ |
@@ -2637,4 +2656,18 @@ void btrfs_reloc_pre_snapshot(struct btrfs_trans_handle *trans, |
2637 | 2656 | u64 *bytes_to_reserve); |
2638 | 2657 | void btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans, |
2639 | 2658 | struct btrfs_pending_snapshot *pending); |
| 2659 | + |
| 2660 | +/* scrub.c */ |
| 2661 | +int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end, |
| 2662 | + struct btrfs_scrub_progress *progress); |
| 2663 | +int btrfs_scrub_pause(struct btrfs_root *root); |
| 2664 | +int btrfs_scrub_pause_super(struct btrfs_root *root); |
| 2665 | +int btrfs_scrub_continue(struct btrfs_root *root); |
| 2666 | +int btrfs_scrub_continue_super(struct btrfs_root *root); |
| 2667 | +int btrfs_scrub_cancel(struct btrfs_root *root); |
| 2668 | +int btrfs_scrub_cancel_dev(struct btrfs_root *root, struct btrfs_device *dev); |
| 2669 | +int btrfs_scrub_cancel_devid(struct btrfs_root *root, u64 devid); |
| 2670 | +int btrfs_scrub_progress(struct btrfs_root *root, u64 devid, |
| 2671 | + struct btrfs_scrub_progress *progress); |
| 2672 | + |
2640 | 2673 | #endif |
0 commit comments