usr/src/uts/common/fs/zfs/sys/dmu_traverse.h
author ahrens
Mon, 31 Oct 2005 11:33:35 -0800
changeset 789 b348f31ed315
child 1544 938876158511
permissions -rw-r--r--
PSARC 2002/240 ZFS 6338653 Integrate ZFS PSARC 2004/652 - DKIOCFLUSH 5096886 Write caching disks need mechanism to flush cache to physical media
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     5
 * Common Development and Distribution License, Version 1.0 only
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     6
 * (the "License").  You may not use this file except in compliance
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 * with the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    22
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#ifndef	_SYS_DMU_TRAVERSE_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#define	_SYS_DMU_TRAVERSE_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/zio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#include <sys/dnode.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#include <sys/arc.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
#define	ADVANCE_POST	0		/* post-order traversal */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
#define	ADVANCE_PRE	0x01		/* pre-order traversal */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
#define	ADVANCE_PRUNE	0x02		/* prune by prev snapshot birth time */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
#define	ADVANCE_DATA	0x04		/* read user data blocks */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
#define	ADVANCE_HOLES	0x08		/* visit holes */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
#define	ADVANCE_NOLOCK	0x10		/* Don't grab SPA sync lock */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
#define	ZB_NO_LEVEL	-2
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
#define	ZB_MAXLEVEL	32		/* Next power of 2 >= DN_MAX_LEVELS */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
#define	ZB_MAXBLKID	(1ULL << 62)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
#define	ZB_MAXOBJSET	(1ULL << 62)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
#define	ZB_MAXOBJECT	(1ULL << 62)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
#define	ZB_MOS_CACHE	0
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
#define	ZB_MDN_CACHE	1
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
#define	ZB_DN_CACHE	2
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
#define	ZB_DEPTH	3
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
typedef struct zbookmark {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
	uint64_t	zb_objset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
	uint64_t	zb_object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
	int		zb_level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
	uint64_t	zb_blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
} zbookmark_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
typedef struct zseg {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
	uint64_t	seg_mintxg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
	uint64_t	seg_maxtxg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
	zbookmark_t	seg_start;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
	zbookmark_t	seg_end;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	list_node_t	seg_node;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
} zseg_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
typedef struct traverse_blk_cache {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
	zbookmark_t	bc_bookmark;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	blkptr_t	bc_blkptr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
	void		*bc_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
	dnode_phys_t	*bc_dnode;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	int		bc_errno;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
	int		bc_pad1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
	uint64_t	bc_pad2;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
} traverse_blk_cache_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
typedef int (blkptr_cb_t)(traverse_blk_cache_t *bc, spa_t *spa, void *arg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
struct traverse_handle {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
	spa_t		*th_spa;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
	blkptr_cb_t	*th_func;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
	void		*th_arg;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
	int		th_advance;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
	int		th_zio_flags;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
	list_t		th_seglist;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
	traverse_blk_cache_t th_cache[ZB_DEPTH][ZB_MAXLEVEL];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
	uint64_t	th_hits;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
	uint64_t	th_arc_hits;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
	uint64_t	th_reads;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
	uint64_t	th_callbacks;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
	uint64_t	th_syncs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
	uint64_t	th_restarts;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
	zbookmark_t	th_noread;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
	zbookmark_t	th_lastcb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
int traverse_dsl_dataset(struct dsl_dataset *ds, uint64_t txg_start,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
    int advance, blkptr_cb_t func, void *arg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
traverse_handle_t *traverse_init(spa_t *spa, blkptr_cb_t *func, void *arg,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
    int advance, int zio_flags);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
void traverse_fini(traverse_handle_t *th);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
void traverse_add_dnode(traverse_handle_t *th,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
    uint64_t mintxg, uint64_t maxtxg, uint64_t objset, uint64_t object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
void traverse_add_objset(traverse_handle_t *th,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
    uint64_t mintxg, uint64_t maxtxg, uint64_t objset);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
void traverse_add_pool(traverse_handle_t *th, uint64_t mintxg, uint64_t maxtxg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
int traverse_more(traverse_handle_t *th);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
#endif /* _SYS_DMU_TRAVERSE_H */