Deleted Added
full compact
dsl_dir.c (282127) dsl_dir.c (286575)
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

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

19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
24 * All rights reserved.
25 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
26 * Copyright (c) 2014 Joyent, Inc. 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

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

19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
24 * All rights reserved.
25 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
26 * Copyright (c) 2014 Joyent, Inc. All rights reserved.
27 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
27 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
28 */
29
30#include <sys/dmu.h>
31#include <sys/dmu_objset.h>
32#include <sys/dmu_tx.h>
33#include <sys/dsl_dataset.h>
34#include <sys/dsl_dir.h>

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

126 * Likewise, we do not update the snapshot counts for temporary snapshots,
127 * such as those created by zfs diff.
128 */
129
130extern inline dsl_dir_phys_t *dsl_dir_phys(dsl_dir_t *dd);
131
132static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd);
133
28 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
29 */
30
31#include <sys/dmu.h>
32#include <sys/dmu_objset.h>
33#include <sys/dmu_tx.h>
34#include <sys/dsl_dataset.h>
35#include <sys/dsl_dir.h>

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

127 * Likewise, we do not update the snapshot counts for temporary snapshots,
128 * such as those created by zfs diff.
129 */
130
131extern inline dsl_dir_phys_t *dsl_dir_phys(dsl_dir_t *dd);
132
133static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd);
134
134/* ARGSUSED */
135static void
135static void
136dsl_dir_evict(dmu_buf_t *db, void *arg)
136dsl_dir_evict(void *dbu)
137{
137{
138 dsl_dir_t *dd = arg;
138 dsl_dir_t *dd = dbu;
139 dsl_pool_t *dp = dd->dd_pool;
140 int t;
141
139 dsl_pool_t *dp = dd->dd_pool;
140 int t;
141
142 dd->dd_dbuf = NULL;
143
142 for (t = 0; t < TXG_SIZE; t++) {
143 ASSERT(!txg_list_member(&dp->dp_dirty_dirs, dd, t));
144 ASSERT(dd->dd_tempreserved[t] == 0);
145 ASSERT(dd->dd_space_towrite[t] == 0);
146 }
147
148 if (dd->dd_parent)
144 for (t = 0; t < TXG_SIZE; t++) {
145 ASSERT(!txg_list_member(&dp->dp_dirty_dirs, dd, t));
146 ASSERT(dd->dd_tempreserved[t] == 0);
147 ASSERT(dd->dd_space_towrite[t] == 0);
148 }
149
150 if (dd->dd_parent)
149 dsl_dir_rele(dd->dd_parent, dd);
151 dsl_dir_async_rele(dd->dd_parent, dd);
150
152
151 spa_close(dd->dd_pool->dp_spa, dd);
153 spa_async_close(dd->dd_pool->dp_spa, dd);
152
153 /*
154 * The props callback list should have been cleaned up by
155 * objset_evict().
156 */
157 list_destroy(&dd->dd_prop_cbs);
158 mutex_destroy(&dd->dd_lock);
159 kmem_free(dd, sizeof (dsl_dir_t));

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

239 if (err != 0)
240 goto errout;
241 origin_phys = origin_bonus->db_data;
242 dd->dd_origin_txg =
243 origin_phys->ds_creation_txg;
244 dmu_buf_rele(origin_bonus, FTAG);
245 }
246
154
155 /*
156 * The props callback list should have been cleaned up by
157 * objset_evict().
158 */
159 list_destroy(&dd->dd_prop_cbs);
160 mutex_destroy(&dd->dd_lock);
161 kmem_free(dd, sizeof (dsl_dir_t));

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

241 if (err != 0)
242 goto errout;
243 origin_phys = origin_bonus->db_data;
244 dd->dd_origin_txg =
245 origin_phys->ds_creation_txg;
246 dmu_buf_rele(origin_bonus, FTAG);
247 }
248
247 winner = dmu_buf_set_user_ie(dbuf, dd, dsl_dir_evict);
248 if (winner) {
249 dmu_buf_init_user(&dd->dd_dbu, dsl_dir_evict, &dd->dd_dbuf);
250 winner = dmu_buf_set_user_ie(dbuf, &dd->dd_dbu);
251 if (winner != NULL) {
249 if (dd->dd_parent)
250 dsl_dir_rele(dd->dd_parent, dd);
251 mutex_destroy(&dd->dd_lock);
252 kmem_free(dd, sizeof (dsl_dir_t));
253 dd = winner;
254 } else {
255 spa_open_ref(dp->dp_spa, dd);
256 }

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

284void
285dsl_dir_rele(dsl_dir_t *dd, void *tag)
286{
287 dprintf_dd(dd, "%s\n", "");
288 spa_close(dd->dd_pool->dp_spa, tag);
289 dmu_buf_rele(dd->dd_dbuf, tag);
290}
291
252 if (dd->dd_parent)
253 dsl_dir_rele(dd->dd_parent, dd);
254 mutex_destroy(&dd->dd_lock);
255 kmem_free(dd, sizeof (dsl_dir_t));
256 dd = winner;
257 } else {
258 spa_open_ref(dp->dp_spa, dd);
259 }

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

