Deleted Added
full compact
dsl_deadlist.c (229578) dsl_deadlist.c (243674)
1/*
2 * CDDL HEADER START
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

--- 6 unchanged lines hidden (view full) ---

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) 2010, Oracle and/or its affiliates. All rights reserved.
1/*
2 * CDDL HEADER START
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

--- 6 unchanged lines hidden (view full) ---

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) 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011 by Delphix. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 */
25
26#include <sys/dsl_dataset.h>
27#include <sys/dmu.h>
28#include <sys/refcount.h>
29#include <sys/zap.h>
30#include <sys/zfs_context.h>
31#include <sys/dsl_pool.h>

--- 126 unchanged lines hidden (view full) ---

158 VERIFY3U(0, ==, dmu_object_info(os, dlobj, &doi));
159 if (doi.doi_type == DMU_OT_BPOBJ) {
160 bpobj_free(os, dlobj, tx);
161 return;
162 }
163
164 for (zap_cursor_init(&zc, os, dlobj);
165 zap_cursor_retrieve(&zc, &za) == 0;
24 */
25
26#include <sys/dsl_dataset.h>
27#include <sys/dmu.h>
28#include <sys/refcount.h>
29#include <sys/zap.h>
30#include <sys/zfs_context.h>
31#include <sys/dsl_pool.h>

--- 126 unchanged lines hidden (view full) ---

158 VERIFY3U(0, ==, dmu_object_info(os, dlobj, &doi));
159 if (doi.doi_type == DMU_OT_BPOBJ) {
160 bpobj_free(os, dlobj, tx);
161 return;
162 }
163
164 for (zap_cursor_init(&zc, os, dlobj);
165 zap_cursor_retrieve(&zc, &za) == 0;
166 zap_cursor_advance(&zc))
167 bpobj_free(os, za.za_first_integer, tx);
166 zap_cursor_advance(&zc)) {
167 uint64_t obj = za.za_first_integer;
168 if (obj == dmu_objset_pool(os)->dp_empty_bpobj)
169 bpobj_decr_empty(os, tx);
170 else
171 bpobj_free(os, obj, tx);
172 }
168 zap_cursor_fini(&zc);
169 VERIFY3U(0, ==, dmu_object_free(os, dlobj, tx));
170}
171
173 zap_cursor_fini(&zc);
174 VERIFY3U(0, ==, dmu_object_free(os, dlobj, tx));
175}
176
177static void
178dle_enqueue(dsl_deadlist_t *dl, dsl_deadlist_entry_t *dle,
179 const blkptr_t *bp, dmu_tx_t *tx)
180{
181 if (dle->dle_bpobj.bpo_object ==
182 dmu_objset_pool(dl->dl_os)->dp_empty_bpobj) {
183 uint64_t obj = bpobj_alloc(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
184 bpobj_close(&dle->dle_bpobj);
185 bpobj_decr_empty(dl->dl_os, tx);
186 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
187 VERIFY3U(0, ==, zap_update_int_key(dl->dl_os, dl->dl_object,
188 dle->dle_mintxg, obj, tx));
189 }
190 bpobj_enqueue(&dle->dle_bpobj, bp, tx);
191}
192
193static void
194dle_enqueue_subobj(dsl_deadlist_t *dl, dsl_deadlist_entry_t *dle,
195 uint64_t obj, dmu_tx_t *tx)
196{
197 if (dle->dle_bpobj.bpo_object !=
198 dmu_objset_pool(dl->dl_os)->dp_empty_bpobj) {
199 bpobj_enqueue_subobj(&dle->dle_bpobj, obj, tx);
200 } else {
201 bpobj_close(&dle->dle_bpobj);
202 bpobj_decr_empty(dl->dl_os, tx);
203 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
204 VERIFY3U(0, ==, zap_update_int_key(dl->dl_os, dl->dl_object,
205 dle->dle_mintxg, obj, tx));
206 }
207}
208
172void
173dsl_deadlist_insert(dsl_deadlist_t *dl, const blkptr_t *bp, dmu_tx_t *tx)
174{
175 dsl_deadlist_entry_t dle_tofind;
176 dsl_deadlist_entry_t *dle;
177 avl_index_t where;
178
179 if (dl->dl_oldfmt) {

--- 12 unchanged lines hidden (view full) ---

192 mutex_exit(&dl->dl_lock);
193
194 dle_tofind.dle_mintxg = bp->blk_birth;
195 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
196 if (dle == NULL)
197 dle = avl_nearest(&dl->dl_tree, where, AVL_BEFORE);
198 else
199 dle = AVL_PREV(&dl->dl_tree, dle);
209void
210dsl_deadlist_insert(dsl_deadlist_t *dl, const blkptr_t *bp, dmu_tx_t *tx)
211{
212 dsl_deadlist_entry_t dle_tofind;
213 dsl_deadlist_entry_t *dle;
214 avl_index_t where;
215
216 if (dl->dl_oldfmt) {

--- 12 unchanged lines hidden (view full) ---

229 mutex_exit(&dl->dl_lock);
230
231 dle_tofind.dle_mintxg = bp->blk_birth;
232 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
233 if (dle == NULL)
234 dle = avl_nearest(&dl->dl_tree, where, AVL_BEFORE);
235 else
236 dle = AVL_PREV(&dl->dl_tree, dle);
200 bpobj_enqueue(&dle->dle_bpobj, bp, tx);
237 dle_enqueue(dl, dle, bp, tx);
201}
202
203/*
204 * Insert new key in deadlist, which must be > all current entries.
205 * mintxg is not inclusive.
206 */
207void
208dsl_deadlist_add_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx)
209{
210 uint64_t obj;
211 dsl_deadlist_entry_t *dle;
212
213 if (dl->dl_oldfmt)
214 return;
215
216 dsl_deadlist_load_tree(dl);
217
218 dle = kmem_alloc(sizeof (*dle), KM_SLEEP);
219 dle->dle_mintxg = mintxg;
238}
239
240/*
241 * Insert new key in deadlist, which must be > all current entries.
242 * mintxg is not inclusive.
243 */
244void
245dsl_deadlist_add_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx)
246{
247 uint64_t obj;
248 dsl_deadlist_entry_t *dle;
249
250 if (dl->dl_oldfmt)
251 return;
252
253 dsl_deadlist_load_tree(dl);
254
255 dle = kmem_alloc(sizeof (*dle), KM_SLEEP);
256 dle->dle_mintxg = mintxg;
220 obj = bpobj_alloc(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
257 obj = bpobj_alloc_empty(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
221 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
222 avl_add(&dl->dl_tree, dle);
223
224 VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, dl->dl_object,
225 mintxg, obj, tx));
226}
227
228/*

--- 9 unchanged lines hidden (view full) ---

238 return;
239
240 dsl_deadlist_load_tree(dl);
241
242 dle_tofind.dle_mintxg = mintxg;
243 dle = avl_find(&dl->dl_tree, &dle_tofind, NULL);
244 dle_prev = AVL_PREV(&dl->dl_tree, dle);
245
258 VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
259 avl_add(&dl->dl_tree, dle);
260
261 VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, dl->dl_object,
262 mintxg, obj, tx));
263}
264
265/*

--- 9 unchanged lines hidden (view full) ---

275 return;
276
277 dsl_deadlist_load_tree(dl);
278
279 dle_tofind.dle_mintxg = mintxg;
280 dle = avl_find(&dl->dl_tree, &dle_tofind, NULL);
281 dle_prev = AVL_PREV(&dl->dl_tree, dle);
282
246 bpobj_enqueue_subobj(&dle_prev->dle_bpobj,
247 dle->dle_bpobj.bpo_object, tx);
283 dle_enqueue_subobj(dl, dle_prev, dle->dle_bpobj.bpo_object, tx);
248
249 avl_remove(&dl->dl_tree, dle);
250 bpobj_close(&dle->dle_bpobj);
251 kmem_free(dle, sizeof (*dle));
252
253 VERIFY3U(0, ==, zap_remove_int(dl->dl_os, dl->dl_object, mintxg, tx));
254}
255

--- 41 unchanged lines hidden (view full) ---

297
298 for (dle = avl_first(&dl->dl_tree); dle;
299 dle = AVL_NEXT(&dl->dl_tree, dle)) {
300 uint64_t obj;
301
302 if (dle->dle_mintxg >= maxtxg)
303 break;
304
284
285 avl_remove(&dl->dl_tree, dle);
286 bpobj_close(&dle->dle_bpobj);
287 kmem_free(dle, sizeof (*dle));
288
289 VERIFY3U(0, ==, zap_remove_int(dl->dl_os, dl->dl_object, mintxg, tx));
290}
291

--- 41 unchanged lines hidden (view full) ---

333
334 for (dle = avl_first(&dl->dl_tree); dle;
335 dle = AVL_NEXT(&dl->dl_tree, dle)) {
336 uint64_t obj;
337
338 if (dle->dle_mintxg >= maxtxg)
339 break;
340
305 obj = bpobj_alloc(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
341 obj = bpobj_alloc_empty(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
306 VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, newobj,
307 dle->dle_mintxg, obj, tx));
308 }
309 return (newobj);
310}
311
312void
313dsl_deadlist_space(dsl_deadlist_t *dl,

--- 81 unchanged lines hidden (view full) ---

395 dl->dl_phys->dl_comp += comp;
396 dl->dl_phys->dl_uncomp += uncomp;
397 mutex_exit(&dl->dl_lock);
398
399 dle_tofind.dle_mintxg = birth;
400 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
401 if (dle == NULL)
402 dle = avl_nearest(&dl->dl_tree, where, AVL_BEFORE);
342 VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, newobj,
343 dle->dle_mintxg, obj, tx));
344 }
345 return (newobj);
346}
347
348void
349dsl_deadlist_space(dsl_deadlist_t *dl,

--- 81 unchanged lines hidden (view full) ---

431 dl->dl_phys->dl_comp += comp;
432 dl->dl_phys->dl_uncomp += uncomp;
433 mutex_exit(&dl->dl_lock);
434
435 dle_tofind.dle_mintxg = birth;
436 dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
437 if (dle == NULL)
438 dle = avl_nearest(&dl->dl_tree, where, AVL_BEFORE);
403 bpobj_enqueue_subobj(&dle->dle_bpobj, obj, tx);
439 dle_enqueue_subobj(dl, dle, obj, tx);
404}
405
406static int
407dsl_deadlist_insert_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
408{
409 dsl_deadlist_t *dl = arg;
410 dsl_deadlist_insert(dl, bp, tx);
411 return (0);

--- 87 unchanged lines hidden ---
440}
441
442static int
443dsl_deadlist_insert_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
444{
445 dsl_deadlist_t *dl = arg;
446 dsl_deadlist_insert(dl, bp, tx);
447 return (0);

--- 87 unchanged lines hidden ---