zap.c (275782) | zap.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 --- 7 unchanged lines hidden (view full) --- 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, 2014 by Delphix. 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 --- 7 unchanged lines hidden (view full) --- 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, 2014 by Delphix. All rights reserved. |
24 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. |
|
24 */ 25 26/* 27 * This file contains the top half of the zfs directory structure 28 * implementation. The bottom half is in zap_leaf.c. 29 * 30 * The zdir is an extendable hash data structure. There is a table of 31 * pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are --- 15 unchanged lines hidden (view full) --- 47#include <sys/refcount.h> 48#include <sys/zap_impl.h> 49#include <sys/zap_leaf.h> 50 51int fzap_default_block_shift = 14; /* 16k blocksize */ 52 53extern inline zap_phys_t *zap_f_phys(zap_t *zap); 54 | 25 */ 26 27/* 28 * This file contains the top half of the zfs directory structure 29 * implementation. The bottom half is in zap_leaf.c. 30 * 31 * The zdir is an extendable hash data structure. There is a table of 32 * pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are --- 15 unchanged lines hidden (view full) --- 48#include <sys/refcount.h> 49#include <sys/zap_impl.h> 50#include <sys/zap_leaf.h> 51 52int fzap_default_block_shift = 14; /* 16k blocksize */ 53 54extern inline zap_phys_t *zap_f_phys(zap_t *zap); 55 |
55static void zap_leaf_pageout(dmu_buf_t *db, void *vl); | |
56static uint64_t zap_allocate_blocks(zap_t *zap, int nblocks); 57 58void 59fzap_byteswap(void *vbuf, size_t size) 60{ 61 uint64_t block_type; 62 63 block_type = *(uint64_t *)vbuf; --- 12 unchanged lines hidden (view full) --- 76 dmu_buf_t *db; 77 zap_leaf_t *l; 78 int i; 79 zap_phys_t *zp; 80 81 ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); 82 zap->zap_ismicro = FALSE; 83 | 56static uint64_t zap_allocate_blocks(zap_t *zap, int nblocks); 57 58void 59fzap_byteswap(void *vbuf, size_t size) 60{ 61 uint64_t block_type; 62 63 block_type = *(uint64_t *)vbuf; --- 12 unchanged lines hidden (view full) --- 76 dmu_buf_t *db; 77 zap_leaf_t *l; 78 int i; 79 zap_phys_t *zp; 80 81 ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); 82 zap->zap_ismicro = FALSE; 83 |
84 (void) dmu_buf_update_user(zap->zap_dbuf, zap, zap, zap_evict); | 84 zap->zap_dbu.dbu_evict_func = zap_evict; |
85 86 mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0); 87 zap->zap_f.zap_block_shift = highbit64(zap->zap_dbuf->db_size) - 1; 88 89 zp = zap_f_phys(zap); 90 /* 91 * explicitly zero it since it might be coming from an 92 * initialized microzap --- 289 unchanged lines hidden (view full) --- 382{ 383 uint64_t newblk; 384 ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); 385 newblk = zap_f_phys(zap)->zap_freeblk; 386 zap_f_phys(zap)->zap_freeblk += nblocks; 387 return (newblk); 388} 389 | 85 86 mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0); 87 zap->zap_f.zap_block_shift = highbit64(zap->zap_dbuf->db_size) - 1; 88 89 zp = zap_f_phys(zap); 90 /* 91 * explicitly zero it since it might be coming from an 92 * initialized microzap --- 289 unchanged lines hidden (view full) --- 382{ 383 uint64_t newblk; 384 ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); 385 newblk = zap_f_phys(zap)->zap_freeblk; 386 zap_f_phys(zap)->zap_freeblk += nblocks; 387 return (newblk); 388} 389 |
390static void 391zap_leaf_pageout(void *dbu) 392{ 393 zap_leaf_t *l = dbu; 394 395 rw_destroy(&l->l_rwlock); 396 kmem_free(l, sizeof (zap_leaf_t)); 397} 398 |
|
390static zap_leaf_t * 391zap_create_leaf(zap_t *zap, dmu_tx_t *tx) 392{ 393 void *winner; | 399static zap_leaf_t * 400zap_create_leaf(zap_t *zap, dmu_tx_t *tx) 401{ 402 void *winner; |
394 zap_leaf_t *l = kmem_alloc(sizeof (zap_leaf_t), KM_SLEEP); | 403 zap_leaf_t *l = kmem_zalloc(sizeof (zap_leaf_t), KM_SLEEP); |
395 396 ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); 397 398 rw_init(&l->l_rwlock, 0, 0, 0); 399 rw_enter(&l->l_rwlock, RW_WRITER); 400 l->l_blkid = zap_allocate_blocks(zap, 1); 401 l->l_dbuf = NULL; 402 403 VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, 404 l->l_blkid << FZAP_BLOCK_SHIFT(zap), NULL, &l->l_dbuf, 405 DMU_READ_NO_PREFETCH)); | 404 405 ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); 406 407 rw_init(&l->l_rwlock, 0, 0, 0); 408 rw_enter(&l->l_rwlock, RW_WRITER); 409 l->l_blkid = zap_allocate_blocks(zap, 1); 410 l->l_dbuf = NULL; 411 412 VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, 413 l->l_blkid << FZAP_BLOCK_SHIFT(zap), NULL, &l->l_dbuf, 414 DMU_READ_NO_PREFETCH)); |
406 winner = dmu_buf_set_user(l->l_dbuf, l, zap_leaf_pageout); | 415 dmu_buf_init_user(&l->l_dbu, zap_leaf_pageout, &l->l_dbuf); 416 winner = dmu_buf_set_user(l->l_dbuf, &l->l_dbu); |
407 ASSERT(winner == NULL); 408 dmu_buf_will_dirty(l->l_dbuf, tx); 409 410 zap_leaf_init(l, zap->zap_normflags != 0); 411 412 zap_f_phys(zap)->zap_num_leafs++; 413 414 return (l); --- 15 unchanged lines hidden (view full) --- 430 431void 432zap_put_leaf(zap_leaf_t *l) 433{ 434 rw_exit(&l->l_rwlock); 435 dmu_buf_rele(l->l_dbuf, NULL); 436} 437 | 417 ASSERT(winner == NULL); 418 dmu_buf_will_dirty(l->l_dbuf, tx); 419 420 zap_leaf_init(l, zap->zap_normflags != 0); 421 422 zap_f_phys(zap)->zap_num_leafs++; 423 424 return (l); --- 15 unchanged lines hidden (view full) --- 440 441void 442zap_put_leaf(zap_leaf_t *l) 443{ 444 rw_exit(&l->l_rwlock); 445 dmu_buf_rele(l->l_dbuf, NULL); 446} 447 |
438_NOTE(ARGSUSED(0)) 439static void 440zap_leaf_pageout(dmu_buf_t *db, void *vl) 441{ 442 zap_leaf_t *l = vl; 443 444 rw_destroy(&l->l_rwlock); 445 kmem_free(l, sizeof (zap_leaf_t)); 446} 447 | |
448static zap_leaf_t * 449zap_open_leaf(uint64_t blkid, dmu_buf_t *db) 450{ 451 zap_leaf_t *l, *winner; 452 453 ASSERT(blkid != 0); 454 | 448static zap_leaf_t * 449zap_open_leaf(uint64_t blkid, dmu_buf_t *db) 450{ 451 zap_leaf_t *l, *winner; 452 453 ASSERT(blkid != 0); 454 |
455 l = kmem_alloc(sizeof (zap_leaf_t), KM_SLEEP); | 455 l = kmem_zalloc(sizeof (zap_leaf_t), KM_SLEEP); |
456 rw_init(&l->l_rwlock, 0, 0, 0); 457 rw_enter(&l->l_rwlock, RW_WRITER); 458 l->l_blkid = blkid; 459 l->l_bs = highbit64(db->db_size) - 1; 460 l->l_dbuf = db; 461 | 456 rw_init(&l->l_rwlock, 0, 0, 0); 457 rw_enter(&l->l_rwlock, RW_WRITER); 458 l->l_blkid = blkid; 459 l->l_bs = highbit64(db->db_size) - 1; 460 l->l_dbuf = db; 461 |
462 winner = dmu_buf_set_user(db, l, zap_leaf_pageout); | 462 dmu_buf_init_user(&l->l_dbu, zap_leaf_pageout, &l->l_dbuf); 463 winner = dmu_buf_set_user(db, &l->l_dbu); |
463 464 rw_exit(&l->l_rwlock); 465 if (winner != NULL) { 466 /* someone else set it first */ | 464 465 rw_exit(&l->l_rwlock); 466 if (winner != NULL) { 467 /* someone else set it first */ |
467 zap_leaf_pageout(NULL, l); | 468 zap_leaf_pageout(&l->l_dbu); |
468 l = winner; 469 } 470 471 /* 472 * lhr_pad was previously used for the next leaf in the leaf 473 * chain. There should be no chained leafs (as we have removed 474 * support for them). 475 */ --- 911 unchanged lines hidden --- | 469 l = winner; 470 } 471 472 /* 473 * lhr_pad was previously used for the next leaf in the leaf 474 * chain. There should be no chained leafs (as we have removed 475 * support for them). 476 */ --- 911 unchanged lines hidden --- |