예제 #1
0
void init_bio_entry_by_clone_never_giveup(
	struct bio_entry *bioe, struct bio *bio,
	struct block_device *bdev, gfp_t gfp_mask)
{
	while (!init_bio_entry_by_clone(bioe, bio, bdev, gfp_mask)) {
		LOGd_("clone bio failed %p.\n", bio);
		schedule();
	}
}
예제 #2
0
/**
 * Read logpack data.
 * Padding area will be also read.
 *
 * @fd file descriptor of log device.
 * @super super sector.
 * @logh logpack header.
 * @salt checksum salt.
 * @sect_ary sector array.
 *
 * RETURN:
 *   index of invalid record found at first.
 *   logh->n_records if the whole logpack is valid.
 */
unsigned int read_logpack_data_from_wldev(
	int fd,
	const struct walb_super_sector* super,
	const struct walb_logpack_header* logh, u32 salt,
	struct sector_data_array *sect_ary)
{
	const int lbs = super->logical_bs;
	const int pbs = super->physical_bs;
	int i;
	int total_pb;

	ASSERT(lbs == LOGICAL_BLOCK_SIZE);
	ASSERT_PBS(pbs);

	if (logh->total_io_size > sect_ary->size) {
		LOGe("buffer size is not enough.\n");
		return false;
	}

	total_pb = 0;
	for (i = 0; i < logh->n_records; i++) {
		u64 log_off;
		u32 log_lb, log_pb;

		if (test_bit_u32(LOG_RECORD_DISCARD, &logh->record[i].flags)) {
			continue;
		}
		log_lb = logh->record[i].io_size;
		log_pb = capacity_pb(pbs, log_lb);
		log_off = get_offset_of_lsid_2
			(super, logh->record[i].lsid);
		LOGd_("lsid: %"PRIu64" log_off: %"PRIu64"\n",
			logh->record[i].lsid,
			log_off);

		/* Read data for the log record. */
		if (!sector_array_pread(
				fd, log_off, sect_ary,
				total_pb, log_pb)) {
			LOGe("read sectors failed.\n");
			return i;
		}

		if (test_bit_u32(LOG_RECORD_PADDING, &logh->record[i].flags)) {
			total_pb += log_pb;
			continue;
		}
		/* Confirm checksum */
		u32 csum = sector_array_checksum(
			sect_ary, total_pb * pbs,
			log_lb * lbs, salt);
		if (csum != logh->record[i].checksum) {
			LOGe("log header checksum is invalid. %08x %08x\n",
				csum, logh->record[i].checksum);
			return i;
		}
		total_pb += log_pb;
	}
	ASSERT(i == logh->n_records);
	return logh->n_records;
}