usr/src/uts/common/fs/zfs/dbuf.c
changeset 10298 a0d52501437c
parent 9653 a70048a304d1
child 10922 e2081f502306
equal deleted inserted replaced
10297:614c29db4bc4 10298:a0d52501437c
   107 
   107 
   108 dmu_buf_impl_t *
   108 dmu_buf_impl_t *
   109 dbuf_find(dnode_t *dn, uint8_t level, uint64_t blkid)
   109 dbuf_find(dnode_t *dn, uint8_t level, uint64_t blkid)
   110 {
   110 {
   111 	dbuf_hash_table_t *h = &dbuf_hash_table;
   111 	dbuf_hash_table_t *h = &dbuf_hash_table;
   112 	objset_impl_t *os = dn->dn_objset;
   112 	objset_t *os = dn->dn_objset;
   113 	uint64_t obj = dn->dn_object;
   113 	uint64_t obj = dn->dn_object;
   114 	uint64_t hv = DBUF_HASH(os, obj, level, blkid);
   114 	uint64_t hv = DBUF_HASH(os, obj, level, blkid);
   115 	uint64_t idx = hv & h->hash_table_mask;
   115 	uint64_t idx = hv & h->hash_table_mask;
   116 	dmu_buf_impl_t *db;
   116 	dmu_buf_impl_t *db;
   117 
   117 
   138  */
   138  */
   139 static dmu_buf_impl_t *
   139 static dmu_buf_impl_t *
   140 dbuf_hash_insert(dmu_buf_impl_t *db)
   140 dbuf_hash_insert(dmu_buf_impl_t *db)
   141 {
   141 {
   142 	dbuf_hash_table_t *h = &dbuf_hash_table;
   142 	dbuf_hash_table_t *h = &dbuf_hash_table;
   143 	objset_impl_t *os = db->db_objset;
   143 	objset_t *os = db->db_objset;
   144 	uint64_t obj = db->db.db_object;
   144 	uint64_t obj = db->db.db_object;
   145 	int level = db->db_level;
   145 	int level = db->db_level;
   146 	uint64_t blkid = db->db_blkid;
   146 	uint64_t blkid = db->db_blkid;
   147 	uint64_t hv = DBUF_HASH(os, obj, level, blkid);
   147 	uint64_t hv = DBUF_HASH(os, obj, level, blkid);
   148 	uint64_t idx = hv & h->hash_table_mask;
   148 	uint64_t idx = hv & h->hash_table_mask;
   892 
   892 
   893 dbuf_dirty_record_t *
   893 dbuf_dirty_record_t *
   894 dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
   894 dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
   895 {
   895 {
   896 	dnode_t *dn = db->db_dnode;
   896 	dnode_t *dn = db->db_dnode;
   897 	objset_impl_t *os = dn->dn_objset;
   897 	objset_t *os = dn->dn_objset;
   898 	dbuf_dirty_record_t **drp, *dr;
   898 	dbuf_dirty_record_t **drp, *dr;
   899 	int drop_struct_lock = FALSE;
   899 	int drop_struct_lock = FALSE;
   900 	boolean_t do_free_accounting = B_FALSE;
   900 	boolean_t do_free_accounting = B_FALSE;
   901 	int txgoff = tx->tx_txg & TXG_MASK;
   901 	int txgoff = tx->tx_txg & TXG_MASK;
   902 
   902 
  1486 
  1486 
  1487 static dmu_buf_impl_t *
  1487 static dmu_buf_impl_t *
  1488 dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
  1488 dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
  1489     dmu_buf_impl_t *parent, blkptr_t *blkptr)
  1489     dmu_buf_impl_t *parent, blkptr_t *blkptr)
  1490 {
  1490 {
  1491 	objset_impl_t *os = dn->dn_objset;
  1491 	objset_t *os = dn->dn_objset;
  1492 	dmu_buf_impl_t *db, *odb;
  1492 	dmu_buf_impl_t *db, *odb;
  1493 
  1493 
  1494 	ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
  1494 	ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
  1495 	ASSERT(dn->dn_type != DMU_OT_NONE);
  1495 	ASSERT(dn->dn_type != DMU_OT_NONE);
  1496 
  1496 
  2009 dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
  2009 dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
  2010 {
  2010 {
  2011 	arc_buf_t **datap = &dr->dt.dl.dr_data;
  2011 	arc_buf_t **datap = &dr->dt.dl.dr_data;
  2012 	dmu_buf_impl_t *db = dr->dr_dbuf;
  2012 	dmu_buf_impl_t *db = dr->dr_dbuf;
  2013 	dnode_t *dn = db->db_dnode;
  2013 	dnode_t *dn = db->db_dnode;
  2014 	objset_impl_t *os = dn->dn_objset;
  2014 	objset_t *os = dn->dn_objset;
  2015 	uint64_t txg = tx->tx_txg;
  2015 	uint64_t txg = tx->tx_txg;
  2016 
  2016 
  2017 	ASSERT(dmu_tx_is_syncing(tx));
  2017 	ASSERT(dmu_tx_is_syncing(tx));
  2018 
  2018 
  2019 	dprintf_dbuf_bp(db, db->db_blkptr, "blkptr=%p", db->db_blkptr);
  2019 	dprintf_dbuf_bp(db, db->db_blkptr, "blkptr=%p", db->db_blkptr);
  2180 static void
  2180 static void
  2181 dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx)
  2181 dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx)
  2182 {
  2182 {
  2183 	dmu_buf_impl_t *db = dr->dr_dbuf;
  2183 	dmu_buf_impl_t *db = dr->dr_dbuf;
  2184 	dnode_t *dn = db->db_dnode;
  2184 	dnode_t *dn = db->db_dnode;
  2185 	objset_impl_t *os = dn->dn_objset;
  2185 	objset_t *os = dn->dn_objset;
  2186 	dmu_buf_impl_t *parent = db->db_parent;
  2186 	dmu_buf_impl_t *parent = db->db_parent;
  2187 	uint64_t txg = tx->tx_txg;
  2187 	uint64_t txg = tx->tx_txg;
  2188 	zbookmark_t zb;
  2188 	zbookmark_t zb;
  2189 	writeprops_t wp = { 0 };
  2189 	writeprops_t wp = { 0 };
  2190 	zio_t *zio;
  2190 	zio_t *zio;
  2277 static void
  2277 static void
  2278 dbuf_write_ready(zio_t *zio, arc_buf_t *buf, void *vdb)
  2278 dbuf_write_ready(zio_t *zio, arc_buf_t *buf, void *vdb)
  2279 {
  2279 {
  2280 	dmu_buf_impl_t *db = vdb;
  2280 	dmu_buf_impl_t *db = vdb;
  2281 	dnode_t *dn = db->db_dnode;
  2281 	dnode_t *dn = db->db_dnode;
  2282 	objset_impl_t *os = dn->dn_objset;
  2282 	objset_t *os = dn->dn_objset;
  2283 	blkptr_t *bp = zio->io_bp;
  2283 	blkptr_t *bp = zio->io_bp;
  2284 	blkptr_t *bp_orig = &zio->io_bp_orig;
  2284 	blkptr_t *bp_orig = &zio->io_bp_orig;
  2285 	uint64_t fill = 0;
  2285 	uint64_t fill = 0;
  2286 	int old_size, new_size, i;
  2286 	int old_size, new_size, i;
  2287 
  2287