diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-08-14 21:02:52 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2010-02-26 18:41:09 -0500 |
commit | 6b240ff63c9dda93366c61c969b81ca22fe676ac (patch) | |
tree | 0db4d58997e690940588ed7aad5188bcc1091136 /fs/ocfs2/xattr.c | |
parent | bde1e5400a1b21ef47932ab00446c7361ff3c139 (diff) |
ocfs2: Prefix the member fields of struct ocfs2_xattr_info.
struct ocfs2_xattr_info is a useful structure describing an xattr
you'd like to set. Let's put prefixes on the member fields so it's
easier to read and use.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r-- | fs/ocfs2/xattr.c | 212 |
1 files changed, 108 insertions, 104 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 22a60a7c35ca..c675a6cda0bb 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -116,10 +116,10 @@ static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { | |||
116 | }; | 116 | }; |
117 | 117 | ||
118 | struct ocfs2_xattr_info { | 118 | struct ocfs2_xattr_info { |
119 | int name_index; | 119 | int xi_name_index; |
120 | const char *name; | 120 | const char *xi_name; |
121 | const void *value; | 121 | const void *xi_value; |
122 | size_t value_len; | 122 | size_t xi_value_len; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | struct ocfs2_xattr_search { | 125 | struct ocfs2_xattr_search { |
@@ -1361,7 +1361,7 @@ static int ocfs2_xattr_cleanup(struct inode *inode, | |||
1361 | size_t offs) | 1361 | size_t offs) |
1362 | { | 1362 | { |
1363 | int ret = 0; | 1363 | int ret = 0; |
1364 | size_t name_len = strlen(xi->name); | 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(name_len) + OCFS2_XATTR_ROOT_SIZE; |
1367 | 1367 | ||
@@ -1401,8 +1401,8 @@ static int ocfs2_xattr_update_entry(struct inode *inode, | |||
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | xs->here->xe_name_offset = cpu_to_le16(offs); | 1403 | xs->here->xe_name_offset = cpu_to_le16(offs); |
1404 | xs->here->xe_value_size = cpu_to_le64(xi->value_len); | 1404 | xs->here->xe_value_size = cpu_to_le64(xi->xi_value_len); |
1405 | if (xi->value_len <= OCFS2_XATTR_INLINE_SIZE) | 1405 | if (xi->xi_value_len <= OCFS2_XATTR_INLINE_SIZE) |
1406 | ocfs2_xattr_set_local(xs->here, 1); | 1406 | ocfs2_xattr_set_local(xs->here, 1); |
1407 | else | 1407 | else |
1408 | ocfs2_xattr_set_local(xs->here, 0); | 1408 | ocfs2_xattr_set_local(xs->here, 0); |
@@ -1427,14 +1427,14 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode, | |||
1427 | struct ocfs2_xattr_value_buf *vb, | 1427 | struct ocfs2_xattr_value_buf *vb, |
1428 | size_t offs) | 1428 | size_t offs) |
1429 | { | 1429 | { |
1430 | size_t name_len = strlen(xi->name); | 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(name_len) + OCFS2_XATTR_ROOT_SIZE; |
1434 | int ret = 0; | 1434 | int ret = 0; |
1435 | 1435 | ||
1436 | memset(val, 0, size); | 1436 | memset(val, 0, size); |
1437 | memcpy(val, xi->name, name_len); | 1437 | memcpy(val, xi->xi_name, name_len); |
1438 | xv = (struct ocfs2_xattr_value_root *) | 1438 | xv = (struct ocfs2_xattr_value_root *) |
1439 | (val + OCFS2_XATTR_SIZE(name_len)); | 1439 | (val + OCFS2_XATTR_SIZE(name_len)); |
1440 | xv->xr_clusters = 0; | 1440 | xv->xr_clusters = 0; |
@@ -1444,7 +1444,7 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode, | |||
1444 | xv->xr_list.l_next_free_rec = 0; | 1444 | xv->xr_list.l_next_free_rec = 0; |
1445 | vb->vb_xv = xv; | 1445 | vb->vb_xv = xv; |
1446 | 1446 | ||
1447 | ret = ocfs2_xattr_value_truncate(inode, vb, xi->value_len, ctxt); | 1447 | ret = ocfs2_xattr_value_truncate(inode, vb, xi->xi_value_len, ctxt); |
1448 | if (ret < 0) { | 1448 | if (ret < 0) { |
1449 | mlog_errno(ret); | 1449 | mlog_errno(ret); |
1450 | return ret; | 1450 | return ret; |
@@ -1455,7 +1455,7 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode, | |||
1455 | return ret; | 1455 | return ret; |
1456 | } | 1456 | } |
1457 | ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb, | 1457 | ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb, |
1458 | xi->value, xi->value_len); | 1458 | xi->xi_value, xi->xi_value_len); |
1459 | if (ret < 0) | 1459 | if (ret < 0) |
1460 | mlog_errno(ret); | 1460 | mlog_errno(ret); |
1461 | 1461 | ||
@@ -1659,7 +1659,7 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1659 | struct ocfs2_xattr_entry *last, | 1659 | struct ocfs2_xattr_entry *last, |
1660 | size_t min_offs) | 1660 | size_t min_offs) |
1661 | { | 1661 | { |
1662 | size_t name_len = strlen(xi->name); | 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) |
@@ -1668,10 +1668,10 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1668 | else | 1668 | else |
1669 | ocfs2_init_xattr_block_xa_loc(&loc, xs->xattr_bh, | 1669 | ocfs2_init_xattr_block_xa_loc(&loc, xs->xattr_bh, |
1670 | xs->not_found ? NULL : xs->here); | 1670 | xs->not_found ? NULL : xs->here); |
1671 | if (xi->value && xs->not_found) { | 1671 | if (xi->xi_value && xs->not_found) { |
1672 | /* Insert the new xattr entry. */ | 1672 | /* Insert the new xattr entry. */ |
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->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 = name_len; |
1677 | } else { | 1677 | } else { |
@@ -1691,42 +1691,42 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode, | |||
1691 | size = OCFS2_XATTR_SIZE(name_len) + | 1691 | size = OCFS2_XATTR_SIZE(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->value && size == OCFS2_XATTR_SIZE(name_len) + | 1694 | if (xi->xi_value && size == OCFS2_XATTR_SIZE(name_len) + |
1695 | OCFS2_XATTR_SIZE(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->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(name_len), |
1702 | 0, | 1702 | 0, |
1703 | OCFS2_XATTR_SIZE(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(name_len), |
1705 | xi->value, | 1705 | xi->xi_value, |
1706 | xi->value_len); | 1706 | xi->xi_value_len); |
1707 | return; | 1707 | return; |
1708 | } | 1708 | } |
1709 | 1709 | ||
1710 | if (!xi->value) | 1710 | if (!xi->xi_value) |
1711 | ocfs2_xa_remove_entry(&loc); | 1711 | ocfs2_xa_remove_entry(&loc); |
1712 | else | 1712 | else |
1713 | ocfs2_xa_wipe_namevalue(&loc); | 1713 | ocfs2_xa_wipe_namevalue(&loc); |
1714 | 1714 | ||
1715 | min_offs += size; | 1715 | min_offs += size; |
1716 | } | 1716 | } |
1717 | if (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(name_len) + |
1720 | OCFS2_XATTR_SIZE(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->name, name_len); | 1725 | memcpy(val, xi->xi_name, name_len); |
1726 | memcpy(val + OCFS2_XATTR_SIZE(name_len), | 1726 | memcpy(val + OCFS2_XATTR_SIZE(name_len), |
1727 | xi->value, | 1727 | xi->xi_value, |
1728 | xi->value_len); | 1728 | xi->xi_value_len); |
1729 | xs->here->xe_value_size = cpu_to_le64(xi->value_len); | 1729 | xs->here->xe_value_size = cpu_to_le64(xi->xi_value_len); |
1730 | ocfs2_xattr_set_local(xs->here, 1); | 1730 | ocfs2_xattr_set_local(xs->here, 1); |
1731 | ocfs2_xattr_hash_entry(inode, xs->header, xs->here); | 1731 | ocfs2_xattr_hash_entry(inode, xs->header, xs->here); |
1732 | } | 1732 | } |
@@ -1752,15 +1752,15 @@ 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->name); | 1755 | size_t min_offs = xs->end - xs->base, name_len = strlen(xi->xi_name); |
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 | .name_index = xi->name_index, | 1760 | .xi_name_index = xi->xi_name_index, |
1761 | .name = xi->name, | 1761 | .xi_name = xi->xi_name, |
1762 | .value = xi->value, | 1762 | .xi_value = xi->xi_value, |
1763 | .value_len = xi->value_len, | 1763 | .xi_value_len = xi->xi_value_len, |
1764 | }; | 1764 | }; |
1765 | struct ocfs2_xattr_value_buf vb = { | 1765 | struct ocfs2_xattr_value_buf vb = { |
1766 | .vb_bh = xs->xattr_bh, | 1766 | .vb_bh = xs->xattr_bh, |
@@ -1798,7 +1798,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1798 | free += (size + sizeof(struct ocfs2_xattr_entry)); | 1798 | free += (size + sizeof(struct ocfs2_xattr_entry)); |
1799 | } | 1799 | } |
1800 | /* Check free space in inode or block */ | 1800 | /* Check free space in inode or block */ |
1801 | if (xi->value && xi->value_len > OCFS2_XATTR_INLINE_SIZE) { | 1801 | if (xi->xi_value && xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
1802 | if (free < sizeof(struct ocfs2_xattr_entry) + | 1802 | if (free < sizeof(struct ocfs2_xattr_entry) + |
1803 | OCFS2_XATTR_SIZE(name_len) + | 1803 | OCFS2_XATTR_SIZE(name_len) + |
1804 | OCFS2_XATTR_ROOT_SIZE) { | 1804 | OCFS2_XATTR_ROOT_SIZE) { |
@@ -1806,12 +1806,12 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1806 | goto out; | 1806 | goto out; |
1807 | } | 1807 | } |
1808 | size_l = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; | 1808 | size_l = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; |
1809 | xi_l.value = (void *)&def_xv; | 1809 | xi_l.xi_value = (void *)&def_xv; |
1810 | xi_l.value_len = OCFS2_XATTR_ROOT_SIZE; | 1810 | xi_l.xi_value_len = OCFS2_XATTR_ROOT_SIZE; |
1811 | } else if (xi->value) { | 1811 | } else if (xi->xi_value) { |
1812 | if (free < sizeof(struct ocfs2_xattr_entry) + | 1812 | if (free < sizeof(struct ocfs2_xattr_entry) + |
1813 | OCFS2_XATTR_SIZE(name_len) + | 1813 | OCFS2_XATTR_SIZE(name_len) + |
1814 | OCFS2_XATTR_SIZE(xi->value_len)) { | 1814 | OCFS2_XATTR_SIZE(xi->xi_value_len)) { |
1815 | ret = -ENOSPC; | 1815 | ret = -ENOSPC; |
1816 | goto out; | 1816 | goto out; |
1817 | } | 1817 | } |
@@ -1836,16 +1836,16 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1836 | vb.vb_xv = (struct ocfs2_xattr_value_root *) | 1836 | vb.vb_xv = (struct ocfs2_xattr_value_root *) |
1837 | (val + OCFS2_XATTR_SIZE(name_len)); | 1837 | (val + OCFS2_XATTR_SIZE(name_len)); |
1838 | 1838 | ||
1839 | if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) { | 1839 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
1840 | /* | 1840 | /* |
1841 | * If new value need set outside also, | 1841 | * If new value need set outside also, |
1842 | * first truncate old value to new value, | 1842 | * first truncate old value to new value, |
1843 | * then set new value with set_value_outside(). | 1843 | * then set new value with set_value_outside(). |
1844 | */ | 1844 | */ |
1845 | ret = ocfs2_xattr_value_truncate(inode, | 1845 | ret = ocfs2_xattr_value_truncate(inode, |
1846 | &vb, | 1846 | &vb, |
1847 | xi->value_len, | 1847 | xi->xi_value_len, |
1848 | ctxt); | 1848 | ctxt); |
1849 | if (ret < 0) { | 1849 | if (ret < 0) { |
1850 | mlog_errno(ret); | 1850 | mlog_errno(ret); |
1851 | goto out; | 1851 | goto out; |
@@ -1863,10 +1863,10 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1863 | } | 1863 | } |
1864 | 1864 | ||
1865 | ret = __ocfs2_xattr_set_value_outside(inode, | 1865 | ret = __ocfs2_xattr_set_value_outside(inode, |
1866 | handle, | 1866 | handle, |
1867 | &vb, | 1867 | &vb, |
1868 | xi->value, | 1868 | xi->xi_value, |
1869 | xi->value_len); | 1869 | xi->xi_value_len); |
1870 | if (ret < 0) | 1870 | if (ret < 0) |
1871 | mlog_errno(ret); | 1871 | mlog_errno(ret); |
1872 | goto out; | 1872 | goto out; |
@@ -1944,7 +1944,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode, | |||
1944 | if (ret < 0) | 1944 | if (ret < 0) |
1945 | mlog_errno(ret); | 1945 | mlog_errno(ret); |
1946 | 1946 | ||
1947 | if (!ret && xi->value_len > OCFS2_XATTR_INLINE_SIZE) { | 1947 | if (!ret && xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
1948 | /* | 1948 | /* |
1949 | * Set value outside in B tree. | 1949 | * Set value outside in B tree. |
1950 | * This is the second step for value size > INLINE_SIZE. | 1950 | * This is the second step for value size > INLINE_SIZE. |
@@ -2610,13 +2610,13 @@ static int ocfs2_xattr_can_be_in_inode(struct inode *inode, | |||
2610 | 2610 | ||
2611 | BUG_ON(!xs->not_found); | 2611 | BUG_ON(!xs->not_found); |
2612 | 2612 | ||
2613 | if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) | 2613 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) |
2614 | value_size = OCFS2_XATTR_ROOT_SIZE; | 2614 | value_size = OCFS2_XATTR_ROOT_SIZE; |
2615 | else | 2615 | else |
2616 | value_size = OCFS2_XATTR_SIZE(xi->value_len); | 2616 | value_size = OCFS2_XATTR_SIZE(xi->xi_value_len); |
2617 | 2617 | ||
2618 | if (free >= sizeof(struct ocfs2_xattr_entry) + | 2618 | if (free >= sizeof(struct ocfs2_xattr_entry) + |
2619 | OCFS2_XATTR_SIZE(strlen(xi->name)) + value_size) | 2619 | OCFS2_XATTR_SIZE(strlen(xi->xi_name)) + value_size) |
2620 | return 1; | 2620 | return 1; |
2621 | 2621 | ||
2622 | return 0; | 2622 | return 0; |
@@ -2640,7 +2640,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, | |||
2640 | char *base = NULL; | 2640 | char *base = NULL; |
2641 | int name_offset, name_len = 0; | 2641 | int name_offset, name_len = 0; |
2642 | u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, | 2642 | u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, |
2643 | xi->value_len); | 2643 | xi->xi_value_len); |
2644 | u64 value_size; | 2644 | u64 value_size; |
2645 | 2645 | ||
2646 | /* | 2646 | /* |
@@ -2648,14 +2648,14 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, | |||
2648 | * No matter whether we replace an old one or add a new one, | 2648 | * No matter whether we replace an old one or add a new one, |
2649 | * we need this for writing. | 2649 | * we need this for writing. |
2650 | */ | 2650 | */ |
2651 | if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) | 2651 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) |
2652 | credits += new_clusters * | 2652 | credits += new_clusters * |
2653 | ocfs2_clusters_to_blocks(inode->i_sb, 1); | 2653 | ocfs2_clusters_to_blocks(inode->i_sb, 1); |
2654 | 2654 | ||
2655 | if (xis->not_found && xbs->not_found) { | 2655 | if (xis->not_found && xbs->not_found) { |
2656 | credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb); | 2656 | credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb); |
2657 | 2657 | ||
2658 | if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) { | 2658 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
2659 | clusters_add += new_clusters; | 2659 | clusters_add += new_clusters; |
2660 | credits += ocfs2_calc_extend_credits(inode->i_sb, | 2660 | credits += ocfs2_calc_extend_credits(inode->i_sb, |
2661 | &def_xv.xv.xr_list, | 2661 | &def_xv.xv.xr_list, |
@@ -2700,7 +2700,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, | |||
2700 | * The credits for removing the value tree will be extended | 2700 | * The credits for removing the value tree will be extended |
2701 | * by ocfs2_remove_extent itself. | 2701 | * by ocfs2_remove_extent itself. |
2702 | */ | 2702 | */ |
2703 | if (!xi->value) { | 2703 | if (!xi->xi_value) { |
2704 | if (!ocfs2_xattr_is_local(xe)) | 2704 | if (!ocfs2_xattr_is_local(xe)) |
2705 | credits += ocfs2_remove_extent_credits(inode->i_sb); | 2705 | credits += ocfs2_remove_extent_credits(inode->i_sb); |
2706 | 2706 | ||
@@ -2730,7 +2730,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, | |||
2730 | } | 2730 | } |
2731 | } | 2731 | } |
2732 | 2732 | ||
2733 | if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) { | 2733 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { |
2734 | /* the new values will be stored outside. */ | 2734 | /* the new values will be stored outside. */ |
2735 | u32 old_clusters = 0; | 2735 | u32 old_clusters = 0; |
2736 | 2736 | ||
@@ -2763,9 +2763,10 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, | |||
2763 | * value, we don't need any allocation, otherwise we have | 2763 | * value, we don't need any allocation, otherwise we have |
2764 | * to guess metadata allocation. | 2764 | * to guess metadata allocation. |
2765 | */ | 2765 | */ |
2766 | if ((ocfs2_xattr_is_local(xe) && value_size >= xi->value_len) || | 2766 | if ((ocfs2_xattr_is_local(xe) && |
2767 | (value_size >= xi->xi_value_len)) || | ||
2767 | (!ocfs2_xattr_is_local(xe) && | 2768 | (!ocfs2_xattr_is_local(xe) && |
2768 | OCFS2_XATTR_ROOT_SIZE >= xi->value_len)) | 2769 | OCFS2_XATTR_ROOT_SIZE >= xi->xi_value_len)) |
2769 | goto out; | 2770 | goto out; |
2770 | } | 2771 | } |
2771 | 2772 | ||
@@ -2855,7 +2856,7 @@ static int ocfs2_init_xattr_set_ctxt(struct inode *inode, | |||
2855 | 2856 | ||
2856 | meta_add += extra_meta; | 2857 | meta_add += extra_meta; |
2857 | mlog(0, "Set xattr %s, reserve meta blocks = %d, clusters = %d, " | 2858 | mlog(0, "Set xattr %s, reserve meta blocks = %d, clusters = %d, " |
2858 | "credits = %d\n", xi->name, meta_add, clusters_add, *credits); | 2859 | "credits = %d\n", xi->xi_name, meta_add, clusters_add, *credits); |
2859 | 2860 | ||
2860 | if (meta_add) { | 2861 | if (meta_add) { |
2861 | ret = ocfs2_reserve_new_metadata_blocks(osb, meta_add, | 2862 | ret = ocfs2_reserve_new_metadata_blocks(osb, meta_add, |
@@ -2895,7 +2896,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
2895 | { | 2896 | { |
2896 | int ret = 0, credits, old_found; | 2897 | int ret = 0, credits, old_found; |
2897 | 2898 | ||
2898 | if (!xi->value) { | 2899 | if (!xi->xi_value) { |
2899 | /* Remove existing extended attribute */ | 2900 | /* Remove existing extended attribute */ |
2900 | if (!xis->not_found) | 2901 | if (!xis->not_found) |
2901 | ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt); | 2902 | ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt); |
@@ -2909,8 +2910,8 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
2909 | * If succeed and that extended attribute existing in | 2910 | * If succeed and that extended attribute existing in |
2910 | * external block, then we will remove it. | 2911 | * external block, then we will remove it. |
2911 | */ | 2912 | */ |
2912 | xi->value = NULL; | 2913 | xi->xi_value = NULL; |
2913 | xi->value_len = 0; | 2914 | xi->xi_value_len = 0; |
2914 | 2915 | ||
2915 | old_found = xis->not_found; | 2916 | old_found = xis->not_found; |
2916 | xis->not_found = -ENODATA; | 2917 | xis->not_found = -ENODATA; |
@@ -2938,8 +2939,8 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
2938 | } else if (ret == -ENOSPC) { | 2939 | } else if (ret == -ENOSPC) { |
2939 | if (di->i_xattr_loc && !xbs->xattr_bh) { | 2940 | if (di->i_xattr_loc && !xbs->xattr_bh) { |
2940 | ret = ocfs2_xattr_block_find(inode, | 2941 | ret = ocfs2_xattr_block_find(inode, |
2941 | xi->name_index, | 2942 | xi->xi_name_index, |
2942 | xi->name, xbs); | 2943 | xi->xi_name, xbs); |
2943 | if (ret) | 2944 | if (ret) |
2944 | goto out; | 2945 | goto out; |
2945 | 2946 | ||
@@ -2978,8 +2979,8 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
2978 | * If succeed and that extended attribute | 2979 | * If succeed and that extended attribute |
2979 | * existing in inode, we will remove it. | 2980 | * existing in inode, we will remove it. |
2980 | */ | 2981 | */ |
2981 | xi->value = NULL; | 2982 | xi->xi_value = NULL; |
2982 | xi->value_len = 0; | 2983 | xi->xi_value_len = 0; |
2983 | xbs->not_found = -ENODATA; | 2984 | xbs->not_found = -ENODATA; |
2984 | ret = ocfs2_calc_xattr_set_need(inode, | 2985 | ret = ocfs2_calc_xattr_set_need(inode, |
2985 | di, | 2986 | di, |
@@ -3045,10 +3046,10 @@ int ocfs2_xattr_set_handle(handle_t *handle, | |||
3045 | int ret; | 3046 | int ret; |
3046 | 3047 | ||
3047 | struct ocfs2_xattr_info xi = { | 3048 | struct ocfs2_xattr_info xi = { |
3048 | .name_index = name_index, | 3049 | .xi_name_index = name_index, |
3049 | .name = name, | 3050 | .xi_name = name, |
3050 | .value = value, | 3051 | .xi_value = value, |
3051 | .value_len = value_len, | 3052 | .xi_value_len = value_len, |
3052 | }; | 3053 | }; |
3053 | 3054 | ||
3054 | struct ocfs2_xattr_search xis = { | 3055 | struct ocfs2_xattr_search xis = { |
@@ -3128,10 +3129,10 @@ int ocfs2_xattr_set(struct inode *inode, | |||
3128 | struct ocfs2_refcount_tree *ref_tree = NULL; | 3129 | struct ocfs2_refcount_tree *ref_tree = NULL; |
3129 | 3130 | ||
3130 | struct ocfs2_xattr_info xi = { | 3131 | struct ocfs2_xattr_info xi = { |
3131 | .name_index = name_index, | 3132 | .xi_name_index = name_index, |
3132 | .name = name, | 3133 | .xi_name = name, |
3133 | .value = value, | 3134 | .xi_value = value, |
3134 | .value_len = value_len, | 3135 | .xi_value_len = value_len, |
3135 | }; | 3136 | }; |
3136 | 3137 | ||
3137 | struct ocfs2_xattr_search xis = { | 3138 | struct ocfs2_xattr_search xis = { |
@@ -4979,7 +4980,7 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
4979 | int local) | 4980 | int local) |
4980 | { | 4981 | { |
4981 | struct ocfs2_xattr_entry *last, *xe; | 4982 | struct ocfs2_xattr_entry *last, *xe; |
4982 | int name_len = strlen(xi->name); | 4983 | int name_len = strlen(xi->xi_name); |
4983 | struct ocfs2_xattr_header *xh = xs->header; | 4984 | struct ocfs2_xattr_header *xh = xs->header; |
4984 | u16 count = le16_to_cpu(xh->xh_count), start; | 4985 | u16 count = le16_to_cpu(xh->xh_count), start; |
4985 | size_t blocksize = inode->i_sb->s_blocksize; | 4986 | size_t blocksize = inode->i_sb->s_blocksize; |
@@ -5001,22 +5002,24 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
5001 | OCFS2_XATTR_SIZE(OCFS2_XATTR_ROOT_SIZE); | 5002 | OCFS2_XATTR_SIZE(OCFS2_XATTR_ROOT_SIZE); |
5002 | 5003 | ||
5003 | /* | 5004 | /* |
5004 | * If the new value will be stored outside, xi->value has been | 5005 | * If the new value will be stored outside, xi->xi_value has |
5005 | * initalized as an empty ocfs2_xattr_value_root, and the same | 5006 | * been initalized as an empty ocfs2_xattr_value_root, and |
5006 | * goes with xi->value_len, so we can set new_size safely here. | 5007 | * the same goes with xi->xi_value_len, so we can set |
5008 | * new_size safely here. | ||
5007 | * See ocfs2_xattr_set_in_bucket. | 5009 | * See ocfs2_xattr_set_in_bucket. |
5008 | */ | 5010 | */ |
5009 | new_size = OCFS2_XATTR_SIZE(name_len) + | 5011 | new_size = OCFS2_XATTR_SIZE(name_len) + |
5010 | OCFS2_XATTR_SIZE(xi->value_len); | 5012 | OCFS2_XATTR_SIZE(xi->xi_value_len); |
5011 | 5013 | ||
5012 | if (xi->value) { | 5014 | if (xi->xi_value) { |
5013 | ocfs2_xa_wipe_namevalue(&loc); | 5015 | ocfs2_xa_wipe_namevalue(&loc); |
5014 | if (new_size > size) | 5016 | if (new_size > size) |
5015 | goto set_new_name_value; | 5017 | goto set_new_name_value; |
5016 | 5018 | ||
5017 | /* Now replace the old value with new one. */ | 5019 | /* Now replace the old value with new one. */ |
5018 | if (local) | 5020 | if (local) |
5019 | xe->xe_value_size = cpu_to_le64(xi->value_len); | 5021 | xe->xe_value_size = |
5022 | cpu_to_le64(xi->xi_value_len); | ||
5020 | else | 5023 | else |
5021 | xe->xe_value_size = 0; | 5024 | xe->xe_value_size = 0; |
5022 | 5025 | ||
@@ -5024,9 +5027,9 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
5024 | xs->bucket, offs); | 5027 | xs->bucket, offs); |
5025 | memset(val + OCFS2_XATTR_SIZE(name_len), 0, | 5028 | memset(val + OCFS2_XATTR_SIZE(name_len), 0, |
5026 | size - OCFS2_XATTR_SIZE(name_len)); | 5029 | size - OCFS2_XATTR_SIZE(name_len)); |
5027 | if (OCFS2_XATTR_SIZE(xi->value_len) > 0) | 5030 | if (OCFS2_XATTR_SIZE(xi->xi_value_len) > 0) |
5028 | memcpy(val + OCFS2_XATTR_SIZE(name_len), | 5031 | memcpy(val + OCFS2_XATTR_SIZE(name_len), |
5029 | xi->value, xi->value_len); | 5032 | xi->xi_value, xi->xi_value_len); |
5030 | 5033 | ||
5031 | le16_add_cpu(&xh->xh_name_value_len, new_size); | 5034 | le16_add_cpu(&xh->xh_name_value_len, new_size); |
5032 | ocfs2_xattr_set_local(xe, local); | 5035 | ocfs2_xattr_set_local(xe, local); |
@@ -5067,12 +5070,12 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode, | |||
5067 | memset(xe, 0, sizeof(struct ocfs2_xattr_entry)); | 5070 | memset(xe, 0, sizeof(struct ocfs2_xattr_entry)); |
5068 | xe->xe_name_hash = cpu_to_le32(name_hash); | 5071 | xe->xe_name_hash = cpu_to_le32(name_hash); |
5069 | xe->xe_name_len = name_len; | 5072 | xe->xe_name_len = name_len; |
5070 | ocfs2_xattr_set_type(xe, xi->name_index); | 5073 | ocfs2_xattr_set_type(xe, xi->xi_name_index); |
5071 | } | 5074 | } |
5072 | 5075 | ||
5073 | set_new_name_value: | 5076 | set_new_name_value: |
5074 | /* Insert the new name+value. */ | 5077 | /* Insert the new name+value. */ |
5075 | size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_SIZE(xi->value_len); | 5078 | size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_SIZE(xi->xi_value_len); |
5076 | 5079 | ||
5077 | /* | 5080 | /* |
5078 | * We must make sure that the name/value pair | 5081 | * We must make sure that the name/value pair |
@@ -5091,10 +5094,11 @@ set_new_name_value: | |||
5091 | xe->xe_name_offset = cpu_to_le16(offs - size); | 5094 | xe->xe_name_offset = cpu_to_le16(offs - size); |
5092 | 5095 | ||
5093 | memset(val, 0, size); | 5096 | memset(val, 0, size); |
5094 | memcpy(val, xi->name, name_len); | 5097 | memcpy(val, xi->xi_name, name_len); |
5095 | memcpy(val + OCFS2_XATTR_SIZE(name_len), xi->value, xi->value_len); | 5098 | memcpy(val + OCFS2_XATTR_SIZE(name_len), xi->xi_value, |
5099 | xi->xi_value_len); | ||
5096 | 5100 | ||
5097 | xe->xe_value_size = cpu_to_le64(xi->value_len); | 5101 | xe->xe_value_size = cpu_to_le64(xi->xi_value_len); |
5098 | ocfs2_xattr_set_local(xe, local); | 5102 | ocfs2_xattr_set_local(xe, local); |
5099 | xs->here = xe; | 5103 | xs->here = xe; |
5100 | le16_add_cpu(&xh->xh_free_start, -size); | 5104 | le16_add_cpu(&xh->xh_free_start, -size); |
@@ -5119,7 +5123,7 @@ static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode, | |||
5119 | u64 blkno; | 5123 | u64 blkno; |
5120 | 5124 | ||
5121 | mlog(0, "Set xattr entry len = %lu index = %d in bucket %llu\n", | 5125 | mlog(0, "Set xattr entry len = %lu index = %d in bucket %llu\n", |
5122 | (unsigned long)xi->value_len, xi->name_index, | 5126 | (unsigned long)xi->xi_value_len, xi->xi_name_index, |
5123 | (unsigned long long)bucket_blkno(xs->bucket)); | 5127 | (unsigned long long)bucket_blkno(xs->bucket)); |
5124 | 5128 | ||
5125 | if (!xs->bucket->bu_bhs[1]) { | 5129 | if (!xs->bucket->bu_bhs[1]) { |
@@ -5417,10 +5421,10 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode, | |||
5417 | { | 5421 | { |
5418 | int ret, local = 1; | 5422 | int ret, local = 1; |
5419 | size_t value_len; | 5423 | size_t value_len; |
5420 | char *val = (char *)xi->value; | 5424 | char *val = (char *)xi->xi_value; |
5421 | struct ocfs2_xattr_entry *xe = xs->here; | 5425 | struct ocfs2_xattr_entry *xe = xs->here; |
5422 | u32 name_hash = ocfs2_xattr_name_hash(inode, xi->name, | 5426 | u32 name_hash = ocfs2_xattr_name_hash(inode, xi->xi_name, |
5423 | strlen(xi->name)); | 5427 | strlen(xi->xi_name)); |
5424 | 5428 | ||
5425 | if (!xs->not_found && !ocfs2_xattr_is_local(xe)) { | 5429 | if (!xs->not_found && !ocfs2_xattr_is_local(xe)) { |
5426 | /* | 5430 | /* |
@@ -5435,8 +5439,8 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode, | |||
5435 | * the modification to the xattr block will be done | 5439 | * the modification to the xattr block will be done |
5436 | * by following steps. | 5440 | * by following steps. |
5437 | */ | 5441 | */ |
5438 | if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) | 5442 | if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) |
5439 | value_len = xi->value_len; | 5443 | value_len = xi->xi_value_len; |
5440 | else | 5444 | else |
5441 | value_len = 0; | 5445 | value_len = 0; |
5442 | 5446 | ||
@@ -5450,7 +5454,7 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode, | |||
5450 | goto set_value_outside; | 5454 | goto set_value_outside; |
5451 | } | 5455 | } |
5452 | 5456 | ||
5453 | value_len = xi->value_len; | 5457 | value_len = xi->xi_value_len; |
5454 | /* So we have to handle the inside block change now. */ | 5458 | /* So we have to handle the inside block change now. */ |
5455 | if (value_len > OCFS2_XATTR_INLINE_SIZE) { | 5459 | if (value_len > OCFS2_XATTR_INLINE_SIZE) { |
5456 | /* | 5460 | /* |
@@ -5458,8 +5462,8 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode, | |||
5458 | * initalize a new empty value root and insert it first. | 5462 | * initalize a new empty value root and insert it first. |
5459 | */ | 5463 | */ |
5460 | local = 0; | 5464 | local = 0; |
5461 | xi->value = &def_xv; | 5465 | xi->xi_value = &def_xv; |
5462 | xi->value_len = OCFS2_XATTR_ROOT_SIZE; | 5466 | xi->xi_value_len = OCFS2_XATTR_ROOT_SIZE; |
5463 | } | 5467 | } |
5464 | 5468 | ||
5465 | ret = ocfs2_xattr_set_entry_in_bucket(inode, ctxt->handle, xi, xs, | 5469 | ret = ocfs2_xattr_set_entry_in_bucket(inode, ctxt->handle, xi, xs, |
@@ -5533,11 +5537,11 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, | |||
5533 | struct ocfs2_xattr_entry *xe; | 5537 | struct ocfs2_xattr_entry *xe; |
5534 | u16 count, header_size, xh_free_start; | 5538 | u16 count, header_size, xh_free_start; |
5535 | int free, max_free, need, old; | 5539 | int free, max_free, need, old; |
5536 | size_t value_size = 0, name_len = strlen(xi->name); | 5540 | size_t value_size = 0, name_len = strlen(xi->xi_name); |
5537 | size_t blocksize = inode->i_sb->s_blocksize; | 5541 | size_t blocksize = inode->i_sb->s_blocksize; |
5538 | int ret, allocation = 0; | 5542 | int ret, allocation = 0; |
5539 | 5543 | ||
5540 | mlog_entry("Set xattr %s in xattr index block\n", xi->name); | 5544 | mlog_entry("Set xattr %s in xattr index block\n", xi->xi_name); |
5541 | 5545 | ||
5542 | try_again: | 5546 | try_again: |
5543 | xh = xs->header; | 5547 | xh = xs->header; |
@@ -5553,10 +5557,10 @@ try_again: | |||
5553 | (unsigned long long)bucket_blkno(xs->bucket), | 5557 | (unsigned long long)bucket_blkno(xs->bucket), |
5554 | header_size); | 5558 | header_size); |
5555 | 5559 | ||
5556 | if (xi->value && xi->value_len > OCFS2_XATTR_INLINE_SIZE) | 5560 | if (xi->xi_value && xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) |
5557 | value_size = OCFS2_XATTR_ROOT_SIZE; | 5561 | value_size = OCFS2_XATTR_ROOT_SIZE; |
5558 | else if (xi->value) | 5562 | else if (xi->xi_value) |
5559 | value_size = OCFS2_XATTR_SIZE(xi->value_len); | 5563 | value_size = OCFS2_XATTR_SIZE(xi->xi_value_len); |
5560 | 5564 | ||
5561 | if (xs->not_found) | 5565 | if (xs->not_found) |
5562 | need = sizeof(struct ocfs2_xattr_entry) + | 5566 | need = sizeof(struct ocfs2_xattr_entry) + |
@@ -5639,7 +5643,7 @@ try_again: | |||
5639 | */ | 5643 | */ |
5640 | ret = ocfs2_check_xattr_bucket_collision(inode, | 5644 | ret = ocfs2_check_xattr_bucket_collision(inode, |
5641 | xs->bucket, | 5645 | xs->bucket, |
5642 | xi->name); | 5646 | xi->xi_name); |
5643 | if (ret) { | 5647 | if (ret) { |
5644 | mlog_errno(ret); | 5648 | mlog_errno(ret); |
5645 | goto out; | 5649 | goto out; |
@@ -5663,8 +5667,8 @@ try_again: | |||
5663 | */ | 5667 | */ |
5664 | ocfs2_xattr_bucket_relse(xs->bucket); | 5668 | ocfs2_xattr_bucket_relse(xs->bucket); |
5665 | ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh, | 5669 | ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh, |
5666 | xi->name_index, | 5670 | xi->xi_name_index, |
5667 | xi->name, xs); | 5671 | xi->xi_name, xs); |
5668 | if (ret && ret != -ENODATA) | 5672 | if (ret && ret != -ENODATA) |
5669 | goto out; | 5673 | goto out; |
5670 | xs->not_found = ret; | 5674 | xs->not_found = ret; |
@@ -5885,7 +5889,7 @@ static int ocfs2_prepare_refcount_xattr(struct inode *inode, | |||
5885 | * refcount tree, and make the original extent become 3. So we will need | 5889 | * refcount tree, and make the original extent become 3. So we will need |
5886 | * 2 * cluster more extent recs at most. | 5890 | * 2 * cluster more extent recs at most. |
5887 | */ | 5891 | */ |
5888 | if (!xi->value || xi->value_len <= OCFS2_XATTR_INLINE_SIZE) { | 5892 | if (!xi->xi_value || xi->xi_value_len <= OCFS2_XATTR_INLINE_SIZE) { |
5889 | 5893 | ||
5890 | ret = ocfs2_refcounted_xattr_delete_need(inode, | 5894 | ret = ocfs2_refcounted_xattr_delete_need(inode, |
5891 | &(*ref_tree)->rf_ci, | 5895 | &(*ref_tree)->rf_ci, |