[Devel] [PATCH RHEL7 COMMIT] fuse: skip invalidate_inode_pages2 on truncate

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 31 13:23:23 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.20
------>
commit aa06cce9cfe8e16c2f4c6c8a5f9c383e7567150f
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Tue Oct 31 13:23:23 2017 +0300

    fuse: skip invalidate_inode_pages2 on truncate
    
    Using writeback mode in kernel fuse is safe only if we are sure that a file
    cannot be modified externally while we write to it. But then it's useless
    to invalidate page-cache in course of truncate: truncate_pagecache() shrinks
    everything beyond new EOF and all remaining pages are valid as they used to
    be before truncate operation.
    
    Thank you to Alexey Kuznetsov for pointing out.
    
    https://jira.sw.ru/browse/PSBM-76437
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 fs/fuse/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c5ff349..79c78291 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1841,7 +1841,8 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
 	if ((is_truncate || !is_wb) &&
 			S_ISREG(inode->i_mode) && oldsize != outarg.attr.size) {
 		truncate_pagecache(inode, outarg.attr.size);
-		invalidate_inode_pages2(inode->i_mapping);
+		if (!is_wb)
+			invalidate_inode_pages2(inode->i_mapping);
 	}
 
 	clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);


More information about the Devel mailing list