ext4: protect quota acquisition against filesystem freezing
Get series with b4
b4 am [email protected]Versions newest first
- v2 Latest2 patches 2 repliesIn review
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystemfs/ | +4 | 1 reply | |
| 2/2 | ext4: protect ext4_acquire_dquot against freezingfs/ | +19 | 1 reply |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Jan Kara |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/2] ext4: protect quota acquisition against filesystem freezing
From: Ye Bin <[email protected]>
This series fixes quota operations running against a frozen filesystem, and the resulting freeze protection for ext4's dquot acquisition.
Patch 1 makes Q_XGETQUOTA/Q_XGETNEXTQUOTA consistent with Q_GETQUOTA and Q_GETNEXTQUOTA and forbids them on a frozen filesystem. These commands may end up in ->acquire_dquot() when the queried dquot is not cached yet, and thus may write to the filesystem, just like Q_GETQUOTA/Q_GETNEXTQUOTA which commit ccf370e43e08 ("quota: Forbid Q_GETQUOTA and Q_GETNEXTQUOTA for frozen filesystem") already handles. They were historically treated as read-only because they come from XFS, where quota is always coherent, but generic quota now routes them through dquot_get_dqblk()/ dquot_get_next_dqblk() and dqget(). Running them on a frozen filesystem makes ext4 start a transaction on it and warn. As suggested by Jan, they are now handled exactly like the generic commands, including taking write access, so a Q_XGETQUOTA on a read-only mount will report -EROFS; proper read-only querying can be added later if somebody actually needs it.
Patch 2 protects ext4_acquire_dquot() itself. A writable open reaches the filesystem's ->open() callback without superblock freeze protection, so ext4_file_open() -> dquot_file_open() -> dquot_initialize() can acquire a dquot and start a transaction after the filesystem has been frozen. Take sb_start_intwrite() around ext4_acquire_dquot() when no transaction is already running; running transactions are already protected against freezing.
Patch 2 relies on the preceding patch 1. Taking freeze protection in ext4_acquire_dquot() while holding s_umount, as the Q_XGETQUOTA and Q_XGETNEXTQUOTA paths do, would deadlock against thaw_super(), which needs s_umount exclusively to release the SB_FREEZE_FS protection. Patch 1 forbids those commands on a frozen filesystem and thus makes the new protection in patch 2 safe. Both patches must be applied together.
Ye Bin (2):
quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem
ext4: protect ext4_acquire_dquot against freezing
fs/ext4/super.c | 20 +++++++++++++++++++- fs/quota/quota.c | 9 ++++----- 2 files changed, 23 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1