Skip to content
Snippets Groups Projects
check-integrity.c 93.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	state = NULL;
    	list_for_each_entry(device, dev_head, dev_list) {
    		struct btrfsic_dev_state *ds;
    
    		if (!device->bdev || !device->name)
    			continue;
    
    		ds = btrfsic_dev_state_hashtable_lookup(
    				device->bdev,
    				&btrfsic_dev_state_hashtable);
    		if (NULL != ds) {
    			state = ds->state;
    			btrfsic_dev_state_hashtable_remove(ds);
    			btrfsic_dev_state_free(ds);
    		}
    	}
    
    	if (NULL == state) {
    		printk(KERN_INFO
    		       "btrfsic: error, cannot find state information"
    		       " on umount!\n");
    		mutex_unlock(&btrfsic_mutex);
    		return;
    	}
    
    	/*
    	 * Don't care about keeping the lists' state up to date,
    	 * just free all memory that was allocated dynamically.
    	 * Free the blocks and the block_links.
    	 */
    	list_for_each_safe(elem_all, tmp_all, &state->all_blocks_list) {
    		struct btrfsic_block *const b_all =
    		    list_entry(elem_all, struct btrfsic_block,
    			       all_blocks_node);
    		struct list_head *elem_ref_to;
    		struct list_head *tmp_ref_to;
    
    		list_for_each_safe(elem_ref_to, tmp_ref_to,
    				   &b_all->ref_to_list) {
    			struct btrfsic_block_link *const l =
    			    list_entry(elem_ref_to,
    				       struct btrfsic_block_link,
    				       node_ref_to);
    
    			if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE)
    				btrfsic_print_rem_link(state, l);
    
    			l->ref_cnt--;
    			if (0 == l->ref_cnt)
    				btrfsic_block_link_free(l);
    		}
    
    		if (b_all->is_iodone)
    			btrfsic_block_free(b_all);
    		else
    			printk(KERN_INFO "btrfs: attempt to free %c-block"
    			       " @%llu (%s/%llu/%d) on umount which is"
    			       " not yet iodone!\n",
    			       btrfsic_get_block_type(state, b_all),
    			       (unsigned long long)b_all->logical_bytenr,
    			       b_all->dev_state->name,
    			       (unsigned long long)b_all->dev_bytenr,
    			       b_all->mirror_num);
    	}
    
    	mutex_unlock(&btrfsic_mutex);
    
    	kfree(state);
    }