Skip to content

Commit 3897b6f

Browse files
Andrea Righikdave
authored andcommitted
btrfs: raid56: properly unmap parity page in finish_parity_scrub()
Parity page is incorrectly unmapped in finish_parity_scrub(), triggering a reference counter bug on i386, i.e.: [ 157.662401] kernel BUG at mm/highmem.c:349! [ 157.666725] invalid opcode: 0000 [#1] SMP PTI The reason is that kunmap(p_page) was completely left out, so we never did an unmap for the p_page and the loop unmapping the rbio page was iterating over the wrong number of stripes: unmapping should be done with nr_data instead of rbio->real_stripes. Test case to reproduce the bug: - create a raid5 btrfs filesystem: # mkfs.btrfs -m raid5 -d raid5 /dev/sdb /dev/sdc /dev/sdd /dev/sde - mount it: # mount /dev/sdb /mnt - run btrfs scrub in a loop: # while :; do btrfs scrub start -BR /mnt; done BugLink: https://bugs.launchpad.net/bugs/1812845 Fixes: 5a6ac9e ("Btrfs, raid56: support parity scrub on raid56") CC: stable@vger.kernel.org # 4.4+ Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Andrea Righi <andrea.righi@canonical.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 0cc068e commit 3897b6f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/btrfs/raid56.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,8 +2429,9 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
24292429
bitmap_clear(rbio->dbitmap, pagenr, 1);
24302430
kunmap(p);
24312431

2432-
for (stripe = 0; stripe < rbio->real_stripes; stripe++)
2432+
for (stripe = 0; stripe < nr_data; stripe++)
24332433
kunmap(page_in_rbio(rbio, stripe, pagenr, 0));
2434+
kunmap(p_page);
24342435
}
24352436

24362437
__free_page(p_page);

0 commit comments

Comments
 (0)