dmu_traverse.c (177698) | dmu_traverse.c (185029) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 5 unchanged lines hidden (view full) --- 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 5 unchanged lines hidden (view full) --- 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* |
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28#include <sys/zfs_context.h> 29#include <sys/dmu_objset.h> 30#include <sys/dmu_traverse.h> 31#include <sys/dsl_dataset.h> 32#include <sys/dsl_dir.h> 33#include <sys/dsl_pool.h> 34#include <sys/dnode.h> 35#include <sys/spa.h> 36#include <sys/zio.h> 37#include <sys/dmu_impl.h> | 23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28#include <sys/zfs_context.h> 29#include <sys/dmu_objset.h> 30#include <sys/dmu_traverse.h> 31#include <sys/dsl_dataset.h> 32#include <sys/dsl_dir.h> 33#include <sys/dsl_pool.h> 34#include <sys/dnode.h> 35#include <sys/spa.h> 36#include <sys/zio.h> 37#include <sys/dmu_impl.h> |
38#include <sys/zvol.h> |
|
38 39#define BP_SPAN_SHIFT(level, width) ((level) * (width)) 40 41#define BP_EQUAL(b1, b2) \ 42 (DVA_EQUAL(BP_IDENTITY(b1), BP_IDENTITY(b2)) && \ 43 (b1)->blk_birth == (b2)->blk_birth) 44 45/* --- 210 unchanged lines hidden (view full) --- 256 SET_BOOKMARK_LB(zb, level, blkid); 257 258 if (compare_bookmark(zb, &zseg->seg_end, dnp, advance) > 0) 259 return (ERANGE); 260 261 return (EAGAIN); 262} 263 | 39 40#define BP_SPAN_SHIFT(level, width) ((level) * (width)) 41 42#define BP_EQUAL(b1, b2) \ 43 (DVA_EQUAL(BP_IDENTITY(b1), BP_IDENTITY(b2)) && \ 44 (b1)->blk_birth == (b2)->blk_birth) 45 46/* --- 210 unchanged lines hidden (view full) --- 257 SET_BOOKMARK_LB(zb, level, blkid); 258 259 if (compare_bookmark(zb, &zseg->seg_end, dnp, advance) > 0) 260 return (ERANGE); 261 262 return (EAGAIN); 263} 264 |
265/* 266 * The traverse_callback function will call the function specified in th_func. 267 * In the event of an error the callee, specified by th_func, must return 268 * one of the following errors: 269 * 270 * EINTR - Indicates that the callee wants the traversal to 271 * abort immediately. 272 * ERESTART - The callee has acknowledged the error and would 273 * like to continue. 274 */ |
|
264static int 265traverse_callback(traverse_handle_t *th, zseg_t *zseg, traverse_blk_cache_t *bc) 266{ 267 /* 268 * Before we issue the callback, prune against maxtxg. 269 * 270 * We prune against mintxg before we get here because it's a big win. 271 * If a given block was born in txg 37, then we know that the entire --- 326 unchanged lines hidden (view full) --- 598 * traversing a completely static block tree from here on. 599 */ 600 if (th->th_advance & ADVANCE_NOLOCK) { 601 ASSERT(th->th_locked); 602 rw_exit(spa_traverse_rwlock(th->th_spa)); 603 th->th_locked = 0; 604 } 605 | 275static int 276traverse_callback(traverse_handle_t *th, zseg_t *zseg, traverse_blk_cache_t *bc) 277{ 278 /* 279 * Before we issue the callback, prune against maxtxg. 280 * 281 * We prune against mintxg before we get here because it's a big win. 282 * If a given block was born in txg 37, then we know that the entire --- 326 unchanged lines hidden (view full) --- 609 * traversing a completely static block tree from here on. 610 */ 611 if (th->th_advance & ADVANCE_NOLOCK) { 612 ASSERT(th->th_locked); 613 rw_exit(spa_traverse_rwlock(th->th_spa)); 614 th->th_locked = 0; 615 } 616 |
606 rc = traverse_read(th, bc, &dsp->ds_bp, dn); | 617 if (BP_IS_HOLE(&dsp->ds_bp)) 618 rc = ERESTART; 619 else 620 rc = traverse_read(th, bc, &dsp->ds_bp, dn); |
607 608 if (rc != 0) { 609 if (rc == ERESTART) 610 rc = advance_objset(zseg, zb->zb_objset + 1, 611 th->th_advance); 612 return (rc); 613 } 614 --- 102 unchanged lines hidden (view full) --- 717 while ((err = traverse_more(th)) == EAGAIN) 718 continue; 719 720 traverse_fini(th); 721 return (err); 722} 723 724int | 621 622 if (rc != 0) { 623 if (rc == ERESTART) 624 rc = advance_objset(zseg, zb->zb_objset + 1, 625 th->th_advance); 626 return (rc); 627 } 628 --- 102 unchanged lines hidden (view full) --- 731 while ((err = traverse_more(th)) == EAGAIN) 732 continue; 733 734 traverse_fini(th); 735 return (err); 736} 737 738int |
739traverse_zvol(objset_t *os, int advance, blkptr_cb_t func, void *arg) 740{ 741 spa_t *spa = dmu_objset_spa(os); 742 traverse_handle_t *th; 743 int err; 744 745 th = traverse_init(spa, func, arg, advance, ZIO_FLAG_CANFAIL); 746 747 traverse_add_dnode(th, 0, -1ULL, dmu_objset_id(os), ZVOL_OBJ); 748 749 while ((err = traverse_more(th)) == EAGAIN) 750 continue; 751 752 traverse_fini(th); 753 return (err); 754} 755 756int |
|
725traverse_more(traverse_handle_t *th) 726{ 727 zseg_t *zseg = list_head(&th->th_seglist); 728 uint64_t save_txg; /* XXX won't be necessary with real itinerary */ 729 krwlock_t *rw = spa_traverse_rwlock(th->th_spa); 730 blkptr_t *mosbp = spa_get_rootblkptr(th->th_spa); 731 int rc; 732 --- 156 unchanged lines hidden --- | 757traverse_more(traverse_handle_t *th) 758{ 759 zseg_t *zseg = list_head(&th->th_seglist); 760 uint64_t save_txg; /* XXX won't be necessary with real itinerary */ 761 krwlock_t *rw = spa_traverse_rwlock(th->th_spa); 762 blkptr_t *mosbp = spa_get_rootblkptr(th->th_spa); 763 int rc; 764 --- 156 unchanged lines hidden --- |