linux/drivers/md/bcache
Coly Li de1fafab64 bcache: introduce meta_bucket_pages() related helper routines
Currently the in-memory meta data like c->uuids or c->disk_buckets
are allocated by alloc_bucket_pages(). The macro alloc_bucket_pages()
calls __get_free_pages() to allocated continuous pages with order
indicated by ilog2(bucket_pages(c)),
 #define alloc_bucket_pages(gfp, c)                      \
     ((void *) __get_free_pages(__GFP_ZERO|gfp, ilog2(bucket_pages(c))))

The maximum order is defined as MAX_ORDER, the default value is 11 (and
can be overwritten by CONFIG_FORCE_MAX_ZONEORDER). In bcache code the
maximum bucket size width is 16bits, this is restricted both by KEY_SIZE
size and bucket_size size from struct cache_sb_disk. The maximum 16bits
width and power-of-2 value is (1<<15) in unit of sector (512byte). It
means the maximum value of bucket size in bytes is (1<<24) bytes a.k.a
4096 pages.

When the bucket size is set to maximum permitted value, ilog2(4096) is
12, which exceeds the default maximum order __get_free_pages() can
accepted, the failed pages allocation will fail cache set registration
procedure and print a kernel oops message for the exceeded pages order.

This patch introduces meta_bucket_pages(), meta_bucket_bytes(), and
alloc_bucket_pages() helper routines. meta_bucket_pages() indicates the
maximum pages can be allocated to meta data bucket, meta_bucket_bytes()
indicates the according maximum bytes, and alloc_bucket_pages() does
the pages allocation for meta bucket. Because meta_bucket_pages()
chooses the smaller value among the bucket size and MAX_ORDER_NR_PAGES,
it still works when MAX_ORDER overwritten by CONFIG_FORCE_MAX_ZONEORDER.

Following patches will use these helper routines to decide maximum pages
can be allocated for different meta data buckets. If the bucket size is
larger than meta_bucket_bytes(), the bcache registration can continue to
success, just the space more than meta_bucket_bytes() inside the bucket
is wasted. Comparing bcache failed for large bucket size, wasting some
space for meta data buckets is acceptable at this moment.

Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-07-25 07:38:20 -06:00
..
alloc.c Revert "bcache: ignore pending signals when creating gc and allocator thread" 2020-03-02 20:01:32 -07:00
bcache.h bcache: introduce meta_bucket_pages() related helper routines 2020-07-25 07:38:20 -06:00
bset.c bcache: allocate meta data pages as compound pages 2020-07-25 07:38:19 -06:00
bset.h bcache: explicity type cast in bset_bkey_last() 2020-02-01 07:55:39 -07:00
btree.c bcache: allocate meta data pages as compound pages 2020-07-25 07:38:19 -06:00
btree.h bcache: remove dupplicated declaration from btree.h 2020-03-24 19:56:42 -06:00
closure.c bcache: don't export symbols 2019-11-13 15:42:51 -07:00
closure.h bcache: fix typo in code comments of closure_return_with_destructor() 2018-10-08 08:19:43 -06:00
debug.c bcache: Fix an error code in bch_dump_read() 2019-09-03 08:08:29 -06:00
debug.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
extents.c bcache: Convert pr_<level> uses to a more typical style 2020-05-27 05:19:36 -06:00
extents.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
features.h bcache: increase super block version for cache device and backing device 2020-07-25 07:38:20 -06:00
io.c bcache: Convert pr_<level> uses to a more typical style 2020-05-27 05:19:36 -06:00
journal.c bcache: journel: use for_each_clear_bit() to simplify the code 2020-07-25 07:38:19 -06:00
journal.h Revert "bcache: fix fifo index swapping condition in journal_pin_cmp()" 2019-11-18 08:35:47 -07:00
Kconfig bcache: Fix typo in Kconfig name 2020-07-25 07:38:19 -06:00
Makefile bcache: remove the extra cflags for request.o 2019-11-13 15:42:50 -07:00
movinggc.c bcache: movinggc: Use struct_size() helper in kzalloc() 2020-07-25 07:38:20 -06:00
request.c block: rename generic_make_request to submit_bio_noacct 2020-07-01 07:27:24 -06:00
request.h block: move ->make_request_fn to struct block_device_operations 2020-07-01 07:27:24 -06:00
stats.c bcache: fix memory corruption in bch_cache_accounting_clear() 2020-02-01 07:55:39 -07:00
stats.h bcache: add identifier names to arguments of function definitions 2018-08-11 15:46:41 -06:00
super.c bcache: introduce meta_bucket_pages() related helper routines 2020-07-25 07:38:20 -06:00
sysfs.c bcache: Convert pr_<level> uses to a more typical style 2020-05-27 05:19:36 -06:00
sysfs.h bcache: add sysfs_strtoul_bool() for setting bit-field variables 2019-02-09 07:18:32 -07:00
trace.c
util.c bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() 2019-02-15 08:40:11 -07:00
util.h bcache: Revert "bcache: fix high CPU occupancy during journal" 2019-06-28 07:39:17 -06:00
writeback.c bcache: fix overflow in offset_to_stripe() 2020-07-25 07:38:20 -06:00
writeback.h bcache: fix overflow in offset_to_stripe() 2020-07-25 07:38:20 -06:00