From 08355369c3917392ea1d3eabd420452c2e1361a3 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. 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 (cherry picked from commit e385571ba37fa6d43fecca17e9e5d60a22a414cd) Change-Id: Id9b5fa92f48bc83b84bb4f50bc0ae25b028694b0 Reviewed-on: http://gerrit.openafs.org/10984 Tested-by: Andrew Deason Reviewed-by: D Brashear Reviewed-by: Benjamin Kaduk Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- 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 b32ad1881..860642340 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 c4d35ba23..5de249b63 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 7aa2a316f..15839e3d7 100644 --- a/src/afs/IRIX/osi_vfsops.c +++ b/src/afs/IRIX/osi_vfsops.c @@ -320,7 +320,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 e0bea4825..5ae909e00 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -364,7 +364,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 922b1d591..74da69b12 100644 --- a/src/afs/NBSD/osi_vfsops.c +++ b/src/afs/NBSD/osi_vfsops.c @@ -385,14 +385,8 @@ afs_statvfs(struct mount *mp, struct statvfs *abp, struct lwp *l) 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 a7e7d1dd0..7fbbcb6bc 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -250,10 +250,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; 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 88d5f7763..c2140f898 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