Print this page
4045 zfs write throttle & i/o scheduler performance work
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>


   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
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  25  */
  26 
  27 #ifndef _SYS_DBUF_H
  28 #define _SYS_DBUF_H
  29 
  30 #include <sys/dmu.h>
  31 #include <sys/spa.h>
  32 #include <sys/txg.h>
  33 #include <sys/zio.h>
  34 #include <sys/arc.h>
  35 #include <sys/zfs_context.h>
  36 #include <sys/refcount.h>
  37 #include <sys/zrlock.h>
  38 
  39 #ifdef  __cplusplus
  40 extern "C" {
  41 #endif
  42 
  43 #define IN_DMU_SYNC 2


  95 
  96 typedef struct dbuf_dirty_record {
  97         /* link on our parents dirty list */
  98         list_node_t dr_dirty_node;
  99 
 100         /* transaction group this data will sync in */
 101         uint64_t dr_txg;
 102 
 103         /* zio of outstanding write IO */
 104         zio_t *dr_zio;
 105 
 106         /* pointer back to our dbuf */
 107         struct dmu_buf_impl *dr_dbuf;
 108 
 109         /* pointer to next dirty record */
 110         struct dbuf_dirty_record *dr_next;
 111 
 112         /* pointer to parent dirty record */
 113         struct dbuf_dirty_record *dr_parent;
 114 



 115         union dirty_types {
 116                 struct dirty_indirect {
 117 
 118                         /* protect access to list */
 119                         kmutex_t dr_mtx;
 120 
 121                         /* Our list of dirty children */
 122                         list_t dr_children;
 123                 } di;
 124                 struct dirty_leaf {
 125 
 126                         /*
 127                          * dr_data is set when we dirty the buffer
 128                          * so that we can retain the pointer even if it
 129                          * gets COW'd in a subsequent transaction group.
 130                          */
 131                         arc_buf_t *dr_data;
 132                         blkptr_t dr_overridden_by;
 133                         override_states_t dr_override_state;
 134                         uint8_t dr_copies;


 237         dmu_buf_impl_t **hash_table;
 238         kmutex_t hash_mutexes[DBUF_MUTEXES];
 239 } dbuf_hash_table_t;
 240 
 241 
 242 uint64_t dbuf_whichblock(struct dnode *di, uint64_t offset);
 243 
 244 dmu_buf_impl_t *dbuf_create_tlib(struct dnode *dn, char *data);
 245 void dbuf_create_bonus(struct dnode *dn);
 246 int dbuf_spill_set_blksz(dmu_buf_t *db, uint64_t blksz, dmu_tx_t *tx);
 247 void dbuf_spill_hold(struct dnode *dn, dmu_buf_impl_t **dbp, void *tag);
 248 
 249 void dbuf_rm_spill(struct dnode *dn, dmu_tx_t *tx);
 250 
 251 dmu_buf_impl_t *dbuf_hold(struct dnode *dn, uint64_t blkid, void *tag);
 252 dmu_buf_impl_t *dbuf_hold_level(struct dnode *dn, int level, uint64_t blkid,
 253     void *tag);
 254 int dbuf_hold_impl(struct dnode *dn, uint8_t level, uint64_t blkid, int create,
 255     void *tag, dmu_buf_impl_t **dbp);
 256 
 257 void dbuf_prefetch(struct dnode *dn, uint64_t blkid);
 258 
 259 void dbuf_add_ref(dmu_buf_impl_t *db, void *tag);
 260 uint64_t dbuf_refcount(dmu_buf_impl_t *db);
 261 
 262 void dbuf_rele(dmu_buf_impl_t *db, void *tag);
 263 void dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag);
 264 
 265 dmu_buf_impl_t *dbuf_find(struct dnode *dn, uint8_t level, uint64_t blkid);
 266 
 267 int dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags);
 268 void dbuf_will_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
 269 void dbuf_fill_done(dmu_buf_impl_t *db, dmu_tx_t *tx);
 270 void dmu_buf_will_not_fill(dmu_buf_t *db, dmu_tx_t *tx);
 271 void dmu_buf_will_fill(dmu_buf_t *db, dmu_tx_t *tx);
 272 void dmu_buf_fill_done(dmu_buf_t *db, dmu_tx_t *tx);
 273 void dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx);
 274 dbuf_dirty_record_t *dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
 275 arc_buf_t *dbuf_loan_arcbuf(dmu_buf_impl_t *db);
 276 
 277 void dbuf_clear(dmu_buf_impl_t *db);




   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
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013 by Delphix. All rights reserved.
  24  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  25  */
  26 
  27 #ifndef _SYS_DBUF_H
  28 #define _SYS_DBUF_H
  29 
  30 #include <sys/dmu.h>
  31 #include <sys/spa.h>
  32 #include <sys/txg.h>
  33 #include <sys/zio.h>
  34 #include <sys/arc.h>
  35 #include <sys/zfs_context.h>
  36 #include <sys/refcount.h>
  37 #include <sys/zrlock.h>
  38 
  39 #ifdef  __cplusplus
  40 extern "C" {
  41 #endif
  42 
  43 #define IN_DMU_SYNC 2


  95 
  96 typedef struct dbuf_dirty_record {
  97         /* link on our parents dirty list */
  98         list_node_t dr_dirty_node;
  99 
 100         /* transaction group this data will sync in */
 101         uint64_t dr_txg;
 102 
 103         /* zio of outstanding write IO */
 104         zio_t *dr_zio;
 105 
 106         /* pointer back to our dbuf */
 107         struct dmu_buf_impl *dr_dbuf;
 108 
 109         /* pointer to next dirty record */
 110         struct dbuf_dirty_record *dr_next;
 111 
 112         /* pointer to parent dirty record */
 113         struct dbuf_dirty_record *dr_parent;
 114 
 115         /* How much space was changed to dsl_pool_dirty_space() for this? */
 116         unsigned int dr_accounted;
 117 
 118         union dirty_types {
 119                 struct dirty_indirect {
 120 
 121                         /* protect access to list */
 122                         kmutex_t dr_mtx;
 123 
 124                         /* Our list of dirty children */
 125                         list_t dr_children;
 126                 } di;
 127                 struct dirty_leaf {
 128 
 129                         /*
 130                          * dr_data is set when we dirty the buffer
 131                          * so that we can retain the pointer even if it
 132                          * gets COW'd in a subsequent transaction group.
 133                          */
 134                         arc_buf_t *dr_data;
 135                         blkptr_t dr_overridden_by;
 136                         override_states_t dr_override_state;
 137                         uint8_t dr_copies;


 240         dmu_buf_impl_t **hash_table;
 241         kmutex_t hash_mutexes[DBUF_MUTEXES];
 242 } dbuf_hash_table_t;
 243 
 244 
 245 uint64_t dbuf_whichblock(struct dnode *di, uint64_t offset);
 246 
 247 dmu_buf_impl_t *dbuf_create_tlib(struct dnode *dn, char *data);
 248 void dbuf_create_bonus(struct dnode *dn);
 249 int dbuf_spill_set_blksz(dmu_buf_t *db, uint64_t blksz, dmu_tx_t *tx);
 250 void dbuf_spill_hold(struct dnode *dn, dmu_buf_impl_t **dbp, void *tag);
 251 
 252 void dbuf_rm_spill(struct dnode *dn, dmu_tx_t *tx);
 253 
 254 dmu_buf_impl_t *dbuf_hold(struct dnode *dn, uint64_t blkid, void *tag);
 255 dmu_buf_impl_t *dbuf_hold_level(struct dnode *dn, int level, uint64_t blkid,
 256     void *tag);
 257 int dbuf_hold_impl(struct dnode *dn, uint8_t level, uint64_t blkid, int create,
 258     void *tag, dmu_buf_impl_t **dbp);
 259 
 260 void dbuf_prefetch(struct dnode *dn, uint64_t blkid, zio_priority_t prio);
 261 
 262 void dbuf_add_ref(dmu_buf_impl_t *db, void *tag);
 263 uint64_t dbuf_refcount(dmu_buf_impl_t *db);
 264 
 265 void dbuf_rele(dmu_buf_impl_t *db, void *tag);
 266 void dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag);
 267 
 268 dmu_buf_impl_t *dbuf_find(struct dnode *dn, uint8_t level, uint64_t blkid);
 269 
 270 int dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags);
 271 void dbuf_will_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
 272 void dbuf_fill_done(dmu_buf_impl_t *db, dmu_tx_t *tx);
 273 void dmu_buf_will_not_fill(dmu_buf_t *db, dmu_tx_t *tx);
 274 void dmu_buf_will_fill(dmu_buf_t *db, dmu_tx_t *tx);
 275 void dmu_buf_fill_done(dmu_buf_t *db, dmu_tx_t *tx);
 276 void dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx);
 277 dbuf_dirty_record_t *dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
 278 arc_buf_t *dbuf_loan_arcbuf(dmu_buf_impl_t *db);
 279 
 280 void dbuf_clear(dmu_buf_impl_t *db);