106 boolean_t
107 bptree_is_empty(objset_t *os, uint64_t obj)
108 {
109 dmu_buf_t *db;
110 bptree_phys_t *bt;
111 boolean_t rv;
112
113 VERIFY0(dmu_bonus_hold(os, obj, FTAG, &db));
114 bt = db->db_data;
115 rv = (bt->bt_begin == bt->bt_end);
116 dmu_buf_rele(db, FTAG);
117 return (rv);
118 }
119
120 void
121 bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
122 uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx)
123 {
124 dmu_buf_t *db;
125 bptree_phys_t *bt;
126 bptree_entry_phys_t bte = { 0 };
127
128 /*
129 * bptree objects are in the pool mos, therefore they can only be
130 * modified in syncing context. Furthermore, this is only modified
131 * by the sync thread, so no locking is necessary.
132 */
133 ASSERT(dmu_tx_is_syncing(tx));
134
135 VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
136 bt = db->db_data;
137
138 bte.be_birth_txg = birth_txg;
139 bte.be_bp = *bp;
140 dmu_write(os, obj, bt->bt_end * sizeof (bte), sizeof (bte), &bte, tx);
141
142 dmu_buf_will_dirty(db, tx);
143 bt->bt_end++;
144 bt->bt_bytes += bytes;
145 bt->bt_comp += comp;
146 bt->bt_uncomp += uncomp;
|
106 boolean_t
107 bptree_is_empty(objset_t *os, uint64_t obj)
108 {
109 dmu_buf_t *db;
110 bptree_phys_t *bt;
111 boolean_t rv;
112
113 VERIFY0(dmu_bonus_hold(os, obj, FTAG, &db));
114 bt = db->db_data;
115 rv = (bt->bt_begin == bt->bt_end);
116 dmu_buf_rele(db, FTAG);
117 return (rv);
118 }
119
120 void
121 bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
122 uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx)
123 {
124 dmu_buf_t *db;
125 bptree_phys_t *bt;
126 bptree_entry_phys_t bte = { .be_birth_txg = 0 };
127
128 /*
129 * bptree objects are in the pool mos, therefore they can only be
130 * modified in syncing context. Furthermore, this is only modified
131 * by the sync thread, so no locking is necessary.
132 */
133 ASSERT(dmu_tx_is_syncing(tx));
134
135 VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
136 bt = db->db_data;
137
138 bte.be_birth_txg = birth_txg;
139 bte.be_bp = *bp;
140 dmu_write(os, obj, bt->bt_end * sizeof (bte), sizeof (bte), &bte, tx);
141
142 dmu_buf_will_dirty(db, tx);
143 bt->bt_end++;
144 bt->bt_bytes += bytes;
145 bt->bt_comp += comp;
146 bt->bt_uncomp += uncomp;
|