[Devel] [PATCH rh8 7/9] ext4: make data=writeback mode safe
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Mar 3 19:31:16 MSK 2021
From: Kirill Tkhai <ktkhai at parallels.com>
It is not obvious, but delalloc makes data=writeback mode safer.
This is because actual data allocation happens inside writepages,
So stale blocks after unclean umount no longer an issue.
So in order to make data=writeback mode reliable we can not
temporarily disable delalloc in case of low diskspace. It must
be enabled permanently. Original discussion:
http://thread.gmane.org/gmane.comp.file-systems.ext4/19527
https://jira.sw.ru:9443/browse/PCLIN-299
diff-ms-ext4-safe-writeback
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
Signed-off-by: Kirill Tkhai <ktkhai at parallels.com>
(cherry picked from vz7 commit 025b3611cf3eba7f1a83bf34c05ea439c4ade410)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
fs/ext4/inode.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 95db85e44ce6..34893ab118dc 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3006,8 +3006,15 @@ static int ext4_nonda_switch(struct super_block *sb)
if (dirty_clusters && (free_clusters < 2 * dirty_clusters))
try_to_writeback_inodes_sb(sb, WB_REASON_FS_FREE_SPACE);
- if (2 * free_clusters < 3 * dirty_clusters ||
- free_clusters < (dirty_clusters + EXT4_FREECLUSTERS_WATERMARK)) {
+ /*
+ * NOTE: Delalloc make data=writeback mode safer, similar to ordered
+ * mode, so stale blocks after power failure no longer an issue Do not
+ * disable delalloc to guarantee data security on data=writeback mode.
+ * -dmon
+ */
+ if (test_opt(sb, DATA_FLAGS) != EXT4_MOUNT_WRITEBACK_DATA &&
+ (2 * free_clusters < 3 * dirty_clusters ||
+ free_clusters < (dirty_clusters + EXT4_FREECLUSTERS_WATERMARK))) {
/*
* free block count is less than 150% of dirty blocks
* or free blocks is less than watermark
--
2.28.0
More information about the Devel
mailing list