Lines Matching refs:hdl

130 static int sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype);
137 static int sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
211 sa_handle_t *hdl = buf;
213 hdl->sa_bonus_tab = NULL;
214 hdl->sa_spill_tab = NULL;
215 hdl->sa_os = NULL;
216 hdl->sa_userp = NULL;
217 hdl->sa_bonus = NULL;
218 hdl->sa_spill = NULL;
219 mutex_init(&hdl->sa_lock, NULL, MUTEX_DEFAULT, NULL);
227 sa_handle_t *hdl = buf;
228 mutex_destroy(&hdl->sa_lock);
306 sa_get_spill(sa_handle_t *hdl)
309 if (hdl->sa_spill == NULL) {
310 if ((rc = dmu_spill_hold_existing(hdl->sa_bonus, NULL,
311 &hdl->sa_spill)) == 0)
312 VERIFY(0 == sa_build_index(hdl, SA_SPILL));
327 sa_attr_op(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count,
330 sa_os_t *sa = hdl->sa_os->os_sa;
339 ASSERT(bulk[i].sa_attr <= hdl->sa_os->os_sa->sa_num_attrs);
344 if (hdl->sa_bonus_tab && TOC_ATTR_PRESENT(
345 hdl->sa_bonus_tab->sa_idx_tab[bulk[i].sa_attr])) {
346 SA_ATTR_INFO(sa, hdl->sa_bonus_tab,
347 SA_GET_HDR(hdl, SA_BONUS),
348 bulk[i].sa_attr, bulk[i], SA_BONUS, hdl);
350 dmu_buf_will_dirty(hdl->sa_bonus, tx);
355 ((error = sa_get_spill(hdl)) == 0)) {
357 hdl->sa_spill_tab->sa_idx_tab[bulk[i].sa_attr])) {
358 SA_ATTR_INFO(sa, hdl->sa_spill_tab,
359 SA_GET_HDR(hdl, SA_SPILL),
360 bulk[i].sa_attr, bulk[i], SA_SPILL, hdl);
363 dmu_buf_will_dirty(hdl->sa_spill, tx);
392 error = sa_modify_attrs(hdl, bulk[i].sa_attr,
396 error = sa_modify_attrs(hdl, bulk[i].sa_attr,
496 sa_resize_spill(sa_handle_t *hdl, uint32_t size, dmu_tx_t *tx)
510 error = dbuf_spill_set_blksz(hdl->sa_spill, blocksize, tx);
651 sa_build_layouts(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc, int attr_count,
654 sa_os_t *sa = hdl->sa_os->os_sa;
671 dmu_buf_will_dirty(hdl->sa_bonus, tx);
672 bonustype = SA_BONUSTYPE_FROM_DB(hdl->sa_bonus);
675 hdrsize = sa_find_sizes(sa, attr_desc, attr_count, hdl->sa_bonus,
681 VERIFY(0 == dmu_set_bonus(hdl->sa_bonus, spilling ?
692 if (hdl->sa_spill == NULL) {
693 VERIFY(dmu_spill_hold_by_bonus(hdl->sa_bonus, NULL,
694 &hdl->sa_spill) == 0);
696 dmu_buf_will_dirty(hdl->sa_spill, tx);
699 attr_count - i, hdl->sa_spill, SA_SPILL, &i,
705 buf_space = hdl->sa_spill->db_size - spillhdrsize;
707 hdl->sa_spill->db_size)
708 VERIFY(0 == sa_resize_spill(hdl,
713 data_start = (void *)((uintptr_t)hdl->sa_bonus->db_data + hdrsize);
714 sahdr = (sa_hdr_phys_t *)hdl->sa_bonus->db_data;
721 buf_space = hdl->sa_bonus->db_size - hdrsize;
743 sa_find_layout(hdl->sa_os, hash, attrs_start,
752 sahdr = (sa_hdr_phys_t *)hdl->sa_spill->db_data;
757 buf_space = hdl->sa_spill->db_size - spillhdrsize;
775 sa_find_layout(hdl->sa_os, hash, attrs_start, lot_count, tx, &lot);
790 if (hdl->sa_bonus_tab) {
791 sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab);
792 hdl->sa_bonus_tab = NULL;
795 VERIFY(0 == sa_build_index(hdl, SA_BONUS));
796 if (hdl->sa_spill) {
797 sa_idx_tab_rele(hdl->sa_os, hdl->sa_spill_tab);
802 dmu_buf_rele(hdl->sa_spill, NULL);
803 hdl->sa_spill = NULL;
804 hdl->sa_spill_tab = NULL;
805 VERIFY(0 == dmu_rm_spill(hdl->sa_os,
806 sa_handle_object(hdl), tx));
808 VERIFY(0 == sa_build_index(hdl, SA_SPILL));
1222 sa_handle_t *hdl = userp;
1223 sa_os_t *sa = hdl->sa_os->os_sa;
1229 sa_byteswap(sa_handle_t *hdl, sa_buf_type_t buftype)
1231 sa_hdr_phys_t *sa_hdr_phys = SA_GET_HDR(hdl, buftype);
1233 sa_os_t *sa = hdl->sa_os->os_sa;
1241 db = SA_GET_DB(hdl, buftype);
1262 sa_attr_iter(hdl->sa_os, sa_hdr_phys, DMU_OT_SA,
1263 sa_byteswap_cb, NULL, hdl);
1266 arc_buf_freeze(((dmu_buf_impl_t *)hdl->sa_spill)->db_buf);
1270 sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype)
1273 dmu_buf_impl_t *db = SA_GET_DB(hdl, buftype);
1275 sa_os_t *sa = hdl->sa_os->os_sa;
1278 sa_hdr_phys = SA_GET_HDR(hdl, buftype);
1288 sa_byteswap(hdl, buftype);
1291 idx_tab = sa_find_idx_tab(hdl->sa_os, bonustype, sa_hdr_phys);
1294 hdl->sa_bonus_tab = idx_tab;
1296 hdl->sa_spill_tab = idx_tab;
1343 sa_handle_destroy(sa_handle_t *hdl)
1345 mutex_enter(&hdl->sa_lock);
1346 (void) dmu_buf_update_user((dmu_buf_t *)hdl->sa_bonus, hdl,
1349 if (hdl->sa_bonus_tab) {
1350 sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab);
1351 hdl->sa_bonus_tab = NULL;
1353 if (hdl->sa_spill_tab) {
1354 sa_idx_tab_rele(hdl->sa_os, hdl->sa_spill_tab);
1355 hdl->sa_spill_tab = NULL;
1358 dmu_buf_rele(hdl->sa_bonus, NULL);
1360 if (hdl->sa_spill)
1361 dmu_buf_rele((dmu_buf_t *)hdl->sa_spill, NULL);
1362 mutex_exit(&hdl->sa_lock);
1364 kmem_cache_free(sa_cache, hdl);
1434 sa_lookup_impl(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count)
1436 ASSERT(hdl);
1437 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1438 return (sa_attr_op(hdl, bulk, count, SA_LOOKUP, NULL));
1442 sa_lookup(sa_handle_t *hdl, sa_attr_type_t attr, void *buf, uint32_t buflen)
1452 ASSERT(hdl);
1453 mutex_enter(&hdl->sa_lock);
1454 error = sa_lookup_impl(hdl, &bulk, 1);
1455 mutex_exit(&hdl->sa_lock);
1461 sa_lookup_uio(sa_handle_t *hdl, sa_attr_type_t attr, uio_t *uio)
1470 ASSERT(hdl);
1472 mutex_enter(&hdl->sa_lock);
1473 if ((error = sa_attr_op(hdl, &bulk, 1, SA_LOOKUP, NULL)) == 0) {
1477 mutex_exit(&hdl->sa_lock);
1565 sa_attr_register_sync(sa_handle_t *hdl, dmu_tx_t *tx)
1568 sa_os_t *sa = hdl->sa_os->os_sa;
1580 sa->sa_reg_attr_obj = zap_create_link(hdl->sa_os,
1589 VERIFY(0 == zap_update(hdl->sa_os, sa->sa_reg_attr_obj,
1607 sa_replace_all_by_template_locked(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc,
1610 sa_os_t *sa = hdl->sa_os->os_sa;
1613 sa_attr_register_sync(hdl, tx);
1614 return (sa_build_layouts(hdl, attr_desc, attr_count, tx));
1618 sa_replace_all_by_template(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc,
1623 mutex_enter(&hdl->sa_lock);
1624 error = sa_replace_all_by_template_locked(hdl, attr_desc,
1626 mutex_exit(&hdl->sa_lock);
1638 sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
1642 sa_os_t *sa = hdl->sa_os->os_sa;
1643 dmu_buf_impl_t *db = (dmu_buf_impl_t *)hdl->sa_bonus;
1659 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1666 bonus_data_size = hdl->sa_bonus->db_size;
1668 bcopy(hdl->sa_bonus->db_data, old_data[0],
1669 hdl->sa_bonus->db_size);
1670 bonus_attr_count = hdl->sa_bonus_tab->sa_layout->lot_attr_count;
1678 if ((error = sa_get_spill(hdl)) == 0) {
1679 spill_data_size = hdl->sa_spill->db_size;
1681 bcopy(hdl->sa_spill->db_data, old_data[1],
1682 hdl->sa_spill->db_size);
1684 hdl->sa_spill_tab->sa_layout->lot_attr_count;
1709 hdr = SA_GET_HDR(hdl, SA_BONUS);
1710 idx_tab = SA_IDX_TAB_GET(hdl, SA_BONUS);
1741 if (k == 0 && hdl->sa_spill) {
1742 hdr = SA_GET_HDR(hdl, SA_SPILL);
1743 idx_tab = SA_IDX_TAB_GET(hdl, SA_SPILL);
1759 error = sa_build_layouts(hdl, attr_desc, attr_count, tx);
1771 sa_bulk_update_impl(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count,
1775 sa_os_t *sa = hdl->sa_os->os_sa;
1778 bonustype = SA_BONUSTYPE_FROM_DB(SA_GET_DB(hdl, SA_BONUS));
1780 ASSERT(hdl);
1781 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1785 sa_attr_register_sync(hdl, tx);
1787 error = sa_attr_op(hdl, bulk, count, SA_UPDATE, tx);
1789 sa->sa_update_cb(hdl, tx);
1798 sa_update(sa_handle_t *hdl, sa_attr_type_t type,
1809 mutex_enter(&hdl->sa_lock);
1810 error = sa_bulk_update_impl(hdl, &bulk, 1, tx);
1811 mutex_exit(&hdl->sa_lock);
1816 sa_update_from_cb(sa_handle_t *hdl, sa_attr_type_t attr,
1827 mutex_enter(&hdl->sa_lock);
1828 error = sa_bulk_update_impl(hdl, &bulk, 1, tx);
1829 mutex_exit(&hdl->sa_lock);
1838 sa_size(sa_handle_t *hdl, sa_attr_type_t attr, int *size)
1847 ASSERT(hdl);
1848 mutex_enter(&hdl->sa_lock);
1849 if ((error = sa_attr_op(hdl, &bulk, 1, SA_LOOKUP, NULL)) != 0) {
1850 mutex_exit(&hdl->sa_lock);
1855 mutex_exit(&hdl->sa_lock);
1860 sa_bulk_lookup_locked(sa_handle_t *hdl, sa_bulk_attr_t *attrs, int count)
1862 ASSERT(hdl);
1863 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1864 return (sa_lookup_impl(hdl, attrs, count));
1868 sa_bulk_lookup(sa_handle_t *hdl, sa_bulk_attr_t *attrs, int count)
1872 ASSERT(hdl);
1873 mutex_enter(&hdl->sa_lock);
1874 error = sa_bulk_lookup_locked(hdl, attrs, count);
1875 mutex_exit(&hdl->sa_lock);
1880 sa_bulk_update(sa_handle_t *hdl, sa_bulk_attr_t *attrs, int count, dmu_tx_t *tx)
1884 ASSERT(hdl);
1885 mutex_enter(&hdl->sa_lock);
1886 error = sa_bulk_update_impl(hdl, attrs, count, tx);
1887 mutex_exit(&hdl->sa_lock);
1892 sa_remove(sa_handle_t *hdl, sa_attr_type_t attr, dmu_tx_t *tx)
1896 mutex_enter(&hdl->sa_lock);
1897 error = sa_modify_attrs(hdl, attr, SA_REMOVE, NULL,
1899 mutex_exit(&hdl->sa_lock);
1904 sa_object_info(sa_handle_t *hdl, dmu_object_info_t *doi)
1906 dmu_object_info_from_db((dmu_buf_t *)hdl->sa_bonus, doi);
1910 sa_object_size(sa_handle_t *hdl, uint32_t *blksize, u_longlong_t *nblocks)
1912 dmu_object_size_from_db((dmu_buf_t *)hdl->sa_bonus,
1925 sa_set_userp(sa_handle_t *hdl, void *ptr)
1927 hdl->sa_userp = ptr;
1931 sa_get_db(sa_handle_t *hdl)
1933 return ((dmu_buf_t *)hdl->sa_bonus);
1937 sa_get_userdata(sa_handle_t *hdl)
1939 return (hdl->sa_userp);
1959 sa_handle_object(sa_handle_t *hdl)
1961 return (hdl->sa_bonus->db_object);
1992 sa_handle_lock(sa_handle_t *hdl)
1994 ASSERT(hdl);
1995 mutex_enter(&hdl->sa_lock);
1999 sa_handle_unlock(sa_handle_t *hdl)
2001 ASSERT(hdl);
2002 mutex_exit(&hdl->sa_lock);