Call uvm_vnp_uncache() in tmpfs_write(). We currently only call
authorpatrick <patrick@openbsd.org>
Sat, 23 Oct 2021 17:39:08 +0000 (17:39 +0000)
committerpatrick <patrick@openbsd.org>
Sat, 23 Oct 2021 17:39:08 +0000 (17:39 +0000)
uvm_vnp_uncache() in tmpfs_write() when a file grows in size.  This
is not enough.  We need to invalidate UVM's cache of the vnode every
time the contents of the vnode are modified.  Failure to do so might
lead to inconsistencies between read/mmap consumers.

From Pedro Martelletto

sys/tmpfs/tmpfs_vnops.c

index b1a4fe2..690f09b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: tmpfs_vnops.c,v 1.47 2021/10/23 17:38:00 patrick Exp $        */
+/*     $OpenBSD: tmpfs_vnops.c,v 1.48 2021/10/23 17:39:08 patrick Exp $        */
 /*     $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $       */
 
 /*
@@ -625,7 +625,7 @@ tmpfs_write(void *v)
        error = 0;
        while (error == 0 && uio->uio_resid > 0) {
                vsize_t len;
-
+               uvm_vnp_uncache(vp);
                len = MIN(node->tn_size - uio->uio_offset, uio->uio_resid);
                if (len == 0) {
                        break;