[Devel] [PATCH RHEL8 COMMIT] fs: FIEMAP should sync only required range with FIEMAP_FLAG_SYNC

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 16 14:27:17 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.14
------>
commit 426c0db2bc52b58d70ac5d4d9e48b99e9355bd33
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Fri Apr 16 14:27:17 2021 +0300

    fs: FIEMAP should sync only required range with FIEMAP_FLAG_SYNC
    
    https://jira.sw.ru/browse/PSBM-68226
    
    == combined with:
    
    fs: ioctl_fiemap must check what filemap_write_and_wait_range returns
    
    It's safer to check if filemap_write_and_wait_range succeeded or not.
    
    https://jira.sw.ru/browse/PSBM-68454
    
    Signed-off-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
    
    +++
    VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127782
    vz7 commit: 3d0e08a ("fs: FIEMAP should sync only required range with
    FIEMAP_FLAG_SYNC")
    
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
 fs/ioctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index df792d63bced..920dd71d8827 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -210,8 +210,12 @@ static int ioctl_fiemap(struct file *filp, struct fiemap __user *ufiemap)
 		       fieinfo.fi_extents_max * sizeof(struct fiemap_extent)))
 		return -EFAULT;
 
-	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
-		filemap_write_and_wait(inode->i_mapping);
+	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC) {
+		error = filemap_write_and_wait_range(inode->i_mapping,
+				fiemap.fm_start, fiemap.fm_start + len - 1);
+		if (error)
+			return error;
+	}
 
 	error = inode->i_op->fiemap(inode, &fieinfo, fiemap.fm_start, len);
 	fiemap.fm_flags = fieinfo.fi_flags;


More information about the Devel mailing list