diff --git a/sys/arch/xen/xen/xbd.c b/sys/arch/xen/xen/xbd.c index cd1efbd14678..c919d63dbdf6 100644 --- a/sys/arch/xen/xen/xbd.c +++ b/sys/arch/xen/xen/xbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: xbd.c,v 1.26 2005/12/13 08:24:30 yamt Exp $ */ +/* $NetBSD: xbd.c,v 1.27 2005/12/26 10:36:47 yamt Exp $ */ /* * @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.26 2005/12/13 08:24:30 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.27 2005/12/26 10:36:47 yamt Exp $"); #include "xbd.h" #include "rnd.h" @@ -1522,7 +1522,7 @@ xbdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) { struct xbd_softc *xs; struct dk_softc *dksc; - int ret; + int error; struct disk *dk; DPRINTF_FOLLOW(("xbdioctl(%d, %08lx, %p, %d, %p)\n", @@ -1531,13 +1531,18 @@ xbdioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) dksc = &xs->sc_dksc; dk = &dksc->sc_dkdev; + KASSERT(bufq == dksc->sc_bufq); + switch (cmd) { + case DIOCSSTRATEGY: + error = EOPNOTSUPP; + break; default: - ret = dk_ioctl(xs->sc_di, dksc, dev, cmd, data, flag, l); + error = dk_ioctl(xs->sc_di, dksc, dev, cmd, data, flag, l); break; } - return ret; + return error; } int diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 644c1750939f..a85edaac5a80 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.314 2005/12/11 12:21:14 christos Exp $ */ +/* $NetBSD: wd.c,v 1.315 2005/12/26 10:36:47 yamt Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.314 2005/12/11 12:21:14 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.315 2005/12/26 10:36:47 yamt Exp $"); #ifndef ATADEBUG #define ATADEBUG @@ -1440,6 +1440,47 @@ bad: return (dkwedge_list(&wd->sc_dk, dkwl, l)); } + case DIOCGSTRATEGY: + { + struct disk_strategy *dks = (void *)addr; + + s = splbio(); + strlcpy(dks->dks_name, bufq_getstrategyname(wd->sc_q), + sizeof(dks->dks_name)); + splx(s); + dks->dks_paramlen = 0; + + return 0; + } + + case DIOCSSTRATEGY: + { + struct disk_strategy *dks = (void *)addr; + struct bufq_state *new; + struct bufq_state *old; + + if ((flag & FWRITE) == 0) { + return EBADF; + } + if (dks->dks_param != NULL) { + return EINVAL; + } + dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */ + error = bufq_alloc(&new, dks->dks_name, + BUFQ_EXACT|BUFQ_SORT_RAWBLOCK); + if (error) { + return error; + } + s = splbio(); + old = wd->sc_q; + bufq_move(new, old); + wd->sc_q = new; + splx(s); + bufq_free(old); + + return 0; + } + default: return ENOTTY; } diff --git a/sys/dev/dksubr.c b/sys/dev/dksubr.c index bb63a42cb66c..fc4b3e3beb80 100644 --- a/sys/dev/dksubr.c +++ b/sys/dev/dksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: dksubr.c,v 1.20 2005/12/11 23:42:33 rpaulo Exp $ */ +/* $NetBSD: dksubr.c,v 1.21 2005/12/26 10:36:47 yamt Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.20 2005/12/11 23:42:33 rpaulo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.21 2005/12/26 10:36:47 yamt Exp $"); #include #include @@ -451,6 +451,49 @@ dk_ioctl(struct dk_intf *di, struct dk_softc *dksc, dev_t dev, return (dkwedge_list(&dksc->sc_dkdev, dkwl, l)); } + case DIOCGSTRATEGY: + { + struct disk_strategy *dks = (void *)data; + int s; + + s = splbio(); + strlcpy(dks->dks_name, bufq_getstrategyname(dksc->sc_bufq), + sizeof(dks->dks_name)); + splx(s); + dks->dks_paramlen = 0; + + return 0; + } + + case DIOCSSTRATEGY: + { + struct disk_strategy *dks = (void *)data; + struct bufq_state *new; + struct bufq_state *old; + int s; + + if ((flag & FWRITE) == 0) { + return EBADF; + } + if (dks->dks_param != NULL) { + return EINVAL; + } + dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */ + error = bufq_alloc(&new, dks->dks_name, + BUFQ_EXACT|BUFQ_SORT_RAWBLOCK); + if (error) { + return error; + } + s = splbio(); + old = dksc->sc_bufq; + bufq_move(new, old); + dksc->sc_bufq = new; + splx(s); + bufq_free(old); + + return 0; + } + default: error = ENOTTY; } diff --git a/sys/kern/subr_bufq.c b/sys/kern/subr_bufq.c index a6ea1c1ba9c9..82917a292f75 100644 --- a/sys/kern/subr_bufq.c +++ b/sys/kern/subr_bufq.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_bufq.c,v 1.11 2005/12/26 10:00:34 yamt Exp $ */ +/* $NetBSD: subr_bufq.c,v 1.12 2005/12/26 10:36:47 yamt Exp $ */ /* NetBSD: subr_disk.c,v 1.70 2005/08/20 12:00:01 yamt Exp $ */ /*- @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_bufq.c,v 1.11 2005/12/26 10:00:34 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_bufq.c,v 1.12 2005/12/26 10:36:47 yamt Exp $"); #include #include @@ -214,7 +214,6 @@ bufq_free(struct bufq_state *bufq) free(bufq, M_DEVBUF); } -#if 0 /* * get a strategy identifier of a buffer queue. */ @@ -237,7 +236,6 @@ bufq_move(struct bufq_state *dst, struct bufq_state *src) BUFQ_PUT(dst, bp); } } -#endif static int docopy(char *buf, size_t *bufoffp, size_t buflen, diff --git a/sys/sys/disk.h b/sys/sys/disk.h index ce0bd444d18f..394cf010e68d 100644 --- a/sys/sys/disk.h +++ b/sys/sys/disk.h @@ -1,4 +1,4 @@ -/* $NetBSD: disk.h,v 1.31 2005/12/11 12:25:20 christos Exp $ */ +/* $NetBSD: disk.h,v 1.32 2005/12/26 10:36:47 yamt Exp $ */ /*- * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc. @@ -310,6 +310,13 @@ struct disk_badsecinfo { caddr_t dbsi_buffer; /* region to copy disk_badsectors to */ }; +#define DK_STRATEGYNAMELEN 32 +struct disk_strategy { + char dks_name[DK_STRATEGYNAMELEN]; /* name of strategy */ + char *dks_param; /* notyet; should be NULL */ + size_t dks_paramlen; /* notyet; should be 0 */ +}; + #ifdef _KERNEL extern int disk_count; /* number of disks in global disklist */ diff --git a/sys/sys/dkio.h b/sys/sys/dkio.h index 107d4f9a841e..f07f40ba5baf 100644 --- a/sys/sys/dkio.h +++ b/sys/sys/dkio.h @@ -1,4 +1,4 @@ -/* $NetBSD: dkio.h,v 1.11 2005/12/11 12:25:20 christos Exp $ */ +/* $NetBSD: dkio.h,v 1.12 2005/12/26 10:36:47 yamt Exp $ */ /* * Copyright (c) 1987, 1988, 1993 @@ -94,4 +94,8 @@ #define DIOCDWEDGE _IOW('d', 123, struct dkwedge_info) /* del wedge */ #define DIOCLWEDGES _IOWR('d', 124, struct dkwedge_list) /* list wedges */ + /* disk buffer queue strategy */ +#define DIOCGSTRATEGY _IOR('d', 125, struct disk_strategy) +#define DIOCSSTRATEGY _IOW('d', 126, struct disk_strategy) + #endif /* _SYS_DKIO_H_ */