-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API to get condensed tree of modified blocks between two txg #6
Changes from 1 commit
1b6fd5b
48cdaaf
1cc6ce4
1e67fc0
8b9cbad
fb2fec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,9 @@ extern void populate_data(char *buf, uint64_t offset, int idx, | |
uint64_t block_size); | ||
extern uint64_t block_size; | ||
|
||
static int del_from_mblktree(avl_tree_t *tree, uint64_t b_offset, | ||
static int del_from_txg_diff_tree(avl_tree_t *tree, uint64_t b_offset, | ||
uint64_t b_len); | ||
static int uzfs_search_mblktree(avl_tree_t *tree, uint64_t offset, | ||
static int uzfs_search_txg_diff_tree(avl_tree_t *tree, uint64_t offset, | ||
uint64_t *len); | ||
|
||
typedef struct wblkinfo { | ||
|
@@ -44,8 +44,13 @@ typedef struct wblkinfo { | |
list_node_t link; | ||
} wblkinfo_t; | ||
|
||
/* | ||
* Delete entry (offset, len) from tree. | ||
* Note : As of now, this API is used in testing code only. To use it in | ||
* library, move this API to library code. | ||
*/ | ||
int | ||
del_from_mblktree(avl_tree_t *tree, uint64_t offset, uint64_t len) | ||
del_from_txg_diff_tree(avl_tree_t *tree, uint64_t offset, uint64_t len) | ||
{ | ||
uint64_t new_offset, new_len, b_end, b_offset, b_len; | ||
uint64_t entry_len, entry_offset; | ||
|
@@ -61,12 +66,20 @@ del_from_mblktree(avl_tree_t *tree, uint64_t offset, uint64_t len) | |
f_entry.len = new_len; | ||
entry = avl_find(tree, &f_entry, &where); | ||
|
||
// found entry whose offset matches with f_entry's offset | ||
if (entry != NULL) { | ||
// entry's len doesn't match with f_entry's len | ||
if (entry->len < new_len) { | ||
err = -1; | ||
goto done; | ||
} | ||
|
||
/* | ||
* entry's length is not lesser than f_entry. | ||
* If entry's len is greater than f_entry, then | ||
* update entry's offset to (f_entry's end) and len to | ||
* entry's len - f_entry's len. | ||
*/ | ||
entry_offset = entry->offset; | ||
entry_len = entry->len; | ||
avl_remove(tree, entry); | ||
|
@@ -82,9 +95,15 @@ del_from_mblktree(avl_tree_t *tree, uint64_t offset, uint64_t len) | |
goto done; | ||
} | ||
|
||
/* | ||
* Search for nearest entry whose offset is lesser than | ||
* f_entry's offset | ||
*/ | ||
b_entry = avl_nearest(tree, where, AVL_BEFORE); | ||
if (b_entry) { | ||
b_end = (b_entry->offset + b_entry->len); | ||
|
||
// b_entry ends before f_entry ends | ||
if (b_end < (new_offset + new_len)) { | ||
err = -1; | ||
goto done; | ||
|
@@ -120,7 +139,7 @@ del_from_mblktree(avl_tree_t *tree, uint64_t offset, uint64_t len) | |
} | ||
|
||
int | ||
uzfs_search_mblktree(avl_tree_t *tree, uint64_t offset, uint64_t *len) | ||
uzfs_search_txg_diff_tree(avl_tree_t *tree, uint64_t offset, uint64_t *len) | ||
{ | ||
uzfs_zvol_blk_phy_t tofind; | ||
avl_index_t where; | ||
|
@@ -138,7 +157,7 @@ uzfs_search_mblktree(avl_tree_t *tree, uint64_t offset, uint64_t *len) | |
} | ||
|
||
void | ||
uzfs_zvol_txg_diff_blk_test(void *arg) | ||
uzfs_txg_diff_verifcation_test(void *arg) | ||
{ | ||
uzfs_test_info_t *test_info = (uzfs_test_info_t *)arg; | ||
avl_tree_t *tree; | ||
|
@@ -148,9 +167,10 @@ uzfs_zvol_txg_diff_blk_test(void *arg) | |
uint64_t blksz = io_block_size, io_num = 0; | ||
void *spa, *zvol; | ||
char *buf; | ||
int diff_txg = 5, count, i = 0; | ||
int max_io, count, i = 0; | ||
list_t wlist; | ||
wblkinfo_t *blk; | ||
wblkinfo_t *blk, *temp_blk; | ||
boolean_t offset_matched; | ||
|
||
setup_unit_test(); | ||
unit_test_create_pool_ds(); | ||
|
@@ -166,16 +186,37 @@ uzfs_zvol_txg_diff_blk_test(void *arg) | |
|
||
while (i++ < test_iterations) { | ||
count = 0; | ||
max_io = MAX(uzfs_random(100), 5); | ||
|
||
txg_wait_synced(spa_get_dsl(spa), 0); | ||
first_txg = spa_last_synced_txg(spa); | ||
|
||
while (count++ < diff_txg) { | ||
while (count++ < max_io) { | ||
io_num++; | ||
blk_offset = uzfs_random(vol_blocks - 16); | ||
/* | ||
* make sure offset is aligned to block size | ||
*/ | ||
offset = ((blk_offset * blksz + block_size) / | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. offset can be just blk_offset * block_size There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, have a test case with less active size (probably for 30K or 50K blocks), so that, collisions/merges of tree can be verified |
||
block_size) * block_size; | ||
|
||
offset_matched = B_FALSE; | ||
temp_blk = list_head(&wlist); | ||
while (temp_blk) { | ||
if (temp_blk->offset == offset) { | ||
offset_matched = B_TRUE; | ||
break; | ||
} | ||
if (temp_blk->offset + temp_blk->len == | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this condition is not required at all |
||
offset) { | ||
offset_matched = B_TRUE; | ||
break; | ||
} | ||
temp_blk = list_next(&wlist, temp_blk); | ||
} | ||
if (offset_matched) | ||
continue; | ||
|
||
populate_data(buf, offset, 0, block_size); | ||
|
||
if (uzfs_write_data(zvol, buf, offset, block_size, | ||
|
@@ -193,15 +234,17 @@ uzfs_zvol_txg_diff_blk_test(void *arg) | |
txg_wait_synced(spa_get_dsl(spa), 0); | ||
last_txg = spa_last_synced_txg(spa); | ||
|
||
uzfs_txg_block_diff(zvol, first_txg, last_txg, (void **)&tree); | ||
uzfs_get_txg_diff_tree(zvol, first_txg, last_txg, | ||
(void **)&tree); | ||
|
||
while ((blk = list_remove_head(&wlist))) { | ||
VERIFY0(del_from_mblktree(tree, blk->offset, blk->len)); | ||
VERIFY0(del_from_txg_diff_tree(tree, blk->offset, | ||
blk->len)); | ||
umem_free(blk, sizeof (*blk)); | ||
blk = NULL; | ||
} | ||
VERIFY0(avl_numnodes(tree)); | ||
printf("%s pass:%d\n", test_info->name, i); | ||
printf("%s : pass:%d\n", test_info->name, i); | ||
umem_free(tree, sizeof (*tree)); | ||
tree = NULL; | ||
} | ||
|
@@ -219,7 +262,7 @@ check_tree(avl_tree_t *tree, uint64_t offset, uint64_t len, uint64_t exp_off, | |
int ret; | ||
uint64_t len1 = 0; | ||
|
||
ret = uzfs_search_mblktree(tree, exp_off, &len1); | ||
ret = uzfs_search_txg_diff_tree(tree, exp_off, &len1); | ||
|
||
VERIFY(ret == exp_ret); | ||
|
||
|
@@ -231,26 +274,26 @@ static void | |
add_and_check_tree(avl_tree_t *tree, uint64_t offset, uint64_t len, | ||
uint64_t exp_off, uint64_t exp_len, int exp_ret) | ||
{ | ||
add_to_mblktree(tree, offset, len); | ||
add_to_txg_diff_tree(tree, offset, len); | ||
check_tree(tree, offset, len, exp_off, exp_len, exp_ret); | ||
} | ||
|
||
static void | ||
delete_and_check_tree(avl_tree_t *tree, uint64_t offset, uint64_t len, | ||
uint64_t exp_off, uint64_t exp_len, int exp_ret) | ||
{ | ||
del_from_mblktree(tree, offset, len); | ||
del_from_txg_diff_tree(tree, offset, len); | ||
check_tree(tree, offset, len, exp_off, exp_len, exp_ret); | ||
} | ||
|
||
void | ||
uzfs_zvol_txg_mtree_test(void *arg) | ||
uzfs_txg_diff_tree_test(void *arg) | ||
{ | ||
uzfs_test_info_t *test_info = (uzfs_test_info_t *)arg; | ||
avl_tree_t *tree; | ||
uint64_t blksz = io_block_size; | ||
|
||
uzfs_create_mblktree((void **)&tree); | ||
uzfs_create_txg_diff_tree((void **)&tree); | ||
|
||
add_and_check_tree(tree, 100, 50, 100, 50, 1); | ||
add_and_check_tree(tree, 150, 50, 100, 100, 1); | ||
|
@@ -315,6 +358,6 @@ uzfs_zvol_txg_mtree_test(void *arg) | |
add_and_check_tree(tree, 130, 140, 130, 140, 0); | ||
add_and_check_tree(tree, 130, 140, 120, 150, 0); | ||
|
||
uzfs_destroy_mblktree((void *)tree); | ||
uzfs_destroy_txg_diff_tree((void *)tree); | ||
printf("%s pass\n", test_info->name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it as 10K..