Lines Matching defs:hdl
134 static int sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype);
141 static int sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
220 sa_handle_t *hdl = buf;
222 mutex_init(&hdl->sa_lock, NULL, MUTEX_DEFAULT, NULL);
230 sa_handle_t *hdl = buf;
231 mutex_destroy(&hdl->sa_lock);
300 sa_get_spill(sa_handle_t *hdl)
303 if (hdl->sa_spill == NULL) {
304 if ((rc = dmu_spill_hold_existing(hdl->sa_bonus, NULL,
305 &hdl->sa_spill)) == 0)
306 VERIFY(0 == sa_build_index(hdl, SA_SPILL));
321 sa_attr_op(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count,
324 sa_os_t *sa = hdl->sa_os->os_sa;
333 ASSERT(bulk[i].sa_attr <= hdl->sa_os->os_sa->sa_num_attrs);
338 if (hdl->sa_bonus_tab && TOC_ATTR_PRESENT(
339 hdl->sa_bonus_tab->sa_idx_tab[bulk[i].sa_attr])) {
340 SA_ATTR_INFO(sa, hdl->sa_bonus_tab,
341 SA_GET_HDR(hdl, SA_BONUS),
342 bulk[i].sa_attr, bulk[i], SA_BONUS, hdl);
344 dmu_buf_will_dirty(hdl->sa_bonus, tx);
349 ((error = sa_get_spill(hdl)) == 0)) {
351 hdl->sa_spill_tab->sa_idx_tab[bulk[i].sa_attr])) {
352 SA_ATTR_INFO(sa, hdl->sa_spill_tab,
353 SA_GET_HDR(hdl, SA_SPILL),
354 bulk[i].sa_attr, bulk[i], SA_SPILL, hdl);
357 dmu_buf_will_dirty(hdl->sa_spill, tx);
386 error = sa_modify_attrs(hdl, bulk[i].sa_attr,
390 error = sa_modify_attrs(hdl, bulk[i].sa_attr,
492 sa_resize_spill(sa_handle_t *hdl, uint32_t size, dmu_tx_t *tx)
506 error = dbuf_spill_set_blksz(hdl->sa_spill, blocksize, tx);
659 sa_build_layouts(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc, int attr_count,
662 sa_os_t *sa = hdl->sa_os->os_sa;
681 dmu_buf_will_dirty(hdl->sa_bonus, tx);
682 bonustype = SA_BONUSTYPE_FROM_DB(hdl->sa_bonus);
683 dmu_object_dnsize_from_db(hdl->sa_bonus, &dnodesize);
687 hdrsize = sa_find_sizes(sa, attr_desc, attr_count, hdl->sa_bonus,
693 VERIFY0(dmu_set_bonus(hdl->sa_bonus, spilling ?
704 if (hdl->sa_spill == NULL) {
705 VERIFY(dmu_spill_hold_by_bonus(hdl->sa_bonus, 0, NULL,
706 &hdl->sa_spill) == 0);
708 dmu_buf_will_dirty(hdl->sa_spill, tx);
711 attr_count - spill_idx, hdl->sa_spill, SA_SPILL,
712 hdl->sa_spill->db_size, &i, &spill_used, &dummy);
718 hdl->sa_spill->db_size)
719 VERIFY(0 == sa_resize_spill(hdl,
724 data_start = (void *)((uintptr_t)hdl->sa_bonus->db_data + hdrsize);
725 sahdr = (sa_hdr_phys_t *)hdl->sa_bonus->db_data;
744 sa_find_layout(hdl->sa_os, hash, attrs_start,
753 sahdr = (sa_hdr_phys_t *)hdl->sa_spill->db_data;
773 sa_find_layout(hdl->sa_os, hash, attrs_start, lot_count, tx, &lot);
788 if (hdl->sa_bonus_tab) {
789 sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab);
790 hdl->sa_bonus_tab = NULL;
793 VERIFY(0 == sa_build_index(hdl, SA_BONUS));
794 if (hdl->sa_spill) {
795 sa_idx_tab_rele(hdl->sa_os, hdl->sa_spill_tab);
800 dmu_buf_rele(hdl->sa_spill, NULL);
801 hdl->sa_spill = NULL;
802 hdl->sa_spill_tab = NULL;
803 VERIFY(0 == dmu_rm_spill(hdl->sa_os,
804 sa_handle_object(hdl), tx));
806 VERIFY(0 == sa_build_index(hdl, SA_SPILL));
1231 sa_handle_t *hdl = userp;
1232 sa_os_t *sa = hdl->sa_os->os_sa;
1238 sa_byteswap(sa_handle_t *hdl, sa_buf_type_t buftype)
1240 sa_hdr_phys_t *sa_hdr_phys = SA_GET_HDR(hdl, buftype);
1244 sa_os_t *sa __maybe_unused = hdl->sa_os->os_sa;
1250 db = SA_GET_DB(hdl, buftype);
1271 sa_attr_iter(hdl->sa_os, sa_hdr_phys, DMU_OT_SA,
1272 sa_byteswap_cb, NULL, hdl);
1275 arc_buf_freeze(((dmu_buf_impl_t *)hdl->sa_spill)->db_buf);
1279 sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype)
1282 dmu_buf_impl_t *db = SA_GET_DB(hdl, buftype);
1284 sa_os_t *sa = hdl->sa_os->os_sa;
1287 sa_hdr_phys = SA_GET_HDR(hdl, buftype);
1303 sa_byteswap(hdl, buftype);
1306 idx_tab = sa_find_idx_tab(hdl->sa_os, bonustype, sa_hdr_phys);
1309 hdl->sa_bonus_tab = idx_tab;
1311 hdl->sa_spill_tab = idx_tab;
1358 sa_spill_rele(sa_handle_t *hdl)
1360 mutex_enter(&hdl->sa_lock);
1361 if (hdl->sa_spill) {
1362 sa_idx_tab_rele(hdl->sa_os, hdl->sa_spill_tab);
1363 dmu_buf_rele(hdl->sa_spill, NULL);
1364 hdl->sa_spill = NULL;
1365 hdl->sa_spill_tab = NULL;
1367 mutex_exit(&hdl->sa_lock);
1371 sa_handle_destroy(sa_handle_t *hdl)
1373 dmu_buf_t *db = hdl->sa_bonus;
1375 mutex_enter(&hdl->sa_lock);
1376 (void) dmu_buf_remove_user(db, &hdl->sa_dbu);
1378 if (hdl->sa_bonus_tab)
1379 sa_idx_tab_rele(hdl->sa_os, hdl->sa_bonus_tab);
1381 if (hdl->sa_spill_tab)
1382 sa_idx_tab_rele(hdl->sa_os, hdl->sa_spill_tab);
1384 dmu_buf_rele(hdl->sa_bonus, NULL);
1386 if (hdl->sa_spill)
1387 dmu_buf_rele(hdl->sa_spill, NULL);
1388 mutex_exit(&hdl->sa_lock);
1390 kmem_cache_free(sa_cache, hdl);
1470 sa_lookup_impl(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count)
1472 ASSERT(hdl);
1473 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1474 return (sa_attr_op(hdl, bulk, count, SA_LOOKUP, NULL));
1478 sa_lookup_locked(sa_handle_t *hdl, sa_attr_type_t attr, void *buf,
1491 ASSERT(hdl);
1492 error = sa_lookup_impl(hdl, &bulk, 1);
1497 sa_lookup(sa_handle_t *hdl, sa_attr_type_t attr, void *buf, uint32_t buflen)
1501 mutex_enter(&hdl->sa_lock);
1502 error = sa_lookup_locked(hdl, attr, buf, buflen);
1503 mutex_exit(&hdl->sa_lock);
1513 sa_size_locked(sa_handle_t *hdl, sa_attr_type_t attr, int *size)
1522 ASSERT(hdl);
1523 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1524 if ((error = sa_attr_op(hdl, &bulk, 1, SA_LOOKUP, NULL)) != 0) {
1533 sa_size(sa_handle_t *hdl, sa_attr_type_t attr, int *size)
1537 mutex_enter(&hdl->sa_lock);
1538 error = sa_size_locked(hdl, attr, size);
1539 mutex_exit(&hdl->sa_lock);
1546 sa_lookup_uio(sa_handle_t *hdl, sa_attr_type_t attr, zfs_uio_t *uio)
1555 ASSERT(hdl);
1557 mutex_enter(&hdl->sa_lock);
1558 if ((error = sa_attr_op(hdl, &bulk, 1, SA_LOOKUP, NULL)) == 0) {
1562 mutex_exit(&hdl->sa_lock);
1573 sa_add_projid(sa_handle_t *hdl, dmu_tx_t *tx, uint64_t projid)
1575 znode_t *zp = sa_get_userdata(hdl);
1576 dmu_buf_t *db = sa_get_db(hdl);
1600 mutex_enter(&hdl->sa_lock);
1603 err = sa_lookup_locked(hdl, SA_ZPL_PROJID(zfsvfs), &projid,
1660 err = sa_bulk_lookup_locked(hdl, bulk, count);
1664 err = sa_lookup_locked(hdl, SA_ZPL_XATTR(zfsvfs), &xattr, 8);
1668 err = sa_size_locked(hdl, SA_ZPL_DXATTR(zfsvfs), &dxattr_size);
1673 err = sa_lookup_locked(hdl, SA_ZPL_DXATTR(zfsvfs), dxattr_obj,
1736 VERIFY(sa_replace_all_by_template_locked(hdl, attrs, count, tx) == 0);
1746 mutex_exit(&hdl->sa_lock);
1836 sa_attr_register_sync(sa_handle_t *hdl, dmu_tx_t *tx)
1839 sa_os_t *sa = hdl->sa_os->os_sa;
1851 sa->sa_reg_attr_obj = zap_create_link(hdl->sa_os,
1860 VERIFY(0 == zap_update(hdl->sa_os, sa->sa_reg_attr_obj,
1878 sa_replace_all_by_template_locked(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc,
1881 sa_os_t *sa = hdl->sa_os->os_sa;
1884 sa_attr_register_sync(hdl, tx);
1885 return (sa_build_layouts(hdl, attr_desc, attr_count, tx));
1889 sa_replace_all_by_template(sa_handle_t *hdl, sa_bulk_attr_t *attr_desc,
1894 mutex_enter(&hdl->sa_lock);
1895 error = sa_replace_all_by_template_locked(hdl, attr_desc,
1897 mutex_exit(&hdl->sa_lock);
1909 sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
1913 sa_os_t *sa = hdl->sa_os->os_sa;
1914 dmu_buf_impl_t *db = (dmu_buf_impl_t *)hdl->sa_bonus;
1929 ASSERT(MUTEX_HELD(&hdl->sa_lock));
1935 bonus_data_size = hdl->sa_bonus->db_size;
1937 memcpy(old_data[0], hdl->sa_bonus->db_data,
1938 hdl->sa_bonus->db_size);
1939 bonus_attr_count = hdl->sa_bonus_tab->sa_layout->lot_attr_count;
1947 if ((error = sa_get_spill(hdl)) == 0) {
1948 spill_data_size = hdl->sa_spill->db_size;
1950 memcpy(old_data[1], hdl->sa_spill->db_data,
1951 hdl->sa_spill->db_size);
1953 hdl->sa_spill_tab->sa_layout->lot_attr_count;
1978 hdr = SA_GET_HDR(hdl, SA_BONUS);
1979 idx_tab = SA_IDX_TAB_GET(hdl, SA_BONUS);
2026 if (k == 0 && hdl->sa_spill) {
2027 hdr = SA_GET_HDR(hdl, SA_SPILL);
2028 idx_tab = SA_IDX_TAB_GET(hdl, SA_SPILL);
2042 error = sa_build_layouts(hdl, attr_desc, attr_count, tx);
2054 sa_bulk_update_impl(sa_handle_t *hdl, sa_bulk_attr_t *bulk, int count,
2058 sa_os_t *sa = hdl->sa_os->os_sa;
2062 ASSERT(hdl);
2063 ASSERT(MUTEX_HELD(&hdl->sa_lock));
2065 bonustype = SA_BONUSTYPE_FROM_DB(SA_GET_DB(hdl, SA_BONUS));
2066 saved_spill = hdl->sa_spill;
2070 sa_attr_register_sync(hdl, tx);
2072 error = sa_attr_op(hdl, bulk, count, SA_UPDATE, tx);
2074 sa->sa_update_cb(hdl, tx);
2084 if (!saved_spill && hdl->sa_spill) {
2085 if (hdl->sa_spill_tab) {
2086 sa_idx_tab_rele(hdl->sa_os, hdl->sa_spill_tab);
2087 hdl->sa_spill_tab = NULL;
2090 dmu_buf_rele(hdl->sa_spill, NULL);
2091 hdl->sa_spill = NULL;
2101 sa_update(sa_handle_t *hdl, sa_attr_type_t type,
2114 mutex_enter(&hdl->sa_lock);
2115 error = sa_bulk_update_impl(hdl, &bulk, 1, tx);
2116 mutex_exit(&hdl->sa_lock);
2121 sa_bulk_lookup_locked(sa_handle_t *hdl, sa_bulk_attr_t *attrs, int count)
2123 ASSERT(hdl);
2124 ASSERT(MUTEX_HELD(&hdl->sa_lock));
2125 return (sa_lookup_impl(hdl, attrs, count));
2129 sa_bulk_lookup(sa_handle_t *hdl, sa_bulk_attr_t *attrs, int count)
2133 ASSERT(hdl);
2134 mutex_enter(&hdl->sa_lock);
2135 error = sa_bulk_lookup_locked(hdl, attrs, count);
2136 mutex_exit(&hdl->sa_lock);
2141 sa_bulk_update(sa_handle_t *hdl, sa_bulk_attr_t *attrs, int count, dmu_tx_t *tx)
2145 ASSERT(hdl);
2146 mutex_enter(&hdl->sa_lock);
2147 error = sa_bulk_update_impl(hdl, attrs, count, tx);
2148 mutex_exit(&hdl->sa_lock);
2153 sa_remove(sa_handle_t *hdl, sa_attr_type_t attr, dmu_tx_t *tx)
2157 mutex_enter(&hdl->sa_lock);
2158 error = sa_modify_attrs(hdl, attr, SA_REMOVE, NULL,
2160 mutex_exit(&hdl->sa_lock);
2165 sa_object_info(sa_handle_t *hdl, dmu_object_info_t *doi)
2167 dmu_object_info_from_db(hdl->sa_bonus, doi);
2171 sa_object_size(sa_handle_t *hdl, uint32_t *blksize, u_longlong_t *nblocks)
2173 dmu_object_size_from_db(hdl->sa_bonus,
2178 sa_set_userp(sa_handle_t *hdl, void *ptr)
2180 hdl->sa_userp = ptr;
2184 sa_get_db(sa_handle_t *hdl)
2186 return (hdl->sa_bonus);
2190 sa_get_userdata(sa_handle_t *hdl)
2192 return (hdl->sa_userp);
2212 sa_handle_object(sa_handle_t *hdl)
2214 return (hdl->sa_bonus->db_object);
2245 sa_handle_lock(sa_handle_t *hdl)
2247 ASSERT(hdl);
2248 mutex_enter(&hdl->sa_lock);
2252 sa_handle_unlock(sa_handle_t *hdl)
2254 ASSERT(hdl);
2255 mutex_exit(&hdl->sa_lock);