Lines Matching refs:jhdr
138 if (jnl->jhdr->magic != JOURNAL_HEADER_MAGIC) {\
139 panic("%s:%d: jhdr magic corrupted (0x%x != 0x%x)\n",\
140 __FILE__, __LINE__, jnl->jhdr->magic, JOURNAL_HEADER_MAGIC);\
142 if ( jnl->jhdr->start <= 0 \
143 || jnl->jhdr->start > jnl->jhdr->size\
144 || jnl->jhdr->start > 1024*1024*1024) {\
145 panic("%s:%d: jhdr start looks bad (0x%llx max size 0x%llx)\n", \
146 __FILE__, __LINE__, jnl->jhdr->start, jnl->jhdr->size);\
148 if ( jnl->jhdr->end <= 0 \
149 || jnl->jhdr->end > jnl->jhdr->size\
150 || jnl->jhdr->end > 1024*1024*1024) {\
151 panic("%s:%d: jhdr end looks bad (0x%llx max size 0x%llx)\n", \
152 __FILE__, __LINE__, jnl->jhdr->end, jnl->jhdr->size);\
154 if (jnl->jhdr->size > 1024*1024*1024) {\
155 panic("%s:%d: jhdr size looks bad (0x%llx)\n",\
156 __FILE__, __LINE__, jnl->jhdr->size);\
180 if (tr->blhdr && (tr->blhdr->max_blocks <= 0 || tr->blhdr->max_blocks > (tr->jnl->jhdr->size/tr->jnl->jhdr->jhdr_size))) {\
267 if (*offset < 0 || *offset > jnl->jhdr->size) {
268 panic("jnl: do_jnl_io: bad offset 0x%llx (max 0x%llx)\n", *offset, jnl->jhdr->size);
281 if (*offset + (off_t)curlen > jnl->jhdr->size && *offset != 0 && jnl->jhdr->size != 0) {
282 if (*offset == jnl->jhdr->size) {
283 *offset = jnl->jhdr->jhdr_size;
285 curlen = (off_t)jnl->jhdr->size - *offset;
312 buf_setblkno(bp, (daddr64_t) ((jnl->jdev_offset + *offset) / (off_t)jnl->jhdr->jhdr_size));
313 buf_setlblkno(bp, (daddr64_t) ((jnl->jdev_offset + *offset) / (off_t)jnl->jhdr->jhdr_size));
335 if (*offset >= jnl->jhdr->size) {
336 *offset = jnl->jhdr->jhdr_size;
403 jnl->jhdr->checksum = 0;
404 jnl->jhdr->checksum = calc_checksum((char *)jnl->jhdr, JOURNAL_HEADER_CKSUM_SIZE);
405 if (do_journal_io(jnl, &jhdr_offset, jnl->header_buf, jnl->jhdr->jhdr_size, JNL_WRITE|JNL_HEADER) != (size_t)jnl->jhdr->jhdr_size) {
638 jnl->jhdr->magic = SWAP32(jnl->jhdr->magic);
639 jnl->jhdr->endian = SWAP32(jnl->jhdr->endian);
640 jnl->jhdr->start = SWAP64(jnl->jhdr->start);
641 jnl->jhdr->end = SWAP64(jnl->jhdr->end);
642 jnl->jhdr->size = SWAP64(jnl->jhdr->size);
643 jnl->jhdr->blhdr_size = SWAP32(jnl->jhdr->blhdr_size);
644 jnl->jhdr->checksum = SWAP32(jnl->jhdr->checksum);
645 jnl->jhdr->jhdr_size = SWAP32(jnl->jhdr->jhdr_size);
646 jnl->jhdr->sequence_num = SWAP32(jnl->jhdr->sequence_num);
660 if (blhdr->num_blocks >= ((jnl->jhdr->blhdr_size / sizeof(block_info)) - 1)) {
661 printf("jnl: %s: blhdr num blocks looks suspicious (%d / blhdr size %d). not swapping.\n", jnl->jdev_name, blhdr->num_blocks, jnl->jhdr->blhdr_size);
840 if (offset >= jnl->jhdr->size) {
841 offset = jnl->jhdr->jhdr_size + (offset - jnl->jhdr->size);
859 size_t jhdr_size = jnl->jhdr->jhdr_size, new_offset;
926 if (new_offset >= jnl->jhdr->size) {
927 new_offset = jhdr_size + (new_offset - jnl->jhdr->size);
1015 if (jnl->jhdr->start == jnl->jhdr->size) {
1016 jnl->jhdr->start = jnl->jhdr->jhdr_size;
1018 if (jnl->jhdr->end == jnl->jhdr->size) {
1019 jnl->jhdr->end = jnl->jhdr->jhdr_size;
1022 if (jnl->jhdr->start == jnl->jhdr->end) {
1026 orig_jnl_start = jnl->jhdr->start;
1029 if (kmem_alloc(kernel_map, (vm_offset_t *)&buff, jnl->jhdr->blhdr_size)) {
1031 jnl->jdev_name, jnl->jhdr->blhdr_size);
1051 jnl->jdev_name, jnl->jhdr->start, jnl->jhdr->end, jnl->jdev_offset);
1053 while(check_past_jnl_end || jnl->jhdr->start != jnl->jhdr->end) {
1054 offset = blhdr_offset = jnl->jhdr->start;
1055 ret = read_journal_data(jnl, &offset, buff, jnl->jhdr->blhdr_size);
1056 if (ret != (size_t)jnl->jhdr->blhdr_size) {
1086 if (blhdr_offset != jnl->jhdr->end) {
1091 jnl->jhdr->end = blhdr_offset;
1112 txn_start_offset = jnl->jhdr->end = blhdr_offset;
1128 if (blhdr_offset >= jnl->jhdr->end && jnl->jhdr->start <= jnl->jhdr->end) {
1132 jnl->jdev_name, jnl->jhdr->start, jnl->jhdr->end);
1133 if (jnl->jhdr->start != jnl->jhdr->end) {
1134 jnl->jhdr->start = jnl->jhdr->end;
1176 // blhdr->num_blocks-1, jnl->jhdr->start);
1238 if (offset >= jnl->jhdr->size) {
1239 offset = jnl->jhdr->jhdr_size + (offset - jnl->jhdr->size);
1255 jnl->jhdr->start = orig_jnl_start;
1256 jnl->jhdr->end = txn_start_offset;
1259 printf("jnl: %s: restarting journal replay (%lld - %lld)!\n", jnl->jdev_name, jnl->jhdr->start, jnl->jhdr->end);
1263 jnl->jhdr->start += blhdr->bytes_used;
1264 if (jnl->jhdr->start >= jnl->jhdr->size) {
1266 jnl->jhdr->start = (jnl->jhdr->start % jnl->jhdr->size) + jnl->jhdr->jhdr_size;
1269 if (jnl->jhdr->start == jnl->jhdr->end) {
1274 if (jnl->jhdr->start != jnl->jhdr->end) {
1275 printf("jnl: %s: start %lld != end %lld. resetting end.\n", jnl->jdev_name, jnl->jhdr->start, jnl->jhdr->end);
1276 jnl->jhdr->end = jnl->jhdr->start;
1349 kmem_free(kernel_map, (vm_offset_t)buff, jnl->jhdr->blhdr_size);
1359 kmem_free(kernel_map, (vm_offset_t)buff, jnl->jhdr->blhdr_size);
1375 // size of the blhdr. It assumes that jnl->jhdr->size
1376 // and jnl->jhdr->jhdr_size are already valid.
1403 if (tbuffer_size < jnl->jhdr->blhdr_size * 2) {
1404 tbuffer_size = jnl->jhdr->blhdr_size * 2;
1407 if ((tbuffer_size % jnl->jhdr->jhdr_size) != 0) {
1408 tbuffer_size -= (tbuffer_size % jnl->jhdr->jhdr_size);
1414 if (jnl->tbuffer_size > (jnl->jhdr->size / 2)) {
1415 jnl->tbuffer_size = (jnl->jhdr->size / 2);
1422 jnl->jhdr->blhdr_size = (jnl->tbuffer_size / jnl->jhdr->jhdr_size) * sizeof(block_info);
1423 if (jnl->jhdr->blhdr_size < phys_blksz) {
1424 jnl->jhdr->blhdr_size = phys_blksz;
1425 } else if ((jnl->jhdr->blhdr_size % phys_blksz) != 0) {
1427 jnl->jhdr->blhdr_size = (jnl->jhdr->blhdr_size + (phys_blksz - 1)) & ~(phys_blksz - 1);
1563 jnl->jhdr = (journal_header *)jnl->header_buf;
1564 jnl->jhdr->magic = JOURNAL_HEADER_MAGIC;
1565 jnl->jhdr->endian = ENDIAN_MAGIC;
1566 jnl->jhdr->start = phys_blksz; // start at block #1, block #0 is for the jhdr itself
1567 jnl->jhdr->end = phys_blksz;
1568 jnl->jhdr->size = journal_size;
1569 jnl->jhdr->jhdr_size = phys_blksz;
1572 jnl->active_start = jnl->jhdr->start;
1575 // jnl->jhdr->start = jnl->jhdr->size - (phys_blksz*3);
1576 // jnl->jhdr->end = jnl->jhdr->size - (phys_blksz*3);
1578 jnl->jhdr->sequence_num = random() & 0x00ffffff;
1596 jnl->jhdr = NULL;
1659 jnl->jhdr = (journal_header *)jnl->header_buf;
1660 memset(jnl->jhdr, 0, sizeof(journal_header));
1663 jnl->jhdr->jhdr_size = phys_blksz;
1665 if (read_journal_header(jnl, jnl->jhdr, phys_blksz) != phys_blksz) {
1671 orig_checksum = jnl->jhdr->checksum;
1672 jnl->jhdr->checksum = 0;
1674 if (jnl->jhdr->magic == SWAP32(JOURNAL_HEADER_MAGIC)) {
1677 checksum = calc_checksum((char *)jnl->jhdr, JOURNAL_HEADER_CKSUM_SIZE);
1681 checksum = calc_checksum((char *)jnl->jhdr, JOURNAL_HEADER_CKSUM_SIZE);
1684 if (jnl->jhdr->magic != JOURNAL_HEADER_MAGIC && jnl->jhdr->magic != OLD_JOURNAL_HEADER_MAGIC) {
1686 jnl->jdev_name, jnl->jhdr->magic, JOURNAL_HEADER_MAGIC);
1691 if (jnl->jhdr->magic == JOURNAL_HEADER_MAGIC) {
1702 if (jnl->jhdr->magic == OLD_JOURNAL_HEADER_MAGIC) {
1703 jnl->jhdr->magic = JOURNAL_HEADER_MAGIC;
1706 if (phys_blksz != (size_t)jnl->jhdr->jhdr_size && jnl->jhdr->jhdr_size != 0) {
1715 if (jnl->jhdr->start == jnl->jhdr->end) {
1718 jdev_name, jnl->jhdr->jhdr_size, phys_blksz);
1719 jnl->jhdr->jhdr_size = phys_blksz;
1726 jdev_name, phys_blksz, jnl->jhdr->jhdr_size);
1731 if ( jnl->jhdr->start <= 0
1732 || jnl->jhdr->start > jnl->jhdr->size
1733 || jnl->jhdr->start > 1024*1024*1024) {
1734 printf("jnl: %s: open: jhdr start looks bad (0x%llx max size 0x%llx)\n",
1735 jdev_name, jnl->jhdr->start, jnl->jhdr->size);
1739 if ( jnl->jhdr->end <= 0
1740 || jnl->jhdr->end > jnl->jhdr->size
1741 || jnl->jhdr->end > 1024*1024*1024) {
1742 printf("jnl: %s: open: jhdr end looks bad (0x%llx max size 0x%llx)\n",
1743 jdev_name, jnl->jhdr->end, jnl->jhdr->size);
1747 if (jnl->jhdr->size > 1024*1024*1024) {
1748 printf("jnl: %s: open: jhdr size looks bad (0x%llx)\n", jdev_name, jnl->jhdr->size);
1757 // XXXdbg if ((jnl->jhdr->start % jnl->jhdr->jhdr_size) != 0) {
1758 if ((jnl->jhdr->start % 512) != 0) {
1760 jdev_name, jnl->jhdr->start);
1764 //XXXdbg if ((jnl->jhdr->end % jnl->jhdr->jhdr_size) != 0) {
1765 if ((jnl->jhdr->end % 512) != 0) {
1767 jdev_name, jnl->jhdr->end, jnl->jhdr->jhdr_size);
1774 jdev_name, jnl, jnl->jhdr->start, jnl->jhdr->end);
1775 jnl->jhdr->start = jnl->jhdr->end;
1784 if (orig_blksz < jnl->jhdr->jhdr_size) {
1786 jdev_name, jnl->jhdr->jhdr_size, orig_blksz);
1788 jnl->jhdr->jhdr_size = orig_blksz;
1793 jnl->active_start = jnl->jhdr->start;
1860 jnl.jhdr = (journal_header *)jnl.header_buf;
1861 memset(jnl.jhdr, 0, sizeof(journal_header));
1868 jnl.jhdr->jhdr_size = phys_blksz;
1870 if (read_journal_header(&jnl, jnl.jhdr, phys_blksz) != (unsigned)phys_blksz) {
1877 orig_checksum = jnl.jhdr->checksum;
1878 jnl.jhdr->checksum = 0;
1880 if (jnl.jhdr->magic == SWAP32(JOURNAL_HEADER_MAGIC)) {
1883 checksum = calc_checksum((char *)jnl.jhdr, JOURNAL_HEADER_CKSUM_SIZE);
1887 checksum = calc_checksum((char *)jnl.jhdr, JOURNAL_HEADER_CKSUM_SIZE);
1890 if (jnl.jhdr->magic != JOURNAL_HEADER_MAGIC && jnl.jhdr->magic != OLD_JOURNAL_HEADER_MAGIC) {
1892 jdev_name, jnl.jhdr->magic, JOURNAL_HEADER_MAGIC);
1907 if (jnl.jhdr->start == jnl.jhdr->end) {
1959 //start = &jnl->jhdr->start;
1961 end = &jnl->jhdr->end;
1977 jnl->jhdr->start = jnl->active_start;
2004 kmem_free(kernel_map, (vm_offset_t)jnl->header_buf, jnl->jhdr->jhdr_size);
2005 jnl->jhdr = (void *)0xbeefbabe;
2021 printf(" magic: 0x%.8x\n", jnl->jhdr->magic);
2022 printf(" start: 0x%.8llx\n", jnl->jhdr->start);
2023 printf(" end: 0x%.8llx\n", jnl->jhdr->end);
2024 printf(" size: 0x%.8llx\n", jnl->jhdr->size);
2025 printf(" blhdr size: %d\n", jnl->jhdr->blhdr_size);
2026 printf(" jhdr size: %d\n", jnl->jhdr->jhdr_size);
2027 printf(" chksum: 0x%.8x\n", jnl->jhdr->checksum);
2042 if (jnl->jhdr->start < jnl->jhdr->end) {
2043 free_space_offset = jnl->jhdr->size - (jnl->jhdr->end - jnl->jhdr->start) - jnl->jhdr->jhdr_size;
2044 } else if (jnl->jhdr->start > jnl->jhdr->end) {
2045 free_space_offset = jnl->jhdr->start - jnl->jhdr->end;
2048 free_space_offset = jnl->jhdr->size - jnl->jhdr->jhdr_size;
2075 jnl->jhdr->start, jnl->jhdr->end, free_space(jnl), jnl->active_start);
2087 // here's where we lazily bump up jnl->jhdr->start. we'll consume
2115 jnl->jhdr->start = jnl->old_start[i];
2132 // bump the jhdr->start to be the same as active_start
2135 // this then jhdr->start would never get updated and we
2139 jnl->jhdr->start = jnl->active_start;
2182 memset(tr->tbuffer + BLHDR_CHECKSUM_SIZE, 0x5a, jnl->jhdr->blhdr_size - BLHDR_CHECKSUM_SIZE);
2185 tr->blhdr->max_blocks = (jnl->jhdr->blhdr_size / sizeof(block_info)) - 1;
2187 tr->blhdr->bytes_used = jnl->jhdr->blhdr_size;
2190 tr->sequence_num = ++jnl->jhdr->sequence_num;
2192 tr->total_bytes = jnl->jhdr->blhdr_size;
2235 // as well as updating jnl->jhdr->start
2300 if ((buf_size(bp) % jnl->jhdr->jhdr_size) != 0) {
2302 buf_size(bp), jnl->jhdr->jhdr_size);
2307 if (tr->total_bytes+buf_size(bp) >= (jnl->jhdr->size - jnl->jhdr->jhdr_size)) {
2309 tr->total_bytes, (tr->jnl->jhdr->size - jnl->jhdr->jhdr_size), buf_size(bp), tr, bp);
2435 tbuffer_offset = jnl->jhdr->blhdr_size;
2480 memset(nblhdr + BLHDR_CHECKSUM_SIZE, 0x5a, jnl->jhdr->blhdr_size - BLHDR_CHECKSUM_SIZE);
2483 nblhdr->max_blocks = (jnl->jhdr->blhdr_size / sizeof(block_info)) - 1;
2485 nblhdr->bytes_used = jnl->jhdr->blhdr_size;
2489 tr->total_bytes += jnl->jhdr->blhdr_size;
2496 tbuffer_offset = jnl->jhdr->blhdr_size;
2691 if (tr->total_bytes == jnl->jhdr->blhdr_size) {
2717 if (jnl->jhdr->end <= 0 || jnl->jhdr->end > jnl->jhdr->size) {
2719 jnl->jhdr->end, jnl->jhdr->size);
2723 tr->journal_start = jnl->jhdr->end;
2724 end = jnl->jhdr->end;
2765 tbuffer_offset = jnl->jhdr->blhdr_size;
2872 tbuffer_offset = jnl->jhdr->blhdr_size;
2901 jnl->jhdr->end = end; // update where the journal now ends
2933 tr->num_flushed = tr->num_blhdrs * jnl->jhdr->blhdr_size;
3265 if ((offset % jnl->jhdr->jhdr_size) != 0) {
3267 jnl->jdev_name, offset, jnl->jhdr->jhdr_size);
3270 if ((journal_size % jnl->jhdr->jhdr_size) != 0) {
3272 jnl->jdev_name, journal_size, jnl->jhdr->jhdr_size);
3289 size_up_tbuffer(jnl, tbuffer_size, jnl->jhdr->jhdr_size);
3307 jnl->jhdr->start = jnl->jhdr->end = jnl->jhdr->jhdr_size;
3308 jnl->jhdr->size = journal_size;
3309 jnl->active_start = jnl->jhdr->start;