summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2008-03-16 19:42:58 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2008-03-16 19:42:58 +0000
commitd4545e818f0707235e329a03a45dae9d48d70808 (patch)
tree31f7d6172379994f72e216732c09176657d6ddb1 /sys/kern
parent84746867a9863df603adc37bc169855703df4c5b (diff)
Widen some struct statfs fields to support large filesystem stata
and add some to be able to support statvfs(2). Do the compat dance to provide backward compatibility. ok thib@ miod@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/syscalls.master21
-rw-r--r--sys/kern/vfs_bio.c17
-rw-r--r--sys/kern/vfs_subr.c38
3 files changed, 63 insertions, 13 deletions
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 9611838bc9d..7c8970714aa 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.89 2008/01/05 00:36:13 miod Exp $
+; $OpenBSD: syscalls.master,v 1.90 2008/03/16 19:42:57 otto Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -514,17 +514,17 @@
#else
259 UNIMPL
#endif
-260 STD { int sys_getfsstat(struct statfs *buf, size_t bufsize, \
+260 COMPAT_O43 { int sys_getfsstat(struct o43statfs *buf, size_t bufsize, \
int flags); }
-261 STD { int sys_statfs(const char *path, \
- struct statfs *buf); }
-262 STD { int sys_fstatfs(int fd, struct statfs *buf); }
+261 COMPAT_O43 { int sys_statfs(const char *path, \
+ struct o43statfs *buf); }
+262 COMPAT_O43 { int sys_fstatfs(int fd, struct o43statfs *buf); }
263 STD { int sys_pipe(int *fdp); }
264 STD { int sys_fhopen(const fhandle_t *fhp, int flags); }
265 COMPAT_35 { int sys_fhstat(const fhandle_t *fhp, \
struct stat35 *sb); }
-266 STD { int sys_fhstatfs(const fhandle_t *fhp, \
- struct statfs *buf); }
+266 COMPAT_O43 { int sys_fhstatfs(const fhandle_t *fhp, \
+ struct o43statfs *buf); }
267 STD { ssize_t sys_preadv(int fd, \
const struct iovec *iovp, int iovcnt, \
int pad, off_t offset); }
@@ -611,3 +611,10 @@
304 STD { int sys___getcwd(char *buf, size_t len); }
305 STD { int sys_adjfreq(const int64_t *freq, \
int64_t *oldfreq); }
+306 STD { int sys_getfsstat(struct statfs *buf, size_t bufsize, \
+ int flags); }
+307 STD { int sys_statfs(const char *path, \
+ struct statfs *buf); }
+308 STD { int sys_fstatfs(int fd, struct statfs *buf); }
+309 STD { int sys_fhstatfs(const fhandle_t *fhp, \
+ struct statfs *buf); }
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 8b2720b36b6..4d11266537c 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.102 2007/10/21 15:54:55 beck Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.103 2008/03/16 19:42:57 otto Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*-
@@ -377,6 +377,7 @@ struct buf *
bio_doread(struct vnode *vp, daddr64_t blkno, int size, int async)
{
struct buf *bp;
+ struct mount *mp;
bp = getblk(vp, blkno, size, 0, 0);
@@ -395,6 +396,20 @@ bio_doread(struct vnode *vp, daddr64_t blkno, int size, int async)
brelse(bp);
}
+ mp = vp->v_type == VBLK? vp->v_specmountpoint : vp->v_mount;
+
+ /*
+ * Collect statistics on synchronous and asynchronous reads.
+ * Reads from block devices are charged to their associated
+ * filesystem (if any).
+ */
+ if (mp != NULL) {
+ if (async == 0)
+ mp->mnt_stat.f_syncreads++;
+ else
+ mp->mnt_stat.f_asyncreads++;
+ }
+
return (bp);
}
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 05db45dfeb3..a3894346e16 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.161 2007/12/13 18:22:36 blambert Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.162 2008/03/16 19:42:57 otto Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -2228,20 +2228,23 @@ vfs_mount_print(struct mount *mp, int full, int (*pr)(const char *, ...))
vfc->vfc_vfsops, vfc->vfc_name, vfc->vfc_typenum,
vfc->vfc_refcount, vfc->vfc_flags);
- (*pr)("statvfs cache: bsize %x iosize %x\nblocks %u free %u avail %u\n",
+ (*pr)("statvfs cache: bsize %x iosize %x\nblocks %llu free %llu avail %lld\n",
mp->mnt_stat.f_bsize, mp->mnt_stat.f_iosize, mp->mnt_stat.f_blocks,
mp->mnt_stat.f_bfree, mp->mnt_stat.f_bavail);
- (*pr)(" files %u ffiles %u\n", mp->mnt_stat.f_files,
- mp->mnt_stat.f_ffree);
+ (*pr)(" files %llu ffiles %llu favail $lld\n", mp->mnt_stat.f_files,
+ mp->mnt_stat.f_ffree, mp->mnt_stat.f_favail);
(*pr)(" f_fsidx {0x%x, 0x%x} owner %u ctime 0x%x\n",
mp->mnt_stat.f_fsid.val[0], mp->mnt_stat.f_fsid.val[1],
mp->mnt_stat.f_owner, mp->mnt_stat.f_ctime);
- (*pr)(" syncwrites %lu asyncwrites = %lu\n",
+ (*pr)(" syncwrites %llu asyncwrites = %llu\n",
mp->mnt_stat.f_syncwrites, mp->mnt_stat.f_asyncwrites);
+ (*pr)(" syncreads %llu asyncreads = %llu\n",
+ mp->mnt_stat.f_syncreads, mp->mnt_stat.f_asyncreads);
+
(*pr)(" fstype \"%s\" mnton \"%s\" mntfrom \"%s\"\n",
mp->mnt_stat.f_fstypename, mp->mnt_stat.f_mntonname,
mp->mnt_stat.f_mntfromname);
@@ -2273,3 +2276,28 @@ vfs_mount_print(struct mount *mp, int full, int (*pr)(const char *, ...))
}
}
#endif /* DDB */
+
+void
+copy_statfs_info(struct statfs *sbp, const struct mount *mp)
+{
+ const struct statfs *mbp;
+
+ strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
+
+ if (sbp == (mbp = &mp->mnt_stat))
+ return;
+
+ sbp->f_fsid = mbp->f_fsid;
+ sbp->f_owner = mbp->f_owner;
+ sbp->f_flags = mbp->f_flags;
+ sbp->f_syncwrites = mbp->f_syncwrites;
+ sbp->f_asyncwrites = mbp->f_asyncwrites;
+ sbp->f_syncreads = mbp->f_syncreads;
+ sbp->f_asyncreads = mbp->f_asyncreads;
+ sbp->f_namemax = mbp->f_namemax;
+ bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
+ bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
+ bcopy(&mp->mnt_stat.mount_info.ufs_args, &sbp->mount_info.ufs_args,
+ sizeof(struct ufs_args));
+}
+