Re: [PATCH v3 11/16] bcache: handle cache set verify_ondisk properly for bucket size > 8MB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/15/20 4:30 PM, colyli@xxxxxxx wrote:
From: Coly Li <colyli@xxxxxxx>

In bch_btree_cache_alloc() when CONFIG_BCACHE_DEBUG is configured,
allocate memory for c->verify_ondisk may fail if the bucket size > 8MB,
which will require __get_free_pages() to allocate continuous pages
with order > 11 (the default MAX_ORDER of Linux buddy allocator). Such
over size allocation will fail, and cause 2 problems,
- When CONFIG_BCACHE_DEBUG is configured,  bch_btree_verify() does not
   work, because c->verify_ondisk is NULL and bch_btree_verify() returns
   immediately.
- bch_btree_cache_alloc() will fail due to c->verify_ondisk allocation
   failed, then the whole cache device registration fails. And because of
   this failure, the first problem of bch_btree_verify() has no chance to
   be triggered.

This patch fixes the above problem by two means,
1) If pages allocation of c->verify_ondisk fails, set it to NULL and
    returns bch_btree_cache_alloc() with -ENOMEM.
2) When calling __get_free_pages() to allocate c->verify_ondisk pages,
    use ilog2(meta_bucket_pages(&c->sb)) to make sure ilog2() will always
    generate a pages order <= MAX_ORDER (or CONFIG_FORCE_MAX_ZONEORDER).
    Then the buddy system won't directly reject the allocation request.

Signed-off-by: Coly Li <colyli@xxxxxxx>
---
  drivers/md/bcache/btree.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)

Reviewed-by: Hannes Reinecke <hare@xxxxxxx>

Cheers,

Hannes
--
Dr. Hannes Reinecke            Teamlead Storage & Networking
hare@xxxxxxx                               +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux