Lines Matching refs:oh

60 static herr_t H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno,
62 static herr_t H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied,
64 static herr_t H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx,
66 static htri_t H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh,
68 static herr_t H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size,
70 static herr_t H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size,
72 static herr_t H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx);
73 static htri_t H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u);
74 static htri_t H5O_move_msgs_forward(H5F_t *f, H5O_t *oh);
75 static htri_t H5O_merge_null(H5F_t *f, H5O_t *oh);
76 static htri_t H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh);
77 static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno);
113 H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, in H5O_add_gap() argument
123 HDassert(oh); in H5O_add_gap()
124 HDassert(oh->version > H5O_VERSION_1); in H5O_add_gap()
134 if(H5AC_get_entry_status(f, oh->chunk[chunkno].addr, &chk_proxy_status) < 0) in H5O_add_gap()
144 for(u = 0; u < oh->nmesgs && !merged_with_null; u++) { in H5O_add_gap()
147 if(H5O_NULL_ID == oh->mesg[u].type->id && oh->mesg[u].chunkno == chunkno in H5O_add_gap()
150 HDassert(oh->chunk[chunkno].gap == 0); in H5O_add_gap()
153 if(H5O_eliminate_gap(oh, chk_dirtied, &oh->mesg[u], new_gap_loc, new_gap_size) < 0) in H5O_add_gap()
164 for(u = 0; u < oh->nmesgs; u++) in H5O_add_gap()
165 if(oh->mesg[u].chunkno == chunkno && oh->mesg[u].raw > new_gap_loc) in H5O_add_gap()
166 oh->mesg[u].raw -= new_gap_size; in H5O_add_gap()
170 …(size_t)((oh->chunk[chunkno].image + (oh->chunk[chunkno].size - H5O_SIZEOF_CHKSUM_OH(oh))) - (new_… in H5O_add_gap()
173 new_gap_size += oh->chunk[chunkno].gap; in H5O_add_gap()
176 if(new_gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { in H5O_add_gap()
180 if(oh->nmesgs >= oh->alloc_nmesgs) in H5O_add_gap()
181 if(H5O_alloc_msgs(oh, (size_t)1) < 0) in H5O_add_gap()
185 oh->chunk[chunkno].gap += new_gap_size; in H5O_add_gap()
188 null_msg = &(oh->mesg[oh->nmesgs++]); in H5O_add_gap()
191 null_msg->raw_size = new_gap_size - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O_add_gap()
192 null_msg->raw = (oh->chunk[chunkno].image + oh->chunk[chunkno].size) in H5O_add_gap()
193 - (H5O_SIZEOF_CHKSUM_OH(oh) + null_msg->raw_size); in H5O_add_gap()
204 oh->chunk[chunkno].gap = 0; in H5O_add_gap()
207 oh->chunk[chunkno].gap = new_gap_size; in H5O_add_gap()
239 H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, in H5O_eliminate_gap() argument
248 HDassert(oh); in H5O_eliminate_gap()
249 HDassert(oh->version > H5O_VERSION_1); in H5O_eliminate_gap()
265 move_end = mesg->raw - H5O_SIZEOF_MSGHDR_OH(oh); in H5O_eliminate_gap()
274 for(u = 0; u < oh->nmesgs; u++) { in H5O_eliminate_gap()
277 msg_start = oh->mesg[u].raw - H5O_SIZEOF_MSGHDR_OH(oh); in H5O_eliminate_gap()
278 if(oh->mesg[u].chunkno == mesg->chunkno in H5O_eliminate_gap()
282 oh->mesg[u].raw += gap_size; in H5O_eliminate_gap()
284 oh->mesg[u].raw -= gap_size; in H5O_eliminate_gap()
302 HDmemmove(move_start - gap_size, move_start, mesg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); in H5O_eliminate_gap()
315 oh->chunk[mesg->chunkno].gap = 0; in H5O_eliminate_gap()
340 H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, in H5O__alloc_null() argument
351 HDassert(oh); in H5O__alloc_null()
356 alloc_msg = &oh->mesg[null_idx]; in H5O__alloc_null()
359 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, alloc_msg->chunkno))) in H5O__alloc_null()
365 if((alloc_msg->raw_size - new_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { in H5O__alloc_null()
372 …if(H5O_add_gap(f, oh, alloc_msg->chunkno, &chk_dirtied, null_idx, alloc_msg->raw + alloc_msg->raw_… in H5O__alloc_null()
376 …size_t new_mesg_size = new_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); /* Total size of newly alloca… in H5O__alloc_null()
380 if(oh->nmesgs >= oh->alloc_nmesgs) { in H5O__alloc_null()
381 if(H5O_alloc_msgs(oh, (size_t)1) < 0) in H5O__alloc_null()
385 alloc_msg = &oh->mesg[null_idx]; in H5O__alloc_null()
389 null_msg = &(oh->mesg[oh->nmesgs++]); in H5O__alloc_null()
401 if(oh->chunk[null_msg->chunkno].gap > 0) { in H5O__alloc_null()
405 if(H5O_eliminate_gap(oh, &chk_dirtied, null_msg, in H5O__alloc_null()
406 …((oh->chunk[null_chunkno].image + oh->chunk[null_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->… in H5O__alloc_null()
407 oh->chunk[null_chunkno].gap) < 0) in H5O__alloc_null()
448 H5O_alloc_msgs(H5O_t *oh, size_t min_alloc) in H5O_alloc_msgs() argument
458 HDassert(oh); in H5O_alloc_msgs()
461 old_alloc = oh->alloc_nmesgs; in H5O_alloc_msgs()
462 na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); /* At least double */ in H5O_alloc_msgs()
465 if(NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na))) in H5O_alloc_msgs()
469 oh->alloc_nmesgs = na; in H5O_alloc_msgs()
470 oh->mesg = new_mesg; in H5O_alloc_msgs()
473 HDmemset(&oh->mesg[old_alloc], 0, (oh->alloc_nmesgs - old_alloc) * sizeof(H5O_mesg_t)); in H5O_alloc_msgs()
509 H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, in H5O__alloc_extend_chunk() argument
515 size_t aligned_size = H5O_ALIGN_OH(oh, size); in H5O__alloc_extend_chunk()
531 HDassert(oh != NULL); in H5O__alloc_extend_chunk()
532 HDassert(chunkno < oh->nchunks); in H5O__alloc_extend_chunk()
535 HDassert(H5F_addr_defined(oh->chunk[chunkno].addr)); in H5O__alloc_extend_chunk()
540 for(u = 0; u < oh->nmesgs; u++) { in H5O__alloc_extend_chunk()
543 if(oh->mesg[u].chunkno == chunkno && H5O_NULL_ID == oh->mesg[u].type->id && in H5O__alloc_extend_chunk()
544 ((oh->mesg[u].raw + oh->mesg[u].raw_size) in H5O__alloc_extend_chunk()
545 == ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - in H5O__alloc_extend_chunk()
546 (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { in H5O__alloc_extend_chunk()
556 HDassert(oh->chunk[chunkno].gap == 0); in H5O__alloc_extend_chunk()
557 delta = aligned_size - oh->mesg[extend_msg].raw_size; in H5O__alloc_extend_chunk()
560 delta = (aligned_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) - oh->chunk[chunkno].gap; in H5O__alloc_extend_chunk()
561 delta = H5O_ALIGN_OH(oh, delta); in H5O__alloc_extend_chunk()
564 if(oh->version > H5O_VERSION_1 && chunkno == 0) { in H5O__alloc_extend_chunk()
566 …size_t orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size … in H5O__alloc_extend_chunk()
568 HDassert(oh->chunk[0].size >= (size_t)H5O_SIZEOF_HDR(oh)); in H5O__alloc_extend_chunk()
569 chunk0_size = oh->chunk[0].size - (size_t)H5O_SIZEOF_HDR(oh); in H5O__alloc_extend_chunk()
592 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) in H5O__alloc_extend_chunk()
596 …was_extended = H5MF_try_extend(f, H5FD_MEM_OHDR, oh->chunk[chunkno].addr, (hsize_t)(oh->chunk[chun… in H5O__alloc_extend_chunk()
604 oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); in H5O__alloc_extend_chunk()
605 oh->flags |= new_size_flags; in H5O__alloc_extend_chunk()
608 if(H5AC_mark_entry_dirty(oh) < 0) in H5O__alloc_extend_chunk()
615 oh->mesg[extend_msg].raw_size += delta; in H5O__alloc_extend_chunk()
620 if(oh->nmesgs >= oh->alloc_nmesgs) in H5O__alloc_extend_chunk()
621 if(H5O_alloc_msgs(oh, (size_t)1) < 0) in H5O__alloc_extend_chunk()
625 extend_msg = oh->nmesgs++; in H5O__alloc_extend_chunk()
628 oh->mesg[extend_msg].type = H5O_MSG_NULL; in H5O__alloc_extend_chunk()
629 oh->mesg[extend_msg].native = NULL; in H5O__alloc_extend_chunk()
630 oh->mesg[extend_msg].raw = ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) in H5O__alloc_extend_chunk()
631 - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[chunkno].gap)) in H5O__alloc_extend_chunk()
632 + H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_extend_chunk()
633oh->mesg[extend_msg].raw_size = (delta + oh->chunk[chunkno].gap) - (size_t)H5O_SIZEOF_MSGHDR_OH(oh in H5O__alloc_extend_chunk()
634 oh->mesg[extend_msg].chunkno = chunkno; in H5O__alloc_extend_chunk()
638 oh->mesg[extend_msg].dirty = TRUE; in H5O__alloc_extend_chunk()
642 old_image = oh->chunk[chunkno].image; in H5O__alloc_extend_chunk()
643 old_size = oh->chunk[chunkno].size; in H5O__alloc_extend_chunk()
644 oh->chunk[chunkno].size += delta + extra_prfx_size; in H5O__alloc_extend_chunk()
645 oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image, old_image, oh->chunk[chunkno].size); in H5O__alloc_extend_chunk()
646 if(NULL == oh->chunk[chunkno].image) in H5O__alloc_extend_chunk()
648 oh->chunk[chunkno].gap = 0; in H5O__alloc_extend_chunk()
651 HDmemset(oh->chunk[chunkno].image + old_size, 0, oh->chunk[chunkno].size - old_size); in H5O__alloc_extend_chunk()
655 HDmemmove(oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh), in H5O__alloc_extend_chunk()
656oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) - extra_prfx_size, in H5O__alloc_extend_chunk()
657 old_size - (size_t)H5O_SIZEOF_HDR(oh) + extra_prfx_size); in H5O__alloc_extend_chunk()
660 for(u = 0; u < oh->nmesgs; u++) { in H5O__alloc_extend_chunk()
662 if(oh->mesg[u].chunkno == chunkno) in H5O__alloc_extend_chunk()
663oh->mesg[u].raw = oh->chunk[chunkno].image + extra_prfx_size + (oh->mesg[u].raw - old_image); in H5O__alloc_extend_chunk()
668 if(chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && in H5O__alloc_extend_chunk()
669 (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { in H5O__alloc_extend_chunk()
672 unsigned cont_chunkno = oh->mesg[u].chunkno; /* Chunk # for continuation message */ in H5O__alloc_extend_chunk()
675 if(NULL == (chk_proxy2 = H5O__chunk_protect(f, oh, cont_chunkno))) in H5O__alloc_extend_chunk()
679 HDassert(((H5O_cont_t *)(oh->mesg[u].native))->size == old_size); in H5O__alloc_extend_chunk()
680 ((H5O_cont_t *)(oh->mesg[u].native))->size = oh->chunk[chunkno].size; in H5O__alloc_extend_chunk()
683 oh->mesg[u].dirty = TRUE; in H5O__alloc_extend_chunk()
693 if(H5O_chunk_resize(oh, chk_proxy) < 0) in H5O__alloc_extend_chunk()
737 H5O__alloc_find_best_nonnull(const H5F_t *f, const H5O_t *oh, size_t *size, in H5O__alloc_find_best_nonnull() argument
749 HDassert(oh); in H5O__alloc_find_best_nonnull()
764 cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); in H5O__alloc_find_best_nonnull()
766 for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { in H5O__alloc_find_best_nonnull()
770 …uint8_t *end_chunk_data = (oh->chunk[msg_chunkno].image + oh->chunk[msg_chunkno].size) - (H5O_SIZE… in H5O__alloc_find_best_nonnull()
779 gap_size = oh->chunk[msg_chunkno].gap; in H5O__alloc_find_best_nonnull()
785 for(v = 0, tmp_msg = &oh->mesg[0]; v < oh->nmesgs; v++, tmp_msg++) { in H5O__alloc_find_best_nonnull()
786 … if(tmp_msg->type->id == H5O_NULL_ID && (tmp_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == end_msg) { in H5O__alloc_find_best_nonnull()
788 null_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + tmp_msg->raw_size; in H5O__alloc_find_best_nonnull()
840 else if(found_msg->msgno < 0 && msg_chunkno == oh->nchunks - 1) in H5O__alloc_find_best_nonnull()
844 multi_size += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_find_best_nonnull()
861 *size += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; in H5O__alloc_find_best_nonnull()
886 H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, in H5O__alloc_chunk() argument
904 HDassert(oh); in H5O__alloc_chunk()
913 size = MAX(H5O_MIN_SIZE, size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); in H5O__alloc_chunk()
914 HDassert(size == H5O_ALIGN_OH(oh, size)); in H5O__alloc_chunk()
921 size += H5O_SIZEOF_CHKHDR_OH(oh); in H5O__alloc_chunk()
929 if(oh->nchunks >= oh->alloc_nchunks) { in H5O__alloc_chunk()
930 … size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ in H5O__alloc_chunk()
933 if(NULL == (x = H5FL_SEQ_REALLOC(H5O_chunk_t, oh->chunk, na))) in H5O__alloc_chunk()
935 oh->alloc_nchunks = na; in H5O__alloc_chunk()
936 oh->chunk = x; in H5O__alloc_chunk()
939 H5_CHECKED_ASSIGN(chunkno, unsigned, oh->nchunks, size_t); in H5O__alloc_chunk()
940 oh->nchunks++; in H5O__alloc_chunk()
941 oh->chunk[chunkno].addr = new_chunk_addr; in H5O__alloc_chunk()
942 oh->chunk[chunkno].size = size; in H5O__alloc_chunk()
943 oh->chunk[chunkno].gap = 0; in H5O__alloc_chunk()
944 if(NULL == (oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image, size))) in H5O__alloc_chunk()
946 oh->chunk[chunkno].chunk_proxy = NULL; in H5O__alloc_chunk()
951 if(oh->version > H5O_VERSION_1) { in H5O__alloc_chunk()
960 if(oh->nmesgs + 3 > oh->alloc_nmesgs) in H5O__alloc_chunk()
961 if(H5O_alloc_msgs(oh, (size_t)3) < 0) in H5O__alloc_chunk()
965 cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); in H5O__alloc_chunk()
966 if(found_null >= oh->nmesgs) { in H5O__alloc_chunk()
975 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno - 1))) in H5O__alloc_chunk()
979 for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) in H5O__alloc_chunk()
983 if(u < oh->nmesgs - 1) in H5O__alloc_chunk()
984 … HDmemmove(curr_msg, curr_msg + 1, ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); in H5O__alloc_chunk()
985 oh->nmesgs--; in H5O__alloc_chunk()
991 HDmemcpy(p, curr_msg->raw - (size_t)H5O_SIZEOF_MSGHDR_OH(oh), in H5O__alloc_chunk()
992 curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); in H5O__alloc_chunk()
996 curr_msg->raw = p + H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_chunk()
999 p += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; in H5O__alloc_chunk()
1000 size -= (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size; in H5O__alloc_chunk()
1005 found_null = oh->nmesgs++; in H5O__alloc_chunk()
1006 null_msg = &(oh->mesg[found_null]); in H5O__alloc_chunk()
1010 null_msg->raw = oh->chunk[chunkno - 1].image in H5O__alloc_chunk()
1011 + ((chunkno == 1) ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)) in H5O__alloc_chunk()
1012 - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_chunk()
1013 null_msg->raw_size = oh->chunk[chunkno - 1].size in H5O__alloc_chunk()
1014 … - ((chunkno == 1) ? (size_t)H5O_SIZEOF_HDR(oh) : (size_t)H5O_SIZEOF_CHKHDR_OH(oh)) in H5O__alloc_chunk()
1015 - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_chunk()
1021 oh->chunk[chunkno - 1].gap = 0; in H5O__alloc_chunk()
1034 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, oh->mesg[found_msg->msgno].chunkno))) in H5O__alloc_chunk()
1038 found_null = oh->nmesgs++; in H5O__alloc_chunk()
1039 null_msg = &(oh->mesg[found_null]); in H5O__alloc_chunk()
1042 null_msg->raw = oh->mesg[found_msg->msgno].raw; in H5O__alloc_chunk()
1043 null_msg->raw_size = oh->mesg[found_msg->msgno].raw_size; in H5O__alloc_chunk()
1044 null_msg->chunkno = oh->mesg[found_msg->msgno].chunkno; in H5O__alloc_chunk()
1047 HDmemcpy(p, oh->mesg[found_msg->msgno].raw - H5O_SIZEOF_MSGHDR_OH(oh), in H5O__alloc_chunk()
1048 oh->mesg[found_msg->msgno].raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); in H5O__alloc_chunk()
1051 oh->mesg[found_msg->msgno].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_chunk()
1052 oh->mesg[found_msg->msgno].chunkno = chunkno; in H5O__alloc_chunk()
1055 p += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; in H5O__alloc_chunk()
1056 size -= (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[found_msg->msgno].raw_size; in H5O__alloc_chunk()
1061 HDassert(oh->chunk[null_msg->chunkno].gap == found_msg->gap_size); in H5O__alloc_chunk()
1063 oh->chunk[null_msg->chunkno].gap = 0; in H5O__alloc_chunk()
1066 …H5O_mesg_t *old_null_msg = &oh->mesg[found_msg->null_msgno]; /* Pointer to NULL message to elimina… in H5O__alloc_chunk()
1069 … HDassert((null_msg->raw + null_msg->raw_size) == (old_null_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh))); in H5O__alloc_chunk()
1076 if(found_msg->null_msgno < (oh->nmesgs - 1)) in H5O__alloc_chunk()
1077 …HDmemmove(old_null_msg, old_null_msg + 1, ((oh->nmesgs - 1) - found_msg->null_msgno) * sizeof(H5O_… in H5O__alloc_chunk()
1081 oh->nmesgs--; in H5O__alloc_chunk()
1098 idx = oh->nmesgs++; in H5O__alloc_chunk()
1099 oh->mesg[idx].type = H5O_MSG_NULL; in H5O__alloc_chunk()
1100 oh->mesg[idx].dirty = TRUE; in H5O__alloc_chunk()
1101 oh->mesg[idx].native = NULL; in H5O__alloc_chunk()
1102 oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR_OH(oh); in H5O__alloc_chunk()
1103 oh->mesg[idx].raw_size = size - (size_t)(H5O_SIZEOF_CHKHDR_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh)); in H5O__alloc_chunk()
1104 oh->mesg[idx].chunkno = chunkno; in H5O__alloc_chunk()
1107 if(H5O__chunk_add(f, oh, chunkno, oh->mesg[found_null].chunkno) < 0) in H5O__alloc_chunk()
1113 cont->addr = oh->chunk[chunkno].addr; in H5O__alloc_chunk()
1114 cont->size = oh->chunk[chunkno].size; in H5O__alloc_chunk()
1118 if(H5O__alloc_null(f, oh, found_null, H5O_MSG_CONT, cont, cont_size) < 0) in H5O__alloc_chunk()
1165 H5O__alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t *new_idx) in H5O__alloc_new_chunk() argument
1175 HDassert(oh); in H5O__alloc_new_chunk()
1177 size = H5O_ALIGN_OH(oh, size); in H5O__alloc_new_chunk()
1180 idx = oh->nmesgs; in H5O__alloc_new_chunk()
1181 cont_size = H5O_ALIGN_OH(oh, (size_t)(H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f))); in H5O__alloc_new_chunk()
1182 if(H5O__alloc_find_best_null(oh, cont_size, &idx) < 0) in H5O__alloc_new_chunk()
1186 if(idx >= oh->nmesgs) { in H5O__alloc_new_chunk()
1188 if(H5O__alloc_find_best_nonnull(f, oh, &size, &found_msg) < 0) in H5O__alloc_new_chunk()
1193 if(H5O__alloc_chunk(f, oh, size, idx, &found_msg, new_idx) < 0) in H5O__alloc_new_chunk()
1216 H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) in H5O__alloc_find_best_null() argument
1224 HDassert(oh); in H5O__alloc_find_best_null()
1230 for(idx = 0; idx < oh->nmesgs; idx++) { in H5O__alloc_find_best_null()
1231 if(H5O_NULL_ID == oh->mesg[idx].type->id) { in H5O__alloc_find_best_null()
1233 if(oh->mesg[idx].raw_size == size) { in H5O__alloc_find_best_null()
1239 if(oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) { in H5O__alloc_find_best_null()
1246 if(0 == oh->mesg[idx].chunkno) in H5O__alloc_find_best_null()
1251 else if(oh->mesg[idx].raw_size > size) { in H5O__alloc_find_best_null()
1257 if(oh->mesg[idx].raw_size < oh->mesg[found_null].raw_size) in H5O__alloc_find_best_null()
1261 if(oh->mesg[idx].raw_size == oh->mesg[found_null].raw_size) { in H5O__alloc_find_best_null()
1262 if(oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) in H5O__alloc_find_best_null()
1291 H5O__alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, in H5O__alloc() argument
1302 HDassert(oh); in H5O__alloc()
1313 aligned_size = H5O_ALIGN_OH(oh, raw_size); in H5O__alloc()
1316 idx = oh->nmesgs; in H5O__alloc()
1317 if(H5O__alloc_find_best_null(oh, aligned_size, &idx) < 0) in H5O__alloc()
1321 if(idx >= oh->nmesgs) { in H5O__alloc()
1330 for(chunkno = 0; chunkno < oh->nchunks; chunkno++) { in H5O__alloc()
1333 if((tri_result = H5O__alloc_extend_chunk(f, oh, chunkno, raw_size, &idx)) < 0) in H5O__alloc()
1340 if(idx >= oh->nmesgs) in H5O__alloc()
1341 if(H5O__alloc_new_chunk(f, oh, raw_size, &idx) < 0) in H5O__alloc()
1344 HDassert(idx < oh->nmesgs); in H5O__alloc()
1347 if(H5O__alloc_null(f, oh, idx, type, NULL, aligned_size) < 0) in H5O__alloc()
1351 if(H5AC_mark_entry_dirty(oh) < 0) in H5O__alloc()
1377 H5O_release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link) in H5O_release_mesg() argument
1387 HDassert(oh); in H5O_release_mesg()
1393 if(H5O__delete_mesg(f, oh, mesg) < 0) in H5O_release_mesg()
1397 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, mesg->chunkno))) in H5O_release_mesg()
1405 …g->raw + mesg->raw_size <= (oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - (H5O… in H5O_release_mesg()
1416 if(oh->chunk[mesg->chunkno].gap) { in H5O_release_mesg()
1418 if(H5O_eliminate_gap(oh, &chk_dirtied, mesg, in H5O_release_mesg()
1419 …((oh->chunk[mesg->chunkno].image + oh->chunk[mesg->chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh in H5O_release_mesg()
1420 oh->chunk[mesg->chunkno].gap) < 0) in H5O_release_mesg()
1447 H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) in H5O_move_cont() argument
1459 HDassert(oh); in H5O_move_cont()
1462 cont_msg = &oh->mesg[cont_u]; in H5O_move_cont()
1463 H5O_LOAD_NATIVE(f, 0, oh, cont_msg, FAIL) in H5O_move_cont()
1467 if(deleted_chunkno == (oh->nchunks - 1)) { in H5O_move_cont()
1475 for(v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) { in H5O_move_cont()
1480 nonnull_size += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_cont()
1486 gap_size = oh->chunk[cont_msg->chunkno].gap; in H5O_move_cont()
1492 …nnull_size && nonnull_size <= (gap_size + cont_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh))) { in H5O_move_cont()
1497 move_start = cont_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_cont()
1503 if(H5O_release_mesg(f, oh, cont_msg, FALSE) < 0) in H5O_move_cont()
1507 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, cont_chunkno))) in H5O_move_cont()
1511 for(v = 0, curr_msg = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg++) in H5O_move_cont()
1519 move_size = curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_cont()
1522 HDmemcpy(move_start, curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), move_size); in H5O_move_cont()
1523 curr_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_cont()
1533 if(H5O__chunk_delete(f, oh, deleted_chunkno) < 0) in H5O_move_cont()
1541 if(gap_size >= (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { in H5O_move_cont()
1543 cont_msg->raw_size = gap_size - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_cont()
1544 cont_msg->raw = move_start + H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_cont()
1552 … if(H5O_add_gap(f, oh, cont_chunkno, &chk_dirtied, cont_u, move_start, gap_size) < 0) in H5O_move_cont()
1558 if(cont_u < (oh->nmesgs - 1)) in H5O_move_cont()
1559 …HDmemmove(&oh->mesg[cont_u], &oh->mesg[cont_u + 1], ((oh->nmesgs - 1) - cont_u) * sizeof(H5O_mesg_… in H5O_move_cont()
1560 oh->nmesgs--; in H5O_move_cont()
1565 for(v = oh->nmesgs - 1, curr_msg = &oh->mesg[v]; v < oh->nmesgs; v--, curr_msg--) in H5O_move_cont()
1575 if(v < (oh->nmesgs - 1)) in H5O_move_cont()
1576 … HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); in H5O_move_cont()
1577 oh->nmesgs--; in H5O_move_cont()
1582oh->chunk[deleted_chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[deleted_chunkno].image); in H5O_move_cont()
1583 oh->nchunks--; in H5O_move_cont()
1615 H5O_move_msgs_forward(H5F_t *f, H5O_t *oh) in H5O_move_msgs_forward() argument
1629 HDassert(oh); in H5O_move_msgs_forward()
1643 for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { in H5O_move_msgs_forward()
1648 chunk = &(oh->chunk[curr_msg->chunkno]); in H5O_move_msgs_forward()
1650 … != ((chunk->image + chunk->size) - (H5O_SIZEOF_CHKSUM_OH(oh) + chunk->gap))) { in H5O_move_msgs_forward()
1655 for(v = 0, nonnull_msg = &oh->mesg[0]; v < oh->nmesgs; v++, nonnull_msg++) { in H5O_move_msgs_forward()
1658 … ((curr_msg->raw + curr_msg->raw_size) == (nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)))) { in H5O_move_msgs_forward()
1663 … if(NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) in H5O_move_msgs_forward()
1667 HDmemmove(curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), in H5O_move_msgs_forward()
1668 …nonnull_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), nonnull_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH( in H5O_move_msgs_forward()
1675 nonnull_msg->raw_size + H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_msgs_forward()
1698 HDassert(v < oh->nmesgs); in H5O_move_msgs_forward()
1709 if((status = H5O_move_cont(f, oh, u)) < 0) in H5O_move_msgs_forward()
1718 for(v = 0, null_msg = &oh->mesg[0]; v < oh->nmesgs; v++, null_msg++) { in H5O_move_msgs_forward()
1729 if(NULL == (null_chk_proxy = H5O__chunk_protect(f, oh, null_msg->chunkno))) in H5O_move_msgs_forward()
1731 if(NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) in H5O_move_msgs_forward()
1737 if(oh->swmr_write && (H5O_CONT_ID == curr_msg->type->id)) { in H5O_move_msgs_forward()
1744 ? (void *)oh in H5O_move_msgs_forward()
1753 …if(NULL == (cont_targ_chk_proxy = H5O__chunk_protect(f, oh, ((H5O_cont_t *)(curr_msg->native))->ch… in H5O_move_msgs_forward()
1794 …raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh), curr_msg->raw_size + (si… in H5O_move_msgs_forward()
1819 if(oh->chunk[old_chunkno].gap > 0) { in H5O_move_msgs_forward()
1821 if(H5O_eliminate_gap(oh, &null_chk_dirtied, null_msg, in H5O_move_msgs_forward()
1822 …((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->ch… in H5O_move_msgs_forward()
1823 oh->chunk[old_chunkno].gap) < 0) in H5O_move_msgs_forward()
1837 … if((null_msg->raw_size - curr_msg->raw_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { in H5O_move_msgs_forward()
1848 …if(H5O_add_gap(f, oh, null_msg->chunkno, &null_chk_dirtied, v, null_msg->raw + null_msg->raw_size,… in H5O_move_msgs_forward()
1856 … null_msg->raw += curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_msgs_forward()
1857 … null_msg->raw_size -= curr_msg->raw_size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh); in H5O_move_msgs_forward()
1864 if(oh->nmesgs >= oh->alloc_nmesgs) { in H5O_move_msgs_forward()
1865 if(H5O_alloc_msgs(oh, (size_t)1) < 0) in H5O_move_msgs_forward()
1869 curr_msg = &oh->mesg[u]; in H5O_move_msgs_forward()
1873 new_null_msg = oh->nmesgs++; in H5O_move_msgs_forward()
1883 oh->mesg[new_null_msg].type = H5O_MSG_NULL; in H5O_move_msgs_forward()
1884 oh->mesg[new_null_msg].native = NULL; in H5O_move_msgs_forward()
1885 oh->mesg[new_null_msg].raw = old_raw; in H5O_move_msgs_forward()
1886 oh->mesg[new_null_msg].raw_size = curr_msg->raw_size; in H5O_move_msgs_forward()
1887 oh->mesg[new_null_msg].chunkno = old_chunkno; in H5O_move_msgs_forward()
1890 oh->mesg[new_null_msg].dirty = TRUE; in H5O_move_msgs_forward()
1894 if(oh->chunk[old_chunkno].gap > 0) { in H5O_move_msgs_forward()
1896 if(H5O_eliminate_gap(oh, &curr_chk_dirtied, &oh->mesg[new_null_msg], in H5O_move_msgs_forward()
1897 …((oh->chunk[old_chunkno].image + oh->chunk[old_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->ch… in H5O_move_msgs_forward()
1898 oh->chunk[old_chunkno].gap) < 0) in H5O_move_msgs_forward()
1966 H5O_merge_null(H5F_t *f, H5O_t *oh) in H5O_merge_null() argument
1975 HDassert(oh != NULL); in H5O_merge_null()
1989 for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { in H5O_merge_null()
1995 HDassert(oh->chunk[curr_msg->chunkno].gap == 0); in H5O_merge_null()
1998 for(v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) { in H5O_merge_null()
2004 … if((curr_msg->raw + curr_msg->raw_size) == (curr_msg2->raw - H5O_SIZEOF_MSGHDR_OH(oh))) { in H5O_merge_null()
2007 adj_raw_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; in H5O_merge_null()
2013 … else if((curr_msg->raw - H5O_SIZEOF_MSGHDR_OH(oh)) == (curr_msg2->raw + curr_msg2->raw_size)) { in H5O_merge_null()
2015 … adj_raw = -((ssize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size)); in H5O_merge_null()
2016 adj_raw_size = (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg2->raw_size; in H5O_merge_null()
2031 … if(NULL == (curr_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) in H5O_merge_null()
2046 if(v < (oh->nmesgs - 1)) in H5O_merge_null()
2047 … HDmemmove(&oh->mesg[v], &oh->mesg[v + 1], ((oh->nmesgs - 1) - v) * sizeof(H5O_mesg_t)); in H5O_merge_null()
2051 oh->nmesgs--; in H5O_merge_null()
2054 if((result = H5O_remove_empty_chunks(f, oh)) < 0) in H5O_merge_null()
2062 if(H5O__alloc_shrink_chunk(f, oh, curr_msg->chunkno) < 0) in H5O_merge_null()
2109 H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh) in H5O_remove_empty_chunks() argument
2118 HDassert(oh != NULL); in H5O_remove_empty_chunks()
2130 for(u = 0, null_msg = &oh->mesg[0]; u < oh->nmesgs; u++, null_msg++) { in H5O_remove_empty_chunks()
2135 ((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + null_msg->raw_size) in H5O_remove_empty_chunks()
2136 == (oh->chunk[null_msg->chunkno].size - H5O_SIZEOF_CHKHDR_OH(oh))) { in H5O_remove_empty_chunks()
2142 for(v = 0, cont_msg = &oh->mesg[0]; v < oh->nmesgs; v++, cont_msg++) { in H5O_remove_empty_chunks()
2145 H5O_LOAD_NATIVE(f, 0, oh, cont_msg, FAIL) in H5O_remove_empty_chunks()
2153 for(w = 0; w < oh->nchunks; w++) in H5O_remove_empty_chunks()
2154 if(oh->chunk[w].addr == ((H5O_cont_t *)(cont_msg->native))->addr) { in H5O_remove_empty_chunks()
2162 … if(oh->chunk[null_msg->chunkno].addr == ((H5O_cont_t *)(cont_msg->native))->addr) in H5O_remove_empty_chunks()
2167 HDassert(v < oh->nmesgs); in H5O_remove_empty_chunks()
2176 if(H5O_release_mesg(f, oh, cont_msg, TRUE) < 0) in H5O_remove_empty_chunks()
2184oh->chunk[null_msg->chunkno].image = H5FL_BLK_FREE(chunk_image, oh->chunk[null_msg->chunkno].image… in H5O_remove_empty_chunks()
2187 if(null_msg->chunkno < (oh->nchunks - 1)) { in H5O_remove_empty_chunks()
2188 …HDmemmove(&oh->chunk[null_msg->chunkno], &oh->chunk[null_msg->chunkno + 1], ((oh->nchunks - 1) - n… in H5O_remove_empty_chunks()
2191 for(u = null_msg->chunkno; u < (oh->nchunks - 1); u++) { in H5O_remove_empty_chunks()
2195 if(H5AC_get_entry_status(f, oh->chunk[u].addr, &chk_proxy_status) < 0) in H5O_remove_empty_chunks()
2200 if(H5O__chunk_update_idx(f, oh, u) < 0) in H5O_remove_empty_chunks()
2208 oh->nchunks--; in H5O_remove_empty_chunks()
2218 if(null_msg_no < (oh->nmesgs - 1)) in H5O_remove_empty_chunks()
2219 …HDmemmove(&oh->mesg[null_msg_no], &oh->mesg[null_msg_no + 1], ((oh->nmesgs - 1) - null_msg_no) * s… in H5O_remove_empty_chunks()
2223 oh->nmesgs--; in H5O_remove_empty_chunks()
2226 for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { in H5O_remove_empty_chunks()
2237 H5O_LOAD_NATIVE(f, 0, oh, curr_msg, FAIL) in H5O_remove_empty_chunks()
2245 for(w = 0; w < oh->nchunks; w++) in H5O_remove_empty_chunks()
2246 if(oh->chunk[w].addr == ((H5O_cont_t *)(curr_msg->native))->addr) { in H5O_remove_empty_chunks()
2294 H5O_condense_header(H5F_t *f, H5O_t *oh) in H5O_condense_header() argument
2303 HDassert(oh != NULL); in H5O_condense_header()
2311 result = H5O_move_msgs_forward(f, oh); in H5O_condense_header()
2318 result = H5O_merge_null(f, oh); in H5O_condense_header()
2325 result = H5O_remove_empty_chunks(f, oh); in H5O_condense_header()
2332 H5O_assert(oh); in H5O_condense_header()
2355 H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) in H5O__alloc_shrink_chunk() argument
2357 H5O_chunk_t *chunk = &oh->chunk[chunkno]; /* Chunk to shrink */ in H5O__alloc_shrink_chunk()
2364 size_t min_chunk_size = H5O_ALIGN_OH(oh, H5O_MIN_SIZE); /* Minimum chunk size */ in H5O__alloc_shrink_chunk()
2365 size_t sizeof_chksum = H5O_SIZEOF_CHKSUM_OH(oh); /* Size of chunk checksum */ in H5O__alloc_shrink_chunk()
2366 size_t sizeof_msghdr = H5O_SIZEOF_MSGHDR_OH(oh); /* Size of message header */ in H5O__alloc_shrink_chunk()
2377 HDassert(oh); in H5O__alloc_shrink_chunk()
2380 if(NULL == (chk_proxy = H5O__chunk_protect(f, oh, chunkno))) in H5O__alloc_shrink_chunk()
2387 for(u = oh->nmesgs - 1, curr_msg = &oh->mesg[u]; u < oh->nmesgs; u--, curr_msg--) { in H5O__alloc_shrink_chunk()
2405 for(v = 0, curr_msg2 = &oh->mesg[0]; v < oh->nmesgs; v++, curr_msg2++) in H5O__alloc_shrink_chunk()
2417 if(u < (oh->nmesgs - 1)) in H5O__alloc_shrink_chunk()
2418 … HDmemmove(&oh->mesg[u], &oh->mesg[u+1], ((oh->nmesgs - 1) - u) * sizeof(H5O_mesg_t)); in H5O__alloc_shrink_chunk()
2422 oh->nmesgs--; in H5O__alloc_shrink_chunk()
2427 …total_msg_size = new_size - (size_t)(chunkno == 0 ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh)); in H5O__alloc_shrink_chunk()
2429 HDassert(oh->alloc_nmesgs > oh->nmesgs); in H5O__alloc_shrink_chunk()
2430 oh->nmesgs++; in H5O__alloc_shrink_chunk()
2433 curr_msg = &oh->mesg[oh->nmesgs - 1]; in H5O__alloc_shrink_chunk()
2438 curr_msg->raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), in H5O__alloc_shrink_chunk()
2447 if(oh->version > H5O_VERSION_1 && chunkno == 0) { in H5O__alloc_shrink_chunk()
2448 … uint64_t chunk0_newsize = new_size - (size_t)H5O_SIZEOF_HDR(oh); /* New size of chunk 0's data */ in H5O__alloc_shrink_chunk()
2449 …size_t orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size … in H5O__alloc_shrink_chunk()
2473 oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); in H5O__alloc_shrink_chunk()
2474 oh->flags |= new_size_flags; in H5O__alloc_shrink_chunk()
2477 HDmemmove(chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum, in H5O__alloc_shrink_chunk()
2478 chunk->image + H5O_SIZEOF_HDR(oh) - sizeof_chksum + less_prfx_size, in H5O__alloc_shrink_chunk()
2479 new_size - (size_t)H5O_SIZEOF_HDR(oh)); in H5O__alloc_shrink_chunk()
2489 if(NULL == oh->chunk[chunkno].image) in H5O__alloc_shrink_chunk()
2493 for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { in H5O__alloc_shrink_chunk()
2507 if(NULL == (cont_chk_proxy = H5O__chunk_protect(f, oh, curr_msg->chunkno))) in H5O__alloc_shrink_chunk()
2526 if(H5O_chunk_resize(oh, chk_proxy) < 0) in H5O__alloc_shrink_chunk()