static int read_header(struct log_c *log) { int r; unsigned long ebits; r = dm_io_sync_vm(1, &log->header_location, READ, log->disk_header, &ebits); if (r) return r; header_from_disk(&log->header, log->disk_header); /* New log required? */ if (log->sync != DEFAULTSYNC || log->header.magic != MIRROR_MAGIC) { log->header.magic = MIRROR_MAGIC; log->header.version = MIRROR_DISK_VERSION; log->header.nr_regions = 0; } #ifdef __LITTLE_ENDIAN if (log->header.version == 1) log->header.version = 2; #endif if (log->header.version != MIRROR_DISK_VERSION) { DMWARN("incompatible disk log version"); return -EINVAL; } return 0; }
static inline int write_header(struct log_c *log) { unsigned long ebits; header_to_disk(&log->header, log->disk_header); return dm_io_sync_vm(1, &log->header_location, WRITE, log->disk_header, &ebits); }
static int write_bits(struct log_c *log) { unsigned long ebits; bits_to_disk(log->clean_bits, log->disk_bits, log->bitset_uint32_count); return dm_io_sync_vm(1, &log->bits_location, WRITE, log->disk_bits, &ebits); }
static int read_bits(struct log_c *log) { int r; unsigned long ebits; r = dm_io_sync_vm(1, &log->bits_location, READ, log->disk_bits, &ebits); if (r) return r; bits_to_core(log->clean_bits, log->disk_bits, log->bitset_uint32_count); return 0; }