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 226736 2011-10-25 14:05:39Z 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 |
113 if (dp->d_flags & DISKFLAG_NEEDSGIANT) 114 mtx_lock(&Giant); 115} 116 117static void __inline 118g_disk_unlock_giant(struct disk *dp) 119{ |
120 |
121 if (dp->d_flags & DISKFLAG_NEEDSGIANT) 122 mtx_unlock(&Giant); 123} 124 125static int 126g_disk_access(struct g_provider *pp, int r, int w, int e) 127{ 128 struct disk *dp; --- 119 unchanged lines hidden (view full) --- 248 /* XXX: will witness accept a mix of Giant/unGiant drivers here ? */ 249 mtx_lock(&g_disk_done_mtx); 250 bp->bio_completed = bp->bio_length - bp->bio_resid; 251 252 bp2 = bp->bio_parent; 253 if (bp2->bio_error == 0) 254 bp2->bio_error = bp->bio_error; 255 bp2->bio_completed += bp->bio_completed; |
256 if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE)) != 0 && 257 (sc = bp2->bio_to->geom->softc) != NULL && 258 (dp = sc->dp) != NULL) { |
259 devstat_end_transaction_bio(dp->d_devstat, bp); 260 } 261 g_destroy_bio(bp); 262 bp2->bio_inbed++; 263 if (bp2->bio_children == bp2->bio_inbed) { 264 bp2->bio_resid = bp2->bio_bcount - bp2->bio_completed; 265 g_io_deliver(bp2, bp2->bio_error); 266 } --- 12 unchanged lines hidden (view full) --- 279 sc = gp->softc; 280 dp = sc->dp; 281 282 if (dp->d_ioctl == NULL) 283 return (ENOIOCTL); 284 g_disk_lock_giant(dp); 285 error = dp->d_ioctl(dp, cmd, data, fflag, td); 286 g_disk_unlock_giant(dp); |
287 return (error); |
288} 289 290static void 291g_disk_start(struct bio *bp) 292{ 293 struct bio *bp2, *bp3; 294 struct disk *dp; 295 struct g_disk_softc *sc; --- 247 unchanged lines hidden (view full) --- 543{ 544 545 return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO)); 546} 547 548void 549disk_create(struct disk *dp, int version) 550{ |
551 |
552 if (version != DISK_VERSION_00 && version != DISK_VERSION_01) { 553 printf("WARNING: Attempt to add disk %s%d %s", 554 dp->d_name, dp->d_unit, 555 " using incompatible ABI version of disk(9)\n"); 556 printf("WARNING: Ignoring disk %s%d\n", 557 dp->d_name, dp->d_unit); 558 return; 559 } --- 73 unchanged lines hidden (view full) --- 633 error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); 634 sbuf_delete(sb); 635 return error; 636} 637 638SYSCTL_PROC(_kern, OID_AUTO, disks, 639 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, 640 sysctl_disks, "A", "names of available disks"); |