macros.
CFLAGS += -g
LDFLAGS += $(shell if [ -e /usr/lib64/openais ]; then \
- echo '-L/usr/lib64/openais -L/usr/lib64'; \
+ echo '-L/usr/lib64/openais -L/usr/lib64 -L/lib64'; \
else \
- echo '-L/usr/lib/openais -L/usr/lib'; \
+ echo '-L/usr/lib/openais -L/usr/lib -L/lib'; \
fi)
-LDFLAGS += -lcpg -lSaCkpt -lext2fs
+LDFLAGS += -lcpg -lSaCkpt -lext2fs -ldevmapper
all: ${TARGET}
#include <openais/saCkpt.h>
#include "linux/dm-log-userspace.h"
-#include "list.h"
+#include <libdevmapper.h>
#include "functions.h"
#include "local.h"
#include "common.h"
#define MAX_CHECKPOINT_REQUESTERS 10
struct clog_cpg {
- struct list_head list;
+ struct dm_list list;
uint32_t lowest_id;
cpg_handle_t handle;
int free_me;
int delay;
int resend_requests;
- struct list_head startup_list;
- struct list_head working_list;
+ struct dm_list startup_list;
+ struct dm_list working_list;
int checkpoints_needed;
uint32_t checkpoint_requesters[MAX_CHECKPOINT_REQUESTERS];
char debugging[DEBUGGING_HISTORY][128];
};
-/* FIXME: Need lock for this */
-static struct list_head clog_cpg_list;
+static struct dm_list clog_cpg_list;
/*
* cluster_send
struct iovec iov;
struct clog_cpg *entry, *tmp;
- list_for_each_entry_safe(entry, tmp, &clog_cpg_list, list)
+ dm_list_iterate_items(entry, &clog_cpg_list)
if (!strncmp(entry->name.value, rq->u_rq.uuid,
CPG_MAX_NAME_LENGTH)) {
found = 1;
}
static struct clog_request *get_matching_rq(struct clog_request *rq,
- struct list_head *l)
+ struct dm_list *l)
{
struct clog_request *match, *n;
- list_for_each_entry_safe(match, n, l, list) {
+ dm_list_iterate_items_safe(match, n, l)
if (match->u_rq.seq == rq->u_rq.seq) {
- list_del_init(&match->list);
+ dm_list_del(&match->list);
return match;
}
- }
+
return NULL;
}
rq->u_rq.seq);
LOG_ERROR("Current local list:");
- if (list_empty(&entry->working_list))
+ if (dm_list_empty(&entry->working_list))
LOG_ERROR(" [none]");
- list_for_each_entry_safe(orig_rq, n, &entry->working_list, list) {
+ dm_list_iterate_items(orig_rq, &entry->working_list)
LOG_ERROR(" [%s] %s:%u",
SHORT_UUID(orig_rq->u_rq.uuid),
_RQ_TYPE(orig_rq->u_rq.request_type),
orig_rq->u_rq.seq);
- }
return -EINVAL;
}
{
struct clog_cpg *match, *tmp;
- list_for_each_entry_safe(match, tmp, &clog_cpg_list, list) {
+ dm_list_iterate_items(match, &clog_cpg_list)
if (match->handle == handle)
return match;
- }
return NULL;
}
}
memset(rq, 0, sizeof(*rq));
- INIT_LIST_HEAD(&rq->list);
+ dm_list_init(&rq->list);
rq->u_rq.request_type = DM_ULOG_CHECKPOINT_READY;
rq->originator = cp->requester; /* FIXME: hack to overload meaning of originator */
strncpy(rq->u_rq.uuid, cp->uuid, CPG_MAX_NAME_LENGTH);
entry->resend_requests = 0;
- list_for_each_entry_safe(rq, n, &entry->working_list, list) {
- list_del_init(&rq->list);
+ dm_list_iterate_items_safe(rq, n, &entry->working_list) {
+ dm_list_del(&rq->list);
if (strcmp(entry->name.value, rq->u_rq.uuid)) {
LOG_ERROR("[%s] Stray request from another log (%s)",
int r = SA_AIS_OK;
struct clog_cpg *entry, *tmp;
- list_for_each_entry_safe(entry, tmp, &clog_cpg_list, list) {
+ dm_list_iterate_items(entry, &clog_cpg_list) {
r = cpg_dispatch(entry->handle, CPG_DISPATCH_ALL);
if (r != SA_AIS_OK)
LOG_ERROR("cpg_dispatch failed: %s", str_ais_error(r));
struct clog_request *rq, *n;
struct checkpoint_data *new;
- list_for_each_entry_safe(rq, n, &entry->startup_list, list) {
- list_del_init(&rq->list);
+ dm_list_iterate_items_safe(rq, n, &entry->startup_list) {
+ dm_list_del(&rq->list);
if (rq->u_rq.request_type == DM_ULOG_MEMBER_JOIN) {
new = prepare_checkpoint(entry, rq->originator);
return;
}
memcpy(tmp_rq, rq, sizeof(*rq) + rq->u_rq.data_size);
- INIT_LIST_HEAD(&tmp_rq->list);
- list_add_tail(&tmp_rq->list, &match->working_list);
+ dm_list_init(&tmp_rq->list);
+ dm_list_add( &match->working_list, &tmp_rq->list);
}
if (rq->u_rq.request_type == DM_ULOG_POSTSUSPEND) {
match->resend_requests = 1;
LOG_COND(log_resend_requests, "[%s] %u is leaving, resend required%s",
SHORT_UUID(rq->u_rq.uuid), nodeid,
- (list_empty(&match->working_list)) ? " -- working_list empty": "");
-
- list_for_each_entry_safe(tmp_rq, n, &match->working_list, list) {
+ (dm_list_empty(&match->working_list)) ? " -- working_list empty": "");
+
+ dm_list_iterate_items(tmp_rq, &match->working_list)
LOG_COND(log_resend_requests,
"[%s] %s/%u",
SHORT_UUID(tmp_rq->u_rq.uuid),
_RQ_TYPE(tmp_rq->u_rq.request_type),
tmp_rq->u_rq.seq);
- }
}
match->delay++;
memcpy(tmp_rq, rq, sizeof(*rq) + rq->u_rq.data_size);
tmp_rq->pit_server = match->lowest_id;
- INIT_LIST_HEAD(&tmp_rq->list);
- list_add_tail(&tmp_rq->list, &match->startup_list);
+ dm_list_init(&tmp_rq->list);
+ dm_list_add(&match->startup_list, &tmp_rq->list);
goto out;
}
* FIXME: remove checkpoint_requesters/checkpoints_needed, and use
* the startup_list interface exclusively
*/
- if (list_empty(&match->startup_list) && (match->state == VALID) &&
+ if (dm_list_empty(&match->startup_list) && (match->state == VALID) &&
(match->checkpoints_needed < MAX_CHECKPOINT_REQUESTERS)) {
match->checkpoint_requesters[match->checkpoints_needed++] = joined->nodeid;
goto out;
}
rq->u_rq.request_type = DM_ULOG_MEMBER_JOIN;
rq->originator = joined->nodeid;
- INIT_LIST_HEAD(&rq->list);
- list_add_tail(&rq->list, &match->startup_list);
+ dm_list_init(&rq->list);
+ dm_list_add(&match->startup_list, &rq->list);
out:
/* Find the lowest_id, i.e. the server */
/* Am I leaving? */
if (my_cluster_id == left->nodeid) {
LOG_DBG("Finalizing leave...");
- list_del_init(&match->list);
+ dm_list_del(&match->list);
cpg_fd_get(match->handle, &fd);
links_unregister(fd);
cluster_postsuspend(match->name.value, match->luid);
- list_for_each_entry_safe(rq, n, &match->working_list, list) {
- list_del_init(&rq->list);
+ dm_list_iterate_items_safe(rq, n, &match->working_list) {
+ dm_list_del(&rq->list);
if (rq->u_rq.request_type == DM_ULOG_POSTSUSPEND)
kernel_send(&rq->u_rq);
SHORT_UUID(match->name.value), left->nodeid);
free_checkpoint(c_cp);
}
- list_for_each_entry_safe(rq, n, &match->startup_list, list) {
+ dm_list_iterate_items_safe(rq, n, &match->startup_list) {
if ((rq->u_rq.request_type == DM_ULOG_MEMBER_JOIN) &&
(rq->originator == left->nodeid)) {
LOG_COND(log_checkpoint,
"[%s] Removing pending ckpt from startup list (%u is leaving)",
SHORT_UUID(match->name.value), left->nodeid);
- list_del_init(&rq->list);
+ dm_list_del(&rq->list);
free(rq);
}
}
if (left->nodeid < my_cluster_id) {
match->delay = (match->delay > 0) ? match->delay - 1 : 0;
- if (!match->delay && list_empty(&match->working_list))
+ if (!match->delay && dm_list_empty(&match->working_list))
match->resend_requests = 0;
LOG_COND(log_resend_requests, "[%s] %u has left, delay = %d%s",
SHORT_UUID(match->name.value), left->nodeid,
- match->delay, (list_empty(&match->working_list)) ?
+ match->delay, (dm_list_empty(&match->working_list)) ?
" -- working_list empty": "");
}
*/
i = 1; /* We do not have a DM_ULOG_MEMBER_JOIN entry of our own */
- list_for_each_entry_safe(rq, n, &match->startup_list, list) {
+ dm_list_iterate_items(rq, &match->startup_list)
if (rq->u_rq.request_type == DM_ULOG_MEMBER_JOIN)
i++;
- }
if (i == member_list_entries) {
/*
struct clog_cpg *match, *tmp;
int found = 0;
- list_for_each_entry_safe(match, tmp, &clog_cpg_list, list)
+ dm_list_iterate_items(match, &clog_cpg_list)
if (match->handle == handle) {
found = 1;
break;
struct clog_cpg *new = NULL;
struct clog_cpg *tmp, *tmp2;
- list_for_each_entry_safe(tmp, tmp2, &clog_cpg_list, list)
+ dm_list_iterate_items(tmp, &clog_cpg_list)
if (!strncmp(tmp->name.value, uuid, CPG_MAX_NAME_LENGTH)) {
LOG_ERROR("Log entry already exists: %s", uuid);
return -EEXIST;
return -ENOMEM;
}
memset(new, 0, sizeof(*new));
- INIT_LIST_HEAD(&new->list);
+ dm_list_init(&new->list);
new->lowest_id = 0xDEAD;
- INIT_LIST_HEAD(&new->startup_list);
- INIT_LIST_HEAD(&new->working_list);
+ dm_list_init(&new->startup_list);
+ dm_list_init(&new->working_list);
size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
}
new->cpg_state = VALID;
- list_add(&new->list, &clog_cpg_list);
+ dm_list_add(&clog_cpg_list, &new->list);
LOG_DBG("New handle: %llu", (unsigned long long)new->handle);
LOG_DBG("New name: %s", new->name.value);
LOG_DBG("[%s] CPG teardown before checkpoint received",
SHORT_UUID(del->name.value));
- list_for_each_entry_safe(rq, n, &del->startup_list, list) {
- list_del_init(&rq->list);
+ dm_list_iterate_items_safe(rq, n, &del->startup_list) {
+ dm_list_del(&rq->list);
LOG_DBG("[%s] Ignoring request from %u: %s",
SHORT_UUID(del->name.value), rq->originator,
* startup list. If so, we certainly don't want to
* clear the startup_list here by calling abort_startup
*/
- if (!list_empty(&del->startup_list) && (state != VALID))
+ if (!dm_list_empty(&del->startup_list) && (state != VALID))
abort_startup(del);
r = cpg_leave(del->handle, &del->name);
{
struct clog_cpg *del, *tmp;
- list_for_each_entry_safe(del, tmp, &clog_cpg_list, list)
+ dm_list_iterate_items_safe(del, tmp, &clog_cpg_list)
if (!strncmp(del->name.value, uuid, CPG_MAX_NAME_LENGTH))
_destroy_cluster_cpg(del);
{
SaAisErrorT rv;
- INIT_LIST_HEAD(&clog_cpg_list);
+ dm_list_init(&clog_cpg_list);
rv = saCkptInitialize(&ckpt_handle, &callbacks, &version);
if (rv != SA_AIS_OK)
LOG_ERROR("");
LOG_ERROR("CLUSTER COMPONENT DEBUGGING::");
- list_for_each_entry_safe(entry, tmp, &clog_cpg_list, list) {
+ dm_list_iterate_items(entry, &clog_cpg_list) {
LOG_ERROR("%s::", SHORT_UUID(entry->name.value));
LOG_ERROR(" lowest_id : %u", entry->lowest_id);
LOG_ERROR(" state : %s", (entry->state == INVALID) ?
break;
LOG_ERROR(" CKPTs waiting : %d", i);
LOG_ERROR(" Working list:");
- list_for_each_entry_safe(rq, n, &entry->working_list, list) {
+ dm_list_iterate_items(rq, &entry->working_list)
LOG_ERROR(" %s/%u", _RQ_TYPE(rq->u_rq.request_type),
rq->u_rq.seq);
- }
LOG_ERROR(" Startup list:");
- list_for_each_entry_safe(rq, n, &entry->startup_list, list) {
+ dm_list_iterate_items(rq, &entry->startup_list)
LOG_ERROR(" %s/%u", _RQ_TYPE(rq->u_rq.request_type),
rq->u_rq.seq);
- }
LOG_ERROR("Command History:");
for (i = 0; i < DEBUGGING_HISTORY; i++) {
#ifndef __CLUSTER_LOG_CLUSTER_DOT_H__
#define __CLUSTER_LOG_CLUSTER_DOT_H__
-#include "list.h"
+#include <libdevmapper.h>
#include <linux/dm-log-userspace.h>
/*
* available.
*/
struct clog_request {
- struct list_head list;
+ struct dm_list list;
/*
* 'originator' is the machine from which the requests
#include <fcntl.h>
#include <time.h>
#include "linux/dm-log-userspace.h"
-#include "list.h"
#include "functions.h"
#include "common.h"
#include "cluster.h"
};
struct log_c {
- struct list_head list;
+ struct dm_list list;
char uuid[DM_UUID_LEN];
uint64_t luid;
uint32_t state; /* current operational state of the log */
- struct list_head mark_list;
+ struct dm_list mark_list;
uint32_t recovery_halted;
struct recovery_request *recovery_request_list;
};
struct mark_entry {
- struct list_head list;
+ struct dm_list list;
uint32_t nodeid;
uint64_t region;
};
struct recovery_request *next;
};
-static struct list_head log_list = LIST_HEAD_INIT(log_list);
-static struct list_head log_pending_list = LIST_HEAD_INIT(log_pending_list);
-
+static DM_LIST_INIT(log_list);
+static DM_LIST_INIT(log_pending_list);
static int log_test_bit(uint32_t *bs, unsigned bit)
{
*/
static struct log_c *get_log(const char *uuid, uint64_t luid)
{
- struct list_head *l;
struct log_c *lc;
- /* FIXME: Need prefetch to do this right */
- __list_for_each(l, &log_list) {
- lc = list_entry(l, struct log_c, list);
+ dm_list_iterate_items(lc, &log_list)
if (!strcmp(lc->uuid, uuid) &&
(!luid || (luid == lc->luid)))
return lc;
- }
return NULL;
}
*/
static struct log_c *get_pending_log(const char *uuid, uint64_t luid)
{
- struct list_head *l;
struct log_c *lc;
- /* FIXME: Need prefetch to do this right */
- __list_for_each(l, &log_pending_list) {
- lc = list_entry(l, struct log_c, list);
+ dm_list_iterate_items(lc, &log_pending_list)
if (!strcmp(lc->uuid, uuid) &&
(!luid || (luid == lc->luid)))
return lc;
- }
return NULL;
}
return -EINVAL;
}
- INIT_LIST_HEAD(&lc->mark_list);
+ dm_list_init(&lc->mark_list);
lc->bitset_uint32_count = region_count /
(sizeof(*lc->clean_bits) << BYTE_SHIFT);
LOG_DBG("Disk log ready");
}
- list_add(&lc->list, &log_pending_list);
+ dm_list_add(&log_pending_list, &lc->list);
return 0;
fail:
LOG_DBG("[%s] Cluster log removed", SHORT_UUID(lc->uuid));
- list_del_init(&lc->list);
+ dm_list_del(&lc->list);
if (lc->disk_fd != -1)
close(lc->disk_fd);
if (lc->disk_buffer)
lc->resume_override = 0;
/* move log to pending list */
- list_del_init(&lc->list);
- list_add(&lc->list, &log_pending_list);
+ dm_list_del(&lc->list);
+ dm_list_add(&log_pending_list, &lc->list);
return 0;
}
}
/* move log to official list */
- list_del_init(&lc->list);
- list_add(&lc->list, &log_list);
+ dm_list_del(&lc->list);
+ dm_list_add(&log_list, &lc->list);
}
return 0;
{
int found = 0;
struct mark_entry *m;
- struct list_head *p, *n;
- list_for_each_safe(p, n, &lc->mark_list) {
- /* FIXME: Use proper macros */
- m = (struct mark_entry *)p;
+ dm_list_iterate_items(m, &lc->mark_list)
if (m->region == region) {
found = 1;
if (m->nodeid == who)
return 0;
}
- }
if (!found)
log_clear_bit(lc, lc->clean_bits, region);
m->nodeid = who;
m->region = region;
- list_add_tail(&m->list, &lc->mark_list);
+ dm_list_add(&lc->mark_list, &m->list);
return 0;
}
static int clear_region(struct log_c *lc, uint64_t region, uint32_t who)
{
int other_matches = 0;
- struct mark_entry *m;
- struct list_head *p, *n;
+ struct mark_entry *m, *n;
- list_for_each_safe(p, n, &lc->mark_list) {
- /* FIXME: Use proper macros */
- m = (struct mark_entry *)p;
+ dm_list_iterate_items_safe(m, n, &lc->mark_list)
if (m->region == region) {
if (m->nodeid == who) {
- list_del_init(&m->list);
+ dm_list_del(&m->list);
free(m);
} else
other_matches = 1;
}
- }
/*
* Clear region if:
*/
int log_status(void)
{
- struct list_head *l;
-
- __list_for_each(l, &log_list)
- return 1;
-
- __list_for_each(l, &log_pending_list)
+ if (!dm_list_empty(&log_list) || !dm_list_empty(&log_pending_list))
return 1;
return 0;
void log_debug(void)
{
- struct list_head *l;
struct log_c *lc;
uint64_t r;
int i;
LOG_ERROR("LOG COMPONENT DEBUGGING::");
LOG_ERROR("Official log list:");
LOG_ERROR("Pending log list:");
- __list_for_each(l, &log_pending_list) {
- lc = list_entry(l, struct log_c, list);
+ dm_list_iterate_items(lc, &log_pending_list) {
LOG_ERROR("%s", lc->uuid);
LOG_ERROR("sync_bits:");
print_bits((char *)lc->sync_bits,
lc->bitset_uint32_count * sizeof(*lc->clean_bits), 1);
}
- __list_for_each(l, &log_list) {
- lc = list_entry(l, struct log_c, list);
+ dm_list_iterate_items(lc, &log_list) {
LOG_ERROR("%s", lc->uuid);
LOG_ERROR(" recoverer : %u", lc->recoverer);
LOG_ERROR(" recovering_region: %llu",
print_bits((char *)lc->clean_bits,
lc->bitset_uint32_count * sizeof(*lc->clean_bits), 1);
- lc = list_entry(l, struct log_c, list);
LOG_ERROR("Validating %s::", SHORT_UUID(lc->uuid));
r = find_next_zero_bit(lc->sync_bits, lc->region_count, 0);
LOG_ERROR(" lc->region_count = %llu",
+++ /dev/null
-#ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
-
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1 ((void *) 0x00100100)
-#define LIST_POISON2 ((void *) 0x00200200)
-
-/*
- * Simple doubly linked list implementation.
- *
- * Some of the internal functions ("__xxx") are useful when
- * manipulating whole lists rather than single entries, as
- * sometimes we already know the next/prev entries and we can
- * generate better code by using them directly rather than
- * using the generic single-entry routines.
- */
-
-struct list_head {
- struct list_head *next, *prev;
-};
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
-
-#define INIT_LIST_HEAD(ptr) do { \
- (ptr)->next = (ptr); (ptr)->prev = (ptr); \
-} while (0)
-
-/*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
-{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
-}
-
-/**
- * list_add - add a new entry
- * @new: new entry to be added
- * @head: list head to add it after
- *
- * Insert a new entry after the specified head.
- * This is good for implementing stacks.
- */
-static inline void list_add(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head, head->next);
-}
-
-/**
- * list_add_tail - add a new entry
- * @new: new entry to be added
- * @head: list head to add it before
- *
- * Insert a new entry before the specified head.
- * This is useful for implementing queues.
- */
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head->prev, head);
-}
-
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-/**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is
- * in an undefined state.
- */
-static inline void list_del(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- entry->next = LIST_POISON1;
- entry->prev = LIST_POISON2;
-}
-
-/**
- * list_del_init - deletes entry from list and reinitialize it.
- * @entry: the element to delete from the list.
- */
-static inline void list_del_init(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- INIT_LIST_HEAD(entry);
-}
-
-/**
- * list_move - delete from one list and add as another's head
- * @list: the entry to move
- * @head: the head that will precede our entry
- */
-static inline void list_move(struct list_head *list, struct list_head *head)
-{
- __list_del(list->prev, list->next);
- list_add(list, head);
-}
-
-/**
- * list_move_tail - delete from one list and add as another's tail
- * @list: the entry to move
- * @head: the head that will follow our entry
- */
-static inline void list_move_tail(struct list_head *list,
- struct list_head *head)
-{
- __list_del(list->prev, list->next);
- list_add_tail(list, head);
-}
-
-/**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static inline int list_empty(const struct list_head *head)
-{
- return head->next == head;
-}
-
-/**
- * list_empty_careful - tests whether a list is
- * empty _and_ checks that no other CPU might be
- * in the process of still modifying either member
- *
- * NOTE: using list_empty_careful() without synchronization
- * can only be safe if the only activity that can happen
- * to the list entry is list_del_init(). Eg. it cannot be used
- * if another CPU could re-list_add() it.
- *
- * @head: the list to test.
- */
-static inline int list_empty_careful(const struct list_head *head)
-{
- struct list_head *next = head->next;
- return (next == head) && (next == head->prev);
-}
-
-static inline void __list_splice(struct list_head *list,
- struct list_head *head)
-{
- struct list_head *first = list->next;
- struct list_head *last = list->prev;
- struct list_head *at = head->next;
-
- first->prev = head;
- head->next = first;
-
- last->next = at;
- at->prev = last;
-}
-
-/**
- * list_splice - join two lists
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- */
-static inline void list_splice(struct list_head *list, struct list_head *head)
-{
- if (!list_empty(list))
- __list_splice(list, head);
-}
-
-/**
- * list_splice_init - join two lists and reinitialise the emptied list.
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- *
- * The list at @list is reinitialised
- */
-static inline void list_splice_init(struct list_head *list,
- struct list_head *head)
-{
- if (!list_empty(list)) {
- __list_splice(list, head);
- INIT_LIST_HEAD(list);
- }
-}
-
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-
-/**
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-
-/**
- * list_entry - get the struct for this entry
- * @ptr: the &struct list_head pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
- container_of(ptr, type, member)
-
-/**
- * list_for_each - iterate over a list
- * @pos: the &struct list_head to use as a loop counter.
- * @head: the head for your list.
- */
-#define list_for_each(pos, head) \
- for (pos = (head)->next; prefetch(pos->next), pos != (head); \
- pos = pos->next)
-
-/**
- * __list_for_each - iterate over a list
- * @pos: the &struct list_head to use as a loop counter.
- * @head: the head for your list.
- *
- * This variant differs from list_for_each() in that it's the
- * simplest possible list iteration code, no prefetching is done.
- * Use this for code that knows the list to be very short (empty
- * or 1 entry) most of the time.
- */
-#define __list_for_each(pos, head) \
- for (pos = (head)->next; pos != (head); pos = pos->next)
-
-/**
- * list_for_each_prev - iterate over a list backwards
- * @pos: the &struct list_head to use as a loop counter.
- * @head: the head for your list.
- */
-#define list_for_each_prev(pos, head) \
- for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
- pos = pos->prev)
-
-/**
- * list_for_each_safe - iterate over a list safe against removal of list entry
- * @pos: the &struct list_head to use as a loop counter.
- * @n: another &struct list_head to use as temporary storage
- * @head: the head for your list.
- */
-#define list_for_each_safe(pos, n, head) \
- for (pos = (head)->next, n = pos->next; pos != (head); \
- pos = n, n = pos->next)
-
-/**
- * list_for_each_entry - iterate over list of given type
- * @pos: the type * to use as a loop counter.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- */
-#define list_for_each_entry(pos, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-/**
- * list_for_each_entry_reverse - iterate backwards over list of given type.
- * @pos: the type * to use as a loop counter.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- */
-#define list_for_each_entry_reverse(pos, head, member) \
- for (pos = list_entry((head)->prev, typeof(*pos), member); \
- prefetch(pos->member.prev), &pos->member != (head); \
- pos = list_entry(pos->member.prev, typeof(*pos), member))
-
-/**
- * list_prepare_entry - prepare a pos entry for use as a start point in
- * list_for_each_entry_continue
- * @pos: the type * to use as a start point
- * @head: the head of the list
- * @member: the name of the list_struct within the struct.
- */
-#define list_prepare_entry(pos, head, member) \
- ((pos) ? : list_entry(head, typeof(*pos), member))
-
-/**
- * list_for_each_entry_continue - iterate over list of given type
- * continuing after existing point
- * @pos: the type * to use as a loop counter.
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- */
-#define list_for_each_entry_continue(pos, head, member) \
- for (pos = list_entry(pos->member.next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-/**
- * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
- * @pos: the type * to use as a loop counter.
- * @n: another type * to use as temporary storage
- * @head: the head for your list.
- * @member: the name of the list_struct within the struct.
- */
-#define list_for_each_entry_safe(pos, n, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member), \
- n = list_entry(pos->member.next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = n, n = list_entry(n->member.next, typeof(*n), member))
-
-/*
- * Double linked lists with a single pointer list head.
- * Mostly useful for hash tables where the two pointer list head is
- * too wasteful.
- * You lose the ability to access the tail in O(1).
- */
-
-struct hlist_head {
- struct hlist_node *first;
-};
-
-struct hlist_node {
- struct hlist_node *next, **pprev;
-};
-
-#define HLIST_HEAD_INIT { .first = NULL }
-#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
-#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
-#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL)
-
-static inline int hlist_unhashed(const struct hlist_node *h)
-{
- return !h->pprev;
-}
-
-static inline int hlist_empty(const struct hlist_head *h)
-{
- return !h->first;
-}
-
-static inline void __hlist_del(struct hlist_node *n)
-{
- struct hlist_node *next = n->next;
- struct hlist_node **pprev = n->pprev;
- *pprev = next;
- if (next)
- next->pprev = pprev;
-}
-
-static inline void hlist_del(struct hlist_node *n)
-{
- __hlist_del(n);
- n->next = LIST_POISON1;
- n->pprev = LIST_POISON2;
-}
-
-static inline void hlist_del_init(struct hlist_node *n)
-{
- if (n->pprev) {
- __hlist_del(n);
- INIT_HLIST_NODE(n);
- }
-}
-
-static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
-{
- struct hlist_node *first = h->first;
- n->next = first;
- if (first)
- first->pprev = &n->next;
- h->first = n;
- n->pprev = &h->first;
-}
-
-/* next must be != NULL */
-static inline void hlist_add_before(struct hlist_node *n,
- struct hlist_node *next)
-{
- n->pprev = next->pprev;
- n->next = next;
- next->pprev = &n->next;
- *(n->pprev) = n;
-}
-
-static inline void hlist_add_after(struct hlist_node *n,
- struct hlist_node *next)
-{
- next->next = n->next;
- n->next = next;
- next->pprev = &n->next;
-
- if(next->next)
- next->next->pprev = &next->next;
-}
-
-#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
-
-#define hlist_for_each(pos, head) \
- for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
- pos = pos->next)
-
-#define hlist_for_each_safe(pos, n, head) \
- for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
- pos = n)
-
-/**
- * hlist_for_each_entry - iterate over list of given type
- * @tpos: the type * to use as a loop counter.
- * @pos: the &struct hlist_node to use as a loop counter.
- * @head: the head for your list.
- * @member: the name of the hlist_node within the struct.
- */
-#define hlist_for_each_entry(tpos, pos, head, member) \
- for (pos = (head)->first; \
- pos && ({ prefetch(pos->next); 1;}) && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
- pos = pos->next)
-
-/**
- * hlist_for_each_entry_continue - iterate over a hlist continuing after existing point
- * @tpos: the type * to use as a loop counter.
- * @pos: the &struct hlist_node to use as a loop counter.
- * @member: the name of the hlist_node within the struct.
- */
-#define hlist_for_each_entry_continue(tpos, pos, member) \
- for (pos = (pos)->next; \
- pos && ({ prefetch(pos->next); 1;}) && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
- pos = pos->next)
-
-/**
- * hlist_for_each_entry_from - iterate over a hlist continuing from existing point
- * @tpos: the type * to use as a loop counter.
- * @pos: the &struct hlist_node to use as a loop counter.
- * @member: the name of the hlist_node within the struct.
- */
-#define hlist_for_each_entry_from(tpos, pos, member) \
- for (; pos && ({ prefetch(pos->next); 1;}) && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
- pos = pos->next)
-
-/**
- * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
- * @tpos: the type * to use as a loop counter.
- * @pos: the &struct hlist_node to use as a loop counter.
- * @n: another &struct hlist_node to use as temporary storage
- * @head: the head for your list.
- * @member: the name of the hlist_node within the struct.
- */
-#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
- for (pos = (head)->first; \
- pos && ({ n = pos->next; 1; }) && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
- pos = n)
-
-#endif
#include <stdio.h>
#include <syslog.h>
-#if (BITS_PER_LONG == 64)
-#define PRIu64 "lu"
-#define PRId64 "ld"
-#define PRIo64 "lo"
-#define PRIx64 "lx"
-#define PRIX64 "lX"
-#define SCNu64 "lu"
-#define SCNd64 "ld"
-#define SCNo64 "lo"
-#define SCNx64 "lx"
-#define SCNX64 "lX"
-#else
-#define PRIu64 "Lu"
-#define PRId64 "Ld"
-#define PRIo64 "Lo"
-#define PRIx64 "Lx"
-#define PRIX64 "LX"
-#define SCNu64 "Lu"
-#define SCNd64 "Ld"
-#define SCNo64 "Lo"
-#define SCNx64 "Lx"
-#define SCNX64 "LX"
-#endif
-
/* SHORT_UUID - print last 8 chars of a string */
#define SHORT_UUID(x) (strlen(x) > 8) ? ((x) + (strlen(x) - 8)) : (x)