287void
288dsl_dir_rele(dsl_dir_t *dd, void *tag)
289{
290 dprintf_dd(dd, "%s\n", "");
291 spa_close(dd->dd_pool->dp_spa, tag);
292 dmu_buf_rele(dd->dd_dbuf, tag);
293}
294
295/*
296 * Remove a reference to the given dsl dir that is being asynchronously
297 * released. Async releases occur from a taskq performing eviction of
298 * dsl datasets and dirs. This process is identical to a normal release
299 * with the exception of using the async API for releasing the reference on
300 * the spa.
301 */
302void
303dsl_dir_async_rele(dsl_dir_t *dd, void *tag)
304{
305 dprintf_dd(dd, "%s\n", "");
306 spa_async_close(dd->dd_pool->dp_spa, tag);
307 dmu_buf_rele(dd->dd_dbuf, tag);
308}
309
292/* buf must be long enough (MAXNAMELEN + strlen(MOS_DIR_NAME) + 1 should do) */
293void
294dsl_dir_name(dsl_dir_t *dd, char *buf)
295{
296 if (dd->dd_parent) {
297 dsl_dir_name(dd->dd_parent, buf);
298 (void) strcat(buf, "/");
299 } else {

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

414 ASSERT(dsl_pool_config_held(dp));
415
416 err = dsl_dir_hold_obj(dp, dp->dp_root_dir_obj, NULL, tag, &dd);
417 if (err != 0) {
418 return (err);
419 }
420
421 while (next != NULL) {
310/* buf must be long enough (MAXNAMELEN + strlen(MOS_DIR_NAME) + 1 should do) */
311void
312dsl_dir_name(dsl_dir_t *dd, char *buf)
313{
314 if (dd->dd_parent) {
315 dsl_dir_name(dd->dd_parent, buf);
316 (void) strcat(buf, "/");
317 } else {

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

432 ASSERT(dsl_pool_config_held(dp));
433
434 err = dsl_dir_hold_obj(dp, dp->dp_root_dir_obj, NULL, tag, &dd);
435 if (err != 0) {
436 return (err);
437 }
438
439 while (next != NULL) {
422 dsl_dir_t *child_ds;
440 dsl_dir_t *child_dd;
423 err = getcomponent(next, buf, &nextnext);
424 if (err != 0)
425 break;
426 ASSERT(next[0] != '\0');
427 if (next[0] == '@')
428 break;
429 dprintf("looking up %s in obj%lld\n",
430 buf, dsl_dir_phys(dd)->dd_child_dir_zapobj);
431
432 err = zap_lookup(dp->dp_meta_objset,
433 dsl_dir_phys(dd)->dd_child_dir_zapobj,
434 buf, sizeof (ddobj), 1, &ddobj);
435 if (err != 0) {
436 if (err == ENOENT)
437 err = 0;
438 break;
439 }
440
441 err = getcomponent(next, buf, &nextnext);
442 if (err != 0)
443 break;
444 ASSERT(next[0] != '\0');
445 if (next[0] == '@')
446 break;
447 dprintf("looking up %s in obj%lld\n",
448 buf, dsl_dir_phys(dd)->dd_child_dir_zapobj);
449
450 err = zap_lookup(dp->dp_meta_objset,
451 dsl_dir_phys(dd)->dd_child_dir_zapobj,
452 buf, sizeof (ddobj), 1, &ddobj);
453 if (err != 0) {
454 if (err == ENOENT)
455 err = 0;
456 break;
457 }
458
441 err = dsl_dir_hold_obj(dp, ddobj, buf, tag, &child_ds);
459 err = dsl_dir_hold_obj(dp, ddobj, buf, tag, &child_dd);
442 if (err != 0)
443 break;
444 dsl_dir_rele(dd, tag);
460 if (err != 0)
461 break;
462 dsl_dir_rele(dd, tag);
445 dd = child_ds;
463 dd = child_dd;
446 next = nextnext;
447 }
448
449 if (err != 0) {
450 dsl_dir_rele(dd, tag);
451 return (err);
452 }
453

--- 1531 unchanged lines hidden ---
464 next = nextnext;
465 }
466
467 if (err != 0) {
468 dsl_dir_rele(dd, tag);
469 return (err);
470 }
471

--- 1531 unchanged lines hidden ---