1/*-
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
--- 20 unchanged lines hidden (view full) ---
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 226735 2011-10-25 14:04:59Z pjd $");
38
39#include "opt_geom.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>
45#include <sys/bio.h>
--- 58 unchanged lines hidden (view full) ---
104 mtx_destroy(&g_disk_done_mtx);
105}
106
107DECLARE_GEOM_CLASS(g_disk_class, g_disk);
108
109static void __inline
110g_disk_lock_giant(struct disk *dp)
111{
112 if (dp->d_flags & DISKFLAG_NEEDSGIANT)
113 mtx_lock(&Giant);
114}
115
116static void __inline
117g_disk_unlock_giant(struct disk *dp)
118{
119 if (dp->d_flags & DISKFLAG_NEEDSGIANT)
120 mtx_unlock(&Giant);
121}
122
123static int
124g_disk_access(struct g_provider *pp, int r, int w, int e)
125{
126 struct disk *dp;
--- 119 unchanged lines hidden (view full) ---
246 /* XXX: will witness accept a mix of Giant/unGiant drivers here ? */
247 mtx_lock(&g_disk_done_mtx);
248 bp->bio_completed = bp->bio_length - bp->bio_resid;
249
250 bp2 = bp->bio_parent;
251 if (bp2->bio_error == 0)
252 bp2->bio_error = bp->bio_error;
253 bp2->bio_completed += bp->bio_completed;
254 if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) &&
255 (sc = bp2->bio_to->geom->softc) &&
256 (dp = sc->dp)) {
257 devstat_end_transaction_bio(dp->d_devstat, bp);
258 }
259 g_destroy_bio(bp);
260 bp2->bio_inbed++;
261 if (bp2->bio_children == bp2->bio_inbed) {
262 bp2->bio_resid = bp2->bio_bcount - bp2->bio_completed;
263 g_io_deliver(bp2, bp2->bio_error);
264 }
--- 12 unchanged lines hidden (view full) ---
277 sc = gp->softc;
278 dp = sc->dp;
279
280 if (dp->d_ioctl == NULL)
281 return (ENOIOCTL);
282 g_disk_lock_giant(dp);
283 error = dp->d_ioctl(dp, cmd, data, fflag, td);
284 g_disk_unlock_giant(dp);
285 return(error);
286}
287
288static void
289g_disk_start(struct bio *bp)
290{
291 struct bio *bp2, *bp3;
292 struct disk *dp;
293 struct g_disk_softc *sc;
--- 247 unchanged lines hidden (view full) ---
541{
542
543 return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO));
544}
545
546void
547disk_create(struct disk *dp, int version)
548{
549 if (version != DISK_VERSION_00 && version != DISK_VERSION_01) {
550 printf("WARNING: Attempt to add disk %s%d %s",
551 dp->d_name, dp->d_unit,
552 " using incompatible ABI version of disk(9)\n");
553 printf("WARNING: Ignoring disk %s%d\n",
554 dp->d_name, dp->d_unit);
555 return;
556 }
--- 73 unchanged lines hidden (view full) ---
630 error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
631 sbuf_delete(sb);
632 return error;
633}
634
635SYSCTL_PROC(_kern, OID_AUTO, disks,
636 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
637 sysctl_disks, "A", "names of available disks");
638
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
--- 20 unchanged lines hidden (view full) ---
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 226735 2011-10-25 14:04:59Z pjd $");
38
39#include "opt_geom.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>
45#include <sys/bio.h>
--- 58 unchanged lines hidden (view full) ---
104 mtx_destroy(&g_disk_done_mtx);
105}
106
107DECLARE_GEOM_CLASS(g_disk_class, g_disk);
108
109static void __inline
110g_disk_lock_giant(struct disk *dp)
111{
112 if (dp->d_flags & DISKFLAG_NEEDSGIANT)
113 mtx_lock(&Giant);
114}
115
116static void __inline
117g_disk_unlock_giant(struct disk *dp)
118{
119 if (dp->d_flags & DISKFLAG_NEEDSGIANT)
120 mtx_unlock(&Giant);
121}
122
123static int
124g_disk_access(struct g_provider *pp, int r, int w, int e)
125{
126 struct disk *dp;
--- 119 unchanged lines hidden (view full) ---
246 /* XXX: will witness accept a mix of Giant/unGiant drivers here ? */
247 mtx_lock(&g_disk_done_mtx);
248 bp->bio_completed = bp->bio_length - bp->bio_resid;
249
250 bp2 = bp->bio_parent;
251 if (bp2->bio_error == 0)
252 bp2->bio_error = bp->bio_error;
253 bp2->bio_completed += bp->bio_completed;
254 if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) &&
255 (sc = bp2->bio_to->geom->softc) &&
256 (dp = sc->dp)) {
257 devstat_end_transaction_bio(dp->d_devstat, bp);
258 }
259 g_destroy_bio(bp);
260 bp2->bio_inbed++;
261 if (bp2->bio_children == bp2->bio_inbed) {
262 bp2->bio_resid = bp2->bio_bcount - bp2->bio_completed;
263 g_io_deliver(bp2, bp2->bio_error);
264 }
--- 12 unchanged lines hidden (view full) ---
277 sc = gp->softc;
278 dp = sc->dp;
279
280 if (dp->d_ioctl == NULL)
281 return (ENOIOCTL);
282 g_disk_lock_giant(dp);
283 error = dp->d_ioctl(dp, cmd, data, fflag, td);
284 g_disk_unlock_giant(dp);
285 return(error);
286}
287
288static void
289g_disk_start(struct bio *bp)
290{
291 struct bio *bp2, *bp3;
292 struct disk *dp;
293 struct g_disk_softc *sc;
--- 247 unchanged lines hidden (view full) ---
541{
542
543 return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO));
544}
545
546void
547disk_create(struct disk *dp, int version)
548{
549 if (version != DISK_VERSION_00 && version != DISK_VERSION_01) {
550 printf("WARNING: Attempt to add disk %s%d %s",
551 dp->d_name, dp->d_unit,
552 " using incompatible ABI version of disk(9)\n");
553 printf("WARNING: Ignoring disk %s%d\n",
554 dp->d_name, dp->d_unit);
555 return;
556 }
--- 73 unchanged lines hidden (view full) ---
630 error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
631 sbuf_delete(sb);
632 return error;
633}
634
635SYSCTL_PROC(_kern, OID_AUTO, disks,
636 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
637 sysctl_disks, "A", "names of available disks");
638