Lines Matching refs:bsize

82 read_phys_blocks(int fd, fs_off_t bnum, void *data, uint num_blocks, int bsize)
90 if (num_blocks * bsize < CHUNK)
91 ret = read_pos(fd, bnum * bsize, data, num_blocks * bsize);
93 for(sum=0; (sum + CHUNK) <= (num_blocks * bsize); sum += CHUNK) {
94 ret = read_pos(fd, (bnum * bsize) + sum, data, CHUNK);
101 if (ret == CHUNK && ((num_blocks * bsize) - sum) > 0) {
102 ret = read_pos(fd, (bnum * bsize) + sum, data,
103 (num_blocks * bsize) - sum);
105 if (ret == (num_blocks * bsize) - sum)
106 ret = num_blocks * bsize;
108 ret = num_blocks * bsize;
112 if (ret == num_blocks * bsize)
119 write_phys_blocks(int fd, fs_off_t bnum, void *data, uint num_blocks, int bsize)
127 if (num_blocks * bsize < CHUNK)
128 ret = write_pos(fd, bnum * bsize, data, num_blocks * bsize);
130 for(sum=0; (sum + CHUNK) <= (num_blocks * bsize); sum += CHUNK) {
131 ret = write_pos(fd, (bnum * bsize) + sum, data, CHUNK);
138 if (ret == CHUNK && ((num_blocks * bsize) - sum) > 0) {
139 ret = write_pos(fd, (bnum * bsize) + sum, data,
140 (num_blocks * bsize) - sum);
142 if (ret == (num_blocks * bsize) - sum)
143 ret = num_blocks * bsize;
145 ret = num_blocks * bsize;
150 if (ret == num_blocks * bsize)
881 ret = write_phys_blocks(ce->dev, ce->block_num, data, 1, ce->bsize);
905 int i, j, k, ret = 0, bsize, iocnt, do_again = 0;
924 bsize = ents[i]->bsize;
949 iov[iocnt].iov_len = bsize;
955 ret = writev_pos(ents[i]->dev, start_bnum * (fs_off_t)bsize,
957 if (ret != iocnt*bsize) {
961 "bsize %d, ret %d\n", iocnt, start_bnum, bsize, ret);
968 strerror(errno), start_bnum, iocnt, ret, iocnt*bsize);
1261 ce->clone = (void *)malloc(ce->bsize);
1263 panic("*** can't clone bnum %Ld (bsize %d)\n",
1264 ce->block_num, ce->bsize);
1267 memcpy(ce->clone, ce->data, ce->bsize);
1585 new_cache_ent(int bsize)
1595 ce->data = malloc(bsize);
1611 get_ents(cache_ent **ents, int num_needed, int max, int *num_gotten, int bsize)
1621 ents[cur] = new_cache_ent(bsize);
1679 read_into_ents(int dev, fs_off_t bnum, cache_ent **ents, int num, int bsize)
1688 iov[i].iov_len = bsize;
1692 printf("readv @ %Ld for %d blocks (at %Ld, block_size = %d)\n", bnum, num, bnum*bsize, bsize);
1693 ret = readv_pos(dev, bnum*bsize, iov, num);
1697 if (ret != num*bsize) {
1699 num*bsize, ret);
1737 cache_block_io(int dev, fs_off_t bnum, void *data, fs_off_t num_blocks, int bsize,
1745 printf("cbio: bnum = %Ld, num_blocks = %Ld, bsize = %d, op = %s\n", bnum, num_blocks,
1746 bsize, op_to_str(op));
1749 if (bsize == 0)
1782 if (num_blocks * bsize >= 64 * 1024) {
1792 if (read_phys_blocks(dev, bnum, data, num_blocks, bsize) != 0) {
1802 for(tmp=bnum; tmp < bnum+num_blocks; tmp++, ptr+=bsize) {
1819 memcpy(ptr, ce->data, bsize);
1829 for(tmp=bnum; tmp < bnum+num_blocks; tmp++, ptr+=bsize) {
1847 memcpy(ce->data, ptr, bsize);
1853 if (write_phys_blocks(dev, bnum, data, num_blocks, bsize) != 0) {
1879 if (bsize != ce->bsize) {
1880 panic("*** requested bsize %d but ce->bsize %d ce @ 0x%x\n",
1881 bsize, ce->bsize, ce);
1894 memcpy(data, ce->data, bsize);
1903 memcpy(ce->data, data, bsize);
1907 memset(ce->data, 0, bsize);
1909 memset(data, 0, bsize);
1931 data = (void *)((char *)data + bsize);
1965 (cur_nblocks * bsize) < read_ahead_size) {
1968 num_needed < (read_ahead_size / bsize);
1982 get_ents(ents, num_needed, NUM_FLUSH_BLOCKS, &real_nblocks, bsize);
2079 if (ents[cur]->bsize != bsize) {
2092 ents[cur]->data = (void *)malloc(bsize);
2093 ents[cur]->bsize = bsize;
2097 printf("cache: no memory for block (bsize %d)!\n",
2098 bsize);
2163 err = read_into_ents(dev, bnum, ents, num_needed, bsize);
2172 bsize, data, ents[0]);
2273 ce->bsize = bsize;
2282 memcpy(data, ce->data, bsize);
2285 memcpy(ce->data, data, bsize);
2287 memset(ce->data, 0, bsize);
2289 memset(data, 0, bsize);
2310 data = (void *)((char *)data + bsize);
2329 get_block(int dev, fs_off_t bnum, int bsize)
2333 if (cache_block_io(dev, bnum, NULL, 1, bsize, CACHE_READ|CACHE_LOCKED|CACHE_READ_AHEAD_OK,
2341 get_empty_block(int dev, fs_off_t bnum, int bsize)
2345 if (cache_block_io(dev, bnum, NULL, 1, bsize, CACHE_NOOP|CACHE_LOCKED,
2353 cached_read(int dev, fs_off_t bnum, void *data, fs_off_t num_blocks, int bsize)
2355 return cache_block_io(dev, bnum, data, num_blocks, bsize,
2361 cached_write(int dev, fs_off_t bnum, const void *data, fs_off_t num_blocks,int bsize)
2363 return cache_block_io(dev, bnum, (void *)data, num_blocks, bsize,
2369 fs_off_t num_blocks, int bsize)
2371 return cache_block_io(dev, bnum, (void *)data, num_blocks, bsize,