diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-08-14 21:17:07 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2010-02-26 18:41:09 -0500 |
commit | 18853b95d1fb964b76c3393a12c4d861e7779460 (patch) | |
tree | 5834a4797a9eafcc45f9a78b99b5db888060e274 /fs | |
parent | 6b240ff63c9dda93366c61c969b81ca22fe676ac (diff) |
ocfs2: Add a name_len field to ocfs2_xattr_info.
Rather than calculating strlen all over the place, let's store the
name length directly on ocfs2_xattr_info.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/xattr.c | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index c675a6cda0bb..68126adbf311 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -118,6 +118,7 @@ static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { | |||
118 | struct ocfs2_xattr_info { | 118 | struct ocfs2_xattr_info { |
119 | int xi_name_index; | 119 | int xi_name_index; |
120 | const char *xi_name; | 120 | const char *xi_name; |
121 | int xi_name_len; | ||
121 | const void *xi_value; | 122 | const void *xi_value; |
122 | size_t xi_value_len; | 123 | size_t xi_value_len; |
123 | }; | 124 | }; |
@@ -1361,9 +1362,9 @@ static int ocfs2_xattr_cleanup(struct inode *inode, | |||
1361 | size_t offs) | 1362 | size_t offs) |
1362 | { | 1363 | { |
1363 | int ret = 0; | 1364 | int ret = 0; |
1364 | size_t name_len = strlen(xi->xi_name); | ||
1365 | void *val = xs->base + offs; | 1365 | void *val = xs->base + offs; |
1366 | size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; | 1366 | size_t size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1367 | OCFS2_XATTR_ROOT_SIZE; | ||
1367 | 1368 | ||
1368 | ret = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh, | 1369 | ret = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh, |
1369 | OCFS2_JOURNAL_ACCESS_WRITE); | 1370 | OCFS2_JOURNAL_ACCESS_WRITE); |
@@ -1427,16 +1428,16 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode, | |||
1427 | struct ocfs2_xattr_value_buf *vb, | 1428 | struct ocfs2_xattr_value_buf *vb, |
1428 | size_t offs) | 1429 | size_t offs) |
1429 | { | 1430 | { |
1430 | size_t name_len = strlen(xi->xi_name); | ||
1431 | void *val = xs->base + offs; | 1431 | void *val = xs->base + offs; |
1432 | struct ocfs2_xattr_value_root *xv = NULL; | 1432 | struct ocfs2_xattr_value_root *xv = NULL; |
1433 | size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; | 1433 | size_t size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1434 | OCFS2_XATTR_ROOT_SIZE; | ||
1434 | int ret = 0; | 1435 | int ret = 0; |
1435 | 1436 | ||
1436 | memset(val, 0, size); | 1437 | memset(val, 0, size); |
1437 | memcpy(val, xi->xi_name, name_len); | 1438 | memcpy(val, xi->xi_name, xi->xi_name_len); |
1438 | xv = (struct ocfs2_xattr_value_root *) | 1439 | xv = (struct ocfs2_xattr_value_root *) |
1439 | (val + OCFS2_XATTR_SIZE(name_len)); | 1440 | (val + OCFS2_XATTR_SIZE(xi->xi_name_len)); |
1440 | xv->xr_clusters = 0; | 1441 | xv->xr_clusters = 0; |
1441 | xv->xr_last_eb_blk = 0; | 1442 | xv->xr_last_eb_blk = 0; |
1442 | xv->xr_list.l_tree_depth = 0; | 1443 | xv->xr_list.l_tree_depth = 0; |
@@ -1659,7 +1660,6 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1659 | struct ocfs2_xattr_entry *last, | 1660 | struct ocfs2_xattr_entry *last, |
1660 | size_t min_offs) | 1661 | size_t min_offs) |
1661 | { | 1662 | { |
1662 | size_t name_len = strlen(xi->xi_name); | ||
1663 | struct ocfs2_xa_loc loc; | 1663 | struct ocfs2_xa_loc loc; |
1664 | 1664 | ||
1665 | if (xs->xattr_bh == xs->inode_bh) | 1665 | if (xs->xattr_bh == xs->inode_bh) |
@@ -1673,7 +1673,7 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1673 | le16_add_cpu(&xs->header->xh_count, 1); | 1673 | le16_add_cpu(&xs->header->xh_count, 1); |
1674 | ocfs2_xattr_set_type(last, xi->xi_name_index); | 1674 | ocfs2_xattr_set_type(last, xi->xi_name_index); |
1675 | ocfs2_xattr_set_local(last, 1); | 1675 | ocfs2_xattr_set_local(last, 1); |
1676 | last->xe_name_len = name_len; | 1676 | last->xe_name_len = xi->xi_name_len; |
1677 | } else { | 1677 | } else { |
1678 | void *first_val; | 1678 | void *first_val; |
1679 | void *val; | 1679 | void *val; |
@@ -1685,23 +1685,23 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1685 | 1685 | ||
1686 | if (le64_to_cpu(xs->here->xe_value_size) > | 1686 | if (le64_to_cpu(xs->here->xe_value_size) > |
1687 | OCFS2_XATTR_INLINE_SIZE) | 1687 | OCFS2_XATTR_INLINE_SIZE) |
1688 | size = OCFS2_XATTR_SIZE(name_len) + | 1688 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1689 | OCFS2_XATTR_ROOT_SIZE; | 1689 | OCFS2_XATTR_ROOT_SIZE; |
1690 | else | 1690 | else |
1691 | size = OCFS2_XATTR_SIZE(name_len) + | 1691 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1692 | OCFS2_XATTR_SIZE(le64_to_cpu(xs->here->xe_value_size)); | 1692 | OCFS2_XATTR_SIZE(le64_to_cpu(xs->here->xe_value_size)); |
1693 | 1693 | ||
1694 | if (xi->xi_value && size == OCFS2_XATTR_SIZE(name_len) + | 1694 | if (xi->xi_value && size == OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1695 | OCFS2_XATTR_SIZE(xi->xi_value_len)) { | 1695 | OCFS2_XATTR_SIZE(xi->xi_value_len)) { |
1696 | /* The old and the new value have the | 1696 | /* The old and the new value have the |
1697 | same size. Just replace the value. */ | 1697 | same size. Just replace the value. */ |
1698 | ocfs2_xattr_set_local(xs->here, 1); | 1698 | ocfs2_xattr_set_local(xs->here, 1); |
1699 | xs->here->xe_value_size = cpu_to_le64(xi->xi_value_len); | 1699 | xs->here->xe_value_size = cpu_to_le64(xi->xi_value_len); |
1700 | /* Clear value bytes. */ | 1700 | /* Clear value bytes. */ |
1701 | memset(val + OCFS2_XATTR_SIZE(name_len), | 1701 | memset(val + OCFS2_XATTR_SIZE(xi->xi_name_len), |
1702 | 0, | 1702 | 0, |
1703 | OCFS2_XATTR_SIZE(xi->xi_value_len)); | 1703 | OCFS2_XATTR_SIZE(xi->xi_value_len)); |
1704 | memcpy(val + OCFS2_XATTR_SIZE(name_len), | 1704 | memcpy(val + OCFS2_XATTR_SIZE(xi->xi_name_len), |
1705 | xi->xi_value, | 1705 | xi->xi_value, |
1706 | xi->xi_value_len); | 1706 | xi->xi_value_len); |
1707 | return; | 1707 | return; |
@@ -1716,14 +1716,14 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1716 | } | 1716 | } |
1717 | if (xi->xi_value) { | 1717 | if (xi->xi_value) { |
1718 | /* Insert the new name+value. */ | 1718 | /* Insert the new name+value. */ |
1719 | size_t size = OCFS2_XATTR_SIZE(name_len) + | 1719 | size_t size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1720 | OCFS2_XATTR_SIZE(xi->xi_value_len); | 1720 | OCFS2_XATTR_SIZE(xi->xi_value_len); |
1721 | void *val = xs->base + min_offs - size; | 1721 | void *val = xs->base + min_offs - size; |
1722 | 1722 | ||
1723 | xs->here->xe_name_offset = cpu_to_le16(min_offs - size); | 1723 | xs->here->xe_name_offset = cpu_to_le16(min_offs - size); |
1724 | memset(val, 0, size); | 1724 | memset(val, 0, size); |
1725 | memcpy(val, xi->xi_name, name_len); | 1725 | memcpy(val, xi->xi_name, xi->xi_name_len); |
1726 | memcpy(val + OCFS2_XATTR_SIZE(name_len), | 1726 | memcpy(val + OCFS2_XATTR_SIZE(xi->xi_name_len), |
1727 | xi->xi_value, | 1727 | xi->xi_value, |
1728 | xi->xi_value_len); | 1728 | xi->xi_value_len); |
1729 | xs->here->xe_value_size = cpu_to_le64(xi->xi_value_len); | 1729 | xs->here->xe_value_size = cpu_to_le64(xi->xi_value_len); |
@@ -1752,13 +1752,14 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1752 | struct ocfs2_xattr_entry *last; | 1752 | struct ocfs2_xattr_entry *last; |
1753 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1753 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
1754 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data; | 1754 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data; |
1755 | size_t min_offs = xs->end - xs->base, name_len = strlen(xi->xi_name); | 1755 | size_t min_offs = xs->end - xs->base; |
1756 | size_t size_l = 0; | 1756 | size_t size_l = 0; |
1757 | handle_t *handle = ctxt->handle; | 1757 | handle_t *handle = ctxt->handle; |
1758 | int free, i, ret; | 1758 | int free, i, ret; |
1759 | struct ocfs2_xattr_info xi_l = { | 1759 | struct ocfs2_xattr_info xi_l = { |
1760 | .xi_name_index = xi->xi_name_index, | 1760 | .xi_name_index = xi->xi_name_index, |
1761 | .xi_name = xi->xi_name, | 1761 | .xi_name = xi->xi_name, |
1762 | .xi_name_len = xi->xi_name_len, | ||
1762 | .xi_value = xi->xi_value, | 1763 | .xi_value = xi->xi_value, |
1763 | .xi_value_len = xi->xi_value_len, | 1764 | .xi_value_len = xi->xi_value_len, |
1764 | }; | 1765 | }; |
@@ -1790,27 +1791,28 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1790 | if (!xs->not_found) { | 1791 | if (!xs->not_found) { |
1791 | size_t size = 0; | 1792 | size_t size = 0; |
1792 | if (ocfs2_xattr_is_local(xs->here)) | 1793 | if (ocfs2_xattr_is_local(xs->here)) |
1793 | size = OCFS2_XATTR_SIZE(name_len) + | 1794 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1794 | OCFS2_XATTR_SIZE(le64_to_cpu(xs->here->xe_value_size)); | 1795 | OCFS2_XATTR_SIZE(le64_to_cpu(xs->here->xe_value_size)); |
1795 | else | 1796 | else |
1796 | size = OCFS2_XATTR_SIZE(name_len) + | 1797 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1797 | OCFS2_XATTR_ROOT_SIZE; | 1798 | OCFS2_XATTR_ROOT_SIZE; |
1798 | free += (size + sizeof(struct ocfs2_xattr_entry)); | 1799 | free += (size + sizeof(struct ocfs2_xattr_entry)); |
1799 | } | 1800 | } |
1800 | /* Check free space in inode or block */ | 1801 | /* Check free space in inode or block */ |
1801 | if (xi->xi_value && xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { | 1802 | if (xi->xi_value && xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
1802 | if (free < sizeof(struct ocfs2_xattr_entry) + | 1803 | if (free < sizeof(struct ocfs2_xattr_entry) + |
1803 | OCFS2_XATTR_SIZE(name_len) + | 1804 | OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1804 | OCFS2_XATTR_ROOT_SIZE) { | 1805 | OCFS2_XATTR_ROOT_SIZE) { |
1805 | ret = -ENOSPC; | 1806 | ret = -ENOSPC; |
1806 | goto out; | 1807 | goto out; |
1807 | } | 1808 | } |
1808 | size_l = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; | 1809 | size_l = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1810 | OCFS2_XATTR_ROOT_SIZE; | ||
1809 | xi_l.xi_value = (void *)&def_xv; | 1811 | xi_l.xi_value = (void *)&def_xv; |
1810 | xi_l.xi_value_len = OCFS2_XATTR_ROOT_SIZE; | 1812 | xi_l.xi_value_len = OCFS2_XATTR_ROOT_SIZE; |
1811 | } else if (xi->xi_value) { | 1813 | } else if (xi->xi_value) { |
1812 | if (free < sizeof(struct ocfs2_xattr_entry) + | 1814 | if (free < sizeof(struct ocfs2_xattr_entry) + |
1813 | OCFS2_XATTR_SIZE(name_len) + | 1815 | OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1814 | OCFS2_XATTR_SIZE(xi->xi_value_len)) { | 1816 | OCFS2_XATTR_SIZE(xi->xi_value_len)) { |
1815 | ret = -ENOSPC; | 1817 | ret = -ENOSPC; |
1816 | goto out; | 1818 | goto out; |
@@ -1819,7 +1821,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1819 | 1821 | ||
1820 | if (!xs->not_found) { | 1822 | if (!xs->not_found) { |
1821 | /* For existing extended attribute */ | 1823 | /* For existing extended attribute */ |
1822 | size_t size = OCFS2_XATTR_SIZE(name_len) + | 1824 | size_t size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
1823 | OCFS2_XATTR_SIZE(le64_to_cpu(xs->here->xe_value_size)); | 1825 | OCFS2_XATTR_SIZE(le64_to_cpu(xs->here->xe_value_size)); |
1824 | size_t offs = le16_to_cpu(xs->here->xe_name_offset); | 1826 | size_t offs = le16_to_cpu(xs->here->xe_name_offset); |
1825 | void *val = xs->base + offs; | 1827 | void *val = xs->base + offs; |
@@ -1834,7 +1836,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1834 | } else if (!ocfs2_xattr_is_local(xs->here)) { | 1836 | } else if (!ocfs2_xattr_is_local(xs->here)) { |
1835 | /* For existing xattr which has value outside */ | 1837 | /* For existing xattr which has value outside */ |
1836 | vb.vb_xv = (struct ocfs2_xattr_value_root *) | 1838 | vb.vb_xv = (struct ocfs2_xattr_value_root *) |
1837 | (val + OCFS2_XATTR_SIZE(name_len)); | 1839 | (val + OCFS2_XATTR_SIZE(xi->xi_name_len)); |
1838 | 1840 | ||
1839 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { | 1841 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
1840 | /* | 1842 | /* |
@@ -2616,7 +2618,7 @@ static int ocfs2_xattr_can_be_in_inode(struct inode *inode, | |||
2616 | value_size = OCFS2_XATTR_SIZE(xi->xi_value_len); | 2618 | value_size = OCFS2_XATTR_SIZE(xi->xi_value_len); |
2617 | 2619 | ||
2618 | if (free >= sizeof(struct ocfs2_xattr_entry) + | 2620 | if (free >= sizeof(struct ocfs2_xattr_entry) + |
2619 | OCFS2_XATTR_SIZE(strlen(xi->xi_name)) + value_size) | 2621 | OCFS2_XATTR_SIZE(xi->xi_name_len) + value_size) |
2620 | return 1; | 2622 | return 1; |
2621 | 2623 | ||
2622 | return 0; | 2624 | return 0; |
@@ -3048,6 +3050,7 @@ int ocfs2_xattr_set_handle(handle_t *handle, | |||
3048 | struct ocfs2_xattr_info xi = { | 3050 | struct ocfs2_xattr_info xi = { |
3049 | .xi_name_index = name_index, | 3051 | .xi_name_index = name_index, |
3050 | .xi_name = name, | 3052 | .xi_name = name, |
3053 | .xi_name_len = strlen(name), | ||
3051 | .xi_value = value, | 3054 | .xi_value = value, |
3052 | .xi_value_len = value_len, | 3055 | .xi_value_len = value_len, |
3053 | }; | 3056 | }; |
@@ -3131,6 +3134,7 @@ int ocfs2_xattr_set(struct inode *inode, | |||
3131 | struct ocfs2_xattr_info xi = { | 3134 | struct ocfs2_xattr_info xi = { |
3132 | .xi_name_index = name_index, | 3135 | .xi_name_index = name_index, |
3133 | .xi_name = name, | 3136 | .xi_name = name, |
3137 | .xi_name_len = strlen(name), | ||
3134 | .xi_value = value, | 3138 | .xi_value = value, |
3135 | .xi_value_len = value_len, | 3139 | .xi_value_len = value_len, |
3136 | }; | 3140 | }; |
@@ -4980,7 +4984,6 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
4980 | int local) | 4984 | int local) |
4981 | { | 4985 | { |
4982 | struct ocfs2_xattr_entry *last, *xe; | 4986 | struct ocfs2_xattr_entry *last, *xe; |
4983 | int name_len = strlen(xi->xi_name); | ||
4984 | struct ocfs2_xattr_header *xh = xs->header; | 4987 | struct ocfs2_xattr_header *xh = xs->header; |
4985 | u16 count = le16_to_cpu(xh->xh_count), start; | 4988 | u16 count = le16_to_cpu(xh->xh_count), start; |
4986 | size_t blocksize = inode->i_sb->s_blocksize; | 4989 | size_t blocksize = inode->i_sb->s_blocksize; |
@@ -4995,10 +4998,10 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
4995 | xe = xs->here; | 4998 | xe = xs->here; |
4996 | offs = le16_to_cpu(xe->xe_name_offset); | 4999 | offs = le16_to_cpu(xe->xe_name_offset); |
4997 | if (ocfs2_xattr_is_local(xe)) | 5000 | if (ocfs2_xattr_is_local(xe)) |
4998 | size = OCFS2_XATTR_SIZE(name_len) + | 5001 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
4999 | OCFS2_XATTR_SIZE(le64_to_cpu(xe->xe_value_size)); | 5002 | OCFS2_XATTR_SIZE(le64_to_cpu(xe->xe_value_size)); |
5000 | else | 5003 | else |
5001 | size = OCFS2_XATTR_SIZE(name_len) + | 5004 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
5002 | OCFS2_XATTR_SIZE(OCFS2_XATTR_ROOT_SIZE); | 5005 | OCFS2_XATTR_SIZE(OCFS2_XATTR_ROOT_SIZE); |
5003 | 5006 | ||
5004 | /* | 5007 | /* |
@@ -5008,7 +5011,7 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
5008 | * new_size safely here. | 5011 | * new_size safely here. |
5009 | * See ocfs2_xattr_set_in_bucket. | 5012 | * See ocfs2_xattr_set_in_bucket. |
5010 | */ | 5013 | */ |
5011 | new_size = OCFS2_XATTR_SIZE(name_len) + | 5014 | new_size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
5012 | OCFS2_XATTR_SIZE(xi->xi_value_len); | 5015 | OCFS2_XATTR_SIZE(xi->xi_value_len); |
5013 | 5016 | ||
5014 | if (xi->xi_value) { | 5017 | if (xi->xi_value) { |
@@ -5025,10 +5028,10 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
5025 | 5028 | ||
5026 | val = ocfs2_xattr_bucket_get_val(inode, | 5029 | val = ocfs2_xattr_bucket_get_val(inode, |
5027 | xs->bucket, offs); | 5030 | xs->bucket, offs); |
5028 | memset(val + OCFS2_XATTR_SIZE(name_len), 0, | 5031 | memset(val + OCFS2_XATTR_SIZE(xi->xi_name_len), 0, |
5029 | size - OCFS2_XATTR_SIZE(name_len)); | 5032 | size - OCFS2_XATTR_SIZE(xi->xi_name_len)); |
5030 | if (OCFS2_XATTR_SIZE(xi->xi_value_len) > 0) | 5033 | if (OCFS2_XATTR_SIZE(xi->xi_value_len) > 0) |
5031 | memcpy(val + OCFS2_XATTR_SIZE(name_len), | 5034 | memcpy(val + OCFS2_XATTR_SIZE(xi->xi_name_len), |
5032 | xi->xi_value, xi->xi_value_len); | 5035 | xi->xi_value, xi->xi_value_len); |
5033 | 5036 | ||
5034 | le16_add_cpu(&xh->xh_name_value_len, new_size); | 5037 | le16_add_cpu(&xh->xh_name_value_len, new_size); |
@@ -5069,13 +5072,14 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
5069 | le16_add_cpu(&xh->xh_count, 1); | 5072 | le16_add_cpu(&xh->xh_count, 1); |
5070 | memset(xe, 0, sizeof(struct ocfs2_xattr_entry)); | 5073 | memset(xe, 0, sizeof(struct ocfs2_xattr_entry)); |
5071 | xe->xe_name_hash = cpu_to_le32(name_hash); | 5074 | xe->xe_name_hash = cpu_to_le32(name_hash); |
5072 | xe->xe_name_len = name_len; | 5075 | xe->xe_name_len = xi->xi_name_len; |
5073 | ocfs2_xattr_set_type(xe, xi->xi_name_index); | 5076 | ocfs2_xattr_set_type(xe, xi->xi_name_index); |
5074 | } | 5077 | } |
5075 | 5078 | ||
5076 | set_new_name_value: | 5079 | set_new_name_value: |
5077 | /* Insert the new name+value. */ | 5080 | /* Insert the new name+value. */ |
5078 | size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_SIZE(xi->xi_value_len); | 5081 | size = OCFS2_XATTR_SIZE(xi->xi_name_len) + |
5082 | OCFS2_XATTR_SIZE(xi->xi_value_len); | ||
5079 | 5083 | ||
5080 | /* | 5084 | /* |
5081 | * We must make sure that the name/value pair | 5085 | * We must make sure that the name/value pair |
@@ -5094,8 +5098,8 @@ set_new_name_value: | |||
5094 | xe->xe_name_offset = cpu_to_le16(offs - size); | 5098 | xe->xe_name_offset = cpu_to_le16(offs - size); |
5095 | 5099 | ||
5096 | memset(val, 0, size); | 5100 | memset(val, 0, size); |
5097 | memcpy(val, xi->xi_name, name_len); | 5101 | memcpy(val, xi->xi_name, xi->xi_name_len); |
5098 | memcpy(val + OCFS2_XATTR_SIZE(name_len), xi->xi_value, | 5102 | memcpy(val + OCFS2_XATTR_SIZE(xi->xi_name_len), xi->xi_value, |
5099 | xi->xi_value_len); | 5103 | xi->xi_value_len); |
5100 | 5104 | ||
5101 | xe->xe_value_size = cpu_to_le64(xi->xi_value_len); | 5105 | xe->xe_value_size = cpu_to_le64(xi->xi_value_len); |
@@ -5424,7 +5428,7 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode, | |||
5424 | char *val = (char *)xi->xi_value; | 5428 | char *val = (char *)xi->xi_value; |
5425 | struct ocfs2_xattr_entry *xe = xs->here; | 5429 | struct ocfs2_xattr_entry *xe = xs->here; |
5426 | u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name, | 5430 | u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name, |
5427 | strlen(xi->xi_name)); | 5431 | xi->xi_name_len); |
5428 | 5432 | ||
5429 | if (!xs->not_found && !ocfs2_xattr_is_local(xe)) { | 5433 | if (!xs->not_found && !ocfs2_xattr_is_local(xe)) { |
5430 | /* | 5434 | /* |
@@ -5537,7 +5541,7 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, | |||
5537 | struct ocfs2_xattr_entry *xe; | 5541 | struct ocfs2_xattr_entry *xe; |
5538 | u16 count, header_size, xh_free_start; | 5542 | u16 count, header_size, xh_free_start; |
5539 | int free, max_free, need, old; | 5543 | int free, max_free, need, old; |
5540 | size_t value_size = 0, name_len = strlen(xi->xi_name); | 5544 | size_t value_size = 0; |
5541 | size_t blocksize = inode->i_sb->s_blocksize; | 5545 | size_t blocksize = inode->i_sb->s_blocksize; |
5542 | int ret, allocation = 0; | 5546 | int ret, allocation = 0; |
5543 | 5547 | ||
@@ -5564,9 +5568,9 @@ try_again: | |||
5564 | 5568 | ||
5565 | if (xs->not_found) | 5569 | if (xs->not_found) |
5566 | need = sizeof(struct ocfs2_xattr_entry) + | 5570 | need = sizeof(struct ocfs2_xattr_entry) + |
5567 | OCFS2_XATTR_SIZE(name_len) + value_size; | 5571 | OCFS2_XATTR_SIZE(xi->xi_name_len) + value_size; |
5568 | else { | 5572 | else { |
5569 | need = value_size + OCFS2_XATTR_SIZE(name_len); | 5573 | need = value_size + OCFS2_XATTR_SIZE(xi->xi_name_len); |
5570 | 5574 | ||
5571 | /* | 5575 | /* |
5572 | * We only replace the old value if the new length is smaller | 5576 | * We only replace the old value if the new length is smaller |