aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-11-10 20:45:05 -0500
committerChris Mason <chris.mason@oracle.com>2011-11-10 20:45:05 -0500
commit2f120c05e67ae34c93786b1050c6828904314429 (patch)
treed14dfdb4e94b5b562ed35206a8525cd5908fc0db /fs
parent76b9e23d25d5c99f994bee3172de39492e452e93 (diff)
Btrfs: only map pages if we know we need them when reading the space cache
People have been running into a warning when loading space cache because the page is already mapped when trying to read in a bitmap. The way we read in entries and pages is kind of convoluted, so fix it so that io_ctl_read_entry maps the entries if it needs to, and if it hits the end of the page it simply unmaps the page. That way we can unconditionally unmap the io_ctl before reading in the bitmap and we should stop hitting these warnings. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/free-space-cache.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 7a15fcfb3e1f..181760f9d2ab 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -537,6 +537,13 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl,
537 struct btrfs_free_space *entry, u8 *type) 537 struct btrfs_free_space *entry, u8 *type)
538{ 538{
539 struct btrfs_free_space_entry *e; 539 struct btrfs_free_space_entry *e;
540 int ret;
541
542 if (!io_ctl->cur) {
543 ret = io_ctl_check_crc(io_ctl, io_ctl->index);
544 if (ret)
545 return ret;
546 }
540 547
541 e = io_ctl->cur; 548 e = io_ctl->cur;
542 entry->offset = le64_to_cpu(e->offset); 549 entry->offset = le64_to_cpu(e->offset);
@@ -550,10 +557,7 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl,
550 557
551 io_ctl_unmap_page(io_ctl); 558 io_ctl_unmap_page(io_ctl);
552 559
553 if (io_ctl->index >= io_ctl->num_pages) 560 return 0;
554 return 0;
555
556 return io_ctl_check_crc(io_ctl, io_ctl->index);
557} 561}
558 562
559static int io_ctl_read_bitmap(struct io_ctl *io_ctl, 563static int io_ctl_read_bitmap(struct io_ctl *io_ctl,
@@ -561,9 +565,6 @@ static int io_ctl_read_bitmap(struct io_ctl *io_ctl,
561{ 565{
562 int ret; 566 int ret;
563 567
564 if (io_ctl->cur && io_ctl->cur != io_ctl->orig)
565 io_ctl_unmap_page(io_ctl);
566
567 ret = io_ctl_check_crc(io_ctl, io_ctl->index); 568 ret = io_ctl_check_crc(io_ctl, io_ctl->index);
568 if (ret) 569 if (ret)
569 return ret; 570 return ret;
@@ -699,6 +700,8 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
699 num_entries--; 700 num_entries--;
700 } 701 }
701 702
703 io_ctl_unmap_page(&io_ctl);
704
702 /* 705 /*
703 * We add the bitmaps at the end of the entries in order that 706 * We add the bitmaps at the end of the entries in order that
704 * the bitmap entries are added to the cache. 707 * the bitmap entries are added to the cache.