Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 275329
b: refs/heads/master
c: 69f4cb5
h: refs/heads/master
i:
  275327: 63bccce
v: v3
  • Loading branch information
Arne Jansen authored and Chris Mason committed Nov 11, 2011
1 parent 4c049a1 commit 57f6916
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 62f30c5462374b991e7e3f42d49ce2265c1b82f1
refs/heads/master: 69f4cb526bd02ae5af35846f9a710c099eec3347
64 changes: 29 additions & 35 deletions trunk/fs/btrfs/scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,57 +944,27 @@ static int scrub_checksum_super(struct scrub_bio *sbio, void *buffer)
static int scrub_submit(struct scrub_dev *sdev)
{
struct scrub_bio *sbio;
struct bio *bio;
int i;

if (sdev->curr == -1)
return 0;

sbio = sdev->bios[sdev->curr];

bio = bio_alloc(GFP_NOFS, sbio->count);
if (!bio)
goto nomem;

bio->bi_private = sbio;
bio->bi_end_io = scrub_bio_end_io;
bio->bi_bdev = sdev->dev->bdev;
bio->bi_sector = sbio->physical >> 9;

for (i = 0; i < sbio->count; ++i) {
struct page *page;
int ret;

page = alloc_page(GFP_NOFS);
if (!page)
goto nomem;

ret = bio_add_page(bio, page, PAGE_SIZE, 0);
if (!ret) {
__free_page(page);
goto nomem;
}
}

sbio->err = 0;
sdev->curr = -1;
atomic_inc(&sdev->in_flight);

submit_bio(READ, bio);
submit_bio(READ, sbio->bio);

return 0;

nomem:
scrub_free_bio(bio);

return -ENOMEM;
}

static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
u64 physical, u64 flags, u64 gen, int mirror_num,
u8 *csum, int force)
{
struct scrub_bio *sbio;
struct page *page;
int ret;

again:
/*
Expand All @@ -1015,12 +985,22 @@ static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
}
sbio = sdev->bios[sdev->curr];
if (sbio->count == 0) {
struct bio *bio;

sbio->physical = physical;
sbio->logical = logical;
bio = bio_alloc(GFP_NOFS, SCRUB_PAGES_PER_BIO);
if (!bio)
return -ENOMEM;

bio->bi_private = sbio;
bio->bi_end_io = scrub_bio_end_io;
bio->bi_bdev = sdev->dev->bdev;
bio->bi_sector = sbio->physical >> 9;
sbio->err = 0;
sbio->bio = bio;
} else if (sbio->physical + sbio->count * PAGE_SIZE != physical ||
sbio->logical + sbio->count * PAGE_SIZE != logical) {
int ret;

ret = scrub_submit(sdev);
if (ret)
return ret;
Expand All @@ -1030,6 +1010,20 @@ static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,
sbio->spag[sbio->count].generation = gen;
sbio->spag[sbio->count].have_csum = 0;
sbio->spag[sbio->count].mirror_num = mirror_num;

page = alloc_page(GFP_NOFS);
if (!page)
return -ENOMEM;

ret = bio_add_page(sbio->bio, page, PAGE_SIZE, 0);
if (!ret) {
__free_page(page);
ret = scrub_submit(sdev);
if (ret)
return ret;
goto again;
}

if (csum) {
sbio->spag[sbio->count].have_csum = 1;
memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size);
Expand Down

0 comments on commit 57f6916

Please sign in to comment.