usr/src/uts/common/fs/zfs/sys/bplist.h
author George Wilson <George.Wilson@Sun.COM>
Tue, 16 Mar 2010 00:09:25 -0700
changeset 11932 197b866a8e44
parent 10922 e2081f502306
child 12470 54258108784b
permissions -rw-r--r--
6925762 zios blocked on mutex, holder blocked on read
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
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
11932
197b866a8e44 6925762 zios blocked on mutex, holder blocked on read
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
    22
 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#ifndef	_SYS_BPLIST_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#define	_SYS_BPLIST_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/txg.h>
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    32
#include <sys/zio.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
typedef struct bplist_phys {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
	/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
	 * This is the bonus buffer for the dead lists.  The object's
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
	 * contents is an array of bpl_entries blkptr_t's, representing
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
	 * a total of bpl_bytes physical space.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
	 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
	uint64_t	bpl_entries;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
	uint64_t	bpl_bytes;
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    47
	uint64_t	bpl_comp;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    48
	uint64_t	bpl_uncomp;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
} bplist_phys_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    51
#define	BPLIST_SIZE_V0	(2 * sizeof (uint64_t))
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    52
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
typedef struct bplist_q {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
	blkptr_t	bpq_blk;
11932
197b866a8e44 6925762 zios blocked on mutex, holder blocked on read
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
    55
	list_node_t	bpq_node;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
} bplist_q_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
typedef struct bplist {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
	kmutex_t	bpl_lock;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
	objset_t	*bpl_mos;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
	uint64_t	bpl_object;
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    62
	uint8_t		bpl_blockshift;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    63
	uint8_t		bpl_bpshift;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    64
	uint8_t		bpl_havecomp;
11932
197b866a8e44 6925762 zios blocked on mutex, holder blocked on read
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
    65
	kmutex_t	bpl_q_lock;
197b866a8e44 6925762 zios blocked on mutex, holder blocked on read
George Wilson <George.Wilson@Sun.COM>
parents: 10922
diff changeset
    66
	list_t		bpl_queue;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
	bplist_phys_t	*bpl_phys;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
	dmu_buf_t	*bpl_dbuf;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
	dmu_buf_t	*bpl_cached_dbuf;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
} bplist_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    72
typedef void bplist_sync_cb_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    73
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    74
extern void bplist_init(bplist_t *bpl);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    75
extern void bplist_fini(bplist_t *bpl);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
extern uint64_t bplist_create(objset_t *mos, int blocksize, dmu_tx_t *tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
extern void bplist_destroy(objset_t *mos, uint64_t object, dmu_tx_t *tx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    78
extern int bplist_open(bplist_t *bpl, objset_t *mos, uint64_t object);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
extern void bplist_close(bplist_t *bpl);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
extern boolean_t bplist_empty(bplist_t *bpl);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
extern int bplist_iterate(bplist_t *bpl, uint64_t *itorp, blkptr_t *bp);
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 2082
diff changeset
    82
extern int bplist_enqueue(bplist_t *bpl, const blkptr_t *bp, dmu_tx_t *tx);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    83
extern void bplist_enqueue_cb(void *bpl, const blkptr_t *bp, dmu_tx_t *tx);
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 2082
diff changeset
    84
extern void bplist_enqueue_deferred(bplist_t *bpl, const blkptr_t *bp);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    85
extern void bplist_sync(bplist_t *bpl, bplist_sync_cb_t *func,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    86
    void *arg, dmu_tx_t *tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
extern void bplist_vacate(bplist_t *bpl, dmu_tx_t *tx);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    88
extern int bplist_space(bplist_t *bpl,
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    89
    uint64_t *usedp, uint64_t *compp, uint64_t *uncompp);
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
    90
extern int bplist_space_birthrange(bplist_t *bpl,
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
    91
    uint64_t mintxg, uint64_t maxtxg, uint64_t *dsizep);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
#endif /* _SYS_BPLIST_H */