/* * lane_check -- performs check of all lanes */ int lane_check(PMEMobjpool *pop) { int err = 0; int i; /* section index */ uint64_t j; /* lane index */ struct lane_layout *layout; for (i = 0; i < MAX_LANE_SECTION; ++i) { for (j = 0; j < pop->nlanes; ++j) { layout = lane_get_layout(pop, j); err = Section_ops[i]->check(pop, &layout->sections[i], sizeof(layout->sections[i])); if (err) { LOG(2, "section_ops->check %d %ju %d", i, j, err); return err; } } } return err; }
/* * lane_recover_and_boot -- performs initialization and recovery of all lanes */ int lane_recover_and_section_boot(PMEMobjpool *pop) { int err = 0; int i; /* section index */ uint64_t j; /* lane index */ struct lane_layout *layout; for (i = 0; i < MAX_LANE_SECTION; ++i) { for (j = 0; j < pop->nlanes; ++j) { layout = lane_get_layout(pop, j); err = Section_ops[i]->recover(pop, &layout->sections[i], sizeof(layout->sections[i])); if (err != 0) { LOG(2, "section_ops->recover %d %ju %d", i, j, err); return err; } } if ((err = Section_ops[i]->boot(pop)) != 0) { LOG(2, "section_ops->init %d %d", i, err); return err; } } return err; }
/* * lane_boot -- initializes all lanes */ int lane_boot(PMEMobjpool *pop) { int err = 0; pop->lanes_desc.lane = Malloc(sizeof(struct lane) * pop->nlanes); if (pop->lanes_desc.lane == NULL) { err = ENOMEM; ERR("!Malloc of volatile lanes"); goto error_lanes_malloc; } pop->lanes_desc.next_lane_idx = 0; pop->lanes_desc.lane_locks = Zalloc(sizeof(*pop->lanes_desc.lane_locks) * pop->nlanes); if (pop->lanes_desc.lane_locks == NULL) { ERR("!Malloc for lane locks"); goto error_locks_malloc; } /* add lanes to pmemcheck ignored list */ VALGRIND_ADD_TO_GLOBAL_TX_IGNORE((char *)pop + pop->lanes_offset, (sizeof(struct lane_layout) * pop->nlanes)); uint64_t i; for (i = 0; i < pop->nlanes; ++i) { struct lane_layout *layout = lane_get_layout(pop, i); if ((err = lane_init(pop, &pop->lanes_desc.lane[i], layout))) { ERR("!lane_init"); goto error_lane_init; } } return 0; error_lane_init: for (; i >= 1; --i) lane_destroy(pop, &pop->lanes_desc.lane[i - 1]); Free(pop->lanes_desc.lane_locks); pop->lanes_desc.lane_locks = NULL; error_locks_malloc: Free(pop->lanes_desc.lane); pop->lanes_desc.lane = NULL; error_lanes_malloc: return err; }
/* * lane_boot -- initializes all lanes */ int lane_boot(PMEMobjpool *pop) { ASSERTeq(pop->lanes, NULL); int err = 0; pop->lanes = Malloc(sizeof (struct lane) * pop->nlanes); if (pop->lanes == NULL) { ERR("!Malloc of volatile lanes"); err = ENOMEM; goto error_lanes_malloc; } /* add lanes to pmemcheck ignored list */ VALGRIND_ADD_TO_GLOBAL_TX_IGNORE((void *)pop + pop->lanes_offset, (sizeof (struct lane_layout) * pop->nlanes)); int i; for (i = 0; i < pop->nlanes; ++i) { struct lane_layout *layout = lane_get_layout(pop, i); if ((err = lane_init(&pop->lanes[i], layout)) != 0) { ERR("!lane_init"); goto error_lane_init; } } return 0; error_lane_init: for (i = i - 1; i >= 0; --i) if (lane_destroy(&pop->lanes[i]) != 0) ERR("!lane_destroy"); Free(pop->lanes); pop->lanes = NULL; error_lanes_malloc: return err; }
/* * lane_boot -- initializes all lanes */ int lane_boot(PMEMobjpool *pop) { ASSERTeq(pop->lanes, NULL); int err; pthread_mutexattr_t lock_attr; if ((err = pthread_mutexattr_init(&lock_attr)) != 0) { ERR("!pthread_mutexattr_init"); goto error_lanes_malloc; } if ((err = pthread_mutexattr_settype( &lock_attr, PTHREAD_MUTEX_RECURSIVE)) != 0) { ERR("!pthread_mutexattr_settype"); goto error_lanes_malloc; } pop->lanes = Malloc(sizeof (struct lane) * pop->nlanes); if (pop->lanes == NULL) { err = ENOMEM; ERR("!Malloc of volatile lanes"); goto error_lanes_malloc; } pop->lane_locks = Malloc(sizeof (pthread_mutex_t) * pop->nlanes); if (pop->lane_locks == NULL) { err = ENOMEM; ERR("!Malloc for lane locks"); goto error_lock_malloc; } /* add lanes to pmemcheck ignored list */ VALGRIND_ADD_TO_GLOBAL_TX_IGNORE((char *)pop + pop->lanes_offset, (sizeof (struct lane_layout) * pop->nlanes)); uint64_t i; for (i = 0; i < pop->nlanes; ++i) { struct lane_layout *layout = lane_get_layout(pop, i); if ((err = lane_init(pop, &pop->lanes[i], layout, &pop->lane_locks[i], &lock_attr)) != 0) { ERR("!lane_init"); goto error_lane_init; } } if (pthread_mutexattr_destroy(&lock_attr) != 0) { ERR("!pthread_mutexattr_destroy"); goto error_mutexattr_destroy; } return 0; error_lane_init: for (; i >= 1; --i) if (lane_destroy(pop, &pop->lanes[i - 1]) != 0) ERR("!lane_destroy"); Free(pop->lane_locks); pop->lane_locks = NULL; error_lock_malloc: Free(pop->lanes); pop->lanes = NULL; error_lanes_malloc: if (pthread_mutexattr_destroy(&lock_attr) != 0) ERR("!pthread_mutexattr_destroy"); error_mutexattr_destroy: return err; }