| 1771 | } |
| 1772 | |
| 1773 | static void |
| 1774 | sa_attr_register_sync(sa_handle_t *hdl, dmu_tx_t *tx) |
| 1775 | { |
| 1776 | uint64_t attr_value = 0; |
| 1777 | sa_os_t *sa = hdl->sa_os->os_sa; |
| 1778 | sa_attr_table_t *tb = sa->sa_attr_table; |
| 1779 | int i; |
| 1780 | |
| 1781 | mutex_enter(&sa->sa_lock); |
| 1782 | |
| 1783 | if (!sa->sa_need_attr_registration || sa->sa_master_obj == 0) { |
| 1784 | mutex_exit(&sa->sa_lock); |
| 1785 | return; |
| 1786 | } |
| 1787 | |
| 1788 | if (sa->sa_reg_attr_obj == 0) { |
| 1789 | sa->sa_reg_attr_obj = zap_create_link(hdl->sa_os, |
| 1790 | DMU_OT_SA_ATTR_REGISTRATION, |
| 1791 | sa->sa_master_obj, SA_REGISTRY, tx); |
| 1792 | } |
| 1793 | for (i = 0; i != sa->sa_num_attrs; i++) { |
| 1794 | if (sa->sa_attr_table[i].sa_registered) |
| 1795 | continue; |
| 1796 | ATTR_ENCODE(attr_value, tb[i].sa_attr, tb[i].sa_length, |
| 1797 | tb[i].sa_byteswap); |
| 1798 | VERIFY(0 == zap_update(hdl->sa_os, sa->sa_reg_attr_obj, |
| 1799 | tb[i].sa_name, 8, 1, &attr_value, tx)); |
| 1800 | tb[i].sa_registered = B_TRUE; |
| 1801 | } |
| 1802 | sa->sa_need_attr_registration = B_FALSE; |
| 1803 | mutex_exit(&sa->sa_lock); |
| 1804 | } |
| 1805 | |
| 1806 | /* |
| 1807 | * Replace all attributes with attributes specified in template. |
no test coverage detected