Skip to content

Commit

Permalink
ext4: mballoc: Disable preemption before getting per-CPU pointer
Browse files Browse the repository at this point in the history
BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u16:3/2181
caller is ext4_mb_new_blocks+0x388/0xed0
CPU: 2 PID: 2181 Comm: kworker/u16:3 Not tainted 5.7.0+ torvalds#182
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
Workqueue: writeback wb_workfn (flush-8:0)
Call Trace:
 dump_stack+0xb9/0xfc
 debug_smp_processor_id+0xc8/0xd0
 ext4_mb_new_blocks+0x388/0xed0
 ext4_ext_map_blocks+0xa92/0xff0
 ext4_map_blocks+0x34e/0x580
 ext4_writepages+0xa28/0x11b0
 do_writepages+0x46/0xe0
 __writeback_single_inode+0x5f/0x6b0
 writeback_sb_inodes+0x290/0x620
 __writeback_inodes_wb+0x62/0xb0
 wb_writeback+0x36c/0x520
 wb_workfn+0x319/0x680
 process_one_work+0x271/0x640
 worker_thread+0x3a/0x3a0
 kthread+0x14e/0x170
 ret_from_fork+0x27/0x40

Disable preemption before accessing discard_pa_seq.

Fixes: 07b5b8e ("ext4: mballoc: introduce pcpu seqcnt for freeing PA to improve ENOSPC handling")
Signed-off-by: YueHaibing <[email protected]>
  • Loading branch information
YueHaibing authored and intel-lab-lkp committed Jun 10, 2020
1 parent 6b8ed62 commit 0f3846e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ext4/mballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4708,7 +4708,8 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
}

ac->ac_op = EXT4_MB_HISTORY_PREALLOC;
seq = *this_cpu_ptr(&discard_pa_seq);
seq = *get_cpu_ptr(&discard_pa_seq);
put_cpu_ptr(&discard_pa_seq);
if (!ext4_mb_use_preallocated(ac)) {
ac->ac_op = EXT4_MB_HISTORY_ALLOC;
ext4_mb_normalize_request(ac, ar);
Expand Down

0 comments on commit 0f3846e

Please sign in to comment.