[Devel] [PATCH hci-8.1 v2 3/5] fs/ext4: assert presence of journal for swapext
Alexey Kuznetsov
kuznet at virtuozzo.com
Tue Nov 17 19:59:47 MSK 2026
On fs w/o journal swapext would crash f.e. dereferencing
fake journal handle. Actually, the whole swapext
does not make sense without journal.
Fixes: 1a3d440e7fbc ("fs/ext4: swapext ioctl")
Affects: #VSTOR-155599
https://virtuozzo.atlassian.net/browse/VSTOR-155599
Signed-off-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
Feature: ext4: swapext ioctl: swap range of blocks between two files
---
fs/ext4/move_extent.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index dfbdb571105f..cd07efaa1f30 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -868,6 +868,10 @@ ext4_ioc_swap_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
if (!S_ISREG(orig_inode->i_mode) || !S_ISREG(donor_inode->i_mode))
return -EINVAL;
+ /* Do not even try to do atomic swap w/o journal */
+ if (!EXT4_SB(orig_inode->i_sb)->s_journal)
+ return -EOPNOTSUPP;
+
/* TODO: it's not obvious how to swap blocks for inodes with full
* journaling enabled
*/
--
2.47.1
More information about the Devel
mailing list