From 0372a61a28f9aeaf525a6e380278a8e1af62e03e Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 10 Mar 2009 15:26:50 +0000 Subject: [PATCH] Add an ABI compat shim for the vfs.bufspace sysctl for sysctl requests that try to fetch it as an int rather than a long. If the current value is greater than INT_MAX it reports a value of INT_MAX. --- sys/kern/vfs_bio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index b2fbe9392917..9942934f4c16 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "opt_compat.h" #include "opt_directio.h" #include "opt_swap.h" @@ -108,6 +109,10 @@ static int vfs_bio_clcheck(struct vnode *vp, int size, static int flushbufqueues(int, int); static void buf_daemon(void); static void bremfreel(struct buf *bp); +#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) +static int sysctl_bufspace(SYSCTL_HANDLER_ARGS); +#endif int vmiodirenable = TRUE; SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0, @@ -116,8 +121,14 @@ long runningbufspace; SYSCTL_LONG(_vfs, OID_AUTO, runningbufspace, CTLFLAG_RD, &runningbufspace, 0, "Amount of presently outstanding async buffer io"); static long bufspace; +#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) +SYSCTL_PROC(_vfs, OID_AUTO, bufspace, CTLTYPE_LONG|CTLFLAG_MPSAFE|CTLFLAG_RD, + &bufspace, 0, sysctl_bufspace, "L", "KVA memory used for bufs"); +#else SYSCTL_LONG(_vfs, OID_AUTO, bufspace, CTLFLAG_RD, &bufspace, 0, "KVA memory used for bufs"); +#endif static long maxbufspace; SYSCTL_LONG(_vfs, OID_AUTO, maxbufspace, CTLFLAG_RD, &maxbufspace, 0, "Maximum allowed value of bufspace (including buf_daemon)"); @@ -265,6 +276,22 @@ const char *buf_wmesg = BUF_WMESG; #define VFS_BIO_NEED_FREE 0x04 /* wait for free bufs, hi hysteresis */ #define VFS_BIO_NEED_BUFSPACE 0x08 /* wait for buf space, lo hysteresis */ +#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ + defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) +static int +sysctl_bufspace(SYSCTL_HANDLER_ARGS) +{ + long lvalue; + int ivalue; + + if (sizeof(int) == sizeof(long) || req->oldlen == sizeof(long)) + return (sysctl_handle_long(oidp, arg1, arg2, req)); + lvalue = *(long *)arg1; + ivalue = lvalue > INT_MAX ? INT_MAX : lvalue; + return (sysctl_handle_int(oidp, &ivalue, 0, req)); +} +#endif + #ifdef DIRECTIO extern void ffs_rawread_setup(void); #endif /* DIRECTIO */