mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
Btrfs: minor cleanup in scrub
Just a minor cleanup commit in preparation for the big block changes. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
parent
94598ba8d8
commit
1623edebee
1 changed files with 25 additions and 36 deletions
|
@ -36,28 +36,11 @@
|
||||||
* Future enhancements:
|
* Future enhancements:
|
||||||
* - In case an unrepairable extent is encountered, track which files are
|
* - In case an unrepairable extent is encountered, track which files are
|
||||||
* affected and report them
|
* affected and report them
|
||||||
* - In case of a read error on files with nodatasum, map the file and read
|
|
||||||
* the extent to trigger a writeback of the good copy
|
|
||||||
* - track and record media errors, throw out bad devices
|
* - track and record media errors, throw out bad devices
|
||||||
* - add a mode to also read unallocated space
|
* - add a mode to also read unallocated space
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct scrub_bio;
|
|
||||||
struct scrub_page;
|
|
||||||
struct scrub_dev;
|
struct scrub_dev;
|
||||||
static void scrub_bio_end_io(struct bio *bio, int err);
|
|
||||||
static void scrub_checksum(struct btrfs_work *work);
|
|
||||||
static int scrub_checksum_data(struct scrub_dev *sdev,
|
|
||||||
struct scrub_page *spag, void *buffer);
|
|
||||||
static int scrub_checksum_tree_block(struct scrub_dev *sdev,
|
|
||||||
struct scrub_page *spag, u64 logical,
|
|
||||||
void *buffer);
|
|
||||||
static int scrub_checksum_super(struct scrub_bio *sbio, void *buffer);
|
|
||||||
static int scrub_fixup_check(struct scrub_bio *sbio, int ix);
|
|
||||||
static void scrub_fixup_end_io(struct bio *bio, int err);
|
|
||||||
static int scrub_fixup_io(int rw, struct block_device *bdev, sector_t sector,
|
|
||||||
struct page *page);
|
|
||||||
static void scrub_fixup(struct scrub_bio *sbio, int ix);
|
|
||||||
|
|
||||||
#define SCRUB_PAGES_PER_BIO 16 /* 64k per bio */
|
#define SCRUB_PAGES_PER_BIO 16 /* 64k per bio */
|
||||||
#define SCRUB_BIOS_PER_DEV 16 /* 1 MB per device in flight */
|
#define SCRUB_BIOS_PER_DEV 16 /* 1 MB per device in flight */
|
||||||
|
@ -124,6 +107,21 @@ struct scrub_warning {
|
||||||
int scratch_bufsize;
|
int scratch_bufsize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void scrub_bio_end_io(struct bio *bio, int err);
|
||||||
|
static void scrub_checksum(struct btrfs_work *work);
|
||||||
|
static int scrub_checksum_data(struct scrub_dev *sdev,
|
||||||
|
struct scrub_page *spag, void *buffer);
|
||||||
|
static int scrub_checksum_tree_block(struct scrub_dev *sdev,
|
||||||
|
struct scrub_page *spag, u64 logical,
|
||||||
|
void *buffer);
|
||||||
|
static int scrub_checksum_super(struct scrub_bio *sbio, void *buffer);
|
||||||
|
static int scrub_fixup_check(struct scrub_bio *sbio, int ix);
|
||||||
|
static void scrub_fixup_end_io(struct bio *bio, int err);
|
||||||
|
static int scrub_fixup_io(int rw, struct block_device *bdev, sector_t sector,
|
||||||
|
struct page *page);
|
||||||
|
static void scrub_fixup(struct scrub_bio *sbio, int ix);
|
||||||
|
|
||||||
|
|
||||||
static void scrub_free_csums(struct scrub_dev *sdev)
|
static void scrub_free_csums(struct scrub_dev *sdev)
|
||||||
{
|
{
|
||||||
while (!list_empty(&sdev->csum_list)) {
|
while (!list_empty(&sdev->csum_list)) {
|
||||||
|
@ -342,7 +340,8 @@ static void scrub_print_warning(const char *errstr, struct scrub_bio *sbio,
|
||||||
do {
|
do {
|
||||||
ret = tree_backref_for_extent(&ptr, eb, ei, item_size,
|
ret = tree_backref_for_extent(&ptr, eb, ei, item_size,
|
||||||
&ref_root, &ref_level);
|
&ref_root, &ref_level);
|
||||||
printk(KERN_WARNING "%s at logical %llu on dev %s, "
|
printk(KERN_WARNING
|
||||||
|
"btrfs: %s at logical %llu on dev %s, "
|
||||||
"sector %llu: metadata %s (level %d) in tree "
|
"sector %llu: metadata %s (level %d) in tree "
|
||||||
"%llu\n", errstr, swarn.logical, dev->name,
|
"%llu\n", errstr, swarn.logical, dev->name,
|
||||||
(unsigned long long)swarn.sector,
|
(unsigned long long)swarn.sector,
|
||||||
|
@ -948,12 +947,12 @@ static int scrub_checksum_super(struct scrub_bio *sbio, void *buffer)
|
||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scrub_submit(struct scrub_dev *sdev)
|
static void scrub_submit(struct scrub_dev *sdev)
|
||||||
{
|
{
|
||||||
struct scrub_bio *sbio;
|
struct scrub_bio *sbio;
|
||||||
|
|
||||||
if (sdev->curr == -1)
|
if (sdev->curr == -1)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
sbio = sdev->bios[sdev->curr];
|
sbio = sdev->bios[sdev->curr];
|
||||||
sbio->err = 0;
|
sbio->err = 0;
|
||||||
|
@ -961,8 +960,6 @@ static int scrub_submit(struct scrub_dev *sdev)
|
||||||
atomic_inc(&sdev->in_flight);
|
atomic_inc(&sdev->in_flight);
|
||||||
|
|
||||||
btrfsic_submit_bio(READ, sbio->bio);
|
btrfsic_submit_bio(READ, sbio->bio);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
|
static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
|
||||||
|
@ -1008,9 +1005,7 @@ static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
|
||||||
sbio->bio = bio;
|
sbio->bio = bio;
|
||||||
} else if (sbio->physical + sbio->count * PAGE_SIZE != physical ||
|
} else if (sbio->physical + sbio->count * PAGE_SIZE != physical ||
|
||||||
sbio->logical + sbio->count * PAGE_SIZE != logical) {
|
sbio->logical + sbio->count * PAGE_SIZE != logical) {
|
||||||
ret = scrub_submit(sdev);
|
scrub_submit(sdev);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
sbio->spag[sbio->count].flags = flags;
|
sbio->spag[sbio->count].flags = flags;
|
||||||
|
@ -1025,9 +1020,7 @@ static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
|
||||||
ret = bio_add_page(sbio->bio, page, PAGE_SIZE, 0);
|
ret = bio_add_page(sbio->bio, page, PAGE_SIZE, 0);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
__free_page(page);
|
__free_page(page);
|
||||||
ret = scrub_submit(sdev);
|
scrub_submit(sdev);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,13 +1029,8 @@ static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
|
||||||
memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size);
|
memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size);
|
||||||
}
|
}
|
||||||
++sbio->count;
|
++sbio->count;
|
||||||
if (sbio->count == SCRUB_PAGES_PER_BIO || force) {
|
if (sbio->count == SCRUB_PAGES_PER_BIO || force)
|
||||||
int ret;
|
scrub_submit(sdev);
|
||||||
|
|
||||||
ret = scrub_submit(sdev);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1520,7 +1508,7 @@ static noinline_for_stack int scrub_supers(struct scrub_dev *sdev)
|
||||||
|
|
||||||
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
|
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
|
||||||
bytenr = btrfs_sb_offset(i);
|
bytenr = btrfs_sb_offset(i);
|
||||||
if (bytenr + BTRFS_SUPER_INFO_SIZE >= device->total_bytes)
|
if (bytenr + BTRFS_SUPER_INFO_SIZE > device->total_bytes)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ret = scrub_page(sdev, bytenr, PAGE_SIZE, bytenr,
|
ret = scrub_page(sdev, bytenr, PAGE_SIZE, bytenr,
|
||||||
|
@ -1741,6 +1729,7 @@ int btrfs_scrub_cancel_dev(struct btrfs_root *root, struct btrfs_device *dev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int btrfs_scrub_cancel_devid(struct btrfs_root *root, u64 devid)
|
int btrfs_scrub_cancel_devid(struct btrfs_root *root, u64 devid)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||||
|
|
Loading…
Reference in a new issue