388 bulk[i].sa_data, bulk[i].sa_length, tx);
389 } else { /* adding new attribute */
390 error = sa_modify_attrs(hdl, bulk[i].sa_attr,
391 SA_ADD, bulk[i].sa_data_func,
392 bulk[i].sa_data, bulk[i].sa_length, tx);
393 }
394 if (error)
395 return (error);
396 break;
397 }
398 }
399 return (error);
400 }
401
402 static sa_lot_t *
403 sa_add_layout_entry(objset_t *os, sa_attr_type_t *attrs, int attr_count,
404 uint64_t lot_num, uint64_t hash, boolean_t zapadd, dmu_tx_t *tx)
405 {
406 sa_os_t *sa = os->os_sa;
407 sa_lot_t *tb, *findtb;
408 int i;
409 avl_index_t loc;
410
411 ASSERT(MUTEX_HELD(&sa->sa_lock));
412 tb = kmem_zalloc(sizeof (sa_lot_t), KM_SLEEP);
413 tb->lot_attr_count = attr_count;
414 tb->lot_attrs = kmem_alloc(sizeof (sa_attr_type_t) * attr_count,
415 KM_SLEEP);
416 bcopy(attrs, tb->lot_attrs, sizeof (sa_attr_type_t) * attr_count);
417 tb->lot_num = lot_num;
418 tb->lot_hash = hash;
419 tb->lot_instance = 0;
420
421 if (zapadd) {
422 char attr_name[8];
423
424 if (sa->sa_layout_attr_obj == 0) {
425 sa->sa_layout_attr_obj = zap_create_link(os,
426 DMU_OT_SA_ATTR_LAYOUTS,
427 sa->sa_master_obj, SA_LAYOUTS, tx);
428 }
429
430 (void) snprintf(attr_name, sizeof (attr_name),
431 "%d", (int)lot_num);
432 VERIFY(0 == zap_update(os, os->os_sa->sa_layout_attr_obj,
433 attr_name, 2, attr_count, attrs, tx));
434 }
435
436 list_create(&tb->lot_idx_tab, sizeof (sa_idx_tab_t),
|
388 bulk[i].sa_data, bulk[i].sa_length, tx);
389 } else { /* adding new attribute */
390 error = sa_modify_attrs(hdl, bulk[i].sa_attr,
391 SA_ADD, bulk[i].sa_data_func,
392 bulk[i].sa_data, bulk[i].sa_length, tx);
393 }
394 if (error)
395 return (error);
396 break;
397 }
398 }
399 return (error);
400 }
401
402 static sa_lot_t *
403 sa_add_layout_entry(objset_t *os, sa_attr_type_t *attrs, int attr_count,
404 uint64_t lot_num, uint64_t hash, boolean_t zapadd, dmu_tx_t *tx)
405 {
406 sa_os_t *sa = os->os_sa;
407 sa_lot_t *tb, *findtb;
408 int i, size;
409 avl_index_t loc;
410
411 ASSERT(MUTEX_HELD(&sa->sa_lock));
412 tb = kmem_zalloc(sizeof (sa_lot_t), KM_SLEEP);
413 tb->lot_attr_count = attr_count;
414
415 if ((size = sizeof (sa_attr_type_t) * attr_count) != 0) {
416 tb->lot_attrs = kmem_alloc(size, KM_SLEEP);
417 bcopy(attrs, tb->lot_attrs, size);
418 }
419
420 tb->lot_num = lot_num;
421 tb->lot_hash = hash;
422 tb->lot_instance = 0;
423
424 if (zapadd) {
425 char attr_name[8];
426
427 if (sa->sa_layout_attr_obj == 0) {
428 sa->sa_layout_attr_obj = zap_create_link(os,
429 DMU_OT_SA_ATTR_LAYOUTS,
430 sa->sa_master_obj, SA_LAYOUTS, tx);
431 }
432
433 (void) snprintf(attr_name, sizeof (attr_name),
434 "%d", (int)lot_num);
435 VERIFY(0 == zap_update(os, os->os_sa->sa_layout_attr_obj,
436 attr_name, 2, attr_count, attrs, tx));
437 }
438
439 list_create(&tb->lot_idx_tab, sizeof (sa_idx_tab_t),
|