Author: cem
Date: Fri Feb 15 22:51:09 2019
New Revision: 344185
URL: https://svnweb.freebsd.org/changeset/base/344185

Log:
  FUSE: Only "dirty" cached file size when data is dirty
  
  Most users of fuse_vnode_setsize() set the cached fvdat->filesize and update
  the buf cache bounds as a result of either a read from the underlying FUSE
  filesystem, or as part of a write-through type operation (like truncate =>
  VOP_SETATTR).  In these cases, do not set the FN_SIZECHANGE flag, which
  indicates that an inode's data is dirty (in particular, that the local buf
  cache and fvdat->filesize have dirty extended data).
  
  PR:           230258 (related)

Modified:
  head/sys/fs/fuse/fuse_io.c
  head/sys/fs/fuse/fuse_node.c
  head/sys/fs/fuse/fuse_vnops.c

Modified: head/sys/fs/fuse/fuse_io.c
==============================================================================
--- head/sys/fs/fuse/fuse_io.c  Fri Feb 15 22:50:31 2019        (r344184)
+++ head/sys/fs/fuse/fuse_io.c  Fri Feb 15 22:51:09 2019        (r344185)
@@ -362,8 +362,11 @@ fuse_write_directbackend(struct vnode *vp, struct uio 
                }
                uio->uio_resid += diff;
                uio->uio_offset -= diff;
-               if (uio->uio_offset > fvdat->filesize)
+               if (uio->uio_offset > fvdat->filesize &&
+                   fuse_data_cache_enable) {
                        fuse_vnode_setsize(vp, cred, uio->uio_offset);
+                       fvdat->flag &= ~FN_SIZECHANGE;
+               }
        }
 
        fdisp_destroy(&fdi);

Modified: head/sys/fs/fuse/fuse_node.c
==============================================================================
--- head/sys/fs/fuse/fuse_node.c        Fri Feb 15 22:50:31 2019        
(r344184)
+++ head/sys/fs/fuse/fuse_node.c        Fri Feb 15 22:51:09 2019        
(r344185)
@@ -375,6 +375,7 @@ fuse_vnode_refreshsize(struct vnode *vp, struct ucred 
        struct vattr va;
 
        if ((fvdat->flag & FN_SIZECHANGE) != 0 ||
+           fuse_data_cache_enable == 0 ||
            (fuse_refresh_size == 0 && fvdat->filesize != 0))
                return;
 

Modified: head/sys/fs/fuse/fuse_vnops.c
==============================================================================
--- head/sys/fs/fuse/fuse_vnops.c       Fri Feb 15 22:50:31 2019        
(r344184)
+++ head/sys/fs/fuse/fuse_vnops.c       Fri Feb 15 22:51:09 2019        
(r344185)
@@ -538,6 +538,7 @@ fuse_vnop_getattr(struct vop_getattr_args *ap)
 
                if (fvdat->filesize != new_filesize) {
                        fuse_vnode_setsize(vp, cred, new_filesize);
+                       fvdat->flag &= ~FN_SIZECHANGE;
                }
        }
        debug_printf("fuse_getattr e: returning 0\n");
@@ -1637,9 +1638,9 @@ fuse_vnop_setattr(struct vop_setattr_args *ap)
                        err = EAGAIN;
                }
        }
-       if (!err && !sizechanged) {
+       if (err == 0)
                cache_attrs(vp, (struct fuse_attr_out *)fdi.answ, NULL);
-       }
+
 out:
        fdisp_destroy(&fdi);
        if (!err && sizechanged) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to