Skip to content

Commit 62f56b7

Browse files
author
Kent Overstreet
committed
bcachefs: use kvzalloc() for journal bios
We can write quite large journal entries. It's possible that JOURNAL_ENTRY_SIZE_MAX is far larger than it needs to be and should be reduced to something more reasonable (1-2MB), but performance can be sensitive to anything that affects journal pipelining - we've had issues there in the past, so we shouldn't change that without first doing performance testing. For now, apply the simple fix to deal with the following, which caused a mount to fail: [43579.348135] mount.bcachefs: page allocation failure: order:5, mode:0x40dc0(GFP_KERNEL|__GFP_ZERO|__GFP_COMP), nodemask=(null),cpuset=openrc.sshd,mems_allowed=0 [43579.349792] CPU: 3 UID: 0 PID: 14702 Comm: mount.bcachefs Tainted: G U 6.16.0-rc4 #18 VOLUNTARY [43579.349798] Tainted: [U]=USER [43579.349799] Hardware name: MSI MS-7982/B150M PRO-VDH (MS-7982), BIOS 3.H0 07/10/2018 [43579.349800] Call Trace: [43579.349803] <TASK> [43579.349806] dump_stack_lvl (lib/dump_stack.c:122) [43579.349814] warn_alloc (mm/page_alloc.c:3744) [43579.349821] ? __alloc_pages_direct_compact (./arch/x86/include/asm/jump_label.h:36 ./include/linux/delayacct.h:211 mm/page_alloc.c:3882) [43579.349827] __alloc_pages_slowpath.constprop.0 (mm/page_alloc.c:4699) [43579.349833] __alloc_frozen_pages_noprof (mm/page_alloc.c:4972) [43579.349838] __alloc_pages_noprof (mm/page_alloc.c:4994) [43579.349843] ___kmalloc_large_node (./include/linux/gfp.h:284 ./include/linux/gfp.h:311 mm/slub.c:4272) [43579.349848] __kmalloc_large_noprof (./arch/x86/include/asm/bitops.h:414 ./include/asm-generic/getorder.h:46 mm/slub.c:4292) [43579.349852] bch2_dev_journal_init (fs/bcachefs/journal.c:1629 (discriminator 4)) [43579.349857] __bch2_dev_attach_bdev (fs/bcachefs/super.c:1588) [43579.349861] ? kernfs_create_link (fs/kernfs/symlink.c:48) [43579.349865] bch2_dev_attach_bdev (fs/bcachefs/super.c:1630) [43579.349868] bch2_fs_open (fs/bcachefs/super.c:2440) [43579.349874] bch2_fs_get_tree (fs/bcachefs/fs.c:2474) [43579.349880] vfs_get_tree (fs/super.c:1805) Reported-by: Marcin Mirosław <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent fcd4781 commit 62f56b7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fs/bcachefs/journal.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ void bch2_dev_journal_exit(struct bch_dev *ca)
15931593
struct journal_device *ja = &ca->journal;
15941594

15951595
for (unsigned i = 0; i < ARRAY_SIZE(ja->bio); i++) {
1596-
kfree(ja->bio[i]);
1596+
kvfree(ja->bio[i]);
15971597
ja->bio[i] = NULL;
15981598
}
15991599

@@ -1630,7 +1630,16 @@ int bch2_dev_journal_init(struct bch_dev *ca, struct bch_sb *sb)
16301630
unsigned nr_bvecs = DIV_ROUND_UP(JOURNAL_ENTRY_SIZE_MAX, PAGE_SIZE);
16311631

16321632
for (unsigned i = 0; i < ARRAY_SIZE(ja->bio); i++) {
1633-
ja->bio[i] = kzalloc(struct_size(ja->bio[i], bio.bi_inline_vecs,
1633+
/*
1634+
* kvzalloc() is not what we want to be using here:
1635+
* JOURNAL_ENTRY_SIZE_MAX is probably quite a bit bigger than it
1636+
* needs to be.
1637+
*
1638+
* But changing that will require performance testing -
1639+
* performance can be sensitive to anything that affects journal
1640+
* pipelining.
1641+
*/
1642+
ja->bio[i] = kvzalloc(struct_size(ja->bio[i], bio.bi_inline_vecs,
16341643
nr_bvecs), GFP_KERNEL);
16351644
if (!ja->bio[i])
16361645
return bch_err_throw(c, ENOMEM_dev_journal_init);

0 commit comments

Comments
 (0)