Remove the CTLFLAG_NOLOCK as it seems to be both unused and

unfunctional.  Wiring the user buffer has only been done explicitly
since r101422.

Mark the kern.disks sysctl as MPSAFE since it is and it seems to have
been mis-using the NOLOCK flag.

Partially break the KPI (but not the KBI) for the sysctl_req 'lock'
field since this member should be private and the "REQ_LOCKED" state
seems meaningless now.
This commit is contained in:
mdf 2011-01-26 22:48:09 +00:00
parent b2f1af47a5
commit 886222db75
3 changed files with 8 additions and 11 deletions

View File

@ -527,6 +527,7 @@ sysctl_disks(SYSCTL_HANDLER_ARGS)
return error;
}
SYSCTL_PROC(_kern, OID_AUTO, disks, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NOLOCK, 0, 0,
SYSCTL_PROC(_kern, OID_AUTO, disks,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
sysctl_disks, "A", "names of available disks");

View File

@ -1206,7 +1206,7 @@ kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
req.oldfunc = sysctl_old_kernel;
req.newfunc = sysctl_new_kernel;
req.lock = REQ_LOCKED;
req.lock = REQ_UNWIRED;
SYSCTL_XLOCK();
error = sysctl_root(0, name, namelen, &req);
@ -1314,7 +1314,7 @@ sysctl_wire_old_buffer(struct sysctl_req *req, size_t len)
wiredlen = (len > 0 && len < req->oldlen) ? len : req->oldlen;
ret = 0;
if (req->lock == REQ_LOCKED && req->oldptr &&
if (req->lock != REQ_WIRED && req->oldptr &&
req->oldfunc == sysctl_old_user) {
if (wiredlen != 0) {
ret = vslock(req->oldptr, wiredlen);
@ -1350,8 +1350,6 @@ sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
return (ENOENT);
indx++;
if (oid->oid_kind & CTLFLAG_NOLOCK)
req->lock = REQ_UNLOCKED;
if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
if (oid->oid_handler != NULL || indx == namelen) {
*noid = oid;
@ -1548,7 +1546,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
req.oldfunc = sysctl_old_user;
req.newfunc = sysctl_new_user;
req.lock = REQ_LOCKED;
req.lock = REQ_UNWIRED;
#ifdef KTRACE
if (KTRPOINT(curthread, KTR_SYSCTL))

View File

@ -77,7 +77,6 @@ struct ctlname {
#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
#define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */
@ -122,9 +121,8 @@ struct ctlname {
struct sysctl_req *req
/* definitions for sysctl_req 'lock' member */
#define REQ_UNLOCKED 0 /* not locked and not wired */
#define REQ_LOCKED 1 /* locked and not wired */
#define REQ_WIRED 2 /* locked and wired */
#define REQ_UNWIRED 1
#define REQ_WIRED 2
/* definitions for sysctl_req 'flags' member */
#if defined(__amd64__) || defined(__ia64__) || defined(__powerpc64__)
@ -137,7 +135,7 @@ struct ctlname {
*/
struct sysctl_req {
struct thread *td; /* used for access checking */
int lock; /* locking/wiring state */
int lock; /* wiring state */
void *oldptr;
size_t oldlen;
size_t oldidx;