Skip to content

RFC ext4: fast commit: fix lockdep issues

Li Chen linux-ext4 lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 RFC Latest2 patches 6 repliesIn review
  2. v2 RFC2 patches 0 repliesSuperseded
  3. v11 patch 0 repliesSuperseded

Changes in v3 from the cover letter

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ext4: fast_commit: assert i_data_sem only before sleepfs/ext4/fast_commit.c+9 -86 replies
2/2ext4: fast commit: fix s_fc_lock vs i_data_sem inversionfs/ext4/fast_commit.c+60 -190 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [RFC v3 0/2] ext4: fast commit: fix lockdep issues

Hi,

(This RFC v3 series is based on top of the patch posted at
https://lore.kernel.org/linux-ext4/[email protected]/T/#u)

This series fixes two lockdep issues in the ext4 fast commit paths.

1) ext4_fc_track_inode() can return without sleeping when EXT4_STATE_FC_COMMITTING is already clear. The lockdep assertion for i_data_sem should only fire when we actually go to sleep.

2) lockdep reports a possible deadlock due to lock order inversion between s_fc_lock and i_data_sem. The fast commit writer held s_fc_lock while writing the fast commit log. Writing the journal inode mapping can call ext4_map_blocks() and take i_data_sem, while metadata update paths can hold i_data_sem and call ext4_fc_track_inode() which takes s_fc_lock.

The fix drops s_fc_lock before the log writing step and uses EXT4_STATE_FC_COMMITTING to keep inode and create dentry state stable until cleanup.

Testing:
- QEMU VM, ext4 -O fast_commit on virtio-pmem + dax, verified both lockdep report reproduces on an older kernel and is gone with this series.

RFC v2 -> RFC v3:
- rebase ontop of https://lore.kernel.org/linux-ext4/[email protected]/T/#u

RFC v1 -> RFC v2:
- patch 1: move comments to correct place
- patch 2: add it to patchset.
- add missing RFC prefix

RFC v1: https://lore.kernel.org/linux-ext4/[email protected]/T/#u
RFC v2: https://lore.kernel.org/linux-ext4/[email protected]/T/#t

Li Chen (2):
ext4: fast_commit: assert i_data_sem only before sleep
ext4: fast commit: fix s_fc_lock vs i_data_sem inversion

 fs/ext4/fast_commit.c | 96 +++++++++++++++++++++++++++++++------------
 1 file changed, 69 insertions(+), 27 deletions(-)
Signature · 1 line
2.52.0