diff options
| author | Chao Yu <chao@kernel.org> | 2026-10-10 14:55:45 +0800 |
|---|---|---|
| committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2026-10-13 18:45:04 +0000 |
| commit | e4582e5f3b439228d4e900edcf8225aa89be32b4 (patch) | |
| tree | 66b52ca76b1a2008c300cca1f122caa9ad3d35b4 /tools/lib/python | |
| parent | e74476ad8162c1facc74b74ce2d1372492df872e (diff) | |
| download | linux-next-e4582e5f3b439228d4e900edcf8225aa89be32b4.tar.gz linux-next-e4582e5f3b439228d4e900edcf8225aa89be32b4.zip | |
f2fs: fix to use bio_in_atomic() in f2fs_write_end_io()
f2fs_write_end_io() uses in_atomic() to decide whether a write bio which
exceeds max_atc_write_bio_size or max_atc_write_bio_entry_cnt should be
completed in sbi->wq rather than in the current context.
However, in_atomic() is not meant to be used outside core kernel code
(checkpatch.pl warns about it), as it only looks at preempt_count(): it
misses irqs-disabled and RCU read-side critical sections, and on kernels
without CONFIG_PREEMPT_COUNT it cannot see spinlock-held sections at all.
In those contexts, a large write bio will still be completed inline,
which defeats the purpose of the above knobs.
The block layer provides bio_in_atomic() for exactly this purpose, it
checks rcu_preempt_depth() and preemptible(), and conservatively returns
true if CONFIG_PREEMPT_COUNT is disabled, let's use it instead. The
difference is as below:
Context | in_atomic() | bio_in_atomic()
-------------------------------------+----------------+----------------
Hard IRQ / softirq | true | true
IRQs disabled, preempt count 0 | false (missed) | true
RCU read lock (CONFIG_PREEMPTION) | false (missed) | true
Kernel w/o CONFIG_PREEMPT_COUNT | IRQ ctx only | always true
Note that on kernels without CONFIG_PREEMPT_COUNT, write bios exceeding
the thresholds will always be offloaded to sbi->wq, since there is no way
to tell whether the current context is atomic. The thresholds default to
UINT_MAX, so the default behavior is not changed.
Cc: stable@kernel.org
Fixes: 3de6b8094115 ("f2fs: Run f2fs_write_end_io() asynchronously")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
