As a first generation best-effort hack, use NOCACHE to mean "file

size can change without the kernel knowing" and therefore query
the file size before invoking read or write operations.
This commit is contained in:
pooka 2006-11-18 08:18:24 +00:00
parent 9ef6d9f3e5
commit dfa114e254
3 changed files with 34 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_subr.c,v 1.8 2006/11/16 01:33:37 christos Exp $ */
/* $NetBSD: puffs_subr.c,v 1.9 2006/11/18 08:18:24 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_subr.c,v 1.8 2006/11/16 01:33:37 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_subr.c,v 1.9 2006/11/18 08:18:24 pooka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -373,3 +373,15 @@ puffs_updatenode(struct vnode *vp, int flags)
puffs_vntouser_faf(MPTOPUFFSMP(vp->v_mount), PUFFS_VN_SETATTR,
setattr_arg, sizeof(struct puffs_vnreq_setattr), VPTOPNC(vp));
}
void
puffs_updatevpsize(struct vnode *vp)
{
struct vattr va;
if (VOP_GETATTR(vp, &va, FSCRED, NULL))
return;
if (va.va_size != VNOVAL)
vp->v_size = va.va_size;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_sys.h,v 1.8 2006/11/17 17:48:02 pooka Exp $ */
/* $NetBSD: puffs_sys.h,v 1.9 2006/11/18 08:18:24 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -180,6 +180,7 @@ void puffs_updatenode(struct vnode *, int);
#define PUFFS_UPDATECTIME 0x02
#define PUFFS_UPDATEMTIME 0x04
#define PUFFS_UPDATESIZE 0x08
void puffs_updatevpsize(struct vnode *);
int puffs_setpmp(pid_t, int, struct puffs_mount *);
void puffs_nukebypmp(struct puffs_mount *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_vnops.c,v 1.11 2006/11/17 17:48:02 pooka Exp $ */
/* $NetBSD: puffs_vnops.c,v 1.12 2006/11/18 08:18:24 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.11 2006/11/17 17:48:02 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.12 2006/11/18 08:18:24 pooka Exp $");
#include <sys/param.h>
#include <sys/vnode.h>
@ -1143,13 +1143,17 @@ puffs_read(void *v)
if (uio->uio_offset < 0)
return EINVAL;
ubcflags = 0;
if (UBC_WANT_UNMAP(vp) || pmp->pmp_flags & PUFFSFLAG_NOCACHE)
ubcflags = UBC_UNMAP;
if (vp->v_type == VREG) {
const int advice = IO_ADV_DECODE(ap->a_ioflag);
ubcflags = 0;
if (UBC_WANT_UNMAP(vp) || pmp->pmp_flags & PUFFSFLAG_NOCACHE)
ubcflags = UBC_UNMAP;
/* XXX: first generation hack */
if (pmp->pmp_flags & PUFFSFLAG_NOCACHE)
puffs_updatevpsize(vp);
while (uio->uio_resid > 0) {
bytelen = MIN(uio->uio_resid,
vp->v_size - uio->uio_offset);
@ -1258,11 +1262,15 @@ puffs_write(void *v)
write_argp = NULL;
pmp = MPTOPUFFSMP(ap->a_vp->v_mount);
ubcflags = 0;
if (UBC_WANT_UNMAP(vp) || pmp->pmp_flags & PUFFSFLAG_NOCACHE)
ubcflags = UBC_UNMAP;
if (vp->v_type == VREG) {
ubcflags = 0;
if (UBC_WANT_UNMAP(vp) || pmp->pmp_flags & PUFFSFLAG_NOCACHE)
ubcflags = UBC_UNMAP;
/* XXX: first generation hack */
if (pmp->pmp_flags & PUFFSFLAG_NOCACHE)
puffs_updatevpsize(vp);
/*
* userspace *should* be allowed to control this,
* but with UBC it's a bit unclear how to handle it