[Devel] [PATCH RHEL8 COMMIT] ext4: Fix fiemap() with FIEMAP_FLAG_CACHE flag

Konstantin Khorenko khorenko at virtuozzo.com
Thu Sep 24 13:12:00 MSK 2020


The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.7
------>
commit 1fcf8d627d60a0a5dd157b5e1e3e8b411629651b
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon Aug 17 09:52:43 2020 +0300

    ext4: Fix fiemap() with FIEMAP_FLAG_CACHE flag
    
    This flag says to cache extents in extent tree before iterations over
    them, but the combination of these two actions does not work.
    
    ext4_ext_precache() populates cache, but extent iteration can't occur,
    since fiemap_check_flags() does not know this flag.
    
    So, the result of this flag is:
      1)cache is populated,
      2)-EBADR is returned instead of extents array.
    
    This looks like a BUG in mainstream, which was blindly fixed in commit
    bb5835edcdf8bf7 "ext4: add new ioctl EXT4_IOC_GET_ES_CACHE".
    
    This patch makes the flag to work as expected.
    https://jira.sw.ru/browse/PSBM-105347
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    Acked-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    
    (cherry picked from commit df8daecb4f65ab2c7b5447500f6afa5522c113d2)
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 fs/ext4/extents.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 7a72cde366f7..3800860ce81c 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5075,6 +5075,7 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		error = ext4_ext_precache(inode);
 		if (error)
 			return error;
+		fieinfo->fi_flags &= ~FIEMAP_FLAG_CACHE;
 	}
 
 	/* fallback to generic here if not in extents fmt */


More information about the Devel mailing list