[Devel] [PATCH RHEL7 COMMIT] ms/ext4: fix punch hole for inline_data file systems

Vasily Averin vvs at virtuozzo.com
Fri Jun 18 16:08:03 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.31.1.vz7.181.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.31.1.vz7.181.4
------>
commit 747a279f08343a971647a50530904661fcfba815
Author: Theodore Ts'o <tytso at mit.edu>
Date:   Fri Jun 18 16:08:02 2021 +0300

    ms/ext4: fix punch hole for inline_data file systems
    
    ms commit c1e8220bd316
    
    If a program attempts to punch a hole on an inline data file, we need
    to convert it to a normal file first.
    
    This was detected using ext4/032 using the adv configuration.  Simple
    reproducer:
    
    mke2fs -Fq -t ext4 -O inline_data /dev/vdc
    mount /vdc
    echo "" > /vdc/testfile
    xfs_io -c 'truncate 33554432' /vdc/testfile
    xfs_io -c 'fpunch 0 1048576' /vdc/testfile
    umount /vdc
    e2fsck -fy /dev/vdc
    
    Cc: stable at vger.kernel.org
    Signed-off-by: Theodore Ts'o <tytso at mit.edu>
    https://jira.sw.ru/browse/PSBM-129846
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/ext4/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 71b1bf7..5fe7026 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3888,6 +3888,15 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
 
 	trace_ext4_punch_hole(inode, offset, length, 0);
 
+	ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
+	if (ext4_has_inline_data(inode)) {
+		down_write(&EXT4_I(inode)->i_mmap_sem);
+		ret = ext4_convert_inline_data(inode);
+		up_write(&EXT4_I(inode)->i_mmap_sem);
+		if (ret)
+			return ret;
+	}
+
 	/*
 	 * Write out all dirty pages to avoid race conditions
 	 * Then release them.


More information about the Devel mailing list