mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 09:59:32 +00:00
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>
This commit is contained in:
parent
76b9e23d25
commit
2f120c05e6
1 changed files with 10 additions and 7 deletions
|
@ -537,6 +537,13 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl,
|
||||||
struct btrfs_free_space *entry, u8 *type)
|
struct btrfs_free_space *entry, u8 *type)
|
||||||
{
|
{
|
||||||
struct btrfs_free_space_entry *e;
|
struct btrfs_free_space_entry *e;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!io_ctl->cur) {
|
||||||
|
ret = io_ctl_check_crc(io_ctl, io_ctl->index);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
e = io_ctl->cur;
|
e = io_ctl->cur;
|
||||||
entry->offset = le64_to_cpu(e->offset);
|
entry->offset = le64_to_cpu(e->offset);
|
||||||
|
@ -550,10 +557,7 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl,
|
||||||
|
|
||||||
io_ctl_unmap_page(io_ctl);
|
io_ctl_unmap_page(io_ctl);
|
||||||
|
|
||||||
if (io_ctl->index >= io_ctl->num_pages)
|
return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
return io_ctl_check_crc(io_ctl, io_ctl->index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int io_ctl_read_bitmap(struct io_ctl *io_ctl,
|
static 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,
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (io_ctl->cur && io_ctl->cur != io_ctl->orig)
|
|
||||||
io_ctl_unmap_page(io_ctl);
|
|
||||||
|
|
||||||
ret = io_ctl_check_crc(io_ctl, io_ctl->index);
|
ret = io_ctl_check_crc(io_ctl, io_ctl->index);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -699,6 +700,8 @@ int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
|
||||||
num_entries--;
|
num_entries--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io_ctl_unmap_page(&io_ctl);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We add the bitmaps at the end of the entries in order that
|
* We add the bitmaps at the end of the entries in order that
|
||||||
* the bitmap entries are added to the cache.
|
* the bitmap entries are added to the cache.
|
||||||
|
|
Loading…
Reference in a new issue