geom_subr.c (e477abf734cc777a55286bfbd6b80a6760c96acf) geom_subr.c (50199fa0d0739e52f6ae00c7917359b04b4de197)
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

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

432 LIST_FOREACH(cp, &gp->consumer, consumer)
433 if (cp->acr || cp->acw || cp->ace)
434 g_access(cp, -cp->acr, -cp->acw, -cp->ace);
435 g_wither_geom(gp, error);
436}
437
438/*
439 * This function is called (repeatedly) until we cant wash away more
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

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

432 LIST_FOREACH(cp, &gp->consumer, consumer)
433 if (cp->acr || cp->acw || cp->ace)
434 g_access(cp, -cp->acr, -cp->acw, -cp->ace);
435 g_wither_geom(gp, error);
436}
437
438/*
439 * This function is called (repeatedly) until we cant wash away more
440 * withered bits at present. Return value contains two bits. Bit 0
441 * set means "withering stuff we can't wash now", bit 1 means "call
442 * me again, there may be stuff I didn't get the first time around.
440 * withered bits at present.
443 */
441 */
444int
442void
445g_wither_washer()
446{
447 struct g_class *mp;
448 struct g_geom *gp, *gp2;
449 struct g_provider *pp, *pp2;
450 struct g_consumer *cp, *cp2;
443g_wither_washer()
444{
445 struct g_class *mp;
446 struct g_geom *gp, *gp2;
447 struct g_provider *pp, *pp2;
448 struct g_consumer *cp, *cp2;
451 int result;
452
449
453 result = 0;
454 g_topology_assert();
455 LIST_FOREACH(mp, &g_classes, class) {
456 LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) {
457 LIST_FOREACH_SAFE(pp, &gp->provider, provider, pp2) {
458 if (!(pp->flags & G_PF_WITHER))
459 continue;
460 if (LIST_EMPTY(&pp->consumers))
461 g_destroy_provider(pp);
450 g_topology_assert();
451 LIST_FOREACH(mp, &g_classes, class) {
452 LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) {
453 LIST_FOREACH_SAFE(pp, &gp->provider, provider, pp2) {
454 if (!(pp->flags & G_PF_WITHER))
455 continue;
456 if (LIST_EMPTY(&pp->consumers))
457 g_destroy_provider(pp);
462 else
463 result |= 1;
464 }
465 if (!(gp->flags & G_GEOM_WITHER))
466 continue;
467 LIST_FOREACH_SAFE(pp, &gp->provider, provider, pp2) {
468 if (LIST_EMPTY(&pp->consumers))
469 g_destroy_provider(pp);
458 }
459 if (!(gp->flags & G_GEOM_WITHER))
460 continue;
461 LIST_FOREACH_SAFE(pp, &gp->provider, provider, pp2) {
462 if (LIST_EMPTY(&pp->consumers))
463 g_destroy_provider(pp);
470 else
471 result |= 1;
472 }
473 LIST_FOREACH_SAFE(cp, &gp->consumer, consumer, cp2) {
464 }
465 LIST_FOREACH_SAFE(cp, &gp->consumer, consumer, cp2) {
474 if (cp->acr || cp->acw || cp->ace) {
475 result |= 1;
466 if (cp->acr || cp->acw || cp->ace)
476 continue;
467 continue;
477 }
478 if (cp->provider != NULL)
479 g_detach(cp);
480 g_destroy_consumer(cp);
468 if (cp->provider != NULL)
469 g_detach(cp);
470 g_destroy_consumer(cp);
481 result |= 2;
482 }
483 if (LIST_EMPTY(&gp->provider) &&
484 LIST_EMPTY(&gp->consumer))
485 g_destroy_geom(gp);
471 }
472 if (LIST_EMPTY(&gp->provider) &&
473 LIST_EMPTY(&gp->consumer))
474 g_destroy_geom(gp);
486 else
487 result |= 1;
488 }
489 }
475 }
476 }
490 return (result);
491}
492
493struct g_consumer *
494g_new_consumer(struct g_geom *gp)
495{
496 struct g_consumer *cp;
497
498 g_topology_assert();

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

842 KASSERT(cp->acr == 0, ("detach but nonzero acr"));
843 KASSERT(cp->acw == 0, ("detach but nonzero acw"));
844 KASSERT(cp->ace == 0, ("detach but nonzero ace"));
845 KASSERT(cp->nstart == cp->nend,
846 ("detach with active requests"));
847 pp = cp->provider;
848 LIST_REMOVE(cp, consumers);
849 cp->provider = NULL;
477}
478
479struct g_consumer *
480g_new_consumer(struct g_geom *gp)
481{
482 struct g_consumer *cp;
483
484 g_topology_assert();

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

828 KASSERT(cp->acr == 0, ("detach but nonzero acr"));
829 KASSERT(cp->acw == 0, ("detach but nonzero acw"));
830 KASSERT(cp->ace == 0, ("detach but nonzero ace"));
831 KASSERT(cp->nstart == cp->nend,
832 ("detach with active requests"));
833 pp = cp->provider;
834 LIST_REMOVE(cp, consumers);
835 cp->provider = NULL;
850 if (pp->geom->flags & G_GEOM_WITHER)
836 if ((cp->geom->flags & G_GEOM_WITHER) ||
837 (pp->geom->flags & G_GEOM_WITHER) ||
838 (pp->flags & G_PF_WITHER))
851 g_do_wither();
839 g_do_wither();
852 else if (pp->flags & G_PF_WITHER)
853 g_do_wither();
854 redo_rank(cp->geom);
855}
856
857/*
858 * g_access()
859 *
860 * Access-check with delta values. The question asked is "can provider
861 * "cp" change the access counters by the relative amounts dc[rwe] ?"

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

943 pp->acw += dcw;
944 pp->ace += dce;
945 cp->acr += dcr;
946 cp->acw += dcw;
947 cp->ace += dce;
948 if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)
949 KASSERT(pp->sectorsize > 0,
950 ("Provider %s lacks sectorsize", pp->name));
840 redo_rank(cp->geom);
841}
842
843/*
844 * g_access()
845 *
846 * Access-check with delta values. The question asked is "can provider
847 * "cp" change the access counters by the relative amounts dc[rwe] ?"

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

929 pp->acw += dcw;
930 pp->ace += dce;
931 cp->acr += dcr;
932 cp->acw += dcw;
933 cp->ace += dce;
934 if (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)
935 KASSERT(pp->sectorsize > 0,
936 ("Provider %s lacks sectorsize", pp->name));
937 if ((cp->geom->flags & G_GEOM_WITHER) &&
938 cp->acr == 0 && cp->acw == 0 && cp->ace == 0)
939 g_do_wither();
951 }
952 return (error);
953}
954
955int
956g_handleattr_int(struct bio *bp, const char *attribute, int val)
957{
958

--- 570 unchanged lines hidden ---
940 }
941 return (error);
942}
943
944int
945g_handleattr_int(struct bio *bp, const char *attribute, int val)
946{
947

--- 570 unchanged lines hidden ---