If fallocate will change file's data we have to drop csum.

Signed-off-by: Dmitry Monakhov <[email protected]>
---
 fs/ext4/extents.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 08b0709..fe95102 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5062,6 +5062,11 @@ long ext4_fallocate(struct file *file, int mode, loff_t 
offset, loff_t len)
                     FALLOC_FL_CONVERT_AND_EXTEND))
                return -EOPNOTSUPP;
 
+       /* If data is about to change we must drop csum */
+       if (ext4_test_inode_state(inode, EXT4_STATE_CSUM) &&
+           ((mode & ~FALLOC_FL_KEEP_SIZE)  || !(mode & FALLOC_FL_KEEP_SIZE)))
+               ext4_truncate_data_csum(inode, -1);
+
        if (mode & FALLOC_FL_PUNCH_HOLE)
                return ext4_punch_hole(inode, offset, len);
 
-- 
1.7.1

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to