[Devel] [PATCH RHEL9 COMMIT] fuse: call proper fiemap_prep as it is required by new kernel api

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 17 18:23:22 MSK 2023


The commit is pushed to "branch-rh9-5.14.0-284.25.1.vz9.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-284.25.1.vz9.30.6
------>
commit 4b8767d7cd1733eb5bfa6c99e85529ab88ec0a92
Author: Alexey Kuznetsov <kuznet at virtuozzo.com>
Date:   Sat Oct 14 02:35:42 2023 +0800

    fuse: call proper fiemap_prep as it is required by new kernel api
    
    Otherwise we consider locations with dirty page cache as holes.
    
    Notes:
    
    Liu: It’s better to move fiemap_prep() before inode_lock, as it was the
         case before when same thing is done in ioctl_fiemap().
    
    Lesha: It is intentional. It  was  like a bug in older kernels that we
         flushed dirty pages outside of locks so that we could came to
         fiemap with new dirty pages. Not that it is of any importance, as
         user calling write() and fiemap() in parallel deemed to get bogus
         results.
    
         BTW generally flush should be called twice. The first time - out of
         mutex, to make bulk work out of mutex, and then under mutex to
         collect bits dirtied while the fist pass. But in this case as we
         flush only area which is subject of fiemap, the first pass is
         mostly useless.
    
    =====================
    Liu: FIEMAP_FLAG_SYNC as the last parameter is unnecessary, because it
         is always checked in fiemap_prep().
    
    Lesha: It is noop but IMHO not redundant as states intention and
         improves readability w/o necessity to look into actual function to
         figure out why this flag is not marked as "supported".
    
    https://jira.vzint.dev/browse/PSBM-151414
    https://jira.vzint.dev/browse/PSBM-151424
    https://jira.vzint.dev/browse/PSBM-151464
    https://pmc.acronis.work/browse/VSTOR-76073
    
    Signed-off-by: Alexey Kuznetsov <kuznet at acronis.com>
    Acked-by: Andrey Zaitsev <Andrey.Zaitsev at acronis.com>
    Acked-by: Kui Liu <Kui.Liu at acronis.com>
    
    Feature: vStorage
---
 fs/fuse/file.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 6dff580a5d88..869274095664 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -3710,6 +3710,10 @@ int fuse_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
 	inode_lock(inode);
 
+	err = fiemap_prep(inode, fieinfo, start, &len, FIEMAP_FLAG_SYNC);
+	if (err)
+		goto out;
+
 	fuse_sync_writes(inode);
 	fuse_read_dio_wait(fi);
 


More information about the Devel mailing list