• Greg Thelen's avatar
    dm bufio: fully initialize shrinker · 9ee4fa03
    Greg Thelen authored
    commit d8c712ea upstream.
    
    1d3d4437 ("vmscan: per-node deferred work") added a flags field to
    struct shrinker assuming that all shrinkers were zero filled.  The dm
    bufio shrinker is not zero filled, which leaves arbitrary kmalloc() data
    in flags.  So far the only defined flags bit is SHRINKER_NUMA_AWARE.
    But there are proposed patches which add other bits to shrinker.flags
    (e.g. memcg awareness).
    
    Rather than simply initializing the shrinker, this patch uses kzalloc()
    when allocating the dm_bufio_client to ensure that the embedded shrinker
    and any other similar structures are zeroed.
    
    This fixes theoretical over aggressive shrinking of dm bufio objects.
    If the uninitialized dm_bufio_client.shrinker.flags contains
    SHRINKER_NUMA_AWARE then shrink_slab() would call the dm shrinker for
    each numa node rather than just once.  This has been broken since 3.12.
    Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
    Acked-by: default avatarMikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
    9ee4fa03
dm-bufio.c 44 KB