From e385571ba37fa6d43fecca17e9e5d60a22a414cd Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 27 Mar 2013 18:12:41 -0500 Subject: [PATCH] afs: Raise fake free space reporting We report 'fake' values for free space, free file nodes, etc for the 'AFS' filesystem, since these values are not meaningful for AFS itself. Currently we report about 9G of free space for most platforms, and a few different values for a few others. Raise all of these to 2^32-1, so that trying to copy over 9G of data into AFS does not fail for those applications that check the destination free space with statfs(2). Note that one such application is KDE 4.8.x. Consolidate all places that do this, and put the 'fake' value in one place, AFS_VFS_FAKEFREE, along with the relevant comments. Related issues reported by Lars Schimmer, Richard Brittain, and others. Change-Id: Ia15175da32744e11f62489c29bedfe1f5560d2b4 Reviewed-on: http://gerrit.openafs.org/9688 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Markus Koeberl Tested-by: Markus Koeberl Reviewed-by: D Brashear --- src/afs/AIX/osi_vfsops.c | 2 +- src/afs/DARWIN/osi_vfsops.c | 6 +----- src/afs/FBSD/osi_vfsops.c | 6 +----- src/afs/HPUX/osi_vfsops.c | 2 +- src/afs/IRIX/osi_vfsops.c | 2 +- src/afs/LINUX/osi_vfsops.c | 2 +- src/afs/LINUX24/osi_vfsops.c | 2 +- src/afs/NBSD/osi_vfsops.c | 8 +------- src/afs/OBSD/osi_vfsops.c | 8 +------- src/afs/SOLARIS/osi_vfsops.c | 3 +-- src/afs/UKERNEL/osi_vfsops.c | 3 +-- src/afs/afs.h | 6 ++++++ 12 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/afs/AIX/osi_vfsops.c b/src/afs/AIX/osi_vfsops.c index c24fc6eda..32fbbf5c8 100644 --- a/src/afs/AIX/osi_vfsops.c +++ b/src/afs/AIX/osi_vfsops.c @@ -174,7 +174,7 @@ afs_statfs(struct vfs *afsp, struct statfs *abp, struct ucred *credp) abp->f_type = 0; abp->f_bsize = afsp->vfs_bsize; abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 9000000; + abp->f_ffree = AFS_VFS_FAKEFREE; abp->f_vfstype = AFS_VFSFSID; abp->f_vfsnumber = afsp->vfs_number; abp->f_vfsoff = abp->f_vfslen = abp->f_vfsvers = -1; diff --git a/src/afs/DARWIN/osi_vfsops.c b/src/afs/DARWIN/osi_vfsops.c index d0efb8c2d..22cfeba3d 100644 --- a/src/afs/DARWIN/osi_vfsops.c +++ b/src/afs/DARWIN/osi_vfsops.c @@ -361,12 +361,8 @@ afs_statfs(struct mount *mp, STATFS_TYPE *abp, CTX_TYPE ctx) abp->f_type = MOUNT_AFS; #endif - /* Fake a high number below to satisfy programs that use the statfs call - * to make sure that there's enough space in the device partition before - * storing something there. - */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 0x7fffffff; + abp->f_ffree = AFS_VFS_FAKEFREE; if (abp != sysstat) { abp->f_fsid.val[0] = sysstat->f_fsid.val[0]; diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c index 0878e65d7..54d33668c 100644 --- a/src/afs/FBSD/osi_vfsops.c +++ b/src/afs/FBSD/osi_vfsops.c @@ -338,12 +338,8 @@ afs_statfs(struct mount *mp, struct statfs *abp, struct thread *p) abp->f_bsize = mp->vfs_bsize; abp->f_iosize = mp->vfs_bsize; - /* Fake a high number below to satisfy programs that use the statfs call - * to make sure that there's enough space in the device partition before - * storing something there. - */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 2000000; + abp->f_ffree = AFS_VFS_FAKEFREE; abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0]; abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1]; diff --git a/src/afs/HPUX/osi_vfsops.c b/src/afs/HPUX/osi_vfsops.c index acb601bd3..ca5de57fd 100644 --- a/src/afs/HPUX/osi_vfsops.c +++ b/src/afs/HPUX/osi_vfsops.c @@ -165,7 +165,7 @@ afs_statfs(struct vfs *afsp, struct k_statvfs *abp) * before storing something there. */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = abp->f_favail = 9000000; + abp->f_ffree = abp->f_favail = AFS_VFS_FAKEFREE; abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; AFS_GUNLOCK(); diff --git a/src/afs/IRIX/osi_vfsops.c b/src/afs/IRIX/osi_vfsops.c index b876f3f49..bc129d62d 100644 --- a/src/afs/IRIX/osi_vfsops.c +++ b/src/afs/IRIX/osi_vfsops.c @@ -313,7 +313,7 @@ afs_statfs(OSI_VFS_ARG(afsp), abp, avp) * before storing something there. */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = abp->f_favail = 900000; + abp->f_ffree = abp->f_favail = AFS_VFS_FAKEFREE; abp->f_fsid = AFS_VFSMAGIC; /* magic */ strcpy(abp->f_basetype, AFS_MOUNT_AFS); diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index cad22a158..cad455567 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -371,7 +371,7 @@ afs_statfs(struct super_block *sbp, struct kstatfs *statp) statp->f_bsize = sbp->s_blocksize; #endif statp->f_blocks = statp->f_bfree = statp->f_bavail = statp->f_files = - statp->f_ffree = 9000000; + statp->f_ffree = AFS_VFS_FAKEFREE; statp->f_fsid.val[0] = AFS_VFSMAGIC; statp->f_fsid.val[1] = AFS_VFSFSID; statp->f_namelen = 256; diff --git a/src/afs/LINUX24/osi_vfsops.c b/src/afs/LINUX24/osi_vfsops.c index 77b821bb2..6c8d29e6f 100644 --- a/src/afs/LINUX24/osi_vfsops.c +++ b/src/afs/LINUX24/osi_vfsops.c @@ -345,7 +345,7 @@ afs_statfs(struct super_block *sbp, struct statfs *__statp, int size) statp->f_bsize = sbp->s_blocksize; #endif statp->f_blocks = statp->f_bfree = statp->f_bavail = statp->f_files = - statp->f_ffree = 9000000; + statp->f_ffree = AFS_VFS_FAKEFREE; statp->f_fsid.val[0] = AFS_VFSMAGIC; statp->f_fsid.val[1] = AFS_VFSFSID; statp->f_namelen = 256; diff --git a/src/afs/NBSD/osi_vfsops.c b/src/afs/NBSD/osi_vfsops.c index c11d6af6a..3e418471f 100644 --- a/src/afs/NBSD/osi_vfsops.c +++ b/src/afs/NBSD/osi_vfsops.c @@ -422,14 +422,8 @@ afs_statvfs(struct mount *mp, struct statvfs *abp) abp->f_frsize = mp->osi_vfs_bsize; abp->f_iosize = mp->osi_vfs_bsize; - /* - * Fake a high number below to satisfy programs that use the ustat (for - * * AIX), or statfs (for the rest) call to make sure that there's - * enough * space in the device partition before storing something there - * (like * ed(1)) - */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 9000000; + abp->f_ffree = AFS_VFS_FAKEFREE; return (0); } diff --git a/src/afs/OBSD/osi_vfsops.c b/src/afs/OBSD/osi_vfsops.c index 3db75e2a6..aa2ccb4ff 100644 --- a/src/afs/OBSD/osi_vfsops.c +++ b/src/afs/OBSD/osi_vfsops.c @@ -375,14 +375,8 @@ afs_statfs(struct osi_vfs *afsp, struct statfs *abp) AFS_STATCNT(afs_statfs); abp->f_bsize = afsp->osi_vfs_bsize; - /* - * Fake a high number below to satisfy programs that use the ustat (for - * * AIX), or statfs (for the rest) call to make sure that there's - * enough * space in the device partition before storing something there - * (like * ed(1)) - */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 9000000; + abp->f_ffree = AFS_VFS_FAKEFREE; abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */ abp->f_fsid.val[1] = (int)AFS_VFSFSID; return 0; diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index ebb5012f9..ca2553b22 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -229,10 +229,9 @@ afs_statvfs(struct vfs *afsp, struct statvfs64 *abp) AFS_STATCNT(afs_statfs); abp->f_frsize = 1024; - abp->f_favail = 9000000; abp->f_bsize = afsp->vfs_bsize; abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 9000000; + abp->f_favail = abp->f_ffree = AFS_VFS_FAKEFREE; abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; AFS_GUNLOCK(); diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c index 53dd5efa8..42d25abb2 100644 --- a/src/afs/UKERNEL/osi_vfsops.c +++ b/src/afs/UKERNEL/osi_vfsops.c @@ -121,10 +121,9 @@ afs_statvfs(struct vfs *afsp, struct statvfs *abp) AFS_STATCNT(afs_statfs); abp->f_frsize = 1024; - abp->f_favail = 9000000; abp->f_bsize = afsp->vfs_bsize; abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 9000000; + abp->f_favail = abp->f_ffree = AFS_VFS_FAKEFREE; #ifdef AFS_USR_AIX_ENV abp->f_fsid.val[0] = AFS_VFSMAGIC; diff --git a/src/afs/afs.h b/src/afs/afs.h index fd1c54d88..fbd542ddb 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -48,6 +48,12 @@ extern int afs_shuttingdown; #define AFS_VFSFSID AFS_MOUNT_AFS #endif #endif +/* use this value for reporting total space, free space, etc. + * fake a high number to satisfy programs that use the statfs call to make sure + * that there's enough space in the device partition before storing something + * there. keep it just under 2^31, to try and be safe about not breaking + * stuff that looks at the amount of free space. */ +#define AFS_VFS_FAKEFREE (2147483647) /* Moved from VNOPS/afs_vnop_flocks so can be used in prototypes */ #if defined(AFS_HPUX102_ENV) -- 2.39.5