• Zdenek Kabelac's avatar
    md: free unused memory after bitmap resize · b7d3f2b5
    Zdenek Kabelac authored
    
    [ Upstream commit 0868b99c ]
    
    When bitmap is resized, the old kalloced chunks just are not released
    once the resized bitmap starts to use new space.
    
    This fixes in particular kmemleak reports like this one:
    
    unreferenced object 0xffff8f4311e9c000 (size 4096):
      comm "lvm", pid 19333, jiffies 4295263268 (age 528.265s)
      hex dump (first 32 bytes):
        02 80 02 80 02 80 02 80 02 80 02 80 02 80 02 80  ................
        02 80 02 80 02 80 02 80 02 80 02 80 02 80 02 80  ................
      backtrace:
        [<ffffffffa69471ca>] kmemleak_alloc+0x4a/0xa0
        [<ffffffffa628c10e>] kmem_cache_alloc_trace+0x14e/0x2e0
        [<ffffffffa676cfec>] bitmap_checkpage+0x7c/0x110
        [<ffffffffa676d0c5>] bitmap_get_counter+0x45/0xd0
        [<ffffffffa676d6b3>] bitmap_set_memory_bits+0x43/0xe0
        [<ffffffffa676e41c>] bitmap_init_from_disk+0x23c/0x530
        [<ffffffffa676f1ae>] bitmap_load+0xbe/0x160
        [<ffffffffc04c47d3>] raid_preresume+0x203/0x2f0 [dm_raid]...
    b7d3f2b5
bitmap.c 67 KB