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