Add the statfs upcall so df now reports cache size and usage.

This commit is contained in:
phil 2002-03-27 05:10:40 +00:00
parent e0a7781fc7
commit 1e490dbb97
4 changed files with 80 additions and 34 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: coda.h,v 1.6 1998/11/11 19:22:08 rvb Exp $ */
/* $NetBSD: coda.h,v 1.7 2002/03/27 05:10:40 phil Exp $ */
/*
*
@ -90,14 +90,6 @@ typedef unsigned long long u_quad_t;
#define cdev_t dev_t
#endif
#ifdef __CYGWIN32__
typedef unsigned char u_int8_t;
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#endif
/*
* Cfs constants
@ -244,6 +236,15 @@ struct coda_vattr {
#endif
/* structure used by CODA_STATFS for getting cache information from venus */
struct coda_statfs {
int32_t f_blocks;
int32_t f_bfree;
int32_t f_bavail;
int32_t f_files;
int32_t f_ffree;
};
/*
* Kernel <--> Venus communications.
*/
@ -279,7 +280,8 @@ struct coda_vattr {
#define CODA_OPEN_BY_PATH 31
#define CODA_RESOLVE 32
#define CODA_REINTEGRATE 33
#define CODA_NCALLS 34
#define CODA_STATFS 34
#define CODA_NCALLS 35
#define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
@ -653,6 +655,16 @@ struct coda_open_by_path_out {
int path;
};
/* coda_statfs: NO_IN */
struct coda_statfs_in {
struct coda_in_hdr ih;
};
struct coda_statfs_out {
struct coda_out_hdr oh;
struct coda_statfs stat;
};
/*
* Occasionally, we don't cache the fid returned by CODA_LOOKUP.
* For instance, if the fid is inconsistent.
@ -682,7 +694,8 @@ union inputArgs {
struct coda_inactive_in coda_inactive;
struct coda_vget_in coda_vget;
struct coda_rdwr_in coda_rdwr;
struct coda_open_by_path_in coda_open_by_path;
struct coda_open_by_path_in coda_open_by_path;
struct coda_statfs_in coda_statfs;
};
union outputArgs {
@ -704,7 +717,8 @@ union outputArgs {
struct coda_purgefid_out coda_purgefid;
struct coda_rdwr_out coda_rdwr;
struct coda_replace_out coda_replace;
struct coda_open_by_path_out coda_open_by_path;
struct coda_open_by_path_out coda_open_by_path;
struct coda_statfs_out coda_statfs;
};
union coda_downcalls {

View File

@ -1,4 +1,4 @@
/* $NetBSD: coda_venus.c,v 1.11 2001/11/12 23:08:57 lukem Exp $ */
/* $NetBSD: coda_venus.c,v 1.12 2002/03/27 05:10:40 phil Exp $ */
/*
*
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: coda_venus.c,v 1.11 2001/11/12 23:08:57 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: coda_venus.c,v 1.12 2002/03/27 05:10:40 phil Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -640,6 +640,25 @@ venus_readdir(void *mdp, ViceFid *fid,
return error;
}
int
venus_statfs(void *mdp, struct ucred *cred, struct proc *p,
/*out*/ struct coda_statfs *fsp)
{
DECL(coda_statfs); /* sets Isize & Osize */
ALLOC(coda_statfs); /* sets inp & outp */
/* send the open to venus. */
INIT_IN(&inp->ih, CODA_STATFS, cred, p);
error = coda_call(mdp, Isize, &Osize, (char *)inp);
if (!error) {
*fsp = outp->stat;
}
CODA_FREE(inp, coda_statfs_size);
return error;
}
int
venus_fhtovp(void *mdp, ViceFid *fid,
struct ucred *cred, struct proc *p,

View File

@ -1,4 +1,4 @@
/* $NetBSD: coda_venus.h,v 1.3 1998/09/15 02:02:59 rvb Exp $ */
/* $NetBSD: coda_venus.h,v 1.4 2002/03/27 05:10:40 phil Exp $ */
/*
*
@ -127,6 +127,10 @@ venus_readdir(void *mdp, ViceFid *fid,
struct ucred *cred, struct proc *p,
/*out*/ char *buffer, int *len);
int
venus_statfs(void *mdp, struct ucred *cred, struct proc *p,
/*out*/ struct coda_statfs *fsp);
int
venus_fhtovp(void *mdp, ViceFid *fid,
struct ucred *cred, struct proc *p,

View File

@ -1,4 +1,4 @@
/* $NetBSD: coda_vfsops.c,v 1.15 2001/11/23 17:42:48 perry Exp $ */
/* $NetBSD: coda_vfsops.c,v 1.16 2002/03/27 05:10:41 phil Exp $ */
/*
*
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.15 2001/11/23 17:42:48 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.16 2002/03/27 05:10:41 phil Exp $");
#ifdef _LKM
#define NVCODA 4
@ -421,10 +421,13 @@ coda_nb_statfs(vfsp, sbp, p)
struct statfs *sbp;
struct proc *p;
{
struct coda_statfs fsstat;
int error;
ENTRY;
/* MARK_ENTRY(CODA_STATFS_STATS); */
MARK_ENTRY(CODA_STATFS_STATS);
if (!CODA_MOUNTED(vfsp)) {
/* MARK_INT_FAIL(CODA_STATFS_STATS);*/
/* MARK_INT_FAIL(CODA_STATFS_STATS); */
return(EINVAL);
}
@ -434,21 +437,27 @@ coda_nb_statfs(vfsp, sbp, p)
#define NB_SFS_SIZ 0x895440
*/
/* Note: Normal fs's have a bsize of 0x400 == 1024 */
sbp->f_type = 0;
sbp->f_bsize = 8192; /* XXX */
sbp->f_iosize = 8192; /* XXX */
#define NB_SFS_SIZ 0x8AB75D
sbp->f_blocks = NB_SFS_SIZ;
sbp->f_bfree = NB_SFS_SIZ;
sbp->f_bavail = NB_SFS_SIZ;
sbp->f_files = NB_SFS_SIZ;
sbp->f_ffree = NB_SFS_SIZ;
bcopy((caddr_t)&(vfsp->mnt_stat.f_fsid), (caddr_t)&(sbp->f_fsid), sizeof (fsid_t));
strncpy(sbp->f_fstypename, MOUNT_CODA, MFSNAMELEN-1);
strcpy(sbp->f_mntonname, "/coda");
strcpy(sbp->f_mntfromname, "CODA");
/* MARK_INT_SAT(CODA_STATFS_STATS); */
return(0);
error = venus_statfs(vftomi(vfsp), p->p_cred->pc_ucred, p, &fsstat);
if (!error) {
sbp->f_type = 0;
sbp->f_bsize = 8192; /* XXX */
sbp->f_iosize = 8192; /* XXX */
sbp->f_blocks = fsstat.f_blocks;
sbp->f_bfree = fsstat.f_bfree;
sbp->f_bavail = fsstat.f_bavail;
sbp->f_files = fsstat.f_files;
sbp->f_ffree = fsstat.f_ffree;
bcopy((caddr_t)&(vfsp->mnt_stat.f_fsid),
(caddr_t)&(sbp->f_fsid), sizeof (fsid_t));
strncpy(sbp->f_fstypename, MOUNT_CODA, MFSNAMELEN-1);
strcpy(sbp->f_mntonname, "/coda");
strcpy(sbp->f_mntfromname, "CODA");
}
MARK_INT_SAT(CODA_STATFS_STATS);
return(error);
}
/*