mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
Use hash, bitset, malloc, pool from libdevmapper.
This commit is contained in:
parent
a3f6b2ce79
commit
2262b32057
@ -1,5 +1,7 @@
|
||||
Version 2.02.00 -
|
||||
===================================
|
||||
Move mknodes into libdevmapper.
|
||||
Move bitset, hash, pool and dbg_malloc into libdevmapper.
|
||||
|
||||
Version 2.01.15 - 16th October 2005
|
||||
===================================
|
||||
|
@ -66,7 +66,6 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "hash.h"
|
||||
#include "locking.h"
|
||||
#include "log.h"
|
||||
#include "lvm-functions.h"
|
||||
|
@ -49,10 +49,8 @@
|
||||
#include "clvmd-comms.h"
|
||||
#include "lvm-functions.h"
|
||||
#include "clvmd.h"
|
||||
#include "hash.h"
|
||||
#include "clvmd-gulm.h"
|
||||
#include "libgulm.h"
|
||||
#include "hash.h"
|
||||
|
||||
/* Hash list of nodes in the cluster */
|
||||
static struct hash_table *node_hash;
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "toolcontext.h"
|
||||
#include "log.h"
|
||||
#include "activate.h"
|
||||
#include "hash.h"
|
||||
#include "locking.h"
|
||||
|
||||
static struct cmd_context *cmd = NULL;
|
||||
@ -330,7 +329,7 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
|
||||
}
|
||||
|
||||
/* clean the pool for another command */
|
||||
pool_empty(cmd->mem);
|
||||
dm_pool_empty(cmd->mem);
|
||||
|
||||
DEBUGLOG("Command return is %d\n", status);
|
||||
return status;
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "clvmd-comms.h"
|
||||
#include "clvmd.h"
|
||||
#include "clvmd-gulm.h"
|
||||
#include "hash.h"
|
||||
|
||||
#define DEFAULT_TCP_PORT 21064
|
||||
|
||||
|
@ -6,9 +6,7 @@
|
||||
../lib/commands/toolcontext.h
|
||||
../lib/config/config.h
|
||||
../lib/config/defaults.h
|
||||
../lib/datastruct/bitset.h
|
||||
../lib/datastruct/btree.h
|
||||
../lib/datastruct/hash.h
|
||||
../lib/datastruct/list.h
|
||||
../lib/datastruct/lvm-types.h
|
||||
../lib/datastruct/str_list.h
|
||||
@ -34,9 +32,7 @@
|
||||
../lib/metadata/metadata.h
|
||||
../lib/metadata/pv_alloc.h
|
||||
../lib/metadata/segtype.h
|
||||
../lib/mm/dbg_malloc.h
|
||||
../lib/mm/memlock.h
|
||||
../lib/mm/pool.h
|
||||
../lib/mm/xlate.h
|
||||
../lib/misc/crc.h
|
||||
../lib/misc/intl.h
|
||||
|
@ -37,9 +37,7 @@ SOURCES =\
|
||||
cache/lvmcache.c \
|
||||
commands/toolcontext.c \
|
||||
config/config.c \
|
||||
datastruct/bitset.c \
|
||||
datastruct/btree.c \
|
||||
datastruct/hash.c \
|
||||
datastruct/str_list.c \
|
||||
device/dev-cache.c \
|
||||
device/dev-io.c \
|
||||
@ -78,9 +76,7 @@ SOURCES =\
|
||||
misc/crc.c \
|
||||
misc/lvm-file.c \
|
||||
misc/lvm-string.c \
|
||||
mm/dbg_malloc.c \
|
||||
mm/memlock.c \
|
||||
mm/pool.c \
|
||||
regex/matcher.c \
|
||||
regex/parse_rx.c \
|
||||
regex/ttree.c \
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "fs.h"
|
||||
#include "lvm-file.h"
|
||||
#include "lvm-string.h"
|
||||
#include "pool.h"
|
||||
#include "toolcontext.h"
|
||||
#include "dev_manager.h"
|
||||
#include "str_list.h"
|
||||
@ -762,7 +761,7 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
|
||||
int r = 1;
|
||||
|
||||
if (!lv) {
|
||||
r = dev_manager_mknodes();
|
||||
r = dm_mknodes(NULL);
|
||||
fs_unlock();
|
||||
return r;
|
||||
}
|
||||
|
@ -18,10 +18,6 @@
|
||||
|
||||
#include "metadata.h"
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
# include <libdevmapper.h>
|
||||
#endif
|
||||
|
||||
struct lvinfo {
|
||||
int exists;
|
||||
int suspended;
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "lib.h"
|
||||
#include "str_list.h"
|
||||
#include "dev_manager.h"
|
||||
#include "pool.h"
|
||||
#include "hash.h"
|
||||
#include "lvm-string.h"
|
||||
#include "fs.h"
|
||||
#include "defaults.h"
|
||||
@ -27,7 +25,6 @@
|
||||
#include "targets.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <libdevmapper.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
|
||||
@ -113,7 +110,7 @@ struct dl_list {
|
||||
static const char *stripe_filler = NULL;
|
||||
|
||||
struct dev_manager {
|
||||
struct pool *mem;
|
||||
struct dm_pool *mem;
|
||||
|
||||
struct cmd_context *cmd;
|
||||
|
||||
@ -144,7 +141,7 @@ struct dev_manager {
|
||||
*/
|
||||
struct list remove_list;
|
||||
|
||||
struct hash_table *layers;
|
||||
struct dm_hash_table *layers;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -165,7 +162,7 @@ static inline void _clear_flag(struct dev_layer *dl, int bit)
|
||||
dl->flags &= ~(1 << bit);
|
||||
}
|
||||
|
||||
static char *_build_dlid(struct pool *mem, const char *lvid, const char *layer)
|
||||
static char *_build_dlid(struct dm_pool *mem, const char *lvid, const char *layer)
|
||||
{
|
||||
char *dlid;
|
||||
size_t len;
|
||||
@ -175,7 +172,7 @@ static char *_build_dlid(struct pool *mem, const char *lvid, const char *layer)
|
||||
|
||||
len = strlen(lvid) + strlen(layer) + 2;
|
||||
|
||||
if (!(dlid = pool_alloc(mem, len))) {
|
||||
if (!(dlid = dm_pool_alloc(mem, len))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
@ -211,7 +208,7 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
|
||||
}
|
||||
|
||||
static int _info_run(const char *name, const char *uuid, struct dm_info *info,
|
||||
int mknodes, int with_open_count, struct pool *mem,
|
||||
int mknodes, int with_open_count, struct dm_pool *mem,
|
||||
char **uuid_out)
|
||||
{
|
||||
int r = 0;
|
||||
@ -245,7 +242,7 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info,
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
*uuid_out = pool_strdup(mem, u);
|
||||
*uuid_out = dm_pool_strdup(mem, u);
|
||||
}
|
||||
r = 1;
|
||||
|
||||
@ -256,7 +253,7 @@ static int _info_run(const char *name, const char *uuid, struct dm_info *info,
|
||||
|
||||
static int _info(const char *name, const char *uuid, int mknodes,
|
||||
int with_open_count, struct dm_info *info,
|
||||
struct pool *mem, char **uuid_out)
|
||||
struct dm_pool *mem, char **uuid_out)
|
||||
{
|
||||
if (!mknodes && uuid && *uuid &&
|
||||
_info_run(NULL, uuid, info, 0, with_open_count, mem, uuid_out) &&
|
||||
@ -732,7 +729,7 @@ int build_dev_string(struct dev_manager *dm, char *dlid, char *devbuf,
|
||||
{
|
||||
struct dev_layer *dl;
|
||||
|
||||
if (!(dl = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dl = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_error("%s device layer %s missing from hash",
|
||||
desc, dlid);
|
||||
return 0;
|
||||
@ -809,13 +806,13 @@ static int _emit_target(struct dev_manager *dm, struct dm_task *dmt,
|
||||
int ret;
|
||||
|
||||
do {
|
||||
if (!(params = dbg_malloc(paramsize))) {
|
||||
if (!(params = dm_malloc(paramsize))) {
|
||||
log_error("Insufficient space for target parameters.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = _emit_target_line(dm, dmt, seg, params, paramsize);
|
||||
dbg_free(params);
|
||||
dm_free(params);
|
||||
|
||||
if (!ret)
|
||||
stack;
|
||||
@ -936,15 +933,15 @@ static int _populate_snapshot(struct dev_manager *dm,
|
||||
struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
||||
const char *vg_name)
|
||||
{
|
||||
struct pool *mem;
|
||||
struct dm_pool *mem;
|
||||
struct dev_manager *dm;
|
||||
|
||||
if (!(mem = pool_create("dev_manager", 16 * 1024))) {
|
||||
if (!(mem = dm_pool_create("dev_manager", 16 * 1024))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(dm = pool_alloc(mem, sizeof(*dm)))) {
|
||||
if (!(dm = dm_pool_alloc(mem, sizeof(*dm)))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
@ -959,12 +956,12 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
||||
}
|
||||
dm->stripe_filler = stripe_filler;
|
||||
|
||||
if (!(dm->vg_name = pool_strdup(dm->mem, vg_name))) {
|
||||
if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (!(dm->layers = hash_create(32))) {
|
||||
if (!(dm->layers = dm_hash_create(32))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
@ -979,14 +976,14 @@ struct dev_manager *dev_manager_create(struct cmd_context *cmd,
|
||||
return dm;
|
||||
|
||||
bad:
|
||||
pool_destroy(mem);
|
||||
dm_pool_destroy(mem);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dev_manager_destroy(struct dev_manager *dm)
|
||||
{
|
||||
hash_destroy(dm->layers);
|
||||
pool_destroy(dm->mem);
|
||||
dm_hash_destroy(dm->layers);
|
||||
dm_pool_destroy(dm->mem);
|
||||
}
|
||||
|
||||
int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv,
|
||||
@ -1038,7 +1035,7 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME pool_free ? */
|
||||
/* FIXME dm_pool_free ? */
|
||||
|
||||
/* If the snapshot isn't available, percent will be -1 */
|
||||
return 1;
|
||||
@ -1060,7 +1057,7 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME pool_free ? */
|
||||
/* FIXME dm_pool_free ? */
|
||||
|
||||
log_debug("Getting device mirror status percentage for %s", name);
|
||||
if (!(_percent(dm, name, lv->lvid.s, "mirror", wait, lv, percent,
|
||||
@ -1078,7 +1075,7 @@ static struct dev_layer *_create_dev(struct dev_manager *dm, char *name,
|
||||
struct dev_layer *dl;
|
||||
char *uuid;
|
||||
|
||||
if (!(dl = pool_zalloc(dm->mem, sizeof(*dl)))) {
|
||||
if (!(dl = dm_pool_zalloc(dm->mem, sizeof(*dl)))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
@ -1099,7 +1096,7 @@ static struct dev_layer *_create_dev(struct dev_manager *dm, char *name,
|
||||
list_init(&dl->pre_create);
|
||||
list_init(&dl->pre_suspend);
|
||||
|
||||
if (!hash_insert(dm->layers, dl->dlid, dl)) {
|
||||
if (!dm_hash_insert(dm->layers, dl->dlid, dl)) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
@ -1129,7 +1126,7 @@ static struct dev_layer *_create_layer(struct dev_manager *dm,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(dl = hash_lookup(dm->layers, dlid)) &&
|
||||
if (!(dl = dm_hash_lookup(dm->layers, dlid)) &&
|
||||
!(dl = _create_dev(dm, name, dlid))) {
|
||||
stack;
|
||||
return NULL;
|
||||
@ -1157,8 +1154,8 @@ static struct dev_layer *_lookup(struct dev_manager *dm,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dl = hash_lookup(dm->layers, dlid);
|
||||
pool_free(dm->mem, dlid);
|
||||
dl = dm_hash_lookup(dm->layers, dlid);
|
||||
dm_pool_free(dm->mem, dlid);
|
||||
return dl;
|
||||
}
|
||||
|
||||
@ -1229,7 +1226,7 @@ static int _expand_vanilla(struct dev_manager *dm, struct logical_volume *lv,
|
||||
|
||||
/* add the dependency on the real device */
|
||||
if (!str_list_add(dm->mem, &dl->pre_create,
|
||||
pool_strdup(dm->mem, dlr->dlid))) {
|
||||
dm_pool_strdup(dm->mem, dlr->dlid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -1266,7 +1263,7 @@ static int _expand_origin_real(struct dev_manager *dm,
|
||||
|
||||
/* add the dependency on the real device */
|
||||
if (!str_list_add(dm->mem, &dl->pre_create,
|
||||
pool_strdup(dm->mem, real_dlid))) {
|
||||
dm_pool_strdup(dm->mem, real_dlid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -1327,7 +1324,7 @@ static int _expand_snapshot(struct dev_manager *dm, struct logical_volume *lv,
|
||||
|
||||
/* add the dependency on the cow device */
|
||||
if (!str_list_add(dm->mem, &dl->pre_create,
|
||||
pool_strdup(dm->mem, cow_dlid))) {
|
||||
dm_pool_strdup(dm->mem, cow_dlid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -1382,11 +1379,11 @@ static int _expand_lv(struct dev_manager *dm, struct logical_volume *lv)
|
||||
*/
|
||||
static void _clear_marks(struct dev_manager *dm, int flag)
|
||||
{
|
||||
struct hash_node *hn;
|
||||
struct dm_hash_node *hn;
|
||||
struct dev_layer *dl;
|
||||
|
||||
hash_iterate(hn, dm->layers) {
|
||||
dl = hash_get_data(dm->layers, hn);
|
||||
dm_hash_iterate(hn, dm->layers) {
|
||||
dl = dm_hash_get_data(dm->layers, hn);
|
||||
_clear_flag(dl, flag);
|
||||
}
|
||||
}
|
||||
@ -1404,7 +1401,7 @@ static int _trace_layer_marks(struct dev_manager *dm, struct dev_layer *dl,
|
||||
list_iterate_items(strl, &dl->pre_create) {
|
||||
dlid = strl->str;
|
||||
|
||||
if (!(dep = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dep = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_error("Couldn't find device layer '%s'.", dlid);
|
||||
return 0;
|
||||
}
|
||||
@ -1432,11 +1429,11 @@ static int _trace_layer_marks(struct dev_manager *dm, struct dev_layer *dl,
|
||||
*/
|
||||
static int _trace_all_marks(struct dev_manager *dm, int flag)
|
||||
{
|
||||
struct hash_node *hn;
|
||||
struct dm_hash_node *hn;
|
||||
struct dev_layer *dl;
|
||||
|
||||
hash_iterate(hn, dm->layers) {
|
||||
dl = hash_get_data(dm->layers, hn);
|
||||
dm_hash_iterate(hn, dm->layers) {
|
||||
dl = dm_hash_get_data(dm->layers, hn);
|
||||
if (_get_flag(dl, flag) && !_trace_layer_marks(dm, dl, flag)) {
|
||||
stack;
|
||||
return 0;
|
||||
@ -1484,7 +1481,7 @@ static int _suspend_parents(struct dev_manager *dm, struct dev_layer *dl)
|
||||
list_iterate_items(strl, &dl->pre_suspend) {
|
||||
dlid = strl->str;
|
||||
|
||||
if (!(dep = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dep = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_debug("_suspend_parents couldn't find device "
|
||||
"layer '%s' - skipping.", dlid);
|
||||
continue;
|
||||
@ -1518,7 +1515,7 @@ static int _resume_with_deps(struct dev_manager *dm, struct dev_layer *dl)
|
||||
list_iterate_items(strl, &dl->pre_create) {
|
||||
dlid = strl->str;
|
||||
|
||||
if (!(dep = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dep = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_debug("_resume_with_deps couldn't find device "
|
||||
"layer '%s' - skipping.", dlid);
|
||||
continue;
|
||||
@ -1564,7 +1561,7 @@ static int _create_rec(struct dev_manager *dm, struct dev_layer *dl)
|
||||
list_iterate_items(strl, &dl->pre_create) {
|
||||
dlid = strl->str;
|
||||
|
||||
if (!(dep = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dep = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_error("Couldn't find device layer '%s'.", dlid);
|
||||
return 0;
|
||||
}
|
||||
@ -1637,18 +1634,18 @@ static int _build_all_layers(struct dev_manager *dm, struct volume_group *vg)
|
||||
|
||||
static int _fill_in_remove_list(struct dev_manager *dm)
|
||||
{
|
||||
struct hash_node *hn;
|
||||
struct dm_hash_node *hn;
|
||||
struct dev_layer *dl;
|
||||
struct dl_list *dll;
|
||||
|
||||
hash_iterate(hn, dm->layers) {
|
||||
dl = hash_get_data(dm->layers, hn);
|
||||
dm_hash_iterate(hn, dm->layers) {
|
||||
dl = dm_hash_get_data(dm->layers, hn);
|
||||
|
||||
if (_get_flag(dl, REMOVE))
|
||||
_clear_flag(dl, ACTIVE);
|
||||
|
||||
if (!_get_flag(dl, ACTIVE)) {
|
||||
dll = pool_alloc(dm->mem, sizeof(*dll));
|
||||
dll = dm_pool_alloc(dm->mem, sizeof(*dll));
|
||||
if (!dll) {
|
||||
stack;
|
||||
return 0;
|
||||
@ -1664,19 +1661,19 @@ static int _fill_in_remove_list(struct dev_manager *dm)
|
||||
|
||||
static int _populate_pre_suspend_lists(struct dev_manager *dm)
|
||||
{
|
||||
struct hash_node *hn;
|
||||
struct dm_hash_node *hn;
|
||||
struct dev_layer *dl;
|
||||
struct str_list *strl;
|
||||
const char *dlid;
|
||||
struct dev_layer *dep;
|
||||
|
||||
hash_iterate(hn, dm->layers) {
|
||||
dl = hash_get_data(dm->layers, hn);
|
||||
dm_hash_iterate(hn, dm->layers) {
|
||||
dl = dm_hash_get_data(dm->layers, hn);
|
||||
|
||||
list_iterate_items(strl, &dl->pre_suspend) {
|
||||
dlid = strl->str;
|
||||
|
||||
if (!(dep = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dep = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_debug("_populate_pre_suspend_lists: "
|
||||
"Couldn't find device layer '%s' - "
|
||||
"skipping.", dlid);
|
||||
@ -1692,7 +1689,7 @@ static int _populate_pre_suspend_lists(struct dev_manager *dm)
|
||||
list_iterate_items(strl, &dl->pre_create) {
|
||||
dlid = strl->str;
|
||||
|
||||
if (!(dep = hash_lookup(dm->layers, dlid))) {
|
||||
if (!(dep = dm_hash_lookup(dm->layers, dlid))) {
|
||||
log_debug("_populate_pre_suspend_lists: "
|
||||
"Couldn't find device layer '%s' - "
|
||||
"skipping.", dlid);
|
||||
@ -1753,7 +1750,7 @@ static int _remove_old_layers(struct dev_manager *dm)
|
||||
*/
|
||||
static int _execute(struct dev_manager *dm, struct volume_group *vg)
|
||||
{
|
||||
struct hash_node *hn;
|
||||
struct dm_hash_node *hn;
|
||||
struct dev_layer *dl;
|
||||
|
||||
if (!_build_all_layers(dm, vg)) {
|
||||
@ -1801,8 +1798,8 @@ static int _execute(struct dev_manager *dm, struct volume_group *vg)
|
||||
/*
|
||||
* Now only top level devices will be unmarked.
|
||||
*/
|
||||
hash_iterate(hn, dm->layers) {
|
||||
dl = hash_get_data(dm->layers, hn);
|
||||
dm_hash_iterate(hn, dm->layers) {
|
||||
dl = dm_hash_get_data(dm->layers, hn);
|
||||
|
||||
if (_get_flag(dl, ACTIVE) && _get_flag(dl, TOPLEVEL))
|
||||
if (!_create_rec(dm, dl)) {
|
||||
@ -1812,8 +1809,8 @@ static int _execute(struct dev_manager *dm, struct volume_group *vg)
|
||||
}
|
||||
|
||||
/* Resume devices */
|
||||
hash_iterate(hn, dm->layers) {
|
||||
dl = hash_get_data(dm->layers, hn);
|
||||
dm_hash_iterate(hn, dm->layers) {
|
||||
dl = dm_hash_get_data(dm->layers, hn);
|
||||
|
||||
if (!_resume_with_deps(dm, dl)) {
|
||||
stack;
|
||||
@ -1857,7 +1854,7 @@ static int _add_existing_layer(struct dev_manager *dm, const char *name)
|
||||
|
||||
log_debug("Found existing layer '%s'", name);
|
||||
|
||||
if (!(copy = pool_strdup(dm->mem, name))) {
|
||||
if (!(copy = dm_pool_strdup(dm->mem, name))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -1907,12 +1904,12 @@ static int _scan_existing_devices(struct dev_manager *dm)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _add_lv(struct pool *mem,
|
||||
static int _add_lv(struct dm_pool *mem,
|
||||
struct list *head, struct logical_volume *lv)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
|
||||
if (!(lvl = pool_alloc(mem, sizeof(*lvl)))) {
|
||||
if (!(lvl = dm_pool_alloc(mem, sizeof(*lvl)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -1923,7 +1920,7 @@ static int _add_lv(struct pool *mem,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _add_lvs(struct pool *mem,
|
||||
static int _add_lvs(struct dm_pool *mem,
|
||||
struct list *head, struct logical_volume *origin)
|
||||
{
|
||||
struct lv_segment *snap_seg;
|
||||
@ -2093,8 +2090,8 @@ static int _fill_in_active_list(struct dev_manager *dm, struct volume_group *vg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
dl = hash_lookup(dm->layers, dlid);
|
||||
pool_free(dm->mem, dlid);
|
||||
dl = dm_hash_lookup(dm->layers, dlid);
|
||||
dm_pool_free(dm->mem, dlid);
|
||||
|
||||
if (dl) {
|
||||
log_debug("Found active lv %s%s", lvl->lv->name,
|
||||
@ -2207,20 +2204,6 @@ int dev_manager_lv_rmnodes(const struct logical_volume *lv)
|
||||
return fs_del_lv(lv);
|
||||
}
|
||||
|
||||
int dev_manager_mknodes(void)
|
||||
{
|
||||
struct dm_task *dmt;
|
||||
int r;
|
||||
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_MKNODES)))
|
||||
return 0;
|
||||
|
||||
r = dm_task_run(dmt);
|
||||
|
||||
dm_task_destroy(dmt);
|
||||
return r;
|
||||
}
|
||||
|
||||
void dev_manager_exit(void)
|
||||
{
|
||||
dm_lib_exit();
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <libdevmapper.h>
|
||||
|
||||
static int _mk_dir(const char *dev_dir, const char *vg_name)
|
||||
{
|
||||
@ -283,7 +282,7 @@ static int _stack_fs_op(fs_op_t type, const char *dev_dir, const char *vg_name,
|
||||
strlen(dev) + strlen(old_lv_name) + 5;
|
||||
char *pos;
|
||||
|
||||
if (!(fsp = dbg_malloc(sizeof(*fsp) + len))) {
|
||||
if (!(fsp = dm_malloc(sizeof(*fsp) + len))) {
|
||||
log_error("No space to stack fs operation");
|
||||
return 0;
|
||||
}
|
||||
@ -312,7 +311,7 @@ static void _pop_fs_ops(void)
|
||||
_do_fs_op(fsp->type, fsp->dev_dir, fsp->vg_name, fsp->lv_name,
|
||||
fsp->dev, fsp->old_lv_name);
|
||||
list_del(&fsp->list);
|
||||
dbg_free(fsp);
|
||||
dm_free(fsp);
|
||||
}
|
||||
}
|
||||
|
||||
|
99
lib/cache/lvmcache.c
vendored
99
lib/cache/lvmcache.c
vendored
@ -16,7 +16,6 @@
|
||||
|
||||
#include "lib.h"
|
||||
#include "lvmcache.h"
|
||||
#include "hash.h"
|
||||
#include "toolcontext.h"
|
||||
#include "dev-cache.h"
|
||||
#include "metadata.h"
|
||||
@ -24,10 +23,10 @@
|
||||
#include "memlock.h"
|
||||
#include "str_list.h"
|
||||
|
||||
static struct hash_table *_pvid_hash = NULL;
|
||||
static struct hash_table *_vgid_hash = NULL;
|
||||
static struct hash_table *_vgname_hash = NULL;
|
||||
static struct hash_table *_lock_hash = NULL;
|
||||
static struct dm_hash_table *_pvid_hash = NULL;
|
||||
static struct dm_hash_table *_vgid_hash = NULL;
|
||||
static struct dm_hash_table *_vgname_hash = NULL;
|
||||
static struct dm_hash_table *_lock_hash = NULL;
|
||||
static struct list _vginfos;
|
||||
static int _has_scanned = 0;
|
||||
static int _vgs_locked = 0;
|
||||
@ -36,16 +35,16 @@ int lvmcache_init(void)
|
||||
{
|
||||
list_init(&_vginfos);
|
||||
|
||||
if (!(_vgname_hash = hash_create(128)))
|
||||
if (!(_vgname_hash = dm_hash_create(128)))
|
||||
return 0;
|
||||
|
||||
if (!(_vgid_hash = hash_create(128)))
|
||||
if (!(_vgid_hash = dm_hash_create(128)))
|
||||
return 0;
|
||||
|
||||
if (!(_pvid_hash = hash_create(128)))
|
||||
if (!(_pvid_hash = dm_hash_create(128)))
|
||||
return 0;
|
||||
|
||||
if (!(_lock_hash = hash_create(128)))
|
||||
if (!(_lock_hash = dm_hash_create(128)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@ -58,7 +57,7 @@ void lvmcache_lock_vgname(const char *vgname, int read_only)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hash_insert(_lock_hash, vgname, (void *) 1))
|
||||
if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
|
||||
log_error("Cache locking failure for %s", vgname);
|
||||
|
||||
_vgs_locked++;
|
||||
@ -70,13 +69,13 @@ static int _vgname_is_locked(const char *vgname)
|
||||
if (!_lock_hash)
|
||||
return 0;
|
||||
|
||||
return hash_lookup(_lock_hash, vgname) ? 1 : 0;
|
||||
return dm_hash_lookup(_lock_hash, vgname) ? 1 : 0;
|
||||
}
|
||||
|
||||
void lvmcache_unlock_vgname(const char *vgname)
|
||||
{
|
||||
/* FIXME: Clear all CACHE_LOCKED flags in this vg */
|
||||
hash_remove(_lock_hash, vgname);
|
||||
dm_hash_remove(_lock_hash, vgname);
|
||||
|
||||
/* FIXME Do this per-VG */
|
||||
if (!--_vgs_locked)
|
||||
@ -95,7 +94,7 @@ struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname)
|
||||
if (!_vgname_hash)
|
||||
return NULL;
|
||||
|
||||
if (!(vginfo = hash_lookup(_vgname_hash, vgname)))
|
||||
if (!(vginfo = dm_hash_lookup(_vgname_hash, vgname)))
|
||||
return NULL;
|
||||
|
||||
return vginfo;
|
||||
@ -117,7 +116,7 @@ const struct format_type *fmt_from_vgname(const char *vgname)
|
||||
* we check cached labels here. Unfortunately vginfo is volatile. */
|
||||
list_init(&devs);
|
||||
list_iterate_items(info, &vginfo->infos) {
|
||||
devl = dbg_malloc(sizeof(*devl));
|
||||
devl = dm_malloc(sizeof(*devl));
|
||||
devl->dev = info->dev;
|
||||
list_add(&devs, &devl->list);
|
||||
}
|
||||
@ -126,7 +125,7 @@ const struct format_type *fmt_from_vgname(const char *vgname)
|
||||
devl = list_item(devh, struct device_list);
|
||||
label_read(devl->dev, &label);
|
||||
list_del(&devl->list);
|
||||
dbg_free(devl);
|
||||
dm_free(devl);
|
||||
}
|
||||
|
||||
return vginfo->fmt;
|
||||
@ -144,7 +143,7 @@ struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid)
|
||||
strncpy(&id[0], vgid, ID_LEN);
|
||||
id[ID_LEN] = '\0';
|
||||
|
||||
if (!(vginfo = hash_lookup(_vgid_hash, id)))
|
||||
if (!(vginfo = dm_hash_lookup(_vgid_hash, id)))
|
||||
return NULL;
|
||||
|
||||
return vginfo;
|
||||
@ -161,7 +160,7 @@ struct lvmcache_info *info_from_pvid(const char *pvid)
|
||||
strncpy(&id[0], pvid, ID_LEN);
|
||||
id[ID_LEN] = '\0';
|
||||
|
||||
if (!(info = hash_lookup(_pvid_hash, id)))
|
||||
if (!(info = dm_hash_lookup(_pvid_hash, id)))
|
||||
return NULL;
|
||||
|
||||
return info;
|
||||
@ -177,7 +176,7 @@ static void _rescan_entry(struct lvmcache_info *info)
|
||||
|
||||
static int _scan_invalid(void)
|
||||
{
|
||||
hash_iter(_pvid_hash, (iterate_fn) _rescan_entry);
|
||||
dm_hash_iter(_pvid_hash, (dm_hash_iterate_fn) _rescan_entry);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -248,7 +247,7 @@ struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan)
|
||||
|
||||
list_iterate_items(vgi, &_vginfos) {
|
||||
if (!str_list_add(cmd->mem, vgnames,
|
||||
pool_strdup(cmd->mem, vgi->vgname))) {
|
||||
dm_pool_strdup(cmd->mem, vgi->vgname))) {
|
||||
log_error("strlist allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
@ -307,13 +306,13 @@ static void _drop_vginfo(struct lvmcache_info *info)
|
||||
}
|
||||
|
||||
if (info->vginfo && list_empty(&info->vginfo->infos)) {
|
||||
hash_remove(_vgname_hash, info->vginfo->vgname);
|
||||
dm_hash_remove(_vgname_hash, info->vginfo->vgname);
|
||||
if (info->vginfo->vgname)
|
||||
dbg_free(info->vginfo->vgname);
|
||||
dm_free(info->vginfo->vgname);
|
||||
if (*info->vginfo->vgid)
|
||||
hash_remove(_vgid_hash, info->vginfo->vgid);
|
||||
dm_hash_remove(_vgid_hash, info->vginfo->vgid);
|
||||
list_del(&info->vginfo->list);
|
||||
dbg_free(info->vginfo);
|
||||
dm_free(info->vginfo);
|
||||
}
|
||||
|
||||
info->vginfo = NULL;
|
||||
@ -323,13 +322,13 @@ static void _drop_vginfo(struct lvmcache_info *info)
|
||||
void lvmcache_del(struct lvmcache_info *info)
|
||||
{
|
||||
if (info->dev->pvid[0] && _pvid_hash)
|
||||
hash_remove(_pvid_hash, info->dev->pvid);
|
||||
dm_hash_remove(_pvid_hash, info->dev->pvid);
|
||||
|
||||
_drop_vginfo(info);
|
||||
|
||||
info->label->labeller->ops->destroy_label(info->label->labeller,
|
||||
info->label);
|
||||
dbg_free(info);
|
||||
dm_free(info);
|
||||
|
||||
return;
|
||||
} */
|
||||
@ -339,10 +338,10 @@ static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid)
|
||||
if (!strcmp(info->dev->pvid, pvid))
|
||||
return 1;
|
||||
if (*info->dev->pvid) {
|
||||
hash_remove(_pvid_hash, info->dev->pvid);
|
||||
dm_hash_remove(_pvid_hash, info->dev->pvid);
|
||||
}
|
||||
strncpy(info->dev->pvid, pvid, sizeof(info->dev->pvid));
|
||||
if (!hash_insert(_pvid_hash, pvid, info)) {
|
||||
if (!dm_hash_insert(_pvid_hash, pvid, info)) {
|
||||
log_error("_lvmcache_update: pvid insertion failed: %s", pvid);
|
||||
return 0;
|
||||
}
|
||||
@ -357,13 +356,13 @@ static int _lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid)
|
||||
return 1;
|
||||
|
||||
if (info->vginfo && *info->vginfo->vgid)
|
||||
hash_remove(_vgid_hash, info->vginfo->vgid);
|
||||
dm_hash_remove(_vgid_hash, info->vginfo->vgid);
|
||||
if (!vgid)
|
||||
return 1;
|
||||
|
||||
strncpy(info->vginfo->vgid, vgid, sizeof(info->vginfo->vgid));
|
||||
info->vginfo->vgid[sizeof(info->vginfo->vgid) - 1] = '\0';
|
||||
if (!hash_insert(_vgid_hash, info->vginfo->vgid, info->vginfo)) {
|
||||
if (!dm_hash_insert(_vgid_hash, info->vginfo->vgid, info->vginfo)) {
|
||||
log_error("_lvmcache_update: vgid hash insertion failed: %s",
|
||||
info->vginfo->vgid);
|
||||
return 0;
|
||||
@ -391,22 +390,22 @@ int lvmcache_update_vgname(struct lvmcache_info *info, const char *vgname)
|
||||
|
||||
/* Get existing vginfo or create new one */
|
||||
if (!(vginfo = vginfo_from_vgname(vgname))) {
|
||||
if (!(vginfo = dbg_malloc(sizeof(*vginfo)))) {
|
||||
if (!(vginfo = dm_malloc(sizeof(*vginfo)))) {
|
||||
log_error("lvmcache_update_vgname: list alloc failed");
|
||||
return 0;
|
||||
}
|
||||
memset(vginfo, 0, sizeof(*vginfo));
|
||||
if (!(vginfo->vgname = dbg_strdup(vgname))) {
|
||||
dbg_free(vginfo);
|
||||
if (!(vginfo->vgname = dm_strdup(vgname))) {
|
||||
dm_free(vginfo);
|
||||
log_error("cache vgname alloc failed for %s", vgname);
|
||||
return 0;
|
||||
}
|
||||
list_init(&vginfo->infos);
|
||||
if (!hash_insert(_vgname_hash, vginfo->vgname, vginfo)) {
|
||||
if (!dm_hash_insert(_vgname_hash, vginfo->vgname, vginfo)) {
|
||||
log_error("cache_update: vg hash insertion failed: %s",
|
||||
vginfo->vgname);
|
||||
dbg_free(vginfo->vgname);
|
||||
dbg_free(vginfo);
|
||||
dm_free(vginfo->vgname);
|
||||
dm_free(vginfo);
|
||||
return 0;
|
||||
}
|
||||
/* Ensure orphans appear last on list_iterate */
|
||||
@ -474,7 +473,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
if (!(info = dbg_malloc(sizeof(*info)))) {
|
||||
if (!(info = dm_malloc(sizeof(*info)))) {
|
||||
log_error("lvmcache_info allocation failed");
|
||||
label_destroy(label);
|
||||
return NULL;
|
||||
@ -540,7 +539,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
|
||||
if (!_lvmcache_update_pvid(info, pvid_s)) {
|
||||
if (!existing) {
|
||||
dbg_free(info);
|
||||
dm_free(info);
|
||||
label_destroy(label);
|
||||
}
|
||||
return NULL;
|
||||
@ -548,9 +547,9 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
|
||||
if (!lvmcache_update_vgname(info, vgname)) {
|
||||
if (!existing) {
|
||||
hash_remove(_pvid_hash, pvid_s);
|
||||
dm_hash_remove(_pvid_hash, pvid_s);
|
||||
strcpy(info->dev->pvid, "");
|
||||
dbg_free(info);
|
||||
dm_free(info);
|
||||
label_destroy(label);
|
||||
}
|
||||
return NULL;
|
||||
@ -569,14 +568,14 @@ static void _lvmcache_destroy_entry(struct lvmcache_info *info)
|
||||
list_del(&info->list);
|
||||
strcpy(info->dev->pvid, "");
|
||||
label_destroy(info->label);
|
||||
dbg_free(info);
|
||||
dm_free(info);
|
||||
}
|
||||
|
||||
static void _lvmcache_destroy_vgnamelist(struct lvmcache_vginfo *vginfo)
|
||||
{
|
||||
if (vginfo->vgname)
|
||||
dbg_free(vginfo->vgname);
|
||||
dbg_free(vginfo);
|
||||
dm_free(vginfo->vgname);
|
||||
dm_free(vginfo);
|
||||
}
|
||||
|
||||
static void _lvmcache_destroy_lockname(int present)
|
||||
@ -591,26 +590,26 @@ void lvmcache_destroy(void)
|
||||
_has_scanned = 0;
|
||||
|
||||
if (_vgid_hash) {
|
||||
hash_destroy(_vgid_hash);
|
||||
dm_hash_destroy(_vgid_hash);
|
||||
_vgid_hash = NULL;
|
||||
}
|
||||
|
||||
if (_pvid_hash) {
|
||||
hash_iter(_pvid_hash, (iterate_fn) _lvmcache_destroy_entry);
|
||||
hash_destroy(_pvid_hash);
|
||||
dm_hash_iter(_pvid_hash, (dm_hash_iterate_fn) _lvmcache_destroy_entry);
|
||||
dm_hash_destroy(_pvid_hash);
|
||||
_pvid_hash = NULL;
|
||||
}
|
||||
|
||||
if (_vgname_hash) {
|
||||
hash_iter(_vgname_hash,
|
||||
(iterate_fn) _lvmcache_destroy_vgnamelist);
|
||||
hash_destroy(_vgname_hash);
|
||||
dm_hash_iter(_vgname_hash,
|
||||
(dm_hash_iterate_fn) _lvmcache_destroy_vgnamelist);
|
||||
dm_hash_destroy(_vgname_hash);
|
||||
_vgname_hash = NULL;
|
||||
}
|
||||
|
||||
if (_lock_hash) {
|
||||
hash_iter(_lock_hash, (iterate_fn) _lvmcache_destroy_lockname);
|
||||
hash_destroy(_lock_hash);
|
||||
dm_hash_iter(_lock_hash, (dm_hash_iterate_fn) _lvmcache_destroy_lockname);
|
||||
dm_hash_destroy(_lock_hash);
|
||||
_lock_hash = NULL;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "lib.h"
|
||||
#include "toolcontext.h"
|
||||
#include "pool.h"
|
||||
#include "metadata.h"
|
||||
#include "defaults.h"
|
||||
#include "lvm-string.h"
|
||||
@ -213,7 +212,7 @@ static int _process_config(struct cmd_context *cmd)
|
||||
|
||||
static int _set_tag(struct cmd_context *cmd, const char *tag)
|
||||
{
|
||||
log_very_verbose("Setting host tag: %s", pool_strdup(cmd->libmem, tag));
|
||||
log_very_verbose("Setting host tag: %s", dm_pool_strdup(cmd->libmem, tag));
|
||||
|
||||
if (!str_list_add(cmd->libmem, &cmd->tags, tag)) {
|
||||
log_error("_set_tag: str_list_add %s failed", tag);
|
||||
@ -323,7 +322,7 @@ static int _load_config_file(struct cmd_context *cmd, const char *tag)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cfl = pool_alloc(cmd->libmem, sizeof(*cfl)))) {
|
||||
if (!(cfl = dm_pool_alloc(cmd->libmem, sizeof(*cfl)))) {
|
||||
log_error("config_tree_list allocation failed");
|
||||
return 0;
|
||||
}
|
||||
@ -800,13 +799,13 @@ static int _init_hostname(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cmd->hostname = pool_strdup(cmd->libmem, uts.nodename))) {
|
||||
log_error("_init_hostname: pool_strdup failed");
|
||||
if (!(cmd->hostname = dm_pool_strdup(cmd->libmem, uts.nodename))) {
|
||||
log_error("_init_hostname: dm_pool_strdup failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(cmd->kernel_vsn = pool_strdup(cmd->libmem, uts.release))) {
|
||||
log_error("_init_hostname: pool_strdup kernel_vsn failed");
|
||||
if (!(cmd->kernel_vsn = dm_pool_strdup(cmd->libmem, uts.release))) {
|
||||
log_error("_init_hostname: dm_pool_strdup kernel_vsn failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -894,7 +893,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
|
||||
init_syslog(DEFAULT_LOG_FACILITY);
|
||||
|
||||
if (!(cmd = dbg_malloc(sizeof(*cmd)))) {
|
||||
if (!(cmd = dm_malloc(sizeof(*cmd)))) {
|
||||
log_error("Failed to allocate command context");
|
||||
return NULL;
|
||||
}
|
||||
@ -920,7 +919,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(cmd->libmem = pool_create("library", 4 * 1024))) {
|
||||
if (!(cmd->libmem = dm_pool_create("library", 4 * 1024))) {
|
||||
log_error("Library memory pool creation failed");
|
||||
return 0;
|
||||
}
|
||||
@ -951,7 +950,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
if (!_init_filters(cmd))
|
||||
goto error;
|
||||
|
||||
if (!(cmd->mem = pool_create("command", 4 * 1024))) {
|
||||
if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) {
|
||||
log_error("Command memory pool creation failed");
|
||||
return 0;
|
||||
}
|
||||
@ -973,7 +972,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
return cmd;
|
||||
|
||||
error:
|
||||
dbg_free(cmd);
|
||||
dm_free(cmd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1085,15 +1084,15 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
||||
_destroy_segtypes(&cmd->segtypes);
|
||||
_destroy_formats(&cmd->formats);
|
||||
cmd->filter->destroy(cmd->filter);
|
||||
pool_destroy(cmd->mem);
|
||||
dm_pool_destroy(cmd->mem);
|
||||
dev_cache_exit();
|
||||
_destroy_tags(cmd);
|
||||
_destroy_tag_configs(cmd);
|
||||
pool_destroy(cmd->libmem);
|
||||
dbg_free(cmd);
|
||||
dm_pool_destroy(cmd->libmem);
|
||||
dm_free(cmd);
|
||||
|
||||
release_log_memory();
|
||||
dump_memory();
|
||||
dm_dump_memory();
|
||||
fin_log();
|
||||
fin_syslog();
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#define _LVM_TOOLCONTEXT_H
|
||||
|
||||
#include "dev-cache.h"
|
||||
#include "pool.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
@ -50,8 +49,8 @@ struct backup_params;
|
||||
/* FIXME Split into tool & library contexts */
|
||||
/* command-instance-related variables needed by library */
|
||||
struct cmd_context {
|
||||
struct pool *libmem; /* For permanent config data */
|
||||
struct pool *mem; /* Transient: Cleared between each command */
|
||||
struct dm_pool *libmem; /* For permanent config data */
|
||||
struct dm_pool *mem; /* Transient: Cleared between each command */
|
||||
|
||||
const struct format_type *fmt; /* Current format to use by default */
|
||||
struct format_type *fmt_backup; /* Format to use for backups */
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "lib.h"
|
||||
#include "config.h"
|
||||
#include "crc.h"
|
||||
#include "pool.h"
|
||||
#include "device.h"
|
||||
#include "str_list.h"
|
||||
#include "toolcontext.h"
|
||||
@ -50,12 +49,12 @@ struct parser {
|
||||
int fd; /* descriptor for file being parsed */
|
||||
int line; /* line number we are on */
|
||||
|
||||
struct pool *mem;
|
||||
struct dm_pool *mem;
|
||||
};
|
||||
|
||||
struct cs {
|
||||
struct config_tree cft;
|
||||
struct pool *mem;
|
||||
struct dm_pool *mem;
|
||||
time_t timestamp;
|
||||
char *filename;
|
||||
int exists;
|
||||
@ -99,16 +98,16 @@ static int _tok_match(const char *str, const char *b, const char *e)
|
||||
struct config_tree *create_config_tree(const char *filename)
|
||||
{
|
||||
struct cs *c;
|
||||
struct pool *mem = pool_create("config", 10 * 1024);
|
||||
struct dm_pool *mem = dm_pool_create("config", 10 * 1024);
|
||||
|
||||
if (!mem) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(c = pool_zalloc(mem, sizeof(*c)))) {
|
||||
if (!(c = dm_pool_zalloc(mem, sizeof(*c)))) {
|
||||
stack;
|
||||
pool_destroy(mem);
|
||||
dm_pool_destroy(mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -117,13 +116,13 @@ struct config_tree *create_config_tree(const char *filename)
|
||||
c->timestamp = 0;
|
||||
c->exists = 0;
|
||||
if (filename)
|
||||
c->filename = pool_strdup(c->mem, filename);
|
||||
c->filename = dm_pool_strdup(c->mem, filename);
|
||||
return &c->cft;
|
||||
}
|
||||
|
||||
void destroy_config_tree(struct config_tree *cft)
|
||||
{
|
||||
pool_destroy(((struct cs *) cft)->mem);
|
||||
dm_pool_destroy(((struct cs *) cft)->mem);
|
||||
}
|
||||
|
||||
int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
@ -136,7 +135,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
int use_mmap = 1;
|
||||
off_t mmap_offset = 0;
|
||||
|
||||
if (!(p = pool_alloc(c->mem, sizeof(*p)))) {
|
||||
if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -157,7 +156,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
}
|
||||
p->fb = p->fb + mmap_offset;
|
||||
} else {
|
||||
if (!(p->fb = dbg_malloc(size + size2))) {
|
||||
if (!(p->fb = dm_malloc(size + size2))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@ -197,7 +196,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
||||
|
||||
out:
|
||||
if (!use_mmap)
|
||||
dbg_free(p->fb);
|
||||
dm_free(p->fb);
|
||||
else {
|
||||
/* unmap the file */
|
||||
if (munmap((char *) (p->fb - mmap_offset), size + mmap_offset)) {
|
||||
@ -688,14 +687,14 @@ static void _eat_space(struct parser *p)
|
||||
*/
|
||||
static struct config_value *_create_value(struct parser *p)
|
||||
{
|
||||
struct config_value *v = pool_alloc(p->mem, sizeof(*v));
|
||||
struct config_value *v = dm_pool_alloc(p->mem, sizeof(*v));
|
||||
memset(v, 0, sizeof(*v));
|
||||
return v;
|
||||
}
|
||||
|
||||
static struct config_node *_create_node(struct parser *p)
|
||||
{
|
||||
struct config_node *n = pool_alloc(p->mem, sizeof(*n));
|
||||
struct config_node *n = dm_pool_alloc(p->mem, sizeof(*n));
|
||||
memset(n, 0, sizeof(*n));
|
||||
return n;
|
||||
}
|
||||
@ -703,7 +702,7 @@ static struct config_node *_create_node(struct parser *p)
|
||||
static char *_dup_tok(struct parser *p)
|
||||
{
|
||||
size_t len = p->te - p->tb;
|
||||
char *str = pool_alloc(p->mem, len + 1);
|
||||
char *str = dm_pool_alloc(p->mem, len + 1);
|
||||
if (!str) {
|
||||
stack;
|
||||
return |