• Home
  • Raw
  • Download

Lines Matching refs:reg

161 	struct o2hb_region *reg =  in o2hb_write_timeout()  local
166 "milliseconds\n", reg->hr_dev_name, in o2hb_write_timeout()
167 jiffies_to_msecs(jiffies - reg->hr_last_timeout_start)); in o2hb_write_timeout()
171 static void o2hb_arm_write_timeout(struct o2hb_region *reg) in o2hb_arm_write_timeout() argument
175 cancel_delayed_work(&reg->hr_write_timeout_work); in o2hb_arm_write_timeout()
176 reg->hr_last_timeout_start = jiffies; in o2hb_arm_write_timeout()
177 schedule_delayed_work(&reg->hr_write_timeout_work, in o2hb_arm_write_timeout()
181 static void o2hb_disarm_write_timeout(struct o2hb_region *reg) in o2hb_disarm_write_timeout() argument
183 cancel_delayed_work(&reg->hr_write_timeout_work); in o2hb_disarm_write_timeout()
208 static void o2hb_wait_on_io(struct o2hb_region *reg, in o2hb_wait_on_io() argument
211 struct address_space *mapping = reg->hr_bdev->bd_inode->i_mapping; in o2hb_wait_on_io()
235 static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg, in o2hb_setup_one_bio() argument
242 unsigned int bits = reg->hr_block_bits; in o2hb_setup_one_bio()
243 unsigned int spp = reg->hr_slots_per_page; in o2hb_setup_one_bio()
260 bio->bi_sector = (reg->hr_start_block + cs) << (bits - 9); in o2hb_setup_one_bio()
261 bio->bi_bdev = reg->hr_bdev; in o2hb_setup_one_bio()
268 page = reg->hr_slot_data[current_page]; in o2hb_setup_one_bio()
288 static int o2hb_read_slots(struct o2hb_region *reg, in o2hb_read_slots() argument
299 bio = o2hb_setup_one_bio(reg, &wc, &current_slot, max_slots); in o2hb_read_slots()
313 o2hb_wait_on_io(reg, &wc); in o2hb_read_slots()
320 static int o2hb_issue_node_write(struct o2hb_region *reg, in o2hb_issue_node_write() argument
331 bio = o2hb_setup_one_bio(reg, write_wc, &slot, slot+1); in o2hb_issue_node_write()
346 static u32 o2hb_compute_block_crc_le(struct o2hb_region *reg, in o2hb_compute_block_crc_le() argument
358 ret = crc32_le(0, (unsigned char *) hb_block, reg->hr_block_bytes); in o2hb_compute_block_crc_le()
374 static int o2hb_verify_crc(struct o2hb_region *reg, in o2hb_verify_crc() argument
380 computed = o2hb_compute_block_crc_le(reg, hb_block); in o2hb_verify_crc()
387 static int o2hb_check_last_timestamp(struct o2hb_region *reg) in o2hb_check_last_timestamp() argument
396 slot = &reg->hr_slots[node_num]; in o2hb_check_last_timestamp()
408 static inline void o2hb_prepare_block(struct o2hb_region *reg, in o2hb_prepare_block() argument
417 slot = &reg->hr_slots[node_num]; in o2hb_prepare_block()
420 memset(hb_block, 0, reg->hr_block_bytes); in o2hb_prepare_block()
432 hb_block->hb_cksum = cpu_to_le32(o2hb_compute_block_crc_le(reg, in o2hb_prepare_block()
549 static int o2hb_check_slot(struct o2hb_region *reg, in o2hb_check_slot() argument
556 struct o2hb_disk_heartbeat_block *hb_block = reg->hr_tmp_block; in o2hb_check_slot()
561 memcpy(hb_block, slot->ds_raw_block, reg->hr_block_bytes); in o2hb_check_slot()
569 if (!o2hb_verify_crc(reg, hb_block)) { in o2hb_check_slot()
584 slot->ds_node_num, reg->hr_dev_name); in o2hb_check_slot()
662 slot->ds_node_num, reg->hr_dev_name, slot_dead_ms, in o2hb_check_slot()
728 static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) in o2hb_do_disk_heartbeat() argument
751 ret = o2hb_read_slots(reg, highest_node + 1); in o2hb_do_disk_heartbeat()
760 if (!o2hb_check_last_timestamp(reg)) in o2hb_do_disk_heartbeat()
762 "in our slot!\n", reg->hr_dev_name); in o2hb_do_disk_heartbeat()
765 o2hb_prepare_block(reg, reg->hr_generation); in o2hb_do_disk_heartbeat()
769 ret = o2hb_issue_node_write(reg, &write_wc); in o2hb_do_disk_heartbeat()
778 change |= o2hb_check_slot(reg, &reg->hr_slots[i]); in o2hb_do_disk_heartbeat()
786 o2hb_wait_on_io(reg, &write_wc); in o2hb_do_disk_heartbeat()
792 write_wc.wc_error, reg->hr_dev_name); in o2hb_do_disk_heartbeat()
796 o2hb_arm_write_timeout(reg); in o2hb_do_disk_heartbeat()
799 if (!change && (atomic_read(&reg->hr_steady_iterations) != 0)) { in o2hb_do_disk_heartbeat()
800 if (atomic_dec_and_test(&reg->hr_steady_iterations)) in o2hb_do_disk_heartbeat()
846 struct o2hb_region *reg = data; in o2hb_thread() local
855 while (!kthread_should_stop() && !reg->hr_unclean_stop) { in o2hb_thread()
865 ret = o2hb_do_disk_heartbeat(reg); in o2hb_thread()
876 if (elapsed_msec < reg->hr_timeout_ms) { in o2hb_thread()
879 msleep_interruptible(reg->hr_timeout_ms - elapsed_msec); in o2hb_thread()
883 o2hb_disarm_write_timeout(reg); in o2hb_thread()
886 for(i = 0; !reg->hr_unclean_stop && i < reg->hr_blocks; i++) in o2hb_thread()
887 o2hb_shutdown_slot(&reg->hr_slots[i]); in o2hb_thread()
895 o2hb_prepare_block(reg, 0); in o2hb_thread()
896 ret = o2hb_issue_node_write(reg, &write_wc); in o2hb_thread()
898 o2hb_wait_on_io(reg, &write_wc); in o2hb_thread()
964 struct o2hb_region *reg = to_o2hb_region(item); in o2hb_region_release() local
966 if (reg->hr_tmp_block) in o2hb_region_release()
967 kfree(reg->hr_tmp_block); in o2hb_region_release()
969 if (reg->hr_slot_data) { in o2hb_region_release()
970 for (i = 0; i < reg->hr_num_pages; i++) { in o2hb_region_release()
971 page = reg->hr_slot_data[i]; in o2hb_region_release()
975 kfree(reg->hr_slot_data); in o2hb_region_release()
978 if (reg->hr_bdev) in o2hb_region_release()
979 blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); in o2hb_region_release()
981 if (reg->hr_slots) in o2hb_region_release()
982 kfree(reg->hr_slots); in o2hb_region_release()
985 list_del(&reg->hr_all_item); in o2hb_region_release()
988 kfree(reg); in o2hb_region_release()
991 static int o2hb_read_block_input(struct o2hb_region *reg, in o2hb_read_block_input() argument
1018 static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg, in o2hb_region_block_bytes_read() argument
1021 return sprintf(page, "%u\n", reg->hr_block_bytes); in o2hb_region_block_bytes_read()
1024 static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg, in o2hb_region_block_bytes_write() argument
1032 if (reg->hr_bdev) in o2hb_region_block_bytes_write()
1035 status = o2hb_read_block_input(reg, page, count, in o2hb_region_block_bytes_write()
1040 reg->hr_block_bytes = (unsigned int)block_bytes; in o2hb_region_block_bytes_write()
1041 reg->hr_block_bits = block_bits; in o2hb_region_block_bytes_write()
1046 static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg, in o2hb_region_start_block_read() argument
1049 return sprintf(page, "%llu\n", reg->hr_start_block); in o2hb_region_start_block_read()
1052 static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg, in o2hb_region_start_block_write() argument
1059 if (reg->hr_bdev) in o2hb_region_start_block_write()
1066 reg->hr_start_block = tmp; in o2hb_region_start_block_write()
1071 static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg, in o2hb_region_blocks_read() argument
1074 return sprintf(page, "%d\n", reg->hr_blocks); in o2hb_region_blocks_read()
1077 static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg, in o2hb_region_blocks_write() argument
1084 if (reg->hr_bdev) in o2hb_region_blocks_write()
1094 reg->hr_blocks = (unsigned int)tmp; in o2hb_region_blocks_write()
1099 static ssize_t o2hb_region_dev_read(struct o2hb_region *reg, in o2hb_region_dev_read() argument
1104 if (reg->hr_bdev) in o2hb_region_dev_read()
1105 ret = sprintf(page, "%s\n", reg->hr_dev_name); in o2hb_region_dev_read()
1110 static void o2hb_init_region_params(struct o2hb_region *reg) in o2hb_init_region_params() argument
1112 reg->hr_slots_per_page = PAGE_CACHE_SIZE >> reg->hr_block_bits; in o2hb_init_region_params()
1113 reg->hr_timeout_ms = O2HB_REGION_TIMEOUT_MS; in o2hb_init_region_params()
1116 reg->hr_start_block, reg->hr_blocks); in o2hb_init_region_params()
1118 reg->hr_block_bytes, reg->hr_block_bits); in o2hb_init_region_params()
1119 mlog(ML_HEARTBEAT, "hr_timeout_ms = %u\n", reg->hr_timeout_ms); in o2hb_init_region_params()
1123 static int o2hb_map_slot_data(struct o2hb_region *reg) in o2hb_map_slot_data() argument
1127 unsigned int spp = reg->hr_slots_per_page; in o2hb_map_slot_data()
1132 reg->hr_tmp_block = kmalloc(reg->hr_block_bytes, GFP_KERNEL); in o2hb_map_slot_data()
1133 if (reg->hr_tmp_block == NULL) { in o2hb_map_slot_data()
1138 reg->hr_slots = kcalloc(reg->hr_blocks, in o2hb_map_slot_data()
1140 if (reg->hr_slots == NULL) { in o2hb_map_slot_data()
1145 for(i = 0; i < reg->hr_blocks; i++) { in o2hb_map_slot_data()
1146 slot = &reg->hr_slots[i]; in o2hb_map_slot_data()
1152 reg->hr_num_pages = (reg->hr_blocks + spp - 1) / spp; in o2hb_map_slot_data()
1155 reg->hr_num_pages, reg->hr_blocks, spp); in o2hb_map_slot_data()
1157 reg->hr_slot_data = kcalloc(reg->hr_num_pages, sizeof(struct page *), in o2hb_map_slot_data()
1159 if (!reg->hr_slot_data) { in o2hb_map_slot_data()
1164 for(i = 0; i < reg->hr_num_pages; i++) { in o2hb_map_slot_data()
1171 reg->hr_slot_data[i] = page; in o2hb_map_slot_data()
1176 (j < spp) && ((j + last_slot) < reg->hr_blocks); in o2hb_map_slot_data()
1178 BUG_ON((j + last_slot) >= reg->hr_blocks); in o2hb_map_slot_data()
1180 slot = &reg->hr_slots[j + last_slot]; in o2hb_map_slot_data()
1184 raw += reg->hr_block_bytes; in o2hb_map_slot_data()
1194 static int o2hb_populate_slot_data(struct o2hb_region *reg) in o2hb_populate_slot_data() argument
1202 ret = o2hb_read_slots(reg, reg->hr_blocks); in o2hb_populate_slot_data()
1212 for(i = 0; i < reg->hr_blocks; i++) { in o2hb_populate_slot_data()
1213 slot = &reg->hr_slots[i]; in o2hb_populate_slot_data()
1228 static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, in o2hb_region_dev_write() argument
1240 if (reg->hr_bdev) in o2hb_region_dev_write()
1259 if (reg->hr_blocks == 0 || reg->hr_start_block == 0 || in o2hb_region_dev_write()
1260 reg->hr_block_bytes == 0) in o2hb_region_dev_write()
1270 reg->hr_bdev = I_BDEV(filp->f_mapping->host); in o2hb_region_dev_write()
1271 ret = blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ); in o2hb_region_dev_write()
1273 reg->hr_bdev = NULL; in o2hb_region_dev_write()
1278 bdevname(reg->hr_bdev, reg->hr_dev_name); in o2hb_region_dev_write()
1280 sectsize = bdev_hardsect_size(reg->hr_bdev); in o2hb_region_dev_write()
1281 if (sectsize != reg->hr_block_bytes) { in o2hb_region_dev_write()
1284 reg->hr_block_bytes, sectsize); in o2hb_region_dev_write()
1289 o2hb_init_region_params(reg); in o2hb_region_dev_write()
1293 get_random_bytes(&reg->hr_generation, in o2hb_region_dev_write()
1294 sizeof(reg->hr_generation)); in o2hb_region_dev_write()
1295 } while (reg->hr_generation == 0); in o2hb_region_dev_write()
1297 ret = o2hb_map_slot_data(reg); in o2hb_region_dev_write()
1303 ret = o2hb_populate_slot_data(reg); in o2hb_region_dev_write()
1309 INIT_DELAYED_WORK(&reg->hr_write_timeout_work, o2hb_write_timeout); in o2hb_region_dev_write()
1316 atomic_set(&reg->hr_steady_iterations, O2HB_LIVE_THRESHOLD + 1); in o2hb_region_dev_write()
1318 hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s", in o2hb_region_dev_write()
1319 reg->hr_item.ci_name); in o2hb_region_dev_write()
1327 reg->hr_task = hb_task; in o2hb_region_dev_write()
1331 atomic_read(&reg->hr_steady_iterations) == 0); in o2hb_region_dev_write()
1335 hb_task = reg->hr_task; in o2hb_region_dev_write()
1336 reg->hr_task = NULL; in o2hb_region_dev_write()
1346 hb_task = reg->hr_task; in o2hb_region_dev_write()
1360 if (reg->hr_bdev) { in o2hb_region_dev_write()
1361 blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); in o2hb_region_dev_write()
1362 reg->hr_bdev = NULL; in o2hb_region_dev_write()
1368 static ssize_t o2hb_region_pid_read(struct o2hb_region *reg, in o2hb_region_pid_read() argument
1374 if (reg->hr_task) in o2hb_region_pid_read()
1375 pid = task_pid_nr(reg->hr_task); in o2hb_region_pid_read()
1442 struct o2hb_region *reg = to_o2hb_region(item); in o2hb_region_show() local
1448 ret = o2hb_region_attr->show(reg, page); in o2hb_region_show()
1456 struct o2hb_region *reg = to_o2hb_region(item); in o2hb_region_store() local
1462 ret = o2hb_region_attr->store(reg, page, count); in o2hb_region_store()
1495 struct o2hb_region *reg = NULL; in o2hb_heartbeat_group_make_item() local
1497 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); in o2hb_heartbeat_group_make_item()
1498 if (reg == NULL) in o2hb_heartbeat_group_make_item()
1501 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type); in o2hb_heartbeat_group_make_item()
1504 list_add_tail(&reg->hr_all_item, &o2hb_all_regions); in o2hb_heartbeat_group_make_item()
1507 return &reg->hr_item; in o2hb_heartbeat_group_make_item()
1514 struct o2hb_region *reg = to_o2hb_region(item); in o2hb_heartbeat_group_drop_item() local
1518 hb_task = reg->hr_task; in o2hb_heartbeat_group_drop_item()
1519 reg->hr_task = NULL; in o2hb_heartbeat_group_drop_item()
1529 if (atomic_read(&reg->hr_steady_iterations) != 0) { in o2hb_heartbeat_group_drop_item()
1530 atomic_set(&reg->hr_steady_iterations, 0); in o2hb_heartbeat_group_drop_item()
1547 struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); in o2hb_heartbeat_group_show() local
1553 ret = o2hb_heartbeat_group_attr->show(reg, page); in o2hb_heartbeat_group_show()
1561 struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); in o2hb_heartbeat_group_store() local
1567 ret = o2hb_heartbeat_group_attr->store(reg, page, count); in o2hb_heartbeat_group_store()
1678 struct o2hb_region *p, *reg = NULL; in o2hb_find_region() local
1684 reg = p; in o2hb_find_region()
1689 return reg; in o2hb_find_region()
1695 struct o2hb_region *reg; in o2hb_region_get() local
1699 reg = o2hb_find_region(region_uuid); in o2hb_region_get()
1700 if (!reg) in o2hb_region_get()
1711 ret = o2nm_depend_item(&reg->hr_item); in o2hb_region_get()
1721 struct o2hb_region *reg; in o2hb_region_put() local
1725 reg = o2hb_find_region(region_uuid); in o2hb_region_put()
1729 if (reg) { in o2hb_region_put()
1730 o2nm_undepend_item(&reg->hr_item); in o2hb_region_put()
1857 struct o2hb_region *reg; in o2hb_stop_all_regions() local
1863 list_for_each_entry(reg, &o2hb_all_regions, hr_all_item) in o2hb_stop_all_regions()
1864 reg->hr_unclean_stop = 1; in o2hb_stop_all_regions()