X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fit_test.c;h=7a56b4dfbeaa1e95326e8e12a376bd2d8b2d3229;hb=835335a244f30c44c5f44d3bcc32570016b3bc01;hp=76515d5cdc05b1d8dde0b32677d72e803a85219e;hpb=70e80ade90af09300396706b8910e196a7928520;p=fs%2Flustre-release.git diff --git a/lustre/tests/it_test.c b/lustre/tests/it_test.c index 76515d5..7a56b4d 100644 --- a/lustre/tests/it_test.c +++ b/lustre/tests/it_test.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -16,17 +14,13 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -39,13 +33,20 @@ * * Author: jay */ - +#include +#include +#include #include #include +#include #include #include +#include + +#include + +#define EXPORT_SYMBOL(s) -#include #include <../ldlm/interval_tree.c> #define dprintf(fmt, args...) //printf(fmt, ##args) @@ -55,19 +56,16 @@ abort(); \ } while(0) -#define __F(ext) (ext)->start, (ext)->end -#define __S "["LPX64":"LPX64"]" - #define ALIGN_SIZE 4096 #define ALIGN_MASK (~(ALIGN_SIZE - 1)) static struct it_node { struct interval_node node; - struct list_head list; + struct list_head list; int hit, valid; } *it_array; static int it_count; -static CFS_LIST_HEAD(header); +static struct list_head header = LIST_HEAD_INIT(header); static unsigned long max_count = ULONG_MAX & ALIGN_MASK; static int have_wide_lock = 0; @@ -84,16 +82,16 @@ static enum interval_iter cb(struct interval_node *n, void *args) static int count = 1; if (node->hit == 1) { - dprintf("NODE "__S" has ever been accessed\n", - __F(&n->in_extent)); + error("A duplicate node [%#jx:%#jx] access found\n", + (uintmax_t)n->in_extent.start, + (uintmax_t)n->in_extent.end); return INTERVAL_ITER_CONT; - error("duplicate node accessing found\n"); - return INTERVAL_ITER_STOP; } - + if (node->valid == 0) { - error("A deleted node "__S" being accessed\n", - __F(&n->in_extent)); + error("A deleted node [%#jx:%#jx] being accessed\n", + (uintmax_t)n->in_extent.start, + (uintmax_t)n->in_extent.end); return INTERVAL_ITER_STOP; } @@ -101,7 +99,8 @@ static enum interval_iter cb(struct interval_node *n, void *args) dprintf("\n"); count = 1; } - dprintf(""__S" ", __F(&n->in_extent)); + dprintf("[%#jx:%#jx] ", (uintmax_t)n->in_extent.start, + (uintmax_t)n->in_extent.end); fflush(stdout); node->hit = 1; @@ -122,31 +121,33 @@ static int it_test_search(struct interval_node *root) if (ext.end > max_count) ext.end = max_count; - dprintf("\n\nSearching the node overlapped "__S" ..\n", - __F(&ext)); + dprintf("\n\nSearching the node overlapped [%#jx:%#jx] ..\n", + (uintmax_t)ext.start, (uintmax_t)ext.end); interval_search(root, &ext, cb, NULL); dprintf("\nverifing ..."); - + /* verify */ for (i = 0; i < it_count; i++) { n = &it_array[i]; if (n->valid == 0) continue; - if (extent_overlapped(&ext, &n->node.in_extent) && + if (extent_overlapped(&ext, &n->node.in_extent) && n->hit == 0) - error("node "__S" overlaps" __S"," - "but never to be hit.\n", - __F(&n->node.in_extent), - __F(&ext)); + error("node [%#jx:%#jx] overlaps [%#jx:%#jx]," + "but never to be hit.\n", + (uintmax_t)n->node.in_extent.start, + (uintmax_t)n->node.in_extent.end, + (uintmax_t)ext.start, (uintmax_t)ext.end); - if (!extent_overlapped(&ext, &n->node.in_extent) && + if (!extent_overlapped(&ext, &n->node.in_extent) && n->hit) - error("node "__S" overlaps" __S", but hit.\n", - __F(&n->node.in_extent), - __F(&ext)); + error("node [%#jx:%#jx] overlaps [%#jx:%#jx], but hit.\n", + (uintmax_t)n->node.in_extent.start, + (uintmax_t)n->node.in_extent.end, + (uintmax_t)ext.start, (uintmax_t)ext.end); } if (err) error("search error\n"); dprintf("ok.\n"); @@ -168,11 +169,12 @@ static int it_test_iterate(struct interval_node *root) for (i = 0; i < it_count; i++) { if (it_array[i].valid == 0) continue; - if (it_array[i].hit == 0) - error("Node "__S" is not accessed\n", - __F(&it_array[i].node.in_extent)); - } - + if (it_array[i].hit == 0) { + error("Node [%#jx:%#jx] is not accessed\n", + (uintmax_t)it_array[i].node.in_extent.start, + (uintmax_t)it_array[i].node.in_extent.end); + } + } return 0; } @@ -206,11 +208,14 @@ static int it_test_find(struct interval_node *root) continue; ext = &it_array[idx].node.in_extent; - dprintf("Try to find "__S"\n", __F(ext)); - if (!interval_find(root, ext)) - error("interval_find, try to find "__S"\n", __F(ext)); - } - return 0; + dprintf("Try to find [%#jx:%#jx]\n", (uintmax_t)ext->start, + (uintmax_t)ext->end); + if (!interval_find(root, ext)) { + error("interval_find, try to find [%#jx:%#jx]\n", + (uintmax_t)ext->start, (uintmax_t)ext->end); + } + } + return 0; } /* sanity test is tightly coupled with implementation, so when you changed @@ -230,7 +235,7 @@ static enum interval_iter sanity_cb(struct interval_node *node, void *args) if (tmp->in_max_high > max_high) { dprintf("max high sanity check, max_high is %llu," - "child max_high: %llu"__S"\n", + "child max_high: %llu[%#jx:%#jx]\n", max_high, tmp->in_max_high, __F(&tmp->in_extent)); goto err; @@ -245,15 +250,16 @@ static enum interval_iter sanity_cb(struct interval_node *node, void *args) } if (!has) { - int count = 1; + int count; err: - dprintf("node"__S":%llu Child list:\n", + count = 1; + dprintf("node[%#jx:%#jx]:%llu Child list:\n", node->in_extent.start, node->in_extent.end, node->in_max_high); interval_for_each(tmp, node) { - dprintf(""__S":%llu ", + dprintf("[%#jx:%#jx]:%llu ", __F(&tmp->in_extent), tmp->in_max_high); if (count++ == 8) { @@ -284,7 +290,7 @@ err: } if (nr) error("wrong tree, unbalanced!\n"); - + return 0; } @@ -312,15 +318,20 @@ static int it_test_search_hole(struct interval_node *root) ext2 = ext; interval_expand(root, &ext, NULL); - dprintf("Extending "__S" to .."__S"\n", __F(&ext2), __F(&ext)); + dprintf("Extending [%#jx:%#jx] to ..[%#jx:%#jx]\n", + (uintmax_t)ext2.start, (uintmax_t)ext2.end, + (uintmax_t)ext.start, (uintmax_t)ext.end); for (i = 0; i < it_count; i++) { n = &it_array[i]; if (n->valid == 0) continue; if (extent_overlapped(&ext, &n->node.in_extent)) { - error("Extending "__S" to .."__S" overlaps node"__S"\n", - __F(&ext2), __F(&ext), __F(&n->node.in_extent)); + error("Extending [%#jx:%#jx] to ..[%#jx:%#jx] overlaps node[%#jx:%#jx]\n", + (uintmax_t)ext2.start, (uintmax_t)ext2.end, + (uintmax_t)ext.start, (uintmax_t)ext.end, + (uintmax_t)n->node.in_extent.start, + (uintmax_t)n->node.in_extent.end); } if (n->node.in_extent.end < ext2.start) @@ -333,14 +344,15 @@ static int it_test_search_hole(struct interval_node *root) /* only expanding high right now */ if (ext2.start != ext.start || high != ext.end) { ext2.start = low, ext2.end = high; - error("Real extending result:"__S", expected:"__S"\n", - __F(&ext), __F(&ext2)); + error("Real extending result:[%#jx:%#jx], expected:[%#jx:%#jx]\n", + (uintmax_t)ext.start, (uintmax_t)ext.end, + (uintmax_t)ext2.start, (uintmax_t)ext2.end); } return 0; } -static int contended_count = 0; +static int contended_count = 0; #define LOOP_COUNT 1000 static enum interval_iter perf_cb(struct interval_node *n, void *args) { @@ -355,7 +367,7 @@ static inline long tv_delta(struct timeval *s, struct timeval *e) long c = e->tv_sec - s->tv_sec; c *= 1000; c += (long int)(e->tv_usec - s->tv_usec) / 1000; - dprintf("\tStart: %lu:%lu -> End: %lu:%lu\n", + dprintf("\tStart: %lu:%lu -> End: %lu:%lu\n", s->tv_sec, s->tv_usec, e->tv_sec, e->tv_usec); return c; } @@ -367,7 +379,7 @@ static int it_test_performance(struct interval_node *root, unsigned long len) struct it_node *n; struct timeval start, end; unsigned long count; - + ext.start = (random() % (max_count - len)) & ALIGN_MASK; ext.end = (ext.start + len) & ALIGN_MASK; if (have_wide_lock) { @@ -375,12 +387,13 @@ static int it_test_performance(struct interval_node *root, unsigned long len) ext.end = max_count; } - dprintf("Extent search"__S"\n", __F(&ext)); + dprintf("Extent search[%#jx:%#jx]\n", (uintmax_t)ext.start, + (uintmax_t)ext.end); /* list */ contended_count = 0; gettimeofday(&start, NULL); - list_for_each_entry(n, &header, list) { + list_for_each_entry(n, &header, list) { if (extent_overlapped(&ext, &n->node.in_extent)) { count = LOOP_COUNT; while (count--); @@ -421,11 +434,12 @@ static struct interval_node *it_test_helper(struct interval_node *root) if (n->valid) { if (!interval_find(root, &n->node.in_extent)) error("Cannot find an existent node\n"); - dprintf("Erasing a node "__S"\n", - __F(&n->node.in_extent)); + dprintf("Erasing a node [%#jx:%#jx]\n", + (uintmax_t)n->node.in_extent.start, + (uintmax_t)n->node.in_extent.end); interval_erase(&n->node, &root); n->valid = 0; - list_del_init(&n->list); + list_del_init(&n->list); } else { __u64 low, high; low = (random() % max_count) & ALIGN_MASK; @@ -435,10 +449,11 @@ static struct interval_node *it_test_helper(struct interval_node *root) interval_set(&n->node, low, high); while (interval_insert(&n->node, &root)) interval_set(&n->node, low, ++high); - dprintf("Adding a node "__S"\n", - __F(&n->node.in_extent)); + dprintf("Adding a node [%#jx:%#jx]\n", + (uintmax_t)n->node.in_extent.start, + (uintmax_t)n->node.in_extent.end); n->valid = 1; - list_add(&n->list, &header); + list_add(&n->list, &header); } } @@ -475,9 +490,9 @@ static struct interval_node *it_test_init(int count) n->hit = 0; n->valid = 1; if (i == 0) - list_add_tail(&n->list, &header); + list_add_tail(&n->list, &header); else - list_add_tail(&n->list, &it_array[rand()%i].list); + list_add_tail(&n->list, &it_array[rand()%i].list); } return root;