Deleted Added
full compact
geom_disk.c (237648) geom_disk.c (238216)
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>
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 237648 2012-06-27 16:05:09Z ken $");
37__FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 238216 2012-07-07 21:28:31Z trasz $");
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>
46#include <sys/ctype.h>
47#include <sys/fcntl.h>
48#include <sys/malloc.h>
49#include <sys/sbuf.h>
50#include <sys/sysctl.h>
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>
46#include <sys/ctype.h>
47#include <sys/fcntl.h>
48#include <sys/malloc.h>
49#include <sys/sbuf.h>
50#include <sys/sysctl.h>
51#include <sys/taskqueue.h>
51#include <sys/devicestat.h>
52#include <machine/md_var.h>
53
54#include <sys/lock.h>
55#include <sys/mutex.h>
56#include <geom/geom.h>
57#include <geom/geom_disk.h>
58#include <geom/geom_int.h>
59
60#include <dev/led/led.h>
61
62struct g_disk_softc {
63 struct disk *dp;
64 struct sysctl_ctx_list sysctl_ctx;
65 struct sysctl_oid *sysctl_tree;
66 char led[64];
67 uint32_t state;
52#include <sys/devicestat.h>
53#include <machine/md_var.h>
54
55#include <sys/lock.h>
56#include <sys/mutex.h>
57#include <geom/geom.h>
58#include <geom/geom_disk.h>
59#include <geom/geom_int.h>
60
61#include <dev/led/led.h>
62
63struct g_disk_softc {
64 struct disk *dp;
65 struct sysctl_ctx_list sysctl_ctx;
66 struct sysctl_oid *sysctl_tree;
67 char led[64];
68 uint32_t state;
69 struct task resize_task;
68};
69
70static struct mtx g_disk_done_mtx;
71
72static g_access_t g_disk_access;
73static g_init_t g_disk_init;
74static g_fini_t g_disk_fini;
75static g_start_t g_disk_start;

--- 364 unchanged lines hidden (view full) ---

440 sbuf_printf(sb, "%s<fwsectors>%u</fwsectors>\n",
441 indent, dp->d_fwsectors);
442 sbuf_printf(sb, "%s<ident>%s</ident>\n", indent, dp->d_ident);
443 sbuf_printf(sb, "%s<descr>%s</descr>\n", indent, dp->d_descr);
444 }
445}
446
447static void
70};
71
72static struct mtx g_disk_done_mtx;
73
74static g_access_t g_disk_access;
75static g_init_t g_disk_init;
76static g_fini_t g_disk_fini;
77static g_start_t g_disk_start;

--- 364 unchanged lines hidden (view full) ---

442 sbuf_printf(sb, "%s<fwsectors>%u</fwsectors>\n",
443 indent, dp->d_fwsectors);
444 sbuf_printf(sb, "%s<ident>%s</ident>\n", indent, dp->d_ident);
445 sbuf_printf(sb, "%s<descr>%s</descr>\n", indent, dp->d_descr);
446 }
447}
448
449static void
450g_disk_resize_task(void *context, int pending)
451{
452 struct g_geom *gp;
453 struct g_provider *pp;
454 struct disk *dp;
455 struct g_disk_softc *sc;
456
457 sc = (struct g_disk_softc *)context;
458 dp = sc->dp;
459 gp = dp->d_geom;
460
461 LIST_FOREACH(pp, &gp->provider, provider) {
462 if (pp->sectorsize != 0 &&
463 pp->sectorsize != dp->d_sectorsize)
464 g_wither_provider(pp, ENXIO);
465 else
466 g_resize_provider(pp, dp->d_mediasize);
467 }
468}
469
470static void
448g_disk_create(void *arg, int flag)
449{
450 struct g_geom *gp;
451 struct g_provider *pp;
452 struct disk *dp;
453 struct g_disk_softc *sc;
454 char tmpstr[80];
455

--- 23 unchanged lines hidden (view full) ---

479 snprintf(tmpstr, sizeof(tmpstr),
480 "kern.geom.disk.%s.led", gp->name);
481 TUNABLE_STR_FETCH(tmpstr, sc->led, sizeof(sc->led));
482 SYSCTL_ADD_STRING(&sc->sysctl_ctx,
483 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led",
484 CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led),
485 "LED name");
486 }
471g_disk_create(void *arg, int flag)
472{
473 struct g_geom *gp;
474 struct g_provider *pp;
475 struct disk *dp;
476 struct g_disk_softc *sc;
477 char tmpstr[80];
478

--- 23 unchanged lines hidden (view full) ---

502 snprintf(tmpstr, sizeof(tmpstr),
503 "kern.geom.disk.%s.led", gp->name);
504 TUNABLE_STR_FETCH(tmpstr, sc->led, sizeof(sc->led));
505 SYSCTL_ADD_STRING(&sc->sysctl_ctx,
506 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led",
507 CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led),
508 "LED name");
509 }
510 TASK_INIT(&sc->resize_task, 0, g_disk_resize_task, sc);
487 pp->private = sc;
488 dp->d_geom = gp;
489 g_error_provider(pp, 0);
490}
491
492/*
493 * We get this callback after all of the consumers have gone away, and just
494 * before the provider is freed. If the disk driver provided a d_gone

--- 135 unchanged lines hidden (view full) ---

630 struct g_provider *pp;
631
632 gp = dp->d_geom;
633 if (gp != NULL)
634 LIST_FOREACH(pp, &gp->provider, provider)
635 (void)g_attr_changed(pp, attr, flag);
636}
637
511 pp->private = sc;
512 dp->d_geom = gp;
513 g_error_provider(pp, 0);
514}
515
516/*
517 * We get this callback after all of the consumers have gone away, and just
518 * before the provider is freed. If the disk driver provided a d_gone

--- 135 unchanged lines hidden (view full) ---

654 struct g_provider *pp;
655
656 gp = dp->d_geom;
657 if (gp != NULL)
658 LIST_FOREACH(pp, &gp->provider, provider)
659 (void)g_attr_changed(pp, attr, flag);
660}
661
662void
663disk_resize(struct disk *dp)
664{
665 struct g_geom *gp;
666 struct g_disk_softc *sc;
667 int error;
668
669 gp = dp->d_geom;
670
671 if (gp == NULL)
672 return;
673
674 sc = gp->softc;
675
676 error = taskqueue_enqueue(taskqueue_thread, &sc->resize_task);
677 KASSERT(error == 0, ("taskqueue_enqueue(9) failed."));
678}
679
638static void
639g_kern_disks(void *p, int flag __unused)
640{
641 struct sbuf *sb;
642 struct g_geom *gp;
643 char *sp;
644
645 sb = p;

--- 25 unchanged lines hidden ---
680static void
681g_kern_disks(void *p, int flag __unused)
682{
683 struct sbuf *sb;
684 struct g_geom *gp;
685 char *sp;
686
687 sb = p;

--- 25 unchanged lines hidden ---