FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 /* 00022 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 00023 * Copyright (c) 2012 by Delphix. All rights reserved. 00024 */ 00025 00026 #ifndef _SYS_BPOBJ_H 00027 #define _SYS_BPOBJ_H 00028 00029 #include <sys/dmu.h> 00030 #include <sys/spa.h> 00031 #include <sys/txg.h> 00032 #include <sys/zio.h> 00033 #include <sys/zfs_context.h> 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 typedef struct bpobj_phys { 00040 /* 00041 * This is the bonus buffer for the dead lists. The object's 00042 * contents is an array of bpo_entries blkptr_t's, representing 00043 * a total of bpo_bytes physical space. 00044 */ 00045 uint64_t bpo_num_blkptrs; 00046 uint64_t bpo_bytes; 00047 uint64_t bpo_comp; 00048 uint64_t bpo_uncomp; 00049 uint64_t bpo_subobjs; 00050 uint64_t bpo_num_subobjs; 00051 } bpobj_phys_t; 00052 00053 #define BPOBJ_SIZE_V0 (2 * sizeof (uint64_t)) 00054 #define BPOBJ_SIZE_V1 (4 * sizeof (uint64_t)) 00055 00056 typedef struct bpobj { 00057 kmutex_t bpo_lock; 00058 objset_t *bpo_os; 00059 uint64_t bpo_object; 00060 int bpo_epb; 00061 uint8_t bpo_havecomp; 00062 uint8_t bpo_havesubobj; 00063 bpobj_phys_t *bpo_phys; 00064 dmu_buf_t *bpo_dbuf; 00065 dmu_buf_t *bpo_cached_dbuf; 00066 } bpobj_t; 00067 00068 typedef int bpobj_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx); 00069 00070 uint64_t bpobj_alloc(objset_t *mos, int blocksize, dmu_tx_t *tx); 00071 uint64_t bpobj_alloc_empty(objset_t *os, int blocksize, dmu_tx_t *tx); 00072 void bpobj_free(objset_t *os, uint64_t obj, dmu_tx_t *tx); 00073 void bpobj_decr_empty(objset_t *os, dmu_tx_t *tx); 00074 00075 int bpobj_open(bpobj_t *bpo, objset_t *mos, uint64_t object); 00076 void bpobj_close(bpobj_t *bpo); 00077 00078 int bpobj_iterate(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx); 00079 int bpobj_iterate_nofree(bpobj_t *bpo, bpobj_itor_t func, void *, dmu_tx_t *); 00080 int bpobj_iterate_dbg(bpobj_t *bpo, uint64_t *itorp, blkptr_t *bp); 00081 00082 void bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx); 00083 void bpobj_enqueue(bpobj_t *bpo, const blkptr_t *bp, dmu_tx_t *tx); 00084 00085 int bpobj_space(bpobj_t *bpo, 00086 uint64_t *usedp, uint64_t *compp, uint64_t *uncompp); 00087 int bpobj_space_range(bpobj_t *bpo, uint64_t mintxg, uint64_t maxtxg, 00088 uint64_t *usedp, uint64_t *compp, uint64_t *uncompp); 00089 00090 #ifdef __cplusplus 00091 } 00092 #endif 00093 00094 #endif /* _SYS_BPOBJ_H */