/* keep it simple for now by always updating both data structures */ errcode_t o2fsck_icount_set(o2fsck_icount *icount, uint64_t blkno, uint16_t count) { icount_node *in; errcode_t ret = 0; if (count == 1) o2fsck_bitmap_set(icount->ic_single_bm, blkno, NULL); else o2fsck_bitmap_clear(icount->ic_single_bm, blkno, NULL); in = icount_search(icount, blkno, NULL); if (in) { if (count < 2) { rb_erase(&in->in_node, &icount->ic_multiple_tree); free(in); } else { in->in_icount = count; } } else if (count > 1) { in = calloc(1, sizeof(*in)); if (in == NULL) { ret = OCFS2_ET_NO_MEMORY; goto out; } in->in_blkno = blkno; in->in_icount = count; icount_insert(icount, in); } out: return ret; }
static errcode_t lookup_journal_block(ocfs2_filesys *fs, struct journal_info *ji, uint64_t blkoff, uint64_t *blkno, int check_dup) { errcode_t ret; uint64_t contig; int was_set; ret = ocfs2_extent_map_get_blocks(ji->ji_cinode, blkoff, 1, blkno, &contig, NULL); if (ret) { com_err(whoami, ret, "while looking up logical block " "%"PRIu64" in slot %d's journal", blkoff, ji->ji_slot); goto out; } if (check_dup) { o2fsck_bitmap_set(ji->ji_used_blocks, *blkno, &was_set); if (was_set) { printf("Logical block %"PRIu64" in slot %d's journal " "maps to block %"PRIu64" which has already " "been used in another journal.\n", blkoff, ji->ji_slot, *blkno); ret = OCFS2_ET_DUPLICATE_BLOCK; } } out: return ret; }
void o2fsck_mark_cluster_allocated(o2fsck_state *ost, uint32_t cluster) { int was_set = 0; errcode_t ret; const char *whoami = __FUNCTION__; o2fsck_bitmap_set(ost->ost_allocated_clusters, cluster, &was_set); if (!was_set) return; if (!ost->ost_duplicate_clusters) { fprintf(stderr, "Duplicate clusters detected. Pass 1b will be run\n"); ret = ocfs2_cluster_bitmap_new(ost->ost_fs, "duplicate clusters", &ost->ost_duplicate_clusters); if (ret) { com_err(whoami, ret, "while allocating duplicate cluster bitmap"); o2fsck_abort(); } } verbosef("Cluster %"PRIu32" is allocated to more than one object\n", cluster); ocfs2_bitmap_set(ost->ost_duplicate_clusters, cluster, NULL); }