Date: Tue, 18 Sep 2012 08:02:54 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r240632 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <201209180802.q8I82sbu053613@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Tue Sep 18 08:02:54 2012 New Revision: 240632 URL: http://svn.freebsd.org/changeset/base/240632 Log: zfs: correctly calculate dn_bonuslen for saving SAs to disk Since all attribute values start at 8-byte aligned boundary, we would previously incorrectly calculate dn_bonuslen if any attribute but the last had a variable-length value with length not multiple of 8. Reported by: Nicolas Rachinsky <fbsd-mas-0@ml.turing-complete.org> Tested by: Nicolas Rachinsky <fbsd-mas-0@ml.turing-complete.org> Reviewed by: Matthew Ahrens <mahrens@delphix.com> (for upstream) MFC after: 2 weeks Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c Tue Sep 18 08:00:56 2012 (r240631) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c Tue Sep 18 08:02:54 2012 (r240632) @@ -578,7 +578,7 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_ for (i = 0; i != attr_count; i++) { boolean_t is_var_sz; - *total += attr_desc[i].sa_length; + *total += P2ROUNDUP(attr_desc[i].sa_length, 8); if (done) goto next; @@ -713,6 +713,8 @@ sa_build_layouts(sa_handle_t *hdl, sa_bu length = SA_REGISTERED_LEN(sa, attrs[i]); if (length == 0) length = attr_desc[i].sa_length; + else + VERIFY(length == attr_desc[i].sa_length); if (buf_space < length) { /* switch to spill buffer */ VERIFY(bonustype == DMU_OT_SA); @@ -742,6 +744,7 @@ sa_build_layouts(sa_handle_t *hdl, sa_bu if (sa->sa_attr_table[attrs[i]].sa_length == 0) { sahdr->sa_lengths[len_idx++] = length; } + VERIFY((uintptr_t)data_start % 8 == 0); data_start = (void *)P2ROUNDUP(((uintptr_t)data_start + length), 8); buf_space -= P2ROUNDUP(length, 8);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209180802.q8I82sbu053613>