Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/puffs Improve zero-fill of last page after shrink fix:
details: https://anonhg.NetBSD.org/src/rev/22a983d2364b
branches: trunk
changeset: 332719:22a983d2364b
user: manu <manu%NetBSD.org@localhost>
date: Mon Oct 06 04:41:59 2014 +0000
description:
Improve zero-fill of last page after shrink fix:
1) do it only if the file is open for writing, otherwise we send write
requests to the FS on a file that has never been open.
2) do it inside existing if (vap->va_size != VNOVAL) block
diffstat:
sys/fs/puffs/puffs_vnops.c | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diffs (81 lines):
diff -r 0d461bccbc5c -r 22a983d2364b sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c Sun Oct 05 23:08:01 2014 +0000
+++ b/sys/fs/puffs/puffs_vnops.c Mon Oct 06 04:41:59 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vnops.c,v 1.189 2014/10/05 09:28:24 justin Exp $ */
+/* $NetBSD: puffs_vnops.c,v 1.190 2014/10/06 04:41:59 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.189 2014/10/05 09:28:24 justin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.190 2014/10/06 04:41:59 manu Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -1141,6 +1141,9 @@
if (trunc_page(off) == off)
return;
+
+ if (vp->v_writecount == 0)
+ return;
len = round_page(off) - off;
memset(zbuf, 0, len);
@@ -1157,7 +1160,7 @@
error = ubc_uiomove(&vp->v_uobj, &uio, len,
UVM_ADV_SEQUENTIAL, UBC_WRITE|UBC_UNMAP_FLAG(vp));
if (error)
- DPRINTF(("zero-fill 0x%lx@0x%" PRIx64 " => %d\n", len, off, error));
+ DPRINTF(("zero-fill 0x%lx@0x%llx => %d\n", len, off, error));
return;
}
@@ -1168,6 +1171,7 @@
PUFFS_MSG_VARS(vn, setattr);
struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
struct puffs_node *pn = vp->v_data;
+ vsize_t oldsize = vp->v_size;
int error = 0;
KASSERT(!(flags & SETATTR_CHSIZE) || mutex_owned(&pn->pn_sizemtx));
@@ -1223,17 +1227,6 @@
if ((flags & SETATTR_ASYNC) == 0)
error = puffs_msg_wait2(pmp, park_setattr, vp->v_data, NULL);
- /*
- * If we truncate the file, make sure we zero-fill
- * the end of the last page, otherwise if the file
- * is later truncated to a larger size (creating a
- * a hole), that area will not return zeroes as it
- * should.
- */
- if ((error == 0) && (flags & SETATTR_CHSIZE) &&
- (vap->va_size != VNOVAL) && (vap->va_size < vp->v_size))
- zerofill_lastpage(vp, vap->va_size);
-
if ((error == 0) && PUFFS_USE_FS_TTL(pmp)) {
struct timespec *va_ttl = &setattr_msg->pvnr_va_ttl;
struct vattr *rvap = &setattr_msg->pvnr_va;
@@ -1251,6 +1244,17 @@
}
if (vap->va_size != VNOVAL) {
+ /*
+ * If we truncated the file, make sure the data beyond
+ * EOF in last page does not remain in cache, otherwise
+ * if the file is later truncated to a larger size (creating
+ * a hole), that area will not return zeroes as it
+ * should.
+ */
+ if ((flags & SETATTR_CHSIZE) && PUFFS_USE_PAGECACHE(pmp) &&
+ (vap->va_size < oldsize))
+ zerofill_lastpage(vp, vap->va_size);
+
pn->pn_serversize = vap->va_size;
if (flags & SETATTR_CHSIZE)
uvm_vnp_setsize(vp, vap->va_size);
Home |
Main Index |
Thread Index |
Old Index