Lines Matching refs:buf_ptr

186 static int add_block(journal *jnl, struct bucket **buf_ptr, off_t block_num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr);
187 static int grow_table(struct bucket **buf_ptr, int num_buckets, int new_size);
188 static int lookup_bucket(struct bucket **buf_ptr, off_t block_num, int num_full);
189 static int do_overlap(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t block_num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr);
190 static int insert_block(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr, int overwriting);
813 grow_table(struct bucket **buf_ptr, int num_buckets, int new_size)
831 bcopy(*buf_ptr, newBuf, num_buckets*sizeof(struct bucket));
839 FREE(*buf_ptr, M_TEMP);
841 // reset the buf_ptr
842 *buf_ptr = newBuf;
848 lookup_bucket(struct bucket **buf_ptr, off_t block_num, int num_full)
863 off_t this_num = (*buf_ptr)[mid].block_num;
882 if (block_num == (*buf_ptr)[hi].block_num) {
888 index = (block_num < (*buf_ptr)[hi].block_num) ? hi : hi + 1;
893 while (i < num_full && block_num == (*buf_ptr)[i].block_num) {
905 insert_block(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr, int overwriting)
911 int grow_size = grow_table(buf_ptr, *num_buckets_ptr, new_size);
923 bcopy( (*buf_ptr)+(blk_index), (*buf_ptr)+(blk_index+1), (*num_full_ptr-blk_index)*sizeof(struct bucket) );
937 (*buf_ptr)[blk_index].block_num = num;
938 (*buf_ptr)[blk_index].block_size = size;
939 (*buf_ptr)[blk_index].jnl_offset = offset;
940 (*buf_ptr)[blk_index].cksum = cksum;
946 do_overlap(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t block_num, size_t size, __unused size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr)
954 overwrite = (block_num == (*buf_ptr)[blk_index].block_num && size >= (*buf_ptr)[blk_index].block_size);
958 off_t prev_block_start = (*buf_ptr)[blk_index-1].block_num*jhdr_size;
959 off_t prev_block_end = prev_block_start + (*buf_ptr)[blk_index-1].block_size;
971 new_offset = (*buf_ptr)[blk_index-1].jnl_offset + (block_end - prev_block_start);
973 err = insert_block(jnl, buf_ptr, blk_index, new_num, new_size, new_offset, cksum, num_buckets_ptr, num_full_ptr, 0);
980 (*buf_ptr)[blk_index-1].block_size = block_start - prev_block_start;
981 (*buf_ptr)[blk_index-1].cksum = 0; // have to blow it away because there's no way to check it
986 if (!overwrite && block_end <= (off_t)((*buf_ptr)[blk_index].block_num*jhdr_size)) {
988 } else if (overwrite && (blk_index + 1 >= *num_full_ptr || block_end <= (off_t)((*buf_ptr)[blk_index+1].block_num*jhdr_size))) {
990 (*buf_ptr)[blk_index].cksum = cksum; // update this
1000 while (index < *num_full_ptr && block_end > (off_t)((*buf_ptr)[index].block_num*jhdr_size)) {
1001 if (block_end >= (off_t)(((*buf_ptr)[index].block_num*jhdr_size + (*buf_ptr)[index].block_size))) {
1002 (*buf_ptr)[index].block_num = -2; // mark this for deletion
1005 overlap = block_end - (*buf_ptr)[index].block_num*jhdr_size;
1012 (*buf_ptr)[index].block_num += (overlap / jhdr_size); // make sure overlap is multiple of jhdr_size, or round up
1013 (*buf_ptr)[index].cksum = 0;
1015 new_offset = (*buf_ptr)[index].jnl_offset + overlap; // check for wrap-around
1019 (*buf_ptr)[index].jnl_offset = new_offset;
1021 (*buf_ptr)[index].block_size -= overlap; // sanity check for negative value
1022 if ((*buf_ptr)[index].block_size <= 0) {
1023 panic("jnl: do_overlap: after overlap, new block size is invalid (%u)\n", (*buf_ptr)[index].block_size);
1036 if ((*buf_ptr)[index].block_num == -2) {
1038 (*buf_ptr)[index].block_num = -1; // it's the last item in the table... just mark as free
1040 bcopy( (*buf_ptr)+(index+1), (*buf_ptr)+(index), (*num_full_ptr - (index + 1)) * sizeof(struct bucket) );
1049 (*buf_ptr)[i].block_num = -1;
1064 add_block(journal *jnl, struct bucket **buf_ptr, off_t block_num, size_t size, __unused size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr)
1070 blk_index = lookup_bucket( buf_ptr, block_num, *num_full_ptr);
1080 overwriting = do_overlap(jnl, buf_ptr, blk_index, block_num, size, offset, cksum, num_buckets_ptr, num_full_ptr);
1086 blk_index = insert_block(jnl, buf_ptr, blk_index, block_num, size, offset, cksum, num_buckets_ptr, num_full_ptr, overwriting);