View | Details | Raw Unified | Return to bug 17098
Collapse All | Expand All

(-)./common/bcache.c (-8 / +32 lines)
Lines 23-29 Link Here
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
24
 * SUCH DAMAGE.
25
 *
25
 *
26
 *	$Id: bcache.c,v 1.4.2.1 1999/02/06 14:27:29 dcs Exp $
26
 *	$Id: bcache.c,v 1.2 2000/02/18 22:35:19 jhood Exp $
27
 */
27
 */
28
28
29
/*
29
/*
Lines 62-78 Link Here
62
static int		bcache_hits, bcache_misses, bcache_ops, bcache_bypasses;
62
static int		bcache_hits, bcache_misses, bcache_ops, bcache_bypasses;
63
static int		bcache_bcount;
63
static int		bcache_bcount;
64
64
65
static void		*bcache_dkstrategy;
66
static int		bcache_dkunit;
67
65
static void	bcache_insert(caddr_t buf, daddr_t blkno);
68
static void	bcache_insert(caddr_t buf, daddr_t blkno);
66
static int	bcache_lookup(caddr_t buf, daddr_t blkno);
69
static int	bcache_lookup(caddr_t buf, daddr_t blkno);
67
70
68
/*
71
/*
72
 * Invalidate the cache
73
 */
74
void
75
bcache_flush(void)
76
{
77
    int		i;
78
79
    if (bcache_data != NULL) {
80
        for (i = 0; i < bcache_nblks; i++) {
81
	    bcache_ctl[i].bc_count = -1;
82
	    bcache_ctl[i].bc_blkno = -1;
83
	}
84
    }
85
}
86
/*
69
 * Initialise the cache for (nblks) of (bsize).
87
 * Initialise the cache for (nblks) of (bsize).
70
 */
88
 */
71
int
89
int
72
bcache_init(int nblks, size_t bsize)
90
bcache_init(int nblks, size_t bsize)
73
{
91
{
74
    int		i;
75
76
    /* discard any old contents */
92
    /* discard any old contents */
77
    if (bcache_data != NULL) {
93
    if (bcache_data != NULL) {
78
	free(bcache_data);
94
	free(bcache_data);
Lines 97-107 Link Here
97
	return(ENOMEM);
113
	return(ENOMEM);
98
    }
114
    }
99
115
100
    /* Invalidate the cache */
116
    bcache_dkstrategy = NULL;
101
    for (i = 0; i < bcache_nblks; i++) {
117
102
	bcache_ctl[i].bc_count = -1;
118
    /* bcache_flush() will happen on first call to bcache_strategy */
103
	bcache_ctl[i].bc_blkno = -1;
104
    }
105
119
106
    return(0);
120
    return(0);
107
}
121
}
Lines 130-135 Link Here
130
	DEBUG("bypass %d from %d", size / bcache_blksize, blk);
144
	DEBUG("bypass %d from %d", size / bcache_blksize, blk);
131
	bcache_bypasses++;
145
	bcache_bypasses++;
132
	return(dd->dv_strategy(dd->dv_devdata, rw, blk, size, buf, rsize));
146
	return(dd->dv_strategy(dd->dv_devdata, rw, blk, size, buf, rsize));
147
    }
148
149
    /* has a new device/unit been requested?  flush cache */
150
    if ((bcache_dkstrategy != dd->dv_strategy) || 
151
	(bcache_dkunit != dd->dv_dkunit)) {
152
	    DEBUG("cache flush, lastunit = %d newunit = %d", 
153
		   bcache_dkunit, dd->dv_dkunit);
154
	    bcache_flush();
155
	    bcache_dkstrategy = dd->dv_strategy;
156
	    bcache_dkunit = dd->dv_dkunit;
133
    }
157
    }
134
158
135
    nblk = size / bcache_blksize;
159
    nblk = size / bcache_blksize;
(-)./common/bootstrap.h (-1 / +2 lines)
Lines 23-29 Link Here
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
24
 * SUCH DAMAGE.
25
 *
25
 *
26
 *	$Id: bootstrap.h,v 1.18.2.1 1999/02/06 14:27:29 dcs Exp $
26
 *	$Id: bootstrap.h,v 1.2 2000/02/18 22:35:20 jhood Exp $
27
 */
27
 */
28
28
29
#include <sys/types.h>
29
#include <sys/types.h>
Lines 84-89 Link Here
84
struct bcache_devdata
84
struct bcache_devdata
85
{
85
{
86
    int         (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize);
86
    int         (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize);
87
    int		dv_dkunit;
87
    void	*dv_devdata;
88
    void	*dv_devdata;
88
};
89
};
89
90
(-)./i386/libi386/biosdisk.c (-1 / +3 lines)
Lines 23-29 Link Here
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
24
 * SUCH DAMAGE.
25
 *
25
 *
26
 *	$Id: biosdisk.c,v 1.20.2.4 1999/03/16 14:58:25 dcs Exp $
26
 *	$Id: biosdisk.c,v 1.3 2000/02/18 22:35:47 jhood Exp $
27
 */
27
 */
28
28
29
/*
29
/*
Lines 573-578 Link Here
573
    struct bcache_devdata	bcd;
575
    struct bcache_devdata	bcd;
574
    
576
    
575
    bcd.dv_strategy = bd_realstrategy;
577
    bcd.dv_strategy = bd_realstrategy;
578
    bcd.dv_dkunit = ((struct open_disk *)(((struct i386_devdesc *)
579
		    devdata)->d_kind.biosdisk.data))->od_dkunit;
576
    bcd.dv_devdata = devdata;
580
    bcd.dv_devdata = devdata;
577
    return(bcache_strategy(&bcd, rw, dblk, size, buf, rsize));
581
    return(bcache_strategy(&bcd, rw, dblk, size, buf, rsize));
578
}
582
}

Return to bug 17098