equal
deleted
inserted
replaced
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
24 * Portions Copyright 2011 iXsystems, Inc |
24 * Portions Copyright 2011 iXsystems, Inc |
25 * Copyright (c) 2012 by Delphix. All rights reserved. |
25 * Copyright (c) 2013 by Delphix. All rights reserved. |
26 */ |
26 */ |
27 |
27 |
28 #include <sys/zfs_context.h> |
28 #include <sys/zfs_context.h> |
29 #include <sys/types.h> |
29 #include <sys/types.h> |
30 #include <sys/param.h> |
30 #include <sys/param.h> |
371 } |
371 } |
372 |
372 |
373 switch (data_op) { |
373 switch (data_op) { |
374 case SA_LOOKUP: |
374 case SA_LOOKUP: |
375 if (bulk[i].sa_addr == NULL) |
375 if (bulk[i].sa_addr == NULL) |
376 return (ENOENT); |
376 return (SET_ERROR(ENOENT)); |
377 if (bulk[i].sa_data) { |
377 if (bulk[i].sa_data) { |
378 SA_COPY_DATA(bulk[i].sa_data_func, |
378 SA_COPY_DATA(bulk[i].sa_data_func, |
379 bulk[i].sa_addr, bulk[i].sa_data, |
379 bulk[i].sa_addr, bulk[i].sa_data, |
380 bulk[i].sa_size); |
380 bulk[i].sa_size); |
381 } |
381 } |
501 |
501 |
502 if (size == 0) { |
502 if (size == 0) { |
503 blocksize = SPA_MINBLOCKSIZE; |
503 blocksize = SPA_MINBLOCKSIZE; |
504 } else if (size > SPA_MAXBLOCKSIZE) { |
504 } else if (size > SPA_MAXBLOCKSIZE) { |
505 ASSERT(0); |
505 ASSERT(0); |
506 return (EFBIG); |
506 return (SET_ERROR(EFBIG)); |
507 } else { |
507 } else { |
508 blocksize = P2ROUNDUP_TYPED(size, SPA_MINBLOCKSIZE, uint32_t); |
508 blocksize = P2ROUNDUP_TYPED(size, SPA_MINBLOCKSIZE, uint32_t); |
509 } |
509 } |
510 |
510 |
511 error = dbuf_spill_set_blksz(hdl->sa_spill, blocksize, tx); |
511 error = dbuf_spill_set_blksz(hdl->sa_spill, blocksize, tx); |
675 /* first determine bonus header size and sum of all attributes */ |
675 /* first determine bonus header size and sum of all attributes */ |
676 hdrsize = sa_find_sizes(sa, attr_desc, attr_count, hdl->sa_bonus, |
676 hdrsize = sa_find_sizes(sa, attr_desc, attr_count, hdl->sa_bonus, |
677 SA_BONUS, &i, &used, &spilling); |
677 SA_BONUS, &i, &used, &spilling); |
678 |
678 |
679 if (used > SPA_MAXBLOCKSIZE) |
679 if (used > SPA_MAXBLOCKSIZE) |
680 return (EFBIG); |
680 return (SET_ERROR(EFBIG)); |
681 |
681 |
682 VERIFY(0 == dmu_set_bonus(hdl->sa_bonus, spilling ? |
682 VERIFY(0 == dmu_set_bonus(hdl->sa_bonus, spilling ? |
683 MIN(DN_MAX_BONUSLEN - sizeof (blkptr_t), used + hdrsize) : |
683 MIN(DN_MAX_BONUSLEN - sizeof (blkptr_t), used + hdrsize) : |
684 used + hdrsize, tx)); |
684 used + hdrsize, tx)); |
685 |
685 |
699 spillhdrsize = sa_find_sizes(sa, &attr_desc[i], |
699 spillhdrsize = sa_find_sizes(sa, &attr_desc[i], |
700 attr_count - i, hdl->sa_spill, SA_SPILL, &i, |
700 attr_count - i, hdl->sa_spill, SA_SPILL, &i, |
701 &spill_used, &dummy); |
701 &spill_used, &dummy); |
702 |
702 |
703 if (spill_used > SPA_MAXBLOCKSIZE) |
703 if (spill_used > SPA_MAXBLOCKSIZE) |
704 return (EFBIG); |
704 return (SET_ERROR(EFBIG)); |
705 |
705 |
706 buf_space = hdl->sa_spill->db_size - spillhdrsize; |
706 buf_space = hdl->sa_spill->db_size - spillhdrsize; |
707 if (BUF_SPACE_NEEDED(spill_used, spillhdrsize) > |
707 if (BUF_SPACE_NEEDED(spill_used, spillhdrsize) > |
708 hdl->sa_spill->db_size) |
708 hdl->sa_spill->db_size) |
709 VERIFY(0 == sa_resize_spill(hdl, |
709 VERIFY(0 == sa_resize_spill(hdl, |
856 /* |
856 /* |
857 * Make sure we retrieved a count and that it isn't zero |
857 * Make sure we retrieved a count and that it isn't zero |
858 */ |
858 */ |
859 if (error || (error == 0 && sa_attr_count == 0)) { |
859 if (error || (error == 0 && sa_attr_count == 0)) { |
860 if (error == 0) |
860 if (error == 0) |
861 error = EINVAL; |
861 error = SET_ERROR(EINVAL); |
862 goto bail; |
862 goto bail; |
863 } |
863 } |
864 sa_reg_count = sa_attr_count; |
864 sa_reg_count = sa_attr_count; |
865 } |
865 } |
866 |
866 |
887 |
887 |
888 if (sa->sa_reg_attr_obj) |
888 if (sa->sa_reg_attr_obj) |
889 error = zap_lookup(os, sa->sa_reg_attr_obj, |
889 error = zap_lookup(os, sa->sa_reg_attr_obj, |
890 reg_attrs[i].sa_name, 8, 1, &attr_value); |
890 reg_attrs[i].sa_name, 8, 1, &attr_value); |
891 else |
891 else |
892 error = ENOENT; |
892 error = SET_ERROR(ENOENT); |
893 switch (error) { |
893 switch (error) { |
894 case ENOENT: |
894 case ENOENT: |
895 sa->sa_user_table[i] = (sa_attr_type_t)sa_attr_count; |
895 sa->sa_user_table[i] = (sa_attr_type_t)sa_attr_count; |
896 sa_attr_count++; |
896 sa_attr_count++; |
897 break; |
897 break; |
1046 /* |
1046 /* |
1047 * Layout number count should be > 0 |
1047 * Layout number count should be > 0 |
1048 */ |
1048 */ |
1049 if (error || (error == 0 && layout_count == 0)) { |
1049 if (error || (error == 0 && layout_count == 0)) { |
1050 if (error == 0) |
1050 if (error == 0) |
1051 error = EINVAL; |
1051 error = SET_ERROR(EINVAL); |
1052 goto fail; |
1052 goto fail; |
1053 } |
1053 } |
1054 |
1054 |
1055 for (zap_cursor_init(&zc, os, sa->sa_layout_attr_obj); |
1055 for (zap_cursor_init(&zc, os, sa->sa_layout_attr_obj); |
1056 (error = zap_cursor_retrieve(&zc, &za)) == 0; |
1056 (error = zap_cursor_retrieve(&zc, &za)) == 0; |