summaryrefslogtreecommitdiffstats
path: root/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2012-09-18 08:02:54 +0000
committeravg <avg@FreeBSD.org>2012-09-18 08:02:54 +0000
commita12168f37c6d064662701f62ee5dae2a9ce029f7 (patch)
tree3487216a864b83100389053466cb35ffb364d791 /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
parent63f3204e0bd5413143ec9f71bf54d4722c9ef46a (diff)
downloadFreeBSD-src-a12168f37c6d064662701f62ee5dae2a9ce029f7.zip
FreeBSD-src-a12168f37c6d064662701f62ee5dae2a9ce029f7.tar.gz
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
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
index 9bb5cbc..894bbc3 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
@@ -578,7 +578,7 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
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_bulk_attr_t *attr_desc, int attr_count,
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_bulk_attr_t *attr_desc, int attr_count,
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);
OpenPOWER on IntegriCloud