Skip to content

Commit 45ffbca

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 56d8d90 commit 45ffbca

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
@@ -1591,7 +1591,7 @@ void bch2_dev_journal_exit(struct bch_dev *ca)
15911591
struct journal_device *ja = &ca->journal;
15921592

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

@@ -1628,7 +1628,16 @@ int bch2_dev_journal_init(struct bch_dev *ca, struct bch_sb *sb)
16281628
unsigned nr_bvecs = DIV_ROUND_UP(JOURNAL_ENTRY_SIZE_MAX, PAGE_SIZE);
16291629

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

0 commit comments

Comments
 (0)