FreeBSD/sys/geom/virstor/g_virstor.c
/*
 * Called to notify geom when it's been opened, and for what intent
 */
Called to notify geom when it's been opened, and for what intent
Called to notify geom when it ' s been opened and for what intent
static int
g_virstor_access(struct g_provider *pp, int dr, int dw, int de)
{
	struct g_consumer *c;
	struct g_virstor_softc *sc;
	struct g_geom *gp;
	int error;
	KASSERT(pp != NULL, ("%s: NULL provider", __func__));
	gp = pp->geom;
	KASSERT(gp != NULL, ("%s: NULL geom", __func__));
	sc = gp->softc;
	if (sc == NULL) {
		LOG_MSG(LVL_WARNING, "access(%d, %d, %d) for %s",
		    dr, dw, de, pp->name);
		KASSERT(dr <= 0 && dw <= 0 && de <= 0,
		    ("%s: Positive access for %s", __func__, pp->name));
		if (pp->acr + dr == 0 && pp->acw + dw == 0 && pp->ace + de == 0)
			LOG_MSG(LVL_DEBUG, "Device %s definitely destroyed",
			    pp->name);
		return (0);
	}
	if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
		de++;
	if (pp->acr + dr == 0 && pp->acw + dw == 0 && pp->ace + de == 0) {
		de--;
		update_metadata(sc);	
	}
	error = ENXIO;
	LIST_FOREACH(c, &gp->consumer, consumer) {
		KASSERT(c != NULL, ("%s: consumer is NULL", __func__));
		error = g_access(c, dr, dw, de);
		if (error != 0) {
			struct g_consumer *c2;
			LIST_FOREACH(c2, &gp->consumer, consumer) {
				if (c2 == c) 
					return (error);
				g_access(c2, -dr, -dw, -de);
			}
		}
	}
	return (error);
}
static int g_virstor_access ( struct g_provider * pp , int dr , int dw , int de ) { struct g_consumer * c ; struct g_virstor_softc * sc ; struct g_geom * gp ; int error ; KASSERT ( pp != NULL , ( " " , __func__ ) ) ; gp = pp -> geom ; KASSERT ( gp != NULL , ( " " , __func__ ) ) ; sc = gp -> softc ; if ( sc == NULL ) { LOG_MSG ( LVL_WARNING , " " , dr , dw , de , pp -> name ) ; KASSERT ( dr <= 0 && dw <= 0 && de <= 0 , ( " " , __func__ , pp -> name ) ) ; if ( pp -> acr + dr == 0 && pp -> acw + dw == 0 && pp -> ace + de == 0 ) LOG_MSG ( LVL_DEBUG , " " , pp -> name ) ; return ( 0 ) ; } if ( pp -> acr == 0 && pp -> acw == 0 && pp -> ace == 0 ) de ++ ; if ( pp -> acr + dr == 0 && pp -> acw + dw == 0 && pp -> ace + de == 0 ) { de -- ; update_metadata ( sc ) ; } error = ENXIO ; LIST_FOREACH ( c , & gp -> consumer , consumer ) { KASSERT ( c != NULL , ( " " , __func__ ) ) ; error = g_access ( c , dr , dw , de ) ; if ( error != 0 ) { struct g_consumer * c2 ; LIST_FOREACH ( c2 , & gp -> consumer , consumer ) { if ( c2 == c ) return ( error ) ; g_access ( c2 , - dr , - dw , - de ) ; } } } return ( error ) ; }
Called to notify geom when it's been opened, and for what intent
Called to notify geom when it ' s been opened and for what intent
/* It seems that .access can be called with negative dr,dw,dx
		 * in this case but I want to check for myself */ /* This should only happen when geom is withered so
		 * allow only negative requests */ /* Grab an exclusive bit to propagate on our consumers on first open */ /* ... drop it on close */ /* Writes statistical information */ /* Backout earlier changes */ /* all eariler components fixed */