From 8334b40376f4b820e5f08e0a1f477be7c04c5cc8 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Sat, 28 Aug 2010 20:43:41 -0400 Subject: [PATCH] FBSD, DFBSD (future) vnode_pager_setsize updates Based on review of bundled filesystems on FBSD and DFBSD, call vnode_pager_setsize in three unhandled cases (getattr, setattr, and io growing a file; truncation was handled correctly already). Following up on a suggestion by Ben Kaduk. Change-Id: I05b61c26402bb8ab49ad74b71af2d02b439f959f Reviewed-on: http://gerrit.openafs.org/2621 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/FBSD/osi_vnodeops.c | 2 ++ src/afs/VNOPS/afs_vnop_attrs.c | 12 ++++++++++++ src/afs/VNOPS/afs_vnop_write.c | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c index ea3aa34418..d5c16b285d 100644 --- a/src/afs/FBSD/osi_vnodeops.c +++ b/src/afs/FBSD/osi_vnodeops.c @@ -723,9 +723,11 @@ afs_vop_getattr(ap) * } */ *ap; { int code; + AFS_GLOCK(); code = afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred); AFS_GUNLOCK(); + return code; } diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index f5ac4941c9..b3931e546a 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -45,6 +45,9 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) { struct volume *tvp; struct cell *tcell; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + struct vnode *vp = AFSTOV(avc); +#endif int fakedir = 0; AFS_STATCNT(afs_CopyOutAttrs); @@ -115,6 +118,9 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs) attrs->va_nodeid &= 0x7fffffff; /* Saber C hates negative inode #s! */ attrs->va_nlink = fakedir ? 100 : avc->f.m.LinkCount; attrs->va_size = fakedir ? 4096 : avc->f.m.Length; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + vnode_pager_setsize(vp, (u_long) attrs->va_size); +#endif attrs->va_atime.tv_sec = attrs->va_mtime.tv_sec = attrs->va_ctime.tv_sec = fakedir ? 0 : (int)avc->f.m.Date; /* set microseconds to be dataversion # so that we approximate NFS-style @@ -445,6 +451,9 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs, struct vrequest treq; struct AFSStoreStatus astat; afs_int32 code; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + struct vnode *vp = AFSTOV(avc); +#endif struct afs_fakestat_state fakestate; OSI_VC_CONVERT(avc); @@ -553,6 +562,9 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs, * pdflush */ if (code == 0) i_size_write(AFSTOV(avc), tsize); +#endif +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + vnode_pager_setsize(vp, (u_long) tsize); #endif /* if date not explicitly set by this call, set it ourselves, since we * changed the data */ diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index ac0894e088..9d582f0ced 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -110,6 +110,9 @@ afs_MemWrite(struct vcache *avc, struct uio *auio, int aio, volatile #endif afs_int32 error; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + struct vnode *vp = AFSTOV(avc); +#endif #ifdef AFS_DARWIN80_ENV uio_t tuiop = NULL; #else @@ -268,6 +271,9 @@ afs_MemWrite(struct vcache *avc, struct uio *auio, int aio, ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos)); avc->f.m.Length = filePos; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + vnode_pager_setsize(vp, filePos); +#endif } #endif ReleaseWriteLock(&tdc->lock); @@ -321,6 +327,9 @@ afs_UFSWrite(struct vcache *avc, struct uio *auio, int aio, volatile #endif afs_int32 error; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + struct vnode *vp = AFSTOV(avc); +#endif #ifdef AFS_DARWIN80_ENV uio_t tuiop = NULL; #else @@ -570,6 +579,9 @@ afs_UFSWrite(struct vcache *avc, struct uio *auio, int aio, ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos)); avc->f.m.Length = filePos; +#if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV) + vnode_pager_setsize(vp, filePos); +#endif } #endif osi_UFSClose(tfile